Commit af1544e8 authored by hayato@chromium.org's avatar hayato@chromium.org
Browse files

Allow ShadowContents in HitTests by default.

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

Reviewed by Dimitri Glazkov.

Source/WebCore:

HitTestRequest is widely used in WebCore, but AllowShadowContents
flag is not turned on by default.  In most places, we can set the
flag on.

This change makes HitTests allow shadow contents by default.

To track all existing HitTests which do not allow shadow contents,
and discourage such a HitTest in the future, I've introduced
disallowShadowContenet flag so that callers must turn on this flag
explicitly if they want to disallow shadow contents in their HitTests.

This change should be refactoring and should not include any
behavior changes.  After this change, we'll investigate each place
where disallowShadowContents is used step by step and get rid of
the flag if it is okay to remove.

No new tests, no behavior change.

* dom/Document.h:
(Document):
* dom/TreeScope.cpp:
(WebCore::nodeFromPoint):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::contains):
* page/DragController.cpp:
(WebCore::elementUnderMouse):
(WebCore::DragController::canProcessDrag):
(WebCore::DragController::startDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::eventMayStartDrag):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::isInsideScrollbar):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::handleGestureEvent):
(WebCore::EventHandler::handleGestureLongPress):
(WebCore::EventHandler::handleGestureScrollBegin):
(WebCore::EventHandler::bestClickableNodeForTouchPoint):
(WebCore::EventHandler::bestContextMenuNodeForTouchPoint):
(WebCore::EventHandler::bestZoomableAreaForTouchPoint):
(WebCore::EventHandler::sendContextMenuEvent):
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::EventHandler::hoverTimerFired):
(WebCore::EventHandler::dragSourceEndedAt):
(WebCore::EventHandler::handleDrag):
(WebCore::EventHandler::handleTouchEvent):
(WebCore::EventHandler::dispatchSyntheticTouchEventIfEnabled):
* page/EventHandler.h:
(EventHandler):
* page/FocusController.cpp:
(WebCore::updateFocusCandidateIfNeeded):
* page/Frame.cpp:
(WebCore::Frame::visiblePositionForPoint):
* page/TouchDisambiguation.cpp:
(WebCore::findGoodTouchTargets):
* rendering/HitTestRequest.h:
(WebCore::HitTestRequest::disallowsShadowContent):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::addNodeToRectBasedTestResult):
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::hitTestFlowThreadPortionInRegion):
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::hitTestClipContent):
* testing/Internals.cpp:
(WebCore::Internals::nodesFromRect):

Source/WebKit/blackberry:

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::hitTestResult):
* WebKitSupport/FatFingers.cpp:
(BlackBerry::WebKit::FatFingers::getNodesFromRect):
* WebKitSupport/ProximityDetector.cpp:
(BlackBerry::WebKit::ProximityDetector::findBestPoint):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::visiblePositionForPointIgnoringClipping):

Source/WebKit/chromium:

* src/ContextMenuClientImpl.cpp:
(WebKit::selectMisspelledWord):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::visiblePositionForWindowPoint):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::isRectTopmost):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::computeBlockBounds):
(WebKit::WebViewImpl::bestTapNode):

Source/WebKit/efl:

* ewk/ewk_frame.cpp:
(ewk_frame_hit_test_new):

Source/WebKit/gtk:

* webkit/webkitwebinspector.cpp:
(webkit_web_inspector_inspect_coordinates):
* webkit/webkitwebview.cpp:
(prepareMouseEventForFrame):
(webkit_web_view_get_hit_test_result):

Source/WebKit/mac:

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

Source/WebKit/qt:

* WebCoreSupport/QWebFrameAdapter.cpp:
(QWebFrameAdapter::hitTestContent):

Source/WebKit/win:

* WebView.cpp:
(WebView::gestureNotify):

Source/WebKit2:

* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::hitTest):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::highlightPotentialActivation):
(WebKit::WebPage::findZoomableAreaForPoint):
(WebKit::WebPage::determinePrimarySnapshottedPlugIn):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::shouldDelayWindowOrderingEvent):
(WebKit::WebPage::acceptsFirstMouse):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146961 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0a171184
2013-03-26 Hayato Ito <hayato@chromium.org>
Allow ShadowContents in HitTests by default.
https://bugs.webkit.org/show_bug.cgi?id=113171
Reviewed by Dimitri Glazkov.
HitTestRequest is widely used in WebCore, but AllowShadowContents
flag is not turned on by default. In most places, we can set the
flag on.
This change makes HitTests allow shadow contents by default.
To track all existing HitTests which do not allow shadow contents,
and discourage such a HitTest in the future, I've introduced
disallowShadowContenet flag so that callers must turn on this flag
explicitly if they want to disallow shadow contents in their HitTests.
This change should be refactoring and should not include any
behavior changes. After this change, we'll investigate each place
where disallowShadowContents is used step by step and get rid of
the flag if it is okay to remove.
No new tests, no behavior change.
* dom/Document.h:
(Document):
* dom/TreeScope.cpp:
(WebCore::nodeFromPoint):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::contains):
* page/DragController.cpp:
(WebCore::elementUnderMouse):
(WebCore::DragController::canProcessDrag):
(WebCore::DragController::startDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::eventMayStartDrag):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::isInsideScrollbar):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::handleGestureEvent):
(WebCore::EventHandler::handleGestureLongPress):
(WebCore::EventHandler::handleGestureScrollBegin):
(WebCore::EventHandler::bestClickableNodeForTouchPoint):
(WebCore::EventHandler::bestContextMenuNodeForTouchPoint):
(WebCore::EventHandler::bestZoomableAreaForTouchPoint):
(WebCore::EventHandler::sendContextMenuEvent):
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::EventHandler::hoverTimerFired):
(WebCore::EventHandler::dragSourceEndedAt):
(WebCore::EventHandler::handleDrag):
(WebCore::EventHandler::handleTouchEvent):
(WebCore::EventHandler::dispatchSyntheticTouchEventIfEnabled):
* page/EventHandler.h:
(EventHandler):
* page/FocusController.cpp:
(WebCore::updateFocusCandidateIfNeeded):
* page/Frame.cpp:
(WebCore::Frame::visiblePositionForPoint):
* page/TouchDisambiguation.cpp:
(WebCore::findGoodTouchTargets):
* rendering/HitTestRequest.h:
(WebCore::HitTestRequest::disallowsShadowContent):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::addNodeToRectBasedTestResult):
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::hitTestFlowThreadPortionInRegion):
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::hitTestClipContent):
* testing/Internals.cpp:
(WebCore::Internals::nodesFromRect):
2013-03-26 Tim Horton <timothy_horton@apple.com>
 
[ca] Tell CA to clean up unused resources if a given WebProcess won't be drawing
......@@ -371,8 +371,8 @@ public:
* @param leftPadding How much to expand the left of the rectangle
*/
PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY,
unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding,
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active) const;
unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding,
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent) const;
Element* elementFromPoint(int x, int y) const;
PassRefPtr<Range> caretRangeFromPoint(int x, int y);
......
......@@ -228,7 +228,7 @@ Node* nodeFromPoint(Document* document, int x, int y, LayoutPoint* localPoint)
if (!frameView->visibleContentRect().contains(point))
return 0;
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
HitTestResult result(point);
document->renderView()->hitTest(request, result);
......
......@@ -1542,8 +1542,7 @@ bool FrameSelection::contains(const LayoutPoint& point)
if (!document->renderer())
return false;
HitTestRequest request(HitTestRequest::ReadOnly |
HitTestRequest::Active);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
HitTestResult result(point);
document->renderView()->hitTest(request, result);
Node* innerNode = result.innerNode();
......
......@@ -297,7 +297,7 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint&
float zoomFactor = frame ? frame->pageZoomFactor() : 1;
LayoutPoint point = roundedLayoutPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor));
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
HitTestResult result(point);
documentUnderMouse->renderView()->hitTest(request, result);
......@@ -563,7 +563,7 @@ bool DragController::canProcessDrag(DragData* dragData)
if (!m_page->mainFrame()->contentRenderer())
return false;
result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active);
if (!result.innerNonSharedNode())
return false;
......@@ -747,7 +747,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
if (!src->view() || !src->contentRenderer())
return false;
HitTestResult hitTestResult = src->eventHandler()->hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
HitTestResult hitTestResult = src->eventHandler()->hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active);
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
......
......@@ -738,7 +738,7 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
}
if (m_selectionInitiationState != ExtendedSelection) {
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
HitTestResult result(m_mouseDownPos);
m_frame->document()->renderView()->hitTest(request, result);
......@@ -769,7 +769,7 @@ bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) const
return false;
updateDragSourceActionsAllowed();
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
HitTestResult result(view->windowToContents(event.position()));
m_frame->contentRenderer()->hitTest(request, result);
DragState state;
......@@ -785,9 +785,7 @@ void EventHandler::updateSelectionForMouseDrag()
if (!renderer)
return;
HitTestRequest request(HitTestRequest::ReadOnly |
HitTestRequest::Active |
HitTestRequest::Move);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Move | HitTestRequest::DisallowShadowContent);
HitTestResult result(view->windowToContents(m_lastKnownMousePosition));
renderer->hitTest(request, result);
updateSelectionForMouseDrag(result);
......@@ -1042,7 +1040,7 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
if (!request.readOnly())
m_frame->document()->updateHoverActiveState(request, result.innerElement());
if (!request.allowsShadowContent())
if (request.disallowsShadowContent())
result.setToNonShadowAncestor();
return result;
......@@ -1478,7 +1476,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
}
m_mouseDownWasInSubframe = false;
HitTestRequest request(HitTestRequest::Active);
HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
// 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());
......@@ -1541,7 +1539,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
// in case the scrollbar widget was destroyed when the mouse event was handled.
if (mev.scrollbar()) {
const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMouse.get();
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get())
m_lastScrollbarUnderMouse = 0;
......@@ -1561,7 +1559,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
// we'd like to EventHandler::handleMousePressEvent to pass the event to the widget and thus the
// event target node can't still be the shadow node.
if (mev.targetNode()->isShadowRoot() && toShadowRoot(mev.targetNode())->host()->hasTagName(inputTag)) {
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
}
......@@ -1594,7 +1592,7 @@ bool EventHandler::handleMouseDoubleClickEvent(const PlatformMouseEvent& mouseEv
m_mousePressed = false;
setLastKnownMousePosition(mouseEvent);
HitTestRequest request(HitTestRequest::Active);
HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent);
Frame* subframe = subframeForHitTestResult(mev);
if (m_eventHandlerWillResetCapturingMouseEventsNode)
......@@ -1706,7 +1704,7 @@ bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent, Hi
if (m_lastScrollbarUnderMouse && m_mousePressed)
return m_lastScrollbarUnderMouse->mouseMoved(mouseEvent);
HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move;
HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move | HitTestRequest::DisallowShadowContent;
if (m_mousePressed)
hitType |= HitTestRequest::Active;
else if (onlyUpdateScrollbars) {
......@@ -1859,7 +1857,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
return !dispatchMouseEvent(eventNames().mouseupEvent, m_lastNodeUnderMouse.get(), cancelable, m_clickCount, mouseEvent, setUnder);
}
HitTestRequest request(HitTestRequest::Release);
HitTestRequest request(HitTestRequest::Release | HitTestRequest::DisallowShadowContent);
MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent);
Frame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev);
if (m_eventHandlerWillResetCapturingMouseEventsNode)
......@@ -2008,7 +2006,7 @@ bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard*
if (!m_frame->view())
return false;
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
MouseEventWithHitTestResults mev = prepareMouseEvent(request, event);
// Drag events should never go to text nodes (following IE, and proper mouseover/out dispatch)
......@@ -2321,7 +2319,7 @@ bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
bool EventHandler::isInsideScrollbar(const IntPoint& windowPoint) const
{
if (RenderView* renderView = m_frame->contentRenderer()) {
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
HitTestResult result(windowPoint);
renderView->hitTest(request, result);
return result.scrollbar();
......@@ -2353,7 +2351,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e)
setFrameWasScrolledByUser();
LayoutPoint vPoint = view->windowToContents(e.position());
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
HitTestResult result(vPoint);
doc->renderView()->hitTest(request, result);
......@@ -2464,7 +2462,7 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
}
IntPoint adjustedPoint = gestureEvent.position();
HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent | HitTestRequest::AllowShadowContent;
HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent;
if (gestureEvent.type() == PlatformEvent::GestureTapDown) {
#if ENABLE(TOUCH_ADJUSTMENT)
adjustGesturePosition(gestureEvent, adjustedPoint);
......@@ -2596,7 +2594,7 @@ bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEve
PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, 0, false, false, false, false, WTF::currentTime());
handleMousePressEvent(mouseDownEvent);
PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WTF::currentTime());
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragEvent);
m_didStartDrag = false;
RefPtr<Frame> subframe = subframeForHitTestResult(mev);
......@@ -2625,7 +2623,7 @@ bool EventHandler::handleGestureForTextSelectionOrContextMenu(const PlatformGest
{
#if OS(ANDROID)
IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.position());
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active);
Node* innerNode = result.targetNode();
if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable() || innerNode->isTextNode())) {
selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitespace);
......@@ -2678,7 +2676,7 @@ bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE
return false;
LayoutPoint viewPoint = view->windowToContents(gestureEvent.position());
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
HitTestResult result(viewPoint);
document->renderView()->hitTest(request, result);
......@@ -2788,7 +2786,7 @@ bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode)
{
IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent, touchRadius);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, touchRadius);
IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult());
......@@ -2806,7 +2804,7 @@ bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, c
bool EventHandler::bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode)
{
IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent, touchRadius);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, touchRadius);
IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult());
......@@ -2816,7 +2814,7 @@ bool EventHandler::bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter,
bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode)
{
IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, touchRadius);
HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent, touchRadius);
IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult());
......@@ -2859,7 +2857,7 @@ bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
m_mousePressed = false;
bool swallowEvent;
LayoutPoint viewportPos = v->windowToContents(event.position());
HitTestRequest request(HitTestRequest::Active);
HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportPos, event);
if (m_frame->editor()->behavior().shouldSelectOnContextualMenuClick()
......@@ -2936,7 +2934,7 @@ bool EventHandler::sendContextMenuEventForKey()
// Use the focused node as the target for hover and active.
HitTestResult result(position);
result.setInnerNode(targetNode);
doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement());
doc->updateHoverActiveState(HitTestRequest::Active | HitTestRequest::DisallowShadowContent, result.innerElement());
// The contextmenu event is a mouse event even when invoked using the keyboard.
// This is required for web compatibility.
......@@ -3070,7 +3068,7 @@ void EventHandler::hoverTimerFired(Timer<EventHandler>*)
if (RenderView* renderer = m_frame->contentRenderer()) {
if (FrameView* view = m_frame->view()) {
HitTestRequest request(HitTestRequest::Move);
HitTestRequest request(HitTestRequest::Move | HitTestRequest::DisallowShadowContent);
HitTestResult result(view->windowToContents(m_lastKnownMousePosition));
renderer->hitTest(request, result);
m_frame->document()->updateHoverActiveState(request, result.innerElement());
......@@ -3377,7 +3375,7 @@ void EventHandler::freeClipboard()
void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, DragOperation operation)
{
// Send a hit test request so that RenderLayer gets a chance to update the :hover and :active pseudoclasses.
HitTestRequest request(HitTestRequest::Release);
HitTestRequest request(HitTestRequest::Release | HitTestRequest::DisallowShadowContent);
prepareMouseEvent(request, event);
if (dragState().m_dragSrc && dragState().shouldDispatchEvents()) {
......@@ -3430,7 +3428,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr
dragState().m_eventDispatchPolicy = (updateDragSourceActionsAllowed() & DragSourceActionDHTML) ? DragState::DispatchEvents: DragState::DoNotDispatchEvents;
// try to find an element that wants to be dragged
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
HitTestResult result(m_mouseDownPos);
m_frame->contentRenderer()->hitTest(request, result);
Node* node = result.innerNode();
......@@ -3906,7 +3904,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
if (pointState == PlatformTouchPoint::TouchPressed) {
HitTestResult result;
if (freshTouchEvents) {
result = hitTestResultAtPoint(pagePoint, hitType | HitTestRequest::AllowShadowContent);
result = hitTestResultAtPoint(pagePoint, hitType);
m_originatingTouchPointTargetKey = touchPointTargetKey;
} else if (m_originatingTouchPointDocument.get() && m_originatingTouchPointDocument->frame()) {
LayoutPoint pagePointInOriginatingDocument = documentPointForWindowPoint(m_originatingTouchPointDocument->frame(), point.pos());
......@@ -3940,7 +3938,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, hitType | HitTestRequest::AllowShadowContent);
hitTestResultAtPoint(pagePoint, hitType);
m_originatingTouchPointTargetKey = 0;
} else if (m_originatingTouchPointDocument.get() && m_originatingTouchPointDocument->frame()) {
LayoutPoint pagePointInOriginatingDocument = documentPointForWindowPoint(m_originatingTouchPointDocument->frame(), point.pos());
......@@ -4048,7 +4046,7 @@ bool EventHandler::dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent
if (eventType != PlatformEvent::MouseMoved && eventType != PlatformEvent::MousePressed && eventType != PlatformEvent::MouseReleased)
return false;
HitTestRequest request(HitTestRequest::Active);
HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
MouseEventWithHitTestResults mev = prepareMouseEvent(request, event);
if (mev.scrollbar() || subframeForHitTestResult(mev))
return false;
......
......@@ -131,8 +131,8 @@ public:
void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
HitTestResult hitTestResultAtPoint(const LayoutPoint&,
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active,
const LayoutSize& padding = LayoutSize());
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent,
const LayoutSize& padding = LayoutSize());
bool mousePressed() const { return m_mousePressed; }
void setMousePressed(bool pressed) { m_mousePressed = pressed; }
......@@ -298,7 +298,7 @@ private:
#if ENABLE(TOUCH_EVENTS)
bool dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent&);
HitTestResult hitTestResultInFrame(Frame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestResult hitTestResultInFrame(Frame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
#endif
void invalidateClick();
......
......@@ -721,7 +721,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), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping);
HitTestResult result = candidate.visibleNode->document()->page()->mainFrame()->eventHandler()->hitTestResultAtPoint(IntPoint(x, y), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowShadowContent);
if (candidate.visibleNode->contains(result.innerNode())) {
closest = candidate;
return;
......
......@@ -722,7 +722,7 @@ String Frame::displayStringModifiedByEncoding(const String& str) const
VisiblePosition Frame::visiblePositionForPoint(const IntPoint& framePoint)
{
HitTestResult result = eventHandler()->hitTestResultAtPoint(framePoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
HitTestResult result = eventHandler()->hitTestResultAtPoint(framePoint, HitTestRequest::ReadOnly | HitTestRequest::Active);
Node* node = result.innerNonSharedNode();
if (!node)
return VisiblePosition();
......
......@@ -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, HitTestRequest::ReadOnly | HitTestRequest::Active, IntSize(padding, padding));
HitTestResult result = mainFrame->eventHandler()->hitTestResultAtPoint(contentsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent, IntSize(padding, padding));
const ListHashSet<RefPtr<Node> >& hitResults = result.rectBasedTestResult();
// Blacklist nodes that are container of disambiguated nodes.
......
......@@ -35,7 +35,7 @@ public:
IgnoreClipping = 1 << 5,
SVGClipContent = 1 << 6,
TouchEvent = 1 << 7,
AllowShadowContent = 1 << 8,
DisallowShadowContent = 1 << 8,
AllowFrameScrollbars = 1 << 9,
AllowChildFrameContent = 1 << 10,
ChildFrameHitTest = 1 << 11
......@@ -56,7 +56,7 @@ public:
bool svgClipContent() const { return m_requestType & SVGClipContent; }
bool touchEvent() const { return m_requestType & TouchEvent; }
bool mouseEvent() const { return !touchEvent(); }
bool allowsShadowContent() const { return m_requestType & AllowShadowContent; }
bool disallowsShadowContent() const { return m_requestType & DisallowShadowContent; }
bool allowsFrameScrollbars() const { return m_requestType & AllowFrameScrollbars; }
bool allowsChildFrameContent() const { return m_requestType & AllowChildFrameContent; }
bool isChildFrameHitTest() const { return m_requestType & ChildFrameHitTest; }
......
......@@ -556,7 +556,7 @@ bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestReques
if (!node)
return true;
if (!request.allowsShadowContent())
if (request.disallowsShadowContent())
node = node->document()->ancestorInThisScope(node);
mutableRectBasedTestResult().add(node);
......@@ -576,7 +576,7 @@ bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestReques
if (!node)
return true;
if (!request.allowsShadowContent())
if (request.disallowsShadowContent())
node = node->document()->ancestorInThisScope(node);
mutableRectBasedTestResult().add(node);
......
......@@ -312,7 +312,7 @@ bool RenderFlowThread::hitTestFlowThreadPortionInRegion(RenderRegion* region, La
renderFlowThreadOffset = accumulatedOffset - flowThreadPortionRect.location();
// Always ignore clipping, since the RenderFlowThread has nothing to do with the bounds of the FrameView.
HitTestRequest newRequest(request.type() | HitTestRequest::IgnoreClipping);
HitTestRequest newRequest(request.type() | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowShadowContent);
HitTestResult tempResult(result);
// Make a new temporary HitTestLocation in the new region.
......
......@@ -312,7 +312,7 @@ bool RenderSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundin
continue;
IntPoint hitPoint;
HitTestResult result(hitPoint);
if (renderer->nodeAtFloatPoint(HitTestRequest(HitTestRequest::SVGClipContent), result, point, HitTestForeground))
if (renderer->nodeAtFloatPoint(HitTestRequest(HitTestRequest::SVGClipContent | HitTestRequest::DisallowShadowContent), result, point, HitTestForeground))
return true;
}
......
......@@ -1415,8 +1415,8 @@ PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int x, int y,
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
if (ignoreClipping)
hitType |= HitTestRequest::IgnoreClipping;
if (allowShadowContent)
hitType |= HitTestRequest::AllowShadowContent;
if (!allowShadowContent)
hitType |= HitTestRequest::DisallowShadowContent;
if (allowChildFrameContent)
hitType |= HitTestRequest::AllowChildFrameContent;
......
......@@ -6227,7 +6227,7 @@ const HitTestResult& WebPagePrivate::hitTestResult(const IntPoint& contentPos)
{
if (m_cachedHitTestContentPos != contentPos) {
m_cachedHitTestContentPos = contentPos;
m_cachedHitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(m_cachedHitTestContentPos, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent);
m_cachedHitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(m_cachedHitTestContentPos, HitTestRequest::ReadOnly | HitTestRequest::Active);
}
return m_cachedHitTestResult;
......
2013-03-26 Hayato Ito <hayato@chromium.org>
Allow ShadowContents in HitTests by default.
https://bugs.webkit.org/show_bug.cgi?id=113171
Reviewed by Dimitri Glazkov.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::hitTestResult):
* WebKitSupport/FatFingers.cpp:
(BlackBerry::WebKit::FatFingers::getNodesFromRect):
* WebKitSupport/ProximityDetector.cpp:
(BlackBerry::WebKit::ProximityDetector::findBestPoint):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::visiblePositionForPointIgnoringClipping):
2013-03-26 Xiaobo Wang <xbwang@torchmobile.com.cn>
 
[BlackBerry] Memory leak in WebPagePrivate.cpp - NavigatorContentUtilsClientBlackBerry
......
......@@ -465,8 +465,8 @@ void FatFingers::getNodesFromRect(Document* document, const IntPoint& contentPos
// The user functions checkForText() and findIntersectingRegions() uses the Node.wholeText() to checkFingerIntersection()
// not the text in its shadow tree.
HitTestRequest::HitTestRequestType requestType = HitTestRequest::ReadOnly | HitTestRequest::Active;
if (m_targetType == Text)
requestType |= HitTestRequest::AllowShadowContent;
if (m_targetType != Text)
requestType |= HitTestRequest::DisallowShadowContent;
HitTestResult result(contentPos, topPadding, rightPadding, bottomPadding, leftPadding);
document->renderView()->layer()->hitTest(requestType, result);
......@@ -506,4 +506,3 @@ void FatFingers::setSuccessfulFatFingersResult(FatFingersResult& result, Node* b
}
}
......@@ -73,7 +73,7 @@ IntPoint ProximityDetector::findBestPoint(const IntPoint& documentPos, const Int
// Adjust hit point to frame
IntPoint frameContentPos(document->frame()->view()->windowToContents(m_webPage->m_mainFrame->view()->contentsToWindow(documentPos)));
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::IgnoreClipping);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowShadowContent);
HitTestResult result(frameContentPos, top, right, bottom, left);
document->renderView()->layer()->hitTest(request, result);
......
......@@ -172,7 +172,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, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent | HitTestRequest::IgnoreClipping);
HitTestResult result = frame.eventHandler()->hitTestResultAtPoint(framePoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping);
Node* node = result.innerNode();
if (!node || node->document() != frame.document())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment