Simplify hitTestResultAtPoint and nodesFromRect APIs

https://bugs.webkit.org/show_bug.cgi?id=95720

.:

Reviewed by Julien Chaffraix.

Update exported symbols.

* Source/autotools/symbols.filter:

Source/WebCore:

Reviewed by Julien Chaffraix.

The existing API was overloaded and could be simplified by passing all the bool arguments in
a HitTestRequest argument. This should also help clarify the call as the enum values explicitely
state what they do.

* WebCore.exp.in:
* WebCore.order:
* dom/Document.cpp:
(WebCore::Document::nodesFromRect):
* dom/Document.h:
(Document):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::createContextMenu):
* page/DragController.cpp:
(WebCore::DragController::canProcessDrag):
(WebCore::DragController::startDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleGestureEvent):
(WebCore::EventHandler::handleGestureForTextSelectionOrContextMenu):
(WebCore::EventHandler::bestClickableNodeForTouchPoint):
(WebCore::EventHandler::bestContextMenuNodeForTouchPoint):
(WebCore::EventHandler::bestZoomableAreaForTouchPoint):
(WebCore::EventHandler::handleTouchEvent):
* page/EventHandler.h:
(WebCore):
(EventHandler):
* page/FocusController.cpp:
(WebCore::updateFocusCandidateIfNeeded):
* page/Frame.cpp:
(WebCore::Frame::visiblePositionForPoint):
(WebCore::Frame::documentAtPoint):
* page/TouchDisambiguation.cpp:
(WebCore::findGoodTouchTargets):
* rendering/HitTestRequest.h:
(WebCore::HitTestRequest::allowsFrameScrollbars):
* testing/Internals.cpp:
(WebCore::Internals::nodesFromRect):

Source/WebKit/blackberry:

Reviewed by Julien Chaffraix.

Update calls to new API.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::contextNode):
(BlackBerry::WebKit::WebPagePrivate::nodeForZoomUnderPoint):
(BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
(BlackBerry::WebKit::WebPage::nodeAtDocumentPoint):
(BlackBerry::WebKit::WebPagePrivate::hitTestResult):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::visiblePositionForPointIgnoringClipping):

Source/WebKit/chromium:

Reviewed by Julien Chaffraix.

Update calls to new API.

* src/ContextMenuClientImpl.cpp:
(WebKit::selectMisspelledWord):
* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::characterIndexForPoint):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::isRectTopmost):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleMouseDown):
(WebKit::WebViewImpl::computeBlockBounds):
(WebKit::WebViewImpl::bestTouchLinkNode):
(WebKit::WebViewImpl::hitTestResultForWindowPos):

Source/WebKit/efl:

Reviewed by Julien Chaffraix.

Update calls to new API.

* ewk/ewk_frame.cpp:
(ewk_frame_hit_test_new):

Source/WebKit/mac:

Reviewed by Julien Chaffraix.

Update calls to new API.

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::actionDictionary):
* WebView/WebFrame.mm:
(-[WebFrame elementAtPoint:]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView elementAtPoint:allowShadowContent:]):

Source/WebKit/qt:

Reviewed by Julien Chaffraix.

Update calls to new API.

* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction):
* WebCoreSupport/QWebFrameAdapter.cpp:
(QWebFrameAdapter::hitTestContent):
* WebCoreSupport/QWebPageAdapter.cpp:
(QWebPageAdapter::TouchAdjuster::findCandidatePointForTouch):
(QWebPageAdapter::handleSoftwareInputPanel):
(QWebPageAdapter::updatePositionDependentMenuActions):

Source/WebKit/win:

Reviewed by Julien Chaffraix.

Update calls to new API.

* WebActionPropertyBag.cpp:
(WebActionPropertyBag::Read):
* WebKit.vcproj/WebKitExports.def.in:
* WebView.cpp:
(WebView::handleContextMenuEvent):
(WebView::elementAtPoint):

Source/WebKit/wx:

Reviewed by Julien Chaffraix.

Update calls to new API.

* WebFrame.cpp:
(WebKit::WebFrame::HitTest):

Source/WebKit2:

Reviewed by Julien Chaffraix and Maciej Stachowiak.

Update calls to new API and update exported symbols.

* WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
(WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::hitTest):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::handleContextMenuEvent):
(WebKit::WebPage::highlightPotentialActivation):
(WebKit::WebPage::findZoomableAreaForPoint):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::characterIndexForPoint):
(WebKit::WebPage::performDictionaryLookupAtLocation):
(WebKit::WebPage::shouldDelayWindowOrderingEvent):
(WebKit::WebPage::acceptsFirstMouse):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142977 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cb016350
2013-02-15 Allan Sandfeld Jensen <allan.jensen@digia.com>
Simplify hitTestResultAtPoint and nodesFromRect APIs
https://bugs.webkit.org/show_bug.cgi?id=95720
Reviewed by Julien Chaffraix.
Update exported symbols.
* Source/autotools/symbols.filter:
2013-02-08 Andrey Kosyakov <caseq@chromium.org>
Web Inspector: expose did{Begin,Cancel}Frame() and {will,did}Composite() on WebDebToolsAgent
......
2013-02-15 Allan Sandfeld Jensen <allan.jensen@digia.com>
Simplify hitTestResultAtPoint and nodesFromRect APIs
https://bugs.webkit.org/show_bug.cgi?id=95720
Reviewed by Julien Chaffraix.
The existing API was overloaded and could be simplified by passing all the bool arguments in
a HitTestRequest argument. This should also help clarify the call as the enum values explicitely
state what they do.
* WebCore.exp.in:
* WebCore.order:
* dom/Document.cpp:
(WebCore::Document::nodesFromRect):
* dom/Document.h:
(Document):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::createContextMenu):
* page/DragController.cpp:
(WebCore::DragController::canProcessDrag):
(WebCore::DragController::startDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleGestureEvent):
(WebCore::EventHandler::handleGestureForTextSelectionOrContextMenu):
(WebCore::EventHandler::bestClickableNodeForTouchPoint):
(WebCore::EventHandler::bestContextMenuNodeForTouchPoint):
(WebCore::EventHandler::bestZoomableAreaForTouchPoint):
(WebCore::EventHandler::handleTouchEvent):
* page/EventHandler.h:
(WebCore):
(EventHandler):
* page/FocusController.cpp:
(WebCore::updateFocusCandidateIfNeeded):
* page/Frame.cpp:
(WebCore::Frame::visiblePositionForPoint):
(WebCore::Frame::documentAtPoint):
* page/TouchDisambiguation.cpp:
(WebCore::findGoodTouchTargets):
* rendering/HitTestRequest.h:
(WebCore::HitTestRequest::allowsFrameScrollbars):
* testing/Internals.cpp:
(WebCore::Internals::nodesFromRect):
2013-02-14 Pavel Feldman <pfeldman@chromium.org>
Web Inspector: make component-based compile-front-end happy
......@@ -178,7 +178,7 @@ __ZN7WebCore12EventHandler14scrollOverflowENS_15ScrollDirectionENS_17ScrollGranu
__ZN7WebCore12EventHandler15handleAccessKeyERKNS_21PlatformKeyboardEventE
__ZN7WebCore12EventHandler16handleWheelEventERKNS_18PlatformWheelEventE
__ZN7WebCore12EventHandler17scrollRecursivelyENS_15ScrollDirectionENS_17ScrollGranularityEPNS_4NodeE
__ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_11LayoutPointEbbNS_17HitTestScrollbarsEjRKNS_10LayoutSizeE
__ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_11LayoutPointEjRKNS_10LayoutSizeE
__ZN7WebCore12EventHandler21handleMousePressEventERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler23handleMouseReleaseEventERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler24logicalScrollRecursivelyENS_22ScrollLogicalDirectionENS_17ScrollGranularityEPNS_4NodeE
......@@ -1486,7 +1486,7 @@ __ZNK7WebCore7IntRectcv6CGRectEv
__ZNK7WebCore7RunLoop9TimerBase8isActiveEv
__ZNK7WebCore8Document11completeURLERKN3WTF6StringE
__ZNK7WebCore8Document13axObjectCacheEv
__ZNK7WebCore8Document13nodesFromRectEiijjjjbb
__ZNK7WebCore8Document13nodesFromRectEiijjjjj
__ZNK7WebCore8Document14getElementByIdERKN3WTF12AtomicStringE
__ZNK7WebCore8Document31displayStringModifiedByEncodingERKN3WTF6StringE
__ZNK7WebCore8Document4bodyEv
......
......@@ -22748,7 +22748,7 @@ __ZNK7WebCore12NodeIterator20updateForNodeRemovalEPNS_4NodeERNS0_11NodePointerE
__ZN7WebCore27jsNodeIteratorReferenceNodeEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE
__ZNK7WebCore4Node20traversePreviousNodeEPKS0_
__ZN7WebCore37jsNodeIteratorPrototypeFunctionDetachEPN3JSC9ExecStateE
__ZNK7WebCore8Document13nodesFromRectEiijjjjb
__ZNK7WebCore8Document13nodesFromRectEiijjjjj
__ZNK7WebCore8Document17handleZeroPaddingERKNS_14HitTestRequestERNS_13HitTestResultE
__ZN3WTF21ListHashSetTranslatorINS_6RefPtrIN7WebCore4NodeEEELm256ENS_7PtrHashIS4_EEE9translateERPNS_15ListHashSetNodeIS4_Lm256EEERKS4_PNS_24ListHashSetNodeAllocatorIS4_Lm256EEE
__ZN7WebCore21StaticHashSetNodeListC1ERN3WTF11ListHashSetINS1_6RefPtrINS_4NodeEEELm256ENS1_7PtrHashIS5_EEEE
......@@ -1351,7 +1351,7 @@ String Document::suggestedMIMEType() const
// * making it receive a rect as parameter, i.e. nodesFromRect(x, y, w, h);
// * making it receive the expading size of each direction separately,
// i.e. nodesFromRect(x, y, topSize, rightSize, bottomSize, leftSize);
PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent) const
PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, HitTestRequest::HitTestRequestType hitType) const
{
// FIXME: Share code between this, elementFromPoint and caretRangeFromPoint.
if (!renderer())
......@@ -1366,17 +1366,11 @@ PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned
float zoomFactor = frame->pageZoomFactor();
LayoutPoint point = roundedLayoutPoint(FloatPoint(centerX * zoomFactor + view()->scrollX(), centerY * zoomFactor + view()->scrollY()));
int type = HitTestRequest::ReadOnly | HitTestRequest::Active;
HitTestRequest request(hitType);
// When ignoreClipping is false, this method returns null for coordinates outside of the viewport.
if (ignoreClipping)
type |= HitTestRequest::IgnoreClipping;
else if (!frameView->visibleContentRect().intersects(HitTestLocation::rectForPoint(point, topPadding, rightPadding, bottomPadding, leftPadding)))
if (!request.ignoreClipping() && !frameView->visibleContentRect().intersects(HitTestLocation::rectForPoint(point, topPadding, rightPadding, bottomPadding, leftPadding)))
return 0;
if (allowShadowContent)
type |= HitTestRequest::AllowShadowContent;
HitTestRequest request(type);
// Passing a zero padding will trigger a rect hit test, however for the purposes of nodesFromRect,
// we special handle this case in order to return a valid NodeList.
......
......@@ -35,6 +35,7 @@
#include "DocumentEventQueue.h"
#include "DocumentTiming.h"
#include "FocusDirection.h"
#include "HitTestRequest.h"
#include "IconURL.h"
#include "InspectorCounters.h"
#include "IntRect.h"
......@@ -380,11 +381,10 @@ public:
* @param rightPadding How much to expand the right of the rectangle
* @param bottomPadding How much to expand the bottom of the rectangle
* @param leftPadding How much to expand the left of the rectangle
* @param ignoreClipping whether or not to ignore the root scroll frame when retrieving the element.
* If false, this method returns null for coordinates outside of the viewport.
*/
PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding,
unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent) const;
PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY,
unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding,
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active) const;
Element* elementFromPoint(int x, int y) const;
PassRefPtr<Range> caretRangeFromPoint(int x, int y);
......
......@@ -152,7 +152,7 @@ PassOwnPtr<ContextMenu> ContextMenuController::createContextMenu(Event* event)
HitTestResult result(mouseEvent->absoluteLocation());
if (Frame* frame = event->target()->toNode()->document()->frame())
result = frame->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation(), false);
result = frame->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation());
if (!result.innerNonSharedNode())
return nullptr;
......
......@@ -560,7 +560,7 @@ bool DragController::canProcessDrag(DragData* dragData)
if (!m_page->mainFrame()->contentRenderer())
return false;
result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, true);
result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
if (!result.innerNonSharedNode())
return false;
......@@ -744,7 +744,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
if (!src->view() || !src->contentRenderer())
return false;
HitTestResult hitTestResult = src->eventHandler()->hitTestResultAtPoint(dragOrigin, true);
HitTestResult hitTestResult = src->eventHandler()->hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
if (!state.m_dragSrc->contains(hitTestResult.innerNode()))
// The original node being dragged isn't under the drag origin anymore... maybe it was
// hidden or moved out from under the cursor. Regardless, we don't want to start a drag on
......
......@@ -1001,7 +1001,7 @@ DragSourceAction EventHandler::updateDragSourceActionsAllowed() const
}
#endif // ENABLE(DRAG_SUPPORT)
HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool allowShadowContent, bool ignoreClipping, HitTestScrollbars testScrollbars, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding)
HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding)
{
// We always send hitTestResultAtPoint to the main frame if we have one,
// otherwise we might hit areas that are obscured by higher frames.
......@@ -1012,7 +1012,7 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool
FrameView* mainView = mainFrame->view();
if (frameView && mainView) {
IntPoint mainFramePoint = mainView->rootViewToContents(frameView->contentsToRootView(roundedIntPoint(point)));
return mainFrame->eventHandler()->hitTestResultAtPoint(mainFramePoint, allowShadowContent, ignoreClipping, testScrollbars, hitType, padding);
return mainFrame->eventHandler()->hitTestResultAtPoint(mainFramePoint, hitType, padding);
}
}
}
......@@ -1021,10 +1021,7 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool
if (!m_frame->contentRenderer())
return result;
if (ignoreClipping)
hitType |= HitTestRequest::IgnoreClipping;
if (allowShadowContent)
hitType |= HitTestRequest::AllowShadowContent;
HitTestRequest request(hitType);
m_frame->contentRenderer()->hitTest(request, result);
......@@ -1047,14 +1044,14 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool
frame->contentRenderer()->hitTest(request, widgetHitTestResult);
result = widgetHitTestResult;
if (testScrollbars == ShouldHitTestScrollbars) {
if (request.allowsFrameScrollbars()) {
Scrollbar* eventScrollbar = view->scrollbarAtPoint(roundedIntPoint(point));
if (eventScrollbar)
result.setScrollbar(eventScrollbar);
}
}
if (!allowShadowContent)
if (!request.allowsShadowContent())
result.setToNonShadowAncestor();
return result;
......@@ -1452,7 +1449,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_mouseDownWasInSubframe = false;
HitTestRequest request(HitTestRequest::Active);
// Save the document point we generate in case the window coordinate is invalidated by what happens
// Save the document point we generate in case the window coordinate is invalidated by what happens
// when we dispatch the event.
LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.position());
MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
......@@ -2456,7 +2453,7 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
if ((!scrollbar && !eventTarget) || !(hitType & HitTestRequest::ReadOnly)) {
IntPoint hitTestPoint = m_frame->view()->windowToContents(adjustedPoint);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, false, false, ShouldHitTestScrollbars, hitType);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType | HitTestRequest::AllowFrameScrollbars);
eventTarget = result.targetNode();
if (!scrollbar) {
FrameView* view = m_frame->view();
......@@ -2595,7 +2592,7 @@ bool EventHandler::handleGestureForTextSelectionOrContextMenu(const PlatformGest
{
#if OS(ANDROID)
IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.position());
HitTestResult result = hitTestResultAtPoint(hitTestPoint, true);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
Node* innerNode = result.targetNode();
if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable() || innerNode->isTextNode())) {
selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitespace);
......@@ -2737,9 +2734,8 @@ bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode)
{
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ true, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent, touchRadius);
IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult());
......@@ -2756,9 +2752,8 @@ bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, c
bool EventHandler::bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode)
{
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ true, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent, touchRadius);
IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult());
......@@ -2767,9 +2762,8 @@ bool EventHandler::bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter,
bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode)
{
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ false, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, touchRadius);
IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult());
......@@ -3862,7 +3856,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
if (pointState == PlatformTouchPoint::TouchPressed) {
HitTestResult result;
if (freshTouchEvents) {
result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ true, false, DontHitTestScrollbars, hitType);
result = hitTestResultAtPoint(pagePoint, hitType | HitTestRequest::AllowShadowContent);
m_originatingTouchPointTargetKey = touchPointTargetKey;
} else if (m_originatingTouchPointDocument.get() && m_originatingTouchPointDocument->frame()) {
LayoutPoint pagePointInOriginatingDocument = documentPointForWindowPoint(m_originatingTouchPointDocument->frame(), point.pos());
......@@ -3896,7 +3890,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
} else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
// We only perform a hittest on release or cancel to unset :active or :hover state.
if (touchPointTargetKey == m_originatingTouchPointTargetKey) {
hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ true, false, DontHitTestScrollbars, hitType);
hitTestResultAtPoint(pagePoint, hitType | HitTestRequest::AllowShadowContent);
m_originatingTouchPointTargetKey = 0;
} else if (m_originatingTouchPointDocument.get() && m_originatingTouchPointDocument->frame()) {
LayoutPoint pagePointInOriginatingDocument = documentPointForWindowPoint(m_originatingTouchPointDocument->frame(), point.pos());
......
......@@ -91,7 +91,6 @@ extern const int TextDragHysteresis;
extern const int GeneralDragHysteresis;
#endif // ENABLE(DRAG_SUPPORT)
enum HitTestScrollbars { ShouldHitTestScrollbars, DontHitTestScrollbars };
enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace };
enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis };
......@@ -127,8 +126,7 @@ public:
void dispatchFakeMouseMoveEventSoon();
void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
HitTestResult hitTestResultAtPoint(const LayoutPoint&, bool allowShadowContent, bool ignoreClipping = false,
HitTestScrollbars scrollbars = DontHitTestScrollbars,
HitTestResult hitTestResultAtPoint(const LayoutPoint&,
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active,
const LayoutSize& padding = LayoutSize());
......
......@@ -717,7 +717,7 @@ static void updateFocusCandidateIfNeeded(FocusDirection direction, const FocusCa
// If 2 nodes are intersecting, do hit test to find which node in on top.
LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2;
LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2;
HitTestResult result = candidate.visibleNode->document()->page()->mainFrame()->eventHandler()->hitTestResultAtPoint(IntPoint(x, y), false, true);
HitTestResult result = candidate.visibleNode->document()->page()->mainFrame()->eventHandler()->hitTestResultAtPoint(IntPoint(x, y), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping);
if (candidate.visibleNode->contains(result.innerNode())) {
closest = candidate;
return;
......
......@@ -721,7 +721,7 @@ String Frame::displayStringModifiedByEncoding(const String& str) const
VisiblePosition Frame::visiblePositionForPoint(const IntPoint& framePoint)
{
HitTestResult result = eventHandler()->hitTestResultAtPoint(framePoint, true);
HitTestResult result = eventHandler()->hitTestResultAtPoint(framePoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
Node* node = result.innerNonSharedNode();
if (!node)
return VisiblePosition();
......@@ -743,7 +743,7 @@ Document* Frame::documentAtPoint(const IntPoint& point)
HitTestResult result = HitTestResult(pt);
if (contentRenderer())
result = eventHandler()->hitTestResultAtPoint(pt, false);
result = eventHandler()->hitTestResultAtPoint(pt);
return result.innerNode() ? result.innerNode()->document() : 0;
}
......
......@@ -98,7 +98,7 @@ void findGoodTouchTargets(const IntRect& touchBox, Frame* mainFrame, Vector<IntR
IntPoint touchPoint = touchBox.center();
IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint);
HitTestResult result = mainFrame->eventHandler()->hitTestResultAtPoint(contentsPoint, false, false, DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly, IntSize(padding, padding));
HitTestResult result = mainFrame->eventHandler()->hitTestResultAtPoint(contentsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, IntSize(padding, padding));
const ListHashSet<RefPtr<Node> >& hitResults = result.rectBasedTestResult();
// Blacklist nodes that are container of disambiguated nodes.
......
......@@ -35,7 +35,8 @@ public:
IgnoreClipping = 1 << 5,
SVGClipContent = 1 << 6,
TouchEvent = 1 << 7,
AllowShadowContent = 1 << 8
AllowShadowContent = 1 << 8,
AllowFrameScrollbars = 1 << 9
};
typedef unsigned HitTestRequestType;
......@@ -54,6 +55,7 @@ public:
bool touchEvent() const { return m_requestType & TouchEvent; }
bool mouseEvent() const { return !touchEvent(); }
bool allowsShadowContent() const { return m_requestType & AllowShadowContent; }
bool allowsFrameScrollbars() const { return m_requestType & AllowFrameScrollbars; }
// Convenience functions
bool touchMove() const { return move() && touchEvent(); }
......
......@@ -1385,7 +1385,13 @@ PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int x, int y,
return 0;
}
return document->nodesFromRect(x, y, topPadding, rightPadding, bottomPadding, leftPadding, ignoreClipping, allowShadowContent);
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
if (ignoreClipping)
hitType |= HitTestRequest::IgnoreClipping;
if (allowShadowContent)
hitType |= HitTestRequest::AllowShadowContent;
return document->nodesFromRect(x, y, topPadding, rightPadding, bottomPadding, leftPadding, hitType);
}
void Internals::emitInspectorDidBeginFrame()
......
......@@ -2701,7 +2701,7 @@ PassRefPtr<Node> WebPagePrivate::contextNode(TargetDetectionStrategy strategy)
else
contentPos = mapFromViewportToContents(m_lastMouseEvent.position());
HitTestResult result = eventHandler->hitTestResultAtPoint(contentPos, false /*allowShadowContent*/);
HitTestResult result = eventHandler->hitTestResultAtPoint(contentPos);
return result.innerNode();
}
......@@ -2772,7 +2772,7 @@ Node* WebPagePrivate::nodeForZoomUnderPoint(const IntPoint& documentPoint)
if (!m_mainFrame)
return 0;
HitTestResult result = m_mainFrame->eventHandler()->hitTestResultAtPoint(documentPoint, false);
HitTestResult result = m_mainFrame->eventHandler()->hitTestResultAtPoint(documentPoint);
Node* node = result.innerNonSharedNode();
......@@ -4009,7 +4009,7 @@ bool WebPagePrivate::handleMouseEvent(PlatformMouseEvent& mouseEvent)
}
if (!node) {
HitTestResult result = eventHandler->hitTestResultAtPoint(mapFromViewportToContents(mouseEvent.position()), false /*allowShadowContent*/);
HitTestResult result = eventHandler->hitTestResultAtPoint(mapFromViewportToContents(mouseEvent.position()));
node = result.innerNode();
}
......@@ -4986,7 +4986,7 @@ WebDOMDocument WebPage::document() const
WebDOMNode WebPage::nodeAtDocumentPoint(const Platform::IntPoint& documentPoint)
{
HitTestResult result = d->m_mainFrame->eventHandler()->hitTestResultAtPoint(WebCore::IntPoint(documentPoint), false);
HitTestResult result = d->m_mainFrame->eventHandler()->hitTestResultAtPoint(WebCore::IntPoint(documentPoint));
Node* node = result.innerNonSharedNode();
return WebDOMNode(node);
}
......@@ -6244,7 +6244,7 @@ const HitTestResult& WebPagePrivate::hitTestResult(const IntPoint& contentPos)
{
if (m_cachedHitTestContentPos != contentPos) {
m_cachedHitTestContentPos = contentPos;
m_cachedHitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(m_cachedHitTestContentPos, true /*allowShadowContent*/);
m_cachedHitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(m_cachedHitTestContentPos, HitTestResult::ReadOnly | HitTestResult::Active | HitTestResult::AllowShadowContent);
}
return m_cachedHitTestResult;
......
2013-02-15 Allan Sandfeld Jensen <allan.jensen@digia.com>
Simplify hitTestResultAtPoint and nodesFromRect APIs
https://bugs.webkit.org/show_bug.cgi?id=95720
Reviewed by Julien Chaffraix.
Update calls to new API.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::contextNode):
(BlackBerry::WebKit::WebPagePrivate::nodeForZoomUnderPoint):
(BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
(BlackBerry::WebKit::WebPage::nodeAtDocumentPoint):
(BlackBerry::WebKit::WebPagePrivate::hitTestResult):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::visiblePositionForPointIgnoringClipping):
2013-02-14 Mike Fenton <mifenton@rim.com>
[BlackBerry] Update keyboard event details to match platform details.
......
......@@ -167,7 +167,7 @@ static VisiblePosition visiblePositionForPointIgnoringClipping(const Frame& fram
// outside the visible rect. To work around the bug, this is a copy of
// visiblePositionAtPoint which which passes ignoreClipping=true.
// See RIM Bug #4315.
HitTestResult result = frame.eventHandler()->hitTestResultAtPoint(framePoint, true /* allowShadowContent */, true /* ignoreClipping */);
HitTestResult result = frame.eventHandler()->hitTestResultAtPoint(framePoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent | HitTestRequest::IgnoreClipping);
Node* node = result.innerNode();
if (!node || node->document() != frame.document())
......
2013-02-15 Allan Sandfeld Jensen <allan.jensen@digia.com>
Simplify hitTestResultAtPoint and nodesFromRect APIs
https://bugs.webkit.org/show_bug.cgi?id=95720
Reviewed by Julien Chaffraix.
Update calls to new API.
* src/ContextMenuClientImpl.cpp:
(WebKit::selectMisspelledWord):
* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::characterIndexForPoint):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::isRectTopmost):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleMouseDown):
(WebKit::WebViewImpl::computeBlockBounds):
(WebKit::WebViewImpl::bestTouchLinkNode):
(WebKit::WebViewImpl::hitTestResultForWindowPos):
2013-02-14 Vsevolod Vlasov <vsevik@chromium.org>
Unreviewed chromium test fix: incorrect field was used for UISourceCode url.
......
......@@ -121,7 +121,7 @@ static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* select
// Selection is empty, so change the selection to the word under the cursor.
HitTestResult hitTestResult = selectedFrame->eventHandler()->
hitTestResultAtPoint(selectedFrame->page()->contextMenuController()->hitTestResult().pointInInnerNodeFrame(), true);
hitTestResultAtPoint(selectedFrame->page()->contextMenuController()->hitTestResult().pointInInnerNodeFrame(), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
Node* innerNode = hitTestResult.innerNode();
VisiblePosition pos(innerNode->renderer()->positionForPoint(
hitTestResult.localPoint()));
......
......@@ -1008,8 +1008,7 @@ void FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction(
if (event->isMouseEvent()) {
const MouseEvent* mouseEvent =
static_cast<const MouseEvent*>(event);
node = m_webFrame->frame()->eventHandler()->hitTestResultAtPoint(
mouseEvent->absoluteLocation(), false).innerNonSharedNode();
node = m_webFrame->frame()->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation()).innerNonSharedNode();
break;
}
}
......
......@@ -1181,7 +1181,7 @@ size_t WebFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const
return notFound;
IntPoint point = frame()->view()->windowToContents(webPoint);
HitTestResult result = frame()->eventHandler()->hitTestResultAtPoint(point, false);
HitTestResult result = frame()->eventHandler()->hitTestResultAtPoint(point);
RefPtr<Range> range = frame()->rangeForPoint(result.roundedPointInInnerNodeFrame());
if (!range)
return notFound;
......
......@@ -462,7 +462,7 @@ bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect)
LayoutPoint center = documentRect.center();
// Make the rect we're checking (the point surrounded by padding rects) contained inside the requested rect. (Note that -1/2 is 0.)
LayoutSize padding((documentRect.width() - 1) / 2, (documentRect.height() - 1) / 2);
HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(center, false, false, DontHitTestScrollbars, HitTestRequest::ReadOnly | HitTestRequest::Active, padding);
HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(center, HitTestRequest::ReadOnly | HitTestRequest::Active, padding);
const HitTestResult::NodeSet& nodes = result.rectBasedTestResult();
if (nodes.size() != 1)
return false;
......
......@@ -568,7 +568,7 @@ void WebViewImpl::handleMouseDown(Frame& mainFrame, const WebMouseEvent& event)
if (event.button == WebMouseEvent::ButtonLeft) {
IntPoint point(event.x, event.y);
point = m_page->mainFrame()->view()->windowToContents(point);
HitTestResult result(m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false));
HitTestResult result(m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point));
Node* hitNode = result.innerNonSharedNode();
// Take capture on a mouse down on a plugin so we can send it mouse events.
......@@ -1100,9 +1100,9 @@ WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, AutoZoomType zoomTy
// Use the rect-based hit test to find the node.
IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rect.x, rect.y));
HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResultAtPoint(point,
false, zoomType == FindInPage, DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly,
IntSize(rect.width, rect.height));
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active
| ((zoomType == FindInPage) ? HitTestRequest::IgnoreClipping : 0);
HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResultAtPoint(point, hitType, IntSize(rect.width, rect.height));
Node* node = result.innerNonSharedNode();
if (!node)
......@@ -1293,8 +1293,7 @@ Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
#endif
IntPoint hitTestPoint = m_page->mainFrame()->view()->windowToContents(touchEventLocation);
HitTestResult result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(
hitTestPoint, false, false, DontHitTestScrollbars, HitTestRequest::TouchEvent);
HitTestResult result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(hitTestPoint, HitTestRequest::TouchEvent);
bestTouchNode = result.targetNode();
// Make sure our highlight candidate uses a hand cursor as a heuristic to
......@@ -3954,7 +3953,7 @@ Node* WebViewImpl::focusedWebCoreNode()
HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos)
{
IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos));
return m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(docPoint, false);
return m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(docPoint);
}
void WebViewImpl::setTabsToLinks(bool enable)
......
2013-02-15 Allan Sandfeld Jensen <allan.jensen@digia.com>
Simplify hitTestResultAtPoint and nodesFromRect APIs
https://bugs.webkit.org/show_bug.cgi?id=95720
Reviewed by Julien Chaffraix.
Update calls to new API.
* ewk/ewk_frame.cpp:
(ewk_frame_hit_test_new):
2013-02-13 Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] window.open passes height and width parameters even if not defined in a page
......
......@@ -37,6 +37,7 @@
#include "HTMLNames.h"
#include "HTMLPlugInElement.h"
#include "HistoryItem.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"