Ejemplo n.º 1
0
Node* nodeFromPoint(Document* document, int x, int y, LayoutPoint* localPoint)
{
    Frame* frame = document->frame();

    if (!frame)
        return nullptr;
    FrameView* frameView = frame->view();
    if (!frameView)
        return nullptr;

    float scaleFactor = frame->pageZoomFactor() * frame->frameScaleFactor();

    IntPoint scrollPosition = frameView->contentsScrollPosition();
    IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor  + scrollPosition.x(), y * scaleFactor + scrollPosition.y()));

    IntRect visibleRect;
#if PLATFORM(IOS)
    visibleRect = frameView->unobscuredContentRect();
#else
    visibleRect = frameView->visibleContentRect();
#endif
    if (!visibleRect.contains(point))
        return nullptr;

    HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
    HitTestResult result(point);
    document->renderView()->hitTest(request, result);

    if (localPoint)
        *localPoint = result.localPoint();

    return result.innerNode();
}
Ejemplo n.º 2
0
int HTMLBodyElement::scrollTop()
{
    document().updateLayoutIgnorePendingStylesheets();
    Frame* frame = document().frame();
    if (!frame)
        return 0;
    FrameView* view = frame->view();
    if (!view)
        return 0;
    return adjustForZoom(view->contentsScrollPosition().y(), *frame);
}