Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: Source/core/input/EventHandler.cpp

Issue 1049233003: Keep the selection of the text field when changed by JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (singleClick) 355 if (singleClick)
356 focusDocumentView(); 356 focusDocumentView();
357 357
358 Node* innerNode = event.innerNode(); 358 Node* innerNode = event.innerNode();
359 359
360 m_mousePressNode = innerNode; 360 m_mousePressNode = innerNode;
361 m_dragStartPos = event.event().position(); 361 m_dragStartPos = event.event().position();
362 362
363 bool swallowEvent = false; 363 bool swallowEvent = false;
364 m_mousePressed = true; 364 m_mousePressed = true;
365 selectionController().initializeSelectionState();
366 365
367 if (event.event().clickCount() == 2) 366 if (event.event().clickCount() == 2)
368 swallowEvent = selectionController().handleMousePressEventDoubleClick(ev ent); 367 swallowEvent = selectionController().handleMousePressEventDoubleClick(ev ent);
369 else if (event.event().clickCount() >= 3) 368 else if (event.event().clickCount() >= 3)
370 swallowEvent = selectionController().handleMousePressEventTripleClick(ev ent); 369 swallowEvent = selectionController().handleMousePressEventTripleClick(ev ent);
371 else 370 else
372 swallowEvent = selectionController().handleMousePressEventSingleClick(ev ent); 371 swallowEvent = selectionController().handleMousePressEventSingleClick(ev ent);
373 372
374 m_mouseDownMayStartAutoscroll = selectionController().mouseDownMayStartSelec t() 373 m_mouseDownMayStartAutoscroll = selectionController().mouseDownMayStartSelec t()
375 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled()); 374 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled());
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 m_resizeScrollableArea->setInResizeMode(true); 942 m_resizeScrollableArea->setInResizeMode(true);
944 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); 943 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p));
945 invalidateClick(); 944 invalidateClick();
946 return true; 945 return true;
947 } 946 }
948 } 947 }
949 948
950 m_frame->selection().setCaretBlinkingSuspended(true); 949 m_frame->selection().setCaretBlinkingSuspended(true);
951 950
952 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner Node(), m_clickCount, mouseEvent, true); 951 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner Node(), m_clickCount, mouseEvent, true);
952 // m_selectionInitiationState is initialized after dispatching mousedown eve nt in order not to keep the selection by DOM APIs
yosin_UTC9 2015/07/06 01:57:30 nit: Could you try to keep comments in 80 chars? I
Miyoung Shin(g) 2015/07/13 03:32:57 Done.
953 // 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.
954 // FireFox also has the same behavior and it's more compatible with other br owsers.
955 selectionController().initializeSelectionState();
953 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.posit ion(), HitTestRequest::ReadOnly); 956 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.posit ion(), HitTestRequest::ReadOnly);
954 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults (mouseEvent, hitTestResult)); 957 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults (mouseEvent, hitTestResult));
955 m_capturesDragging = !swallowEvent || mev.scrollbar(); 958 m_capturesDragging = !swallowEvent || mev.scrollbar();
956 959
957 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 960 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults
958 // in case the scrollbar widget was destroyed when the mouse event was handl ed. 961 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
959 if (mev.scrollbar()) { 962 if (mev.scrollbar()) {
960 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 963 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
961 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); 964 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active );
962 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); 965 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent);
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 IntPoint tappedPosition = gestureEvent.position(); 2017 IntPoint tappedPosition = gestureEvent.position();
2015 2018
2016 if (m_clickNode && m_clickNode->isTextNode()) 2019 if (m_clickNode && m_clickNode->isTextNode())
2017 m_clickNode = ComposedTreeTraversal::parent(*m_clickNode); 2020 m_clickNode = ComposedTreeTraversal::parent(*m_clickNode);
2018 2021
2019 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), 2022 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(),
2020 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), 2023 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(),
2021 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), 2024 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown),
2022 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); 2025 PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2023 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); 2026 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true);
2027 selectionController().initializeSelectionState();
2024 if (!swallowMouseDownEvent) 2028 if (!swallowMouseDownEvent)
2025 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest)); 2029 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest));
2026 if (!swallowMouseDownEvent) 2030 if (!swallowMouseDownEvent)
2027 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest)); 2031 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest));
2028 2032
2029 if (currentHitTest.innerNode()) { 2033 if (currentHitTest.innerNode()) {
2030 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap); 2034 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap);
2031 HitTestResult result = currentHitTest; 2035 HitTestResult result = currentHitTest;
2032 result.setToShadowHostIfInUserAgentShadowRoot(); 2036 result.setToShadowHostIfInUserAgentShadowRoot();
2033 m_frame->chromeClient().onMouseDown(result.innerNode()); 2037 m_frame->chromeClient().onMouseDown(result.innerNode());
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3869 unsigned EventHandler::accessKeyModifiers() 3873 unsigned EventHandler::accessKeyModifiers()
3870 { 3874 {
3871 #if OS(MACOSX) 3875 #if OS(MACOSX)
3872 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3876 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3873 #else 3877 #else
3874 return PlatformEvent::AltKey; 3878 return PlatformEvent::AltKey;
3875 #endif 3879 #endif
3876 } 3880 }
3877 3881
3878 } // namespace blink 3882 } // namespace blink
OLDNEW
« Source/core/editing/SelectionController.cpp ('K') | « Source/core/editing/SelectionController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698