本文整理汇总了C++中webcore::IntPoint::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ IntPoint::setX方法的具体用法?C++ IntPoint::setX怎么用?C++ IntPoint::setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webcore::IntPoint
的用法示例。
在下文中一共展示了IntPoint::setX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JumpToNearestElement
//.........这里部分代码省略.........
{
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.
{
// Based on the intended direction of movement, scroll so that some newer elements are visible.
示例2: 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);
}
}