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

Side by Side Diff: third_party/WebKit/Source/core/editing/SelectionController.cpp

Issue 2708703003: Expand FrameSeleciton::isRange() to increase chances of hoisting update layout (Closed)
Patch Set: 2017-02-21T23:48:22 rebase Created 3 years, 10 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 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * Copyright (C) 2015 Google Inc. All rights reserved. 6 * Copyright (C) 2015 Google Inc. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 718
719 if (!selection().isAvailable()) 719 if (!selection().isAvailable())
720 return false; 720 return false;
721 721
722 if (!m_mouseDownAllowsMultiClick) 722 if (!m_mouseDownAllowsMultiClick)
723 return handleMousePressEventSingleClick(event); 723 return handleMousePressEventSingleClick(event);
724 724
725 if (event.event().button != WebPointerProperties::Button::Left) 725 if (event.event().button != WebPointerProperties::Button::Left)
726 return false; 726 return false;
727 727
728 if (selection().isRange()) { 728 if (selection().computeVisibleSelectionInDOMTreeDeprecated().isRange()) {
729 // A double-click when range is already selected 729 // A double-click when range is already selected
730 // should not change the selection. So, do not call 730 // should not change the selection. So, do not call
731 // selectClosestWordFromMouseEvent, but do set 731 // selectClosestWordFromMouseEvent, but do set
732 // m_beganSelectingText to prevent handleMouseReleaseEvent 732 // m_beganSelectingText to prevent handleMouseReleaseEvent
733 // from setting caret selection. 733 // from setting caret selection.
734 m_selectionState = SelectionState::ExtendedSelection; 734 m_selectionState = SelectionState::ExtendedSelection;
735 } else { 735 } else {
736 selectClosestWordFromMouseEvent(event); 736 selectClosestWordFromMouseEvent(event);
737 } 737 }
738 return true; 738 return true;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 846
847 bool handled = false; 847 bool handled = false;
848 m_mouseDownMayStartSelect = false; 848 m_mouseDownMayStartSelect = false;
849 // Clear the selection if the mouse didn't move after the last mouse 849 // Clear the selection if the mouse didn't move after the last mouse
850 // press and it's not a context menu click. We do this so when clicking 850 // press and it's not a context menu click. We do this so when clicking
851 // on the selection, the selection goes away. However, if we are 851 // on the selection, the selection goes away. However, if we are
852 // editing, place the caret. 852 // editing, place the caret.
853 if (m_mouseDownWasSingleClickInSelection && 853 if (m_mouseDownWasSingleClickInSelection &&
854 m_selectionState != SelectionState::ExtendedSelection && 854 m_selectionState != SelectionState::ExtendedSelection &&
855 dragStartPos == flooredIntPoint(event.event().positionInRootFrame()) && 855 dragStartPos == flooredIntPoint(event.event().positionInRootFrame()) &&
856 selection().isRange() && 856 selection().computeVisibleSelectionInDOMTreeDeprecated().isRange() &&
857 event.event().button != WebPointerProperties::Button::Right) { 857 event.event().button != WebPointerProperties::Button::Right) {
858 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 858 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
859 // needs to be audited. See http://crbug.com/590369 for more details. 859 // needs to be audited. See http://crbug.com/590369 for more details.
860 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 860 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
861 861
862 SelectionInFlatTree::Builder builder; 862 SelectionInFlatTree::Builder builder;
863 Node* node = event.innerNode(); 863 Node* node = event.innerNode();
864 if (node && node->layoutObject() && hasEditableStyle(*node)) { 864 if (node && node->layoutObject() && hasEditableStyle(*node)) {
865 const VisiblePositionInFlatTree pos = 865 const VisiblePositionInFlatTree pos =
866 visiblePositionOfHitTestResult(event.hitTestResult()); 866 visiblePositionOfHitTestResult(event.hitTestResult());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1079
1080 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { 1080 bool isExtendingSelection(const MouseEventWithHitTestResults& event) {
1081 bool isMouseDownOnLinkOrImage = 1081 bool isMouseDownOnLinkOrImage =
1082 event.isOverLink() || event.hitTestResult().image(); 1082 event.isOverLink() || event.hitTestResult().image();
1083 return (event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) != 1083 return (event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) !=
1084 0 && 1084 0 &&
1085 !isMouseDownOnLinkOrImage; 1085 !isMouseDownOnLinkOrImage;
1086 } 1086 }
1087 1087
1088 } // namespace blink 1088 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698