void EventTargetNode::dispatchWheelEvent(PlatformWheelEvent& e) { ASSERT(!eventDispatchForbidden()); if (e.deltaX() == 0 && e.deltaY() == 0) return; FrameView* view = document()->view(); if (!view) return; IntPoint pos = view->windowToContents(e.pos()); // Convert the deltas from pixels to lines if we have a pixel scroll event. float deltaX = e.deltaX(); float deltaY = e.deltaY(); // FIXME: Should we do anything with a ScrollByPageWheelEvent here? // It will be treated like a line scroll of 1 right now. if (e.granularity() == ScrollByPixelWheelEvent) { deltaX /= cMouseWheelPixelsPerLineStep; deltaY /= cMouseWheelPixelsPerLineStep; } RefPtr<WheelEvent> we = WheelEvent::create(e.deltaX(), e.deltaY(), document()->defaultView(), e.globalX(), e.globalY(), pos.x(), pos.y(), e.ctrlKey(), e.altKey(), e.shiftKey(), e.metaKey()); ExceptionCode ec = 0; if (!dispatchEvent(we.release(), ec)) e.accept(); }
Vector<FloatRect> DocumentMarkerController::renderedRectsForMarkers(DocumentMarker::MarkerType markerType) { Vector<FloatRect> result; if (!possiblyHasMarkers(markerType)) return result; ASSERT(!(m_markers.isEmpty())); Frame* frame = m_document.frame(); if (!frame) return result; FrameView* frameView = frame->view(); if (!frameView) return result; updateRectsForInvalidatedMarkersOfType(markerType); bool isSubframe = !frame->isMainFrame(); IntRect subframeClipRect; if (isSubframe) subframeClipRect = frameView->windowToContents(frameView->windowClipRect()); for (auto& nodeAndMarkers : m_markers) { Node& node = *nodeAndMarkers.key; FloatRect overflowClipRect; if (RenderObject* renderer = node.renderer()) overflowClipRect = renderer->absoluteClippedOverflowRect(); for (auto& marker : *nodeAndMarkers.value) { if (marker.type() != markerType) continue; auto renderedRects = marker.unclippedAbsoluteRects(); // Clip document markers by their overflow clip. if (node.renderer()) { for (auto& rect : renderedRects) rect.intersect(overflowClipRect); } // Clip subframe document markers by their frame. if (isSubframe) { for (auto& rect : renderedRects) rect.intersect(subframeClipRect); } for (const auto& rect : renderedRects) { if (!rect.isEmpty()) result.append(rect); } } } return result; }
// Manual drag caret manipulation void DragController::placeDragCaret(const IntPoint& windowPoint) { mouseMovedIntoDocument(m_page->mainFrame()->documentAtPoint(windowPoint)); if (!m_documentUnderMouse) return; Frame* frame = m_documentUnderMouse->frame(); FrameView* frameView = frame->view(); if (!frameView) return; IntPoint framePoint = frameView->windowToContents(windowPoint); m_page->dragCaretController()->setCaretPosition(frame->visiblePositionForPoint(framePoint)); }
static IntPoint atkToContents(AccessibilityObject* coreObject, AtkCoordType coordType, gint x, gint y) { IntPoint pos(x, y); FrameView* frameView = coreObject->documentFrameView(); if (frameView) { switch (coordType) { case ATK_XY_SCREEN: return frameView->screenToContents(pos); case ATK_XY_WINDOW: return frameView->windowToContents(pos); } } return pos; }
void EventTargetNode::dispatchWheelEvent(PlatformWheelEvent& e) { ASSERT(!eventDispatchForbidden()); if (e.deltaX() == 0 && e.deltaY() == 0) return; FrameView* view = document()->view(); if (!view) return; IntPoint pos = view->windowToContents(e.pos()); RefPtr<WheelEvent> we = WheelEvent::create(e.deltaX(), e.deltaY(), document()->defaultView(), e.globalX(), e.globalY(), pos.x(), pos.y(), e.ctrlKey(), e.altKey(), e.shiftKey(), e.metaKey()); ExceptionCode ec = 0; if (!dispatchEvent(we.release(), ec, true)) e.accept(); }
/** * webkit_web_inspector_inspect_coordinates: * @web_inspector: the #WebKitWebInspector that will do the inspection * @x: the X coordinate of the node to be inspected * @y: the Y coordinate of the node to be inspected * * Causes the Web Inspector to inspect the node that is located at the * given coordinates of the widget. The coordinates should be relative * to the #WebKitWebView widget, not to the scrollable content, and * may be obtained from a #GdkEvent directly. * * This means @x, and @y being zero doesn't guarantee you will hit the * left-most top corner of the content, since the contents may have * been scrolled. * * Since: 1.1.17 */ void webkit_web_inspector_inspect_coordinates(WebKitWebInspector* webInspector, gdouble x, gdouble y) { g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(webInspector)); g_return_if_fail(x >= 0 && y >= 0); WebKitWebInspectorPrivate* priv = webInspector->priv; Frame* frame = priv->page->focusController()->focusedOrMainFrame(); FrameView* view = frame->view(); if (!view) return; HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); IntPoint documentPoint = view->windowToContents(IntPoint(static_cast<int>(x), static_cast<int>(y))); HitTestResult result(documentPoint); frame->contentRenderer()->layer()->hitTest(request, result); priv->page->inspectorController()->inspect(result.innerNonSharedNode()); }
// Manual drag caret manipulation void DragController::placeDragCaret(const IntPoint& windowPoint) { Frame* mainFrame = m_page->mainFrame(); Document* newDraggingDoc = mainFrame->documentAtPoint(windowPoint); if (m_document != newDraggingDoc) { if (m_document) cancelDrag(); m_document = newDraggingDoc; } if (!m_document) return; Frame* frame = m_document->frame(); ASSERT(frame); FrameView* frameView = frame->view(); if (!frameView) return; IntPoint framePoint = frameView->windowToContents(windowPoint); Selection dragCaret(frame->visiblePositionForPoint(framePoint)); m_page->dragCaretController()->setSelection(dragCaret); }
void WebChromeClient::showPlaybackTargetPicker(uint64_t contextId, const WebCore::IntPoint& position, bool isVideo) { FrameView* frameView = m_page->mainFrame()->view(); FloatRect rect(frameView->contentsToRootView(frameView->windowToContents(position)), FloatSize()); m_page->send(Messages::WebPageProxy::ShowPlaybackTargetPicker(contextId, rect, isVideo)); }