From 2bde8e466a4451c7319e3a072d118917957d6554 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 25 May 2011 19:08:45 +0100 Subject: Merge WebKit at r82507: Initial merge by git Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e --- Source/WebCore/page/EventHandler.cpp | 106 +++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 23 deletions(-) (limited to 'Source/WebCore/page/EventHandler.cpp') diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index ef2ffb3..f05e8b2 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -98,8 +98,13 @@ #include "TouchEvent.h" #endif +<<<<<<< HEAD #if defined(ANDROID_PLUGINS) #include "WebViewCore.h" +======= +#if ENABLE(GESTURE_RECOGNIZER) +#include "PlatformGestureRecognizer.h" +>>>>>>> webkit.org at r82507 #endif namespace WebCore { @@ -209,6 +214,9 @@ EventHandler::EventHandler(Frame* frame) #if ENABLE(TOUCH_EVENTS) , m_touchPressed(false) #endif +#if ENABLE(GESTURE_RECOGNIZER) + , m_gestureRecognizer(PlatformGestureRecognizer::create()) +#endif { } @@ -260,6 +268,20 @@ void EventHandler::clear() #endif } +static void setSelectionIfNeeded(SelectionController* selection, const VisibleSelection& newSelection) +{ + ASSERT(selection); + if (selection->selection() != newSelection && selection->shouldChangeSelection(newSelection)) + selection->setSelection(newSelection); +} + +static void setNonDirectionalSelectionIfNeeded(SelectionController* selection, const VisibleSelection& newSelection, TextGranularity granularity) +{ + ASSERT(selection); + if (selection->selection() != newSelection && selection->shouldChangeSelection(newSelection)) + selection->setSelection(newSelection, granularity, MakeNonDirectionalSelection); +} + void EventHandler::selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults& result) { Node* innerNode = result.targetNode(); @@ -279,9 +301,8 @@ void EventHandler::selectClosestWordFromMouseEvent(const MouseEventWithHitTestRe if (result.event().clickCount() == 2 && m_frame->editor()->isSelectTrailingWhitespaceEnabled()) newSelection.appendTrailingWhitespace(); } - - if (m_frame->selection()->shouldChangeSelection(newSelection)) - m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); + + setNonDirectionalSelectionIfNeeded(m_frame->selection(), newSelection, granularity); } } @@ -305,8 +326,7 @@ void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit m_beganSelectingText = true; } - if (m_frame->selection()->shouldChangeSelection(newSelection)) - m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); + setNonDirectionalSelectionIfNeeded(m_frame->selection(), newSelection, granularity); } } @@ -349,9 +369,8 @@ bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR granularity = ParagraphGranularity; m_beganSelectingText = true; } - - if (m_frame->selection()->shouldChangeSelection(newSelection)) - m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); + + setNonDirectionalSelectionIfNeeded(m_frame->selection(), newSelection, granularity); return true; } @@ -416,9 +435,8 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR m_beganSelectingText = true; } else newSelection = VisibleSelection(visiblePos); - - if (m_frame->selection()->shouldChangeSelection(newSelection)) - m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); + + setNonDirectionalSelectionIfNeeded(m_frame->selection(), newSelection, granularity); return true; } @@ -555,7 +573,13 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e m_mouseDownMayStartAutoscroll = false; } - + + if (!m_beganSelectingText) { + HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); + HitTestResult result(m_mouseDownPos); + m_frame->document()->renderView()->layer()->hitTest(request, result); + updateSelectionForMouseDrag(result.innerNode(), result.localPoint()); + } updateSelectionForMouseDrag(targetNode, event.localPoint()); return true; } @@ -653,10 +677,7 @@ void EventHandler::updateSelectionForMouseDrag(Node* targetNode, const IntPoint& if (m_frame->selection()->granularity() != CharacterGranularity) newSelection.expandUsingGranularity(m_frame->selection()->granularity()); - if (m_frame->selection()->shouldChangeSelection(newSelection)) { - m_frame->selection()->setIsDirectional(false); - m_frame->selection()->setSelection(newSelection, m_frame->selection()->granularity(), MakeNonDirectionalSelection); - } + setNonDirectionalSelectionIfNeeded(m_frame->selection(), newSelection, m_frame->selection()->granularity()); } #endif // ENABLE(DRAG_SUPPORT) @@ -713,12 +734,12 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e VisibleSelection newSelection; Node* node = event.targetNode(); bool caretBrowsing = m_frame->settings()->caretBrowsingEnabled(); - if (node && (caretBrowsing || node->isContentEditable()) && node->renderer()) { + if (node && (caretBrowsing || node->rendererIsEditable()) && node->renderer()) { VisiblePosition pos = node->renderer()->positionForPoint(event.localPoint()); newSelection = VisibleSelection(pos); } - if (m_frame->selection()->shouldChangeSelection(newSelection)) - m_frame->selection()->setSelection(newSelection); + + setSelectionIfNeeded(m_frame->selection(), newSelection); handled = true; } @@ -1165,7 +1186,7 @@ Cursor EventHandler::selectCursor(const MouseEventWithHitTestResults& event, Scr switch (style ? style->cursor() : CURSOR_AUTO) { case CURSOR_AUTO: { - bool editable = (node && node->isContentEditable()); + bool editable = (node && node->rendererIsEditable()); bool editableLinkEnabled = false; // If the link is editable, then we need to check the settings to see whether or not the link should be followed @@ -1456,6 +1477,22 @@ bool EventHandler::handleMouseDoubleClickEvent(const PlatformMouseEvent& mouseEv return swallowMouseUpEvent || swallowClickEvent || swallowMouseReleaseEvent; } +static RenderLayer* layerForNode(Node* node) +{ + if (!node) + return 0; + + RenderObject* renderer = node->renderer(); + if (!renderer) + return 0; + + RenderLayer* layer = renderer->enclosingLayer(); + if (!layer) + return 0; + + return layer; +} + bool EventHandler::mouseMoved(const PlatformMouseEvent& event) { HitTestResult hoveredNode = HitTestResult(IntPoint()); @@ -1465,6 +1502,11 @@ bool EventHandler::mouseMoved(const PlatformMouseEvent& event) if (!page) return result; + if (RenderLayer* layer = layerForNode(hoveredNode.innerNode())) { + if (page->containsScrollableArea(layer)) + layer->scrollAnimator()->mouseMovedInContentArea(); + } + if (FrameView* frameView = m_frame->view()) frameView->scrollAnimator()->mouseMovedInContentArea(); @@ -1889,21 +1931,32 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo // Fire mouseout/mouseover if the mouse has shifted to a different node. if (fireMouseOverOut) { - // FIXME: This code will only correctly handle transitions between frames with scrollbars, - // not transitions between overflow regions, or transitions between two frames - // that don't have scrollbars contained within a frame that does. + RenderLayer* layerForLastNode = layerForNode(m_lastNodeUnderMouse.get()); + RenderLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderMouse.get()); + Page* page = m_frame->page(); + if (m_lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->document() != m_frame->document())) { + // The mouse has moved between frames. if (Frame* frame = m_lastNodeUnderMouse->document()->frame()) { if (FrameView* frameView = frame->view()) frameView->scrollAnimator()->mouseExitedContentArea(); } + } else if (page && (layerForLastNode && (!layerForNodeUnderMouse || layerForNodeUnderMouse != layerForLastNode))) { + // The mouse has moved between layers. + if (page->containsScrollableArea(layerForLastNode)) + layerForLastNode->scrollAnimator()->mouseExitedContentArea(); } if (m_nodeUnderMouse && (!m_lastNodeUnderMouse || m_lastNodeUnderMouse->document() != m_frame->document())) { + // The mouse has moved between frames. if (Frame* frame = m_nodeUnderMouse->document()->frame()) { if (FrameView* frameView = frame->view()) frameView->scrollAnimator()->mouseEnteredContentArea(); } + } else if (page && (layerForNodeUnderMouse && (!layerForLastNode || layerForNodeUnderMouse != layerForLastNode))) { + // The mouse has moved between layers. + if (page->containsScrollableArea(layerForNodeUnderMouse)) + layerForNodeUnderMouse->scrollAnimator()->mouseEnteredContentArea(); } if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame->document()) { @@ -2360,6 +2413,8 @@ bool EventHandler::needsKeyboardEventDisambiguationQuirks() const bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent) { + RefPtr protector(m_frame->view()); + #if ENABLE(PAN_SCROLLING) if (Page* page = m_frame->page()) { if (page->mainFrame()->eventHandler()->panScrollInProgress() || m_autoscrollInProgress) { @@ -3123,6 +3178,11 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) } } +#if ENABLE(GESTURE_RECOGNIZER) + if (m_gestureRecognizer) + m_gestureRecognizer->processTouchEventForGesture(event, this, defaultPrevented); +#endif + return defaultPrevented; } #endif -- cgit v1.1 From 74ee772b3c1ea8b557e5a596e9cbc655d1c0e161 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 8 Jun 2011 10:42:08 +0100 Subject: Merge WebKit at r82507: Fix conflicts - RenderLayerBacking.cpp Due to ANDROID_OVERFLOW_SCROLL http://trac.webkit.org/changeset/81715 - Document.cpp Due to domTreeVersion and ANDROID_STYLE_VERSION http://trac.webkit.org/changeset/80797 - CachedResourceLoader.cpp Due to temporary debugging and ANDROID_BLOCK_NETWORK_IMAGE http://trac.webkit.org/changeset/80695 - Settings.cpp/h http://trac.webkit.org/changeset/81289 http://trac.webkit.org/changeset/81635 - MediaPlayer.cpp Whitespace only http://trac.webkit.org/changeset/80874 - RenderBox.cpp Due to isHorizontalWritingMode http://trac.webkit.org/changeset/81716 - RenderLayer.cpp/h Due to ANDROID_OVERFLOW_SCROLL http://trac.webkit.org/changeset/81981 - CSSStyleSelector.cpp Due to ANDROID_CSS_RING http://trac.webkit.org/changeset/80582 http://trac.webkit.org/changeset/80993 http://trac.webkit.org/changeset/80998 http://trac.webkit.org/changeset/81684 http://trac.webkit.org/changeset/82378 - CSSParser.cpp Due to ANDROID_CSS_RING http://trac.webkit.org/changeset/80582 http://trac.webkit.org/changeset/81684 - StyleElement.cpp Due to cherry pick of http://trac.webkit.org/changeset/80787 http://trac.webkit.org/changeset/82054 - EventHandler.cpp Due to ANDROID_PLUGINS http://trac.webkit.org/changeset/81618 http://trac.webkit.org/changeset/81835 - SliderThumbElement.cpp Due to touch events http://trac.webkit.org/changeset/81216 - MediaControls.cpp Due to touch events http://trac.webkit.org/changeset/80857 Note that the WebKit history for this file is confusing as it was renamed in http://trac.webkit.org/changeset/83545 and then re-added in http://trac.webkit.org/changeset/84222 but trac is not smart enough to track history backwards from http://trac.webkit.org/changeset/84222. Change-Id: Ie1f80e09ae7c3befa7a18773cf846ff130e4354e --- Source/WebCore/page/EventHandler.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Source/WebCore/page/EventHandler.cpp') diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index f05e8b2..de59083 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -98,13 +98,12 @@ #include "TouchEvent.h" #endif -<<<<<<< HEAD -#if defined(ANDROID_PLUGINS) -#include "WebViewCore.h" -======= #if ENABLE(GESTURE_RECOGNIZER) #include "PlatformGestureRecognizer.h" ->>>>>>> webkit.org at r82507 +#endif + +#if defined(ANDROID_PLUGINS) +#include "WebViewCore.h" #endif namespace WebCore { -- cgit v1.1