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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 else | 572 else |
573 newSelection = VisibleSelection(start, pos); | 573 newSelection = VisibleSelection(start, pos); |
574 } | 574 } |
575 } else | 575 } else |
576 newSelection.setExtent(pos); | 576 newSelection.setExtent(pos); |
577 | 577 |
578 if (m_frame->selection().granularity() != CharacterGranularity) { | 578 if (m_frame->selection().granularity() != CharacterGranularity) { |
579 granularity = m_frame->selection().granularity(); | 579 granularity = m_frame->selection().granularity(); |
580 newSelection.expandUsingGranularity(m_frame->selection().granularity ()); | 580 newSelection.expandUsingGranularity(m_frame->selection().granularity ()); |
581 } | 581 } |
582 } else { | 582 } else if (m_selectionInitiationState != ExtendedSelection) { |
583 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos)); | 583 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos)); |
584 } | 584 } |
585 | 585 |
586 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state. | 586 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state. |
587 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity); | 587 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity); |
588 return false; | 588 return false; |
589 } | 589 } |
590 | 590 |
591 static inline bool canMouseDownStartSelect(Node* node) | 591 static inline bool canMouseDownStartSelect(Node* node) |
592 { | 592 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 if (singleClick) | 640 if (singleClick) |
641 focusDocumentView(); | 641 focusDocumentView(); |
642 | 642 |
643 Node* innerNode = event.innerNode(); | 643 Node* innerNode = event.innerNode(); |
644 | 644 |
645 m_mousePressNode = innerNode; | 645 m_mousePressNode = innerNode; |
646 m_dragStartPos = event.event().position(); | 646 m_dragStartPos = event.event().position(); |
647 | 647 |
648 bool swallowEvent = false; | 648 bool swallowEvent = false; |
649 m_mousePressed = true; | 649 m_mousePressed = true; |
650 m_selectionInitiationState = HaveNotStartedSelection; | |
651 | 650 |
652 if (event.event().clickCount() == 2) | 651 if (event.event().clickCount() == 2) |
653 swallowEvent = handleMousePressEventDoubleClick(event); | 652 swallowEvent = handleMousePressEventDoubleClick(event); |
654 else if (event.event().clickCount() >= 3) | 653 else if (event.event().clickCount() >= 3) |
655 swallowEvent = handleMousePressEventTripleClick(event); | 654 swallowEvent = handleMousePressEventTripleClick(event); |
656 else | 655 else |
657 swallowEvent = handleMousePressEventSingleClick(event); | 656 swallowEvent = handleMousePressEventSingleClick(event); |
658 | 657 |
659 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect | 658 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect |
660 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled()); | 659 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled()); |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1325 m_resizeScrollableArea->setInResizeMode(true); | 1324 m_resizeScrollableArea->setInResizeMode(true); |
1326 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); | 1325 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); |
1327 invalidateClick(); | 1326 invalidateClick(); |
1328 return true; | 1327 return true; |
1329 } | 1328 } |
1330 } | 1329 } |
1331 | 1330 |
1332 m_frame->selection().setCaretBlinkingSuspended(true); | 1331 m_frame->selection().setCaretBlinkingSuspended(true); |
1333 | 1332 |
1334 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner Node(), m_clickCount, mouseEvent, true); | 1333 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner Node(), m_clickCount, mouseEvent, true); |
1334 // m_selectionInitiationState is initialized after dispatching mousedown eve nt in order not to keep the selection by DOM APIs | |
1335 // Because we can't give the user the chance to handle the selection by user action like dragging if we keep the selection in case of mousedown. | |
1336 // FireFox also has the same behavior and it's more compatible with other br owsers. | |
1337 m_selectionInitiationState = HaveNotStartedSelection; | |
1335 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.posit ion(), HitTestRequest::ReadOnly); | 1338 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.posit ion(), HitTestRequest::ReadOnly); |
1336 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults (mouseEvent, hitTestResult)); | 1339 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults (mouseEvent, hitTestResult)); |
1337 m_capturesDragging = !swallowEvent || mev.scrollbar(); | 1340 m_capturesDragging = !swallowEvent || mev.scrollbar(); |
1338 | 1341 |
1339 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults | 1342 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults |
1340 // in case the scrollbar widget was destroyed when the mouse event was handl ed. | 1343 // in case the scrollbar widget was destroyed when the mouse event was handl ed. |
1341 if (mev.scrollbar()) { | 1344 if (mev.scrollbar()) { |
1342 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); | 1345 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); |
1343 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); | 1346 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); |
1344 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); | 1347 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2345 IntPoint tappedPosition = gestureEvent.position(); | 2348 IntPoint tappedPosition = gestureEvent.position(); |
2346 | 2349 |
2347 if (m_clickNode && m_clickNode->isTextNode()) | 2350 if (m_clickNode && m_clickNode->isTextNode()) |
2348 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode); | 2351 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode); |
2349 | 2352 |
2350 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), | 2353 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), |
2351 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), | 2354 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), |
2352 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), | 2355 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), |
2353 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2356 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2354 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); | 2357 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); |
2358 m_selectionInitiationState = HaveNotStartedSelection; | |
2355 if (!swallowMouseDownEvent) | 2359 if (!swallowMouseDownEvent) |
2356 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest)); | 2360 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest)); |
2357 if (!swallowMouseDownEvent) | 2361 if (!swallowMouseDownEvent) |
2358 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest)); | 2362 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest)); |
2359 | 2363 |
2360 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 | 2364 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 |
2361 if (currentHitTest.innerNode()) { | 2365 if (currentHitTest.innerNode()) { |
2362 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 2366 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
2363 if (mainFrame && mainFrame->view()) | 2367 if (mainFrame && mainFrame->view()) |
2364 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); | 2368 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3119 } | 3123 } |
3120 | 3124 |
3121 void EventHandler::notifyElementActivated() | 3125 void EventHandler::notifyElementActivated() |
3122 { | 3126 { |
3123 // Since another element has been set to active, stop current timer and clea r reference. | 3127 // Since another element has been set to active, stop current timer and clea r reference. |
3124 if (m_activeIntervalTimer.isActive()) | 3128 if (m_activeIntervalTimer.isActive()) |
3125 m_activeIntervalTimer.stop(); | 3129 m_activeIntervalTimer.stop(); |
3126 m_lastDeferredTapElement = nullptr; | 3130 m_lastDeferredTapElement = nullptr; |
3127 } | 3131 } |
3128 | 3132 |
3133 void EventHandler::notifySelectionChanged() | |
yosin_UTC9
2015/04/10 02:06:09
It is better to move selection handling code in Ev
Miyoung Shin(g)
2015/04/22 15:32:37
I've tried to move the code related to the selecti
yosin_UTC9
2015/04/28 01:59:54
Yes, I'm thinking to have a SelectionHandler class
| |
3134 { | |
3135 if (m_frame->selection().isRange()) | |
3136 m_selectionInitiationState = ExtendedSelection; | |
yosin_UTC9
2015/04/10 02:06:09
|m_selectionInitiationState| is no longer represen
Miyoung Shin(g)
2015/04/22 15:32:37
I've changed |m_selectionInitiationState| to |m_se
yosin_UTC9
2015/04/28 01:59:54
I mean |PlacedCaret| and |ExtendSelection| are sta
| |
3137 else if (m_frame->selection().isCaret()) | |
3138 m_selectionInitiationState = PlacedCaret; | |
3139 else | |
3140 m_selectionInitiationState = HaveNotStartedSelection; | |
3141 } | |
3142 | |
3129 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) | 3143 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) |
3130 { | 3144 { |
3131 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. | 3145 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. |
3132 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and | 3146 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and |
3133 // lower case variants are present in a document, the correct element is mat ched based on Shift key state. | 3147 // lower case variants are present in a document, the correct element is mat ched based on Shift key state. |
3134 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively. | 3148 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively. |
3135 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); | 3149 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); |
3136 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) | 3150 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) |
3137 return false; | 3151 return false; |
3138 String key = evt.unmodifiedText(); | 3152 String key = evt.unmodifiedText(); |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3994 unsigned EventHandler::accessKeyModifiers() | 4008 unsigned EventHandler::accessKeyModifiers() |
3995 { | 4009 { |
3996 #if OS(MACOSX) | 4010 #if OS(MACOSX) |
3997 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4011 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3998 #else | 4012 #else |
3999 return PlatformEvent::AltKey; | 4013 return PlatformEvent::AltKey; |
4000 #endif | 4014 #endif |
4001 } | 4015 } |
4002 | 4016 |
4003 } // namespace blink | 4017 } // namespace blink |
OLD | NEW |