| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 #include "core/loader/FrameLoaderClient.h" | 77 #include "core/loader/FrameLoaderClient.h" |
| 78 #include "core/page/AutoscrollController.h" | 78 #include "core/page/AutoscrollController.h" |
| 79 #include "core/page/ChromeClient.h" | 79 #include "core/page/ChromeClient.h" |
| 80 #include "core/page/DragController.h" | 80 #include "core/page/DragController.h" |
| 81 #include "core/page/DragState.h" | 81 #include "core/page/DragState.h" |
| 82 #include "core/page/FocusController.h" | 82 #include "core/page/FocusController.h" |
| 83 #include "core/page/FrameTree.h" | 83 #include "core/page/FrameTree.h" |
| 84 #include "core/page/Page.h" | 84 #include "core/page/Page.h" |
| 85 #include "core/page/SpatialNavigation.h" | 85 #include "core/page/SpatialNavigation.h" |
| 86 #include "core/page/TouchAdjustment.h" | 86 #include "core/page/TouchAdjustment.h" |
| 87 #include "core/page/scrolling/OverscrollController.h" |
| 87 #include "core/page/scrolling/ScrollState.h" | 88 #include "core/page/scrolling/ScrollState.h" |
| 88 #include "core/paint/PaintLayer.h" | 89 #include "core/paint/PaintLayer.h" |
| 89 #include "core/style/ComputedStyle.h" | 90 #include "core/style/ComputedStyle.h" |
| 90 #include "core/svg/SVGDocumentExtensions.h" | 91 #include "core/svg/SVGDocumentExtensions.h" |
| 91 #include "platform/Histogram.h" | 92 #include "platform/Histogram.h" |
| 92 #include "platform/PlatformGestureEvent.h" | 93 #include "platform/PlatformGestureEvent.h" |
| 93 #include "platform/PlatformKeyboardEvent.h" | 94 #include "platform/PlatformKeyboardEvent.h" |
| 94 #include "platform/PlatformTouchEvent.h" | 95 #include "platform/PlatformTouchEvent.h" |
| 95 #include "platform/PlatformWheelEvent.h" | 96 #include "platform/PlatformWheelEvent.h" |
| 96 #include "platform/RuntimeEnabledFeatures.h" | 97 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // The minimum amount of time an element stays active after a ShowPress | 288 // The minimum amount of time an element stays active after a ShowPress |
| 288 // This is roughly 9 frames, which should be long enough to be noticeable. | 289 // This is roughly 9 frames, which should be long enough to be noticeable. |
| 289 static const double minimumActiveInterval = 0.15; | 290 static const double minimumActiveInterval = 0.15; |
| 290 | 291 |
| 291 #if OS(MACOSX) | 292 #if OS(MACOSX) |
| 292 static const double TextDragDelay = 0.15; | 293 static const double TextDragDelay = 0.15; |
| 293 #else | 294 #else |
| 294 static const double TextDragDelay = 0.0; | 295 static const double TextDragDelay = 0.0; |
| 295 #endif | 296 #endif |
| 296 | 297 |
| 297 // Report Overscroll if OverscrollDelta is greater than minimumOverscrollDelta | |
| 298 // to maintain consistency as did in compositor. | |
| 299 static const float minimumOverscrollDelta = 0.1; | |
| 300 | |
| 301 enum NoCursorChangeType { NoCursorChange }; | 298 enum NoCursorChangeType { NoCursorChange }; |
| 302 | 299 |
| 303 enum class DragInitiator { Mouse, Touch }; | 300 enum class DragInitiator { Mouse, Touch }; |
| 304 | 301 |
| 305 class OptionalCursor { | 302 class OptionalCursor { |
| 306 public: | 303 public: |
| 307 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) { } | 304 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) { } |
| 308 OptionalCursor(const Cursor& cursor) : m_isCursorChange(true), m_cursor(curs
or) { } | 305 OptionalCursor(const Cursor& cursor) : m_isCursorChange(true), m_cursor(curs
or) { } |
| 309 | 306 |
| 310 bool isCursorChange() const { return m_isCursorChange; } | 307 bool isCursorChange() const { return m_isCursorChange; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 323 , m_selectionController(SelectionController::create(*frame)) | 320 , m_selectionController(SelectionController::create(*frame)) |
| 324 , m_hoverTimer(this, &EventHandler::hoverTimerFired) | 321 , m_hoverTimer(this, &EventHandler::hoverTimerFired) |
| 325 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) | 322 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) |
| 326 , m_mouseDownMayStartAutoscroll(false) | 323 , m_mouseDownMayStartAutoscroll(false) |
| 327 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) | 324 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) |
| 328 , m_svgPan(false) | 325 , m_svgPan(false) |
| 329 , m_resizeScrollableArea(nullptr) | 326 , m_resizeScrollableArea(nullptr) |
| 330 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 327 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 331 , m_clickCount(0) | 328 , m_clickCount(0) |
| 332 , m_shouldOnlyFireDragOverEvent(false) | 329 , m_shouldOnlyFireDragOverEvent(false) |
| 333 , m_accumulatedRootOverscroll(FloatSize()) | |
| 334 , m_mousePositionIsUnknown(true) | 330 , m_mousePositionIsUnknown(true) |
| 335 , m_mouseDownTimestamp(0) | 331 , m_mouseDownTimestamp(0) |
| 336 , m_touchPressed(false) | 332 , m_touchPressed(false) |
| 337 , m_scrollGestureHandlingNode(nullptr) | 333 , m_scrollGestureHandlingNode(nullptr) |
| 338 , m_lastGestureScrollOverWidget(false) | 334 , m_lastGestureScrollOverWidget(false) |
| 339 , m_longTapShouldInvokeContextMenu(false) | 335 , m_longTapShouldInvokeContextMenu(false) |
| 340 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 336 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 341 , m_lastShowPressTimestamp(0) | 337 , m_lastShowPressTimestamp(0) |
| 342 , m_deltaConsumedForScrollSequence(false) | 338 , m_deltaConsumedForScrollSequence(false) |
| 343 , m_waitingForFirstTouchMove(false) | 339 , m_waitingForFirstTouchMove(false) |
| (...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2330 } | 2326 } |
| 2331 | 2327 |
| 2332 if (mouseUpEventResult == WebInputEventResult::NotHandled) | 2328 if (mouseUpEventResult == WebInputEventResult::NotHandled) |
| 2333 mouseUpEventResult = handleMouseReleaseEvent(MouseEventWithHitTestResult
s(fakeMouseUp, currentHitTest)); | 2329 mouseUpEventResult = handleMouseReleaseEvent(MouseEventWithHitTestResult
s(fakeMouseUp, currentHitTest)); |
| 2334 | 2330 |
| 2335 WebInputEventResult eventResult = mergeEventResult(mergeEventResult(mouseDow
nEventResult, mouseUpEventResult), clickEventResult); | 2331 WebInputEventResult eventResult = mergeEventResult(mergeEventResult(mouseDow
nEventResult, mouseUpEventResult), clickEventResult); |
| 2336 if (eventResult == WebInputEventResult::NotHandled && tappedNode && m_frame-
>page()) { | 2332 if (eventResult == WebInputEventResult::NotHandled && tappedNode && m_frame-
>page()) { |
| 2337 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()->
domTreeVersion(); | 2333 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()->
domTreeVersion(); |
| 2338 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl
eVersion(); | 2334 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl
eVersion(); |
| 2339 | 2335 |
| 2340 IntPoint tappedPositionInViewport = m_frame->page()->frameHost().visualV
iewport().rootFrameToViewport(tappedPosition); | 2336 IntPoint tappedPositionInViewport = frameHost()->visualViewport().rootFr
ameToViewport(tappedPosition); |
| 2341 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp
ort, tappedNode, domTreeChanged || styleChanged); | 2337 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp
ort, tappedNode, domTreeChanged || styleChanged); |
| 2342 } | 2338 } |
| 2343 return eventResult; | 2339 return eventResult; |
| 2344 } | 2340 } |
| 2345 | 2341 |
| 2346 WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH
itTestResults& targetedEvent) | 2342 WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH
itTestResults& targetedEvent) |
| 2347 { | 2343 { |
| 2348 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2344 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
| 2349 IntPoint adjustedPoint = gestureEvent.position(); | 2345 IntPoint adjustedPoint = gestureEvent.position(); |
| 2350 | 2346 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2494 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsumedFor
ScrollSequence; | 2490 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsumedFor
ScrollSequence; |
| 2495 ScrollState* scrollState = ScrollState::create(scrollStateData.release()
); | 2491 ScrollState* scrollState = ScrollState::create(scrollStateData.release()
); |
| 2496 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); | 2492 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); |
| 2497 } else { | 2493 } else { |
| 2498 if (m_frame->isMainFrame()) | 2494 if (m_frame->isMainFrame()) |
| 2499 m_frame->host()->topControls().scrollBegin(); | 2495 m_frame->host()->topControls().scrollBegin(); |
| 2500 } | 2496 } |
| 2501 return WebInputEventResult::HandledSystem; | 2497 return WebInputEventResult::HandledSystem; |
| 2502 } | 2498 } |
| 2503 | 2499 |
| 2504 void EventHandler::resetOverscroll(bool didScrollX, bool didScrollY) | |
| 2505 { | |
| 2506 if (didScrollX) | |
| 2507 m_accumulatedRootOverscroll.setWidth(0); | |
| 2508 if (didScrollY) | |
| 2509 m_accumulatedRootOverscroll.setHeight(0); | |
| 2510 } | |
| 2511 | |
| 2512 static inline FloatSize adjustOverscroll(FloatSize unusedDelta) | |
| 2513 { | |
| 2514 if (std::abs(unusedDelta.width()) < minimumOverscrollDelta) | |
| 2515 unusedDelta.setWidth(0); | |
| 2516 if (std::abs(unusedDelta.height()) < minimumOverscrollDelta) | |
| 2517 unusedDelta.setHeight(0); | |
| 2518 | |
| 2519 return unusedDelta; | |
| 2520 } | |
| 2521 | |
| 2522 void EventHandler::handleOverscroll(const ScrollResult& scrollResult, const Floa
tPoint& positionInRootFrame, const FloatSize& velocityInRootFrame) | |
| 2523 { | |
| 2524 ASSERT(m_frame->isMainFrame()); | |
| 2525 VisualViewport& visualViewport = m_frame->page()->frameHost().visualViewport
(); | |
| 2526 | |
| 2527 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc
rollDeltaY); | |
| 2528 unusedDelta = adjustOverscroll(unusedDelta); | |
| 2529 | |
| 2530 FloatSize deltaInViewport = unusedDelta.scaledBy(visualViewport.scale()); | |
| 2531 FloatSize velocityInViewport = velocityInRootFrame.scaledBy(visualViewport.s
cale()); | |
| 2532 FloatPoint positionInViewport = | |
| 2533 visualViewport.rootFrameToViewport(positionInRootFrame); | |
| 2534 | |
| 2535 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); | |
| 2536 if (deltaInViewport != FloatSize()) { | |
| 2537 m_accumulatedRootOverscroll += deltaInViewport; | |
| 2538 m_frame->chromeClient().didOverscroll(deltaInViewport, m_accumulatedRoot
Overscroll, positionInViewport, velocityInViewport); | |
| 2539 } | |
| 2540 } | |
| 2541 | |
| 2542 bool EventHandler::isRootScroller(const Node& node) const | 2500 bool EventHandler::isRootScroller(const Node& node) const |
| 2543 { | 2501 { |
| 2544 // The root scroller is the one Element on the page designated to perform | 2502 // The root scroller is the one Element on the page designated to perform |
| 2545 // "viewport actions" like top controls movement and overscroll glow. | 2503 // "viewport actions" like top controls movement and overscroll glow. |
| 2546 | 2504 |
| 2547 if (!node.isElementNode() || node.document().ownerElement()) | 2505 if (!node.isElementNode() || node.document().ownerElement()) |
| 2548 return false; | 2506 return false; |
| 2549 | 2507 |
| 2550 Element* scrollingElement = node.document().scrollingElement(); | 2508 Element* scrollingElement = node.document().scrollingElement(); |
| 2551 return scrollingElement | 2509 return scrollingElement |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2630 delta, | 2588 delta, |
| 2631 FloatPoint(gestureEvent.position()), | 2589 FloatPoint(gestureEvent.position()), |
| 2632 velocity, | 2590 velocity, |
| 2633 node, | 2591 node, |
| 2634 &stopNode, | 2592 &stopNode, |
| 2635 &consumed); | 2593 &consumed); |
| 2636 | 2594 |
| 2637 if (gestureEvent.preventPropagation()) | 2595 if (gestureEvent.preventPropagation()) |
| 2638 m_previousGestureScrolledNode = stopNode; | 2596 m_previousGestureScrolledNode = stopNode; |
| 2639 | 2597 |
| 2640 if (!stopNode || !isRootScroller(*stopNode)) | 2598 if ((!stopNode || !isRootScroller(*stopNode)) && frameHost()) { |
| 2641 resetOverscroll(result.didScrollX, result.didScrollY); | 2599 frameHost()->overscrollController().resetAccumulated( |
| 2600 result.didScrollX, result.didScrollY); |
| 2601 } |
| 2642 | 2602 |
| 2643 if (consumed) | 2603 if (consumed) |
| 2644 return WebInputEventResult::HandledSystem; | 2604 return WebInputEventResult::HandledSystem; |
| 2645 } | 2605 } |
| 2646 } | 2606 } |
| 2647 | 2607 |
| 2648 return WebInputEventResult::NotHandled; | 2608 return WebInputEventResult::NotHandled; |
| 2649 } | 2609 } |
| 2650 | 2610 |
| 2651 void EventHandler::clearGestureScrollState() | 2611 void EventHandler::clearGestureScrollState() |
| 2652 { | 2612 { |
| 2653 m_scrollGestureHandlingNode = nullptr; | 2613 m_scrollGestureHandlingNode = nullptr; |
| 2654 m_previousGestureScrolledNode = nullptr; | 2614 m_previousGestureScrolledNode = nullptr; |
| 2655 m_deltaConsumedForScrollSequence = false; | 2615 m_deltaConsumedForScrollSequence = false; |
| 2656 m_currentScrollChain.clear(); | 2616 m_currentScrollChain.clear(); |
| 2657 m_accumulatedRootOverscroll = FloatSize(); | 2617 |
| 2618 if (FrameHost* host = frameHost()) { |
| 2619 bool resetX = true; |
| 2620 bool resetY = true; |
| 2621 host->overscrollController().resetAccumulated(resetX, resetY); |
| 2622 } |
| 2658 } | 2623 } |
| 2659 | 2624 |
| 2660 bool EventHandler::isScrollbarHandlingGestures() const | 2625 bool EventHandler::isScrollbarHandlingGestures() const |
| 2661 { | 2626 { |
| 2662 return m_scrollbarHandlingScrollGesture.get(); | 2627 return m_scrollbarHandlingScrollGesture.get(); |
| 2663 } | 2628 } |
| 2664 | 2629 |
| 2665 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const | 2630 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const |
| 2666 { | 2631 { |
| 2667 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) | 2632 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3016 #if OS(WIN) | 2981 #if OS(WIN) |
| 3017 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 2982 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
| 3018 #else | 2983 #else |
| 3019 int rightAligned = 0; | 2984 int rightAligned = 0; |
| 3020 #endif | 2985 #endif |
| 3021 IntPoint locationInRootFrame; | 2986 IntPoint locationInRootFrame; |
| 3022 | 2987 |
| 3023 Element* focusedElement = overrideTargetElement ? overrideTargetElement : do
c->focusedElement(); | 2988 Element* focusedElement = overrideTargetElement ? overrideTargetElement : do
c->focusedElement(); |
| 3024 FrameSelection& selection = m_frame->selection(); | 2989 FrameSelection& selection = m_frame->selection(); |
| 3025 Position start = selection.selection().start(); | 2990 Position start = selection.selection().start(); |
| 3026 VisualViewport& visualViewport = m_frame->page()->frameHost().visualViewport
(); | 2991 VisualViewport& visualViewport = frameHost()->visualViewport(); |
| 3027 | 2992 |
| 3028 if (!overrideTargetElement && start.anchorNode() && (selection.rootEditableE
lement() || selection.isRange())) { | 2993 if (!overrideTargetElement && start.anchorNode() && (selection.rootEditableE
lement() || selection.isRange())) { |
| 3029 IntRect firstRect = m_frame->editor().firstRectForRange(selection.select
ion().toNormalizedEphemeralRange()); | 2994 IntRect firstRect = m_frame->editor().firstRectForRange(selection.select
ion().toNormalizedEphemeralRange()); |
| 3030 | 2995 |
| 3031 int x = rightAligned ? firstRect.maxX() : firstRect.x(); | 2996 int x = rightAligned ? firstRect.maxX() : firstRect.x(); |
| 3032 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. | 2997 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. |
| 3033 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; | 2998 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; |
| 3034 locationInRootFrame = view->contentsToRootFrame(IntPoint(x, y)); | 2999 locationInRootFrame = view->contentsToRootFrame(IntPoint(x, y)); |
| 3035 } else if (focusedElement) { | 3000 } else if (focusedElement) { |
| 3036 IntRect clippedRect = focusedElement->boundsInViewport(); | 3001 IntRect clippedRect = focusedElement->boundsInViewport(); |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4174 | 4139 |
| 4175 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4140 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 4176 { | 4141 { |
| 4177 #if OS(MACOSX) | 4142 #if OS(MACOSX) |
| 4178 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 4143 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
| 4179 #else | 4144 #else |
| 4180 return PlatformEvent::AltKey; | 4145 return PlatformEvent::AltKey; |
| 4181 #endif | 4146 #endif |
| 4182 } | 4147 } |
| 4183 | 4148 |
| 4149 FrameHost* EventHandler::frameHost() |
| 4150 { |
| 4151 if (!m_frame->page()) |
| 4152 return nullptr; |
| 4153 |
| 4154 return &m_frame->page()->frameHost(); |
| 4155 } |
| 4156 |
| 4184 } // namespace blink | 4157 } // namespace blink |
| OLD | NEW |