本文整理汇总了C++中webcore::IntPoint类的典型用法代码示例。如果您正苦于以下问题:C++ IntPoint类的具体用法?C++ IntPoint怎么用?C++ IntPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IntPoint类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectionEndCaretRect
WebCore::IntRect SelectionHandler::selectionEndCaretRect()
{
if (!m_selectionActive)
return IntRect();
ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection());
WebCore::IntRect caretLocation(m_webPage->focusedOrMainFrame()->selection()->selection().visibleEnd().absoluteCaretBounds());
SelectionController nextCaretSelection;
nextCaretSelection.setSelection(VisibleSelection(m_webPage->focusedOrMainFrame()->selection()->selection().visibleEnd()));
nextCaretSelection.modify(SelectionController::AlterationMove, SelectionController::DirectionForward, CharacterGranularity);
WebCore::IntRect nextCaretLocation(nextCaretSelection.selection().visibleStart().absoluteCaretBounds());
if (nextCaretLocation.y() == caretLocation.y()) {
// The next caret position is on this line, use the middle of the character
// as the active selection point.
caretLocation.move((nextCaretLocation.x() - caretLocation.x()) / 2, 0);
} else {
// Caret position is at the end of a line, advance 1 pixel to ensure
// overlap with character.
caretLocation.move(1, 0);
}
if (m_webPage->focusedOrMainFrame()->ownerRenderer()) {
WebCore::IntPoint frameOffset = m_webPage->focusedOrMainFrame()->ownerRenderer()->absoluteContentBox().location();
caretLocation.move(frameOffset.x(), frameOffset.y());
}
return caretLocation;
}
示例2: screenToWindow
WebCore::IntPoint ChromeClient::screenToWindow(const WebCore::IntPoint& screePoint) const
{
HWND hwnd = m_webView ? m_webView->hostWindow() : NULL;
if (!IsWindow(hwnd))
return screePoint;
POINT tempPoint = { screePoint.x(), screePoint.y() };
ScreenToClient(hwnd, &tempPoint);
WebCore::IntPoint windowPoint(tempPoint.x, tempPoint.y);
return windowPoint;
}
示例3: selectionStartCaretRect
WebCore::IntRect SelectionHandler::selectionStartCaretRect()
{
if (!m_selectionActive)
return IntRect();
ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection());
WebCore::IntRect caretLocation(m_webPage->focusedOrMainFrame()->selection()->selection().visibleStart().absoluteCaretBounds());
if (m_webPage->focusedOrMainFrame()->ownerRenderer()) {
WebCore::IntPoint frameOffset = m_webPage->focusedOrMainFrame()->ownerRenderer()->absoluteContentBox().location();
caretLocation.move(frameOffset.x(), frameOffset.y());
}
return caretLocation;
}
示例4: selectObject
void SelectionHandler::selectObject(WebCore::IntPoint& location, TextGranularity granularity)
{
m_selectionActive = true;
ASSERT(m_webPage && m_webPage->mainFrame() && m_webPage->mainFrame()->selection());
Frame* frame = m_webPage->mainFrame();
#if SHOWDEBUG_SELECTIONHANDLER
Olympia::Platform::log(Olympia::Platform::LogLevelInfo, "SelectionHandler::selectWord adjusted points %d, %d", location.x(), location.y());
#endif
expandSelectionToGranularity(frame, location.x(), location.y(), granularity, m_webPage->m_inputHandler->isInputMode());
// Need to manually trigger notification as response to change.
selectionPositionChanged();
}
示例5: paintContents
void SelectionOverlay::paintContents(const GraphicsLayer* layer, GraphicsContext& c, GraphicsLayerPaintingPhase, const IntRect& inClip)
{
if (!layer->platformLayer()->superlayer())
return;
Selection::iterator it = m_selection.find(layer->platformLayer()->superlayer()->owner());
if (it == m_selection.end())
return;
const Vector<WebCore::FloatQuad>& quads = it->value;
GraphicsLayer* parent = it->key;
IntRect clip(inClip);
clip.move(parent->offsetFromRenderer().width(), parent->offsetFromRenderer().height());
c.save();
c.translate(-parent->offsetFromRenderer().width(), -parent->offsetFromRenderer().height());
Color color = RenderTheme::defaultTheme()->activeSelectionBackgroundColor();
c.setFillColor(color, ColorSpaceDeviceRGB);
for (unsigned i = 0; i < quads.size(); ++i) {
FloatRect rectToPaint = quads[i].boundingBox();
// Selection on non-composited sub-frames need to be adjusted.
if (!m_page->focusedOrMainFrame()->contentRenderer()->isComposited()) {
WebCore::IntPoint framePosition = m_page->frameOffset(m_page->focusedOrMainFrame());
rectToPaint.move(framePosition.x(), framePosition.y());
}
rectToPaint.intersect(clip);
if (rectToPaint.isEmpty())
continue;
c.fillRect(rectToPaint);
}
c.restore();
}
示例6: JumpToNearestElement
//.........这里部分代码省略.........
case EA::WebKit::JumpUp:
if (GetFixedString(mCachedNavigationUpId)->compare(""))
{
if (!GetFixedString(mCachedNavigationUpId)->compare("ignore"))
{
return false;
}
if (JumpToId(GetFixedString(mCachedNavigationUpId)->c_str()))
{
return true;
}
}
break;
default:
EAW_FAIL_MSG("Should not have got here\n");
}
// Iterate over all the frames and find the closest element in any of all the frames.
WebCore::Frame* pFrame = mView->GetFrame();
float currentRadialDistance = FLT_MAX; // A high value to start with so that the max distance between any two elements in the surface is under it.
WebCore::Node* currentBestNode = NULL;
while(pFrame)
{
WebCore::Document* document = pFrame->document();
EAW_ASSERT(document);
if(document)
{
WebCore::FrameView* pFrameView = document->view();
WebCore::IntPoint scrollOffset;
if(pFrameView)
{
scrollOffset.setX(pFrameView->scrollOffset().width());
scrollOffset.setY(pFrameView->scrollOffset().height());
}
// We figure out the start position(It is center of the currently hovered element almost all the time but can be slightly different
// due to scroll sometimes).
mCentreX = lastX + scrollOffset.x();
mCentreY = lastY + scrollOffset.y();
DocumentNavigator navigator(mView, document, direction, WebCore::IntPoint(mCentreX, mCentreY), mBestNodeX, mBestNodeY, mBestNodeWidth, mBestNodeHeight, mJumpNavigationParams.mNavigationTheta, mJumpNavigationParams.mStrictAxesCheck, currentRadialDistance);
navigator.FindBestNode(document);
if(navigator.GetBestNode())
{
currentBestNode = navigator.GetBestNode();
currentRadialDistance = navigator.GetBestNodeRadialDistance();
}
}
pFrame = pFrame->tree()->traverseNext();
}
bool foundSomething = false;
if (currentBestNode) //We found the node to navigate. Move the cursor and we are done.
{
foundSomething = true;
MoveMouseCursorToNode(currentBestNode, false);
}
else if(scrollIfElementNotFound)// Node is not found.
示例7: MoveMouseCursorToNode
void ViewNavigationDelegate::MoveMouseCursorToNode(WebCore::Node* node, bool scrollIfNecessary)
{
if (node)
{
WebCore::HTMLElement* element = (WebCore::HTMLElement*)node;
WebCore::IntRect rect = element->getRect();
WebCore::IntPoint frameOffset;
WebCore::IntPoint scrollOffset;
WebCore::FrameView* pFrameView = element->document()->view(); //Can be NULL
if(pFrameView)
{
//Use move here instead of setX/setY as it results in 1 call instead of two and takes advantage that ctor sets x,y to 0.
frameOffset.move(pFrameView->x(), pFrameView->y());
scrollOffset.move(pFrameView->scrollOffset().width(), pFrameView->scrollOffset().height());
}
int width = mView->GetSize().mWidth;
int height = mView->GetSize().mHeight;
// This will be true if this function is called from anywhere except JumpToNearestElement(). This enables us to not lose the cursor during
// arbitrary jumping of elements from either code or webpage using the Navigation APIs.
if(scrollIfNecessary)
{
int cursorX, cursorY;
mView->GetCursorPosition(cursorX, cursorY);
WebCore::IntPoint targetCursorLocation(frameOffset.x()+rect.x()+rect.width()/2 - scrollOffset.x(), frameOffset.y()+rect.y()+rect.height()/2 - scrollOffset.y());
// Added 1 in all the line delta below resulting in a better visual behavior when the element happens to be at the edge.
if(targetCursorLocation.y() > height)
{
float numLinesDelta = (((targetCursorLocation.y() - cursorY)/WebCore::Scrollbar::pixelsPerLineStep())+1);
ScrollOnJump(true, -120, numLinesDelta);
}
if(targetCursorLocation.y()< 0.0f)
{
float numLinesDelta = (((cursorY - targetCursorLocation.y())/WebCore::Scrollbar::pixelsPerLineStep())+1);
ScrollOnJump(true, 120, numLinesDelta);
}
if(targetCursorLocation.x() > width)
{
float numLinesDelta = (((targetCursorLocation.x() - cursorX)/WebCore::Scrollbar::pixelsPerLineStep())+1);
ScrollOnJump(false, -120, numLinesDelta);
}
if(targetCursorLocation.x()< 0.0f)
{
float numLinesDelta = (((cursorX - targetCursorLocation.x())/WebCore::Scrollbar::pixelsPerLineStep())+1);
ScrollOnJump(false, 120, numLinesDelta);
}
// Read the scroll offset again as it may have changed.
if(pFrameView)
{
scrollOffset.setX(pFrameView->scrollOffset().width());
scrollOffset.setY(pFrameView->scrollOffset().height());
}
}
mBestNodeFrame = element->document()->frame(); //Can be NULL
mBestNodeX = frameOffset.x() + rect.x();
mBestNodeY = frameOffset.y() + rect.y();
mBestNodeWidth = rect.width();
mBestNodeHeight = rect.height();
int lastX, lastY;
mView->GetCursorPosition(lastX, lastY);
int newX = mBestNodeX + rect.width()/2 - scrollOffset.x();
int newY = mBestNodeY + rect.height()/2 - scrollOffset.y();
EA::WebKit::MouseMoveEvent moveEvent;
memset( &moveEvent, 0, sizeof(moveEvent) );
const int cursorInset = 5;// Make cursor stay inside 5 pixels from boundaries. No known issues but added this as a safety measure so that we do not lose cursor ever.
moveEvent.mX = Clamp( cursorInset, newX, width - cursorInset );
moveEvent.mY = Clamp( cursorInset, newY, height - cursorInset );
mView->OnMouseMoveEvent( moveEvent );
if(EAWebKitClient* const pClient = GetEAWebKitClient())
{
CursorMovedInfo cmInfo(mView, mView->GetUserData(), moveEvent.mX, moveEvent.mY);
pClient->CursorMoved(cmInfo);
}
UpdateCachedHints(node);
}
}
示例8: setSelection
void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint end)
{
m_selectionActive = true;
ASSERT(m_webPage && m_webPage->mainFrame() && m_webPage->mainFrame()->selection());
Frame* frame = m_webPage->mainFrame();
ASSERT(frame);
#if SHOWDEBUG_SELECTIONHANDLER
Olympia::Platform::log(Olympia::Platform::LogLevelInfo, "SelectionHandler::setSelection adjusted points %d, %d, %d, %d", start.x(), start.y(), end.x(), end.y());
#endif
bool selectionIsValid = true;
VisibleSelection newSelection(frame->visiblePositionForPoint(start), frame->visiblePositionForPoint(end));
// Validate the new points to avoid crossing frame or editing boundaries.
if (m_webPage->mainFrame() != m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->ownerRenderer()) {
// Current focus frame is not the main frame, it must be a subframe.
WebCore::IntRect subframeRect = m_webPage->focusedOrMainFrame()->ownerRenderer()->absoluteContentBox();
if (!subframeRect.contains(start) || !subframeRect.contains(end)) {
// Requested selection points are outside of current frame.
selectionIsValid = false;
}
}
// Check whether selection is occurring inside of an input field. Do not handle as
// an else if, an input field may be active inside of a subframe.
if (m_webPage->m_inputHandler->isInputMode() && !selectionIsContainedByAnchorNode(newSelection)) {
// Requested selection points are not contained within the anchor node (input field).
selectionIsValid = false;
}
if (selectionIsValid) {
frame->selection()->setSelection(newSelection);
#if SHOWDEBUG_SELECTIONHANDLER
Olympia::Platform::log(Olympia::Platform::LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated");
#endif
}
// Need to manually trigger notification as response to change.
// This needs to be set even if no selection change occurs to ensure client has accurate
// selection points.
selectionPositionChanged();
}