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

Unified Diff: third_party/WebKit/Source/core/editing/SelectionController.cpp

Issue 2698793003: Get rid of redundant layout tree update related to selection (Closed)
Patch Set: 2017-02-17T16:13:56 selectionTypeWithLegacyGranularity() 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/SelectionController.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp
index 2879cc9efe038d8f372021a6157f19adf7061d17..b57c8ab283af4112baeefc229582a53bc08c47a1 100644
--- a/third_party/WebKit/Source/core/editing/SelectionController.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
@@ -1051,12 +1051,25 @@ bool SelectionController::mouseDownWasSingleClickInSelection() const {
}
void SelectionController::notifySelectionChanged() {
- if (selection().getSelectionType() == SelectionType::RangeSelection)
- m_selectionState = SelectionState::ExtendedSelection;
- else if (selection().getSelectionType() == SelectionType::CaretSelection)
- m_selectionState = SelectionState::PlacedCaret;
- else
- m_selectionState = SelectionState::HaveNotStartedSelection;
+ // To avoid regression on speedometer benchmark[1] test, we should not
+ // update layout tree in this code block.
+ // [1] http://browserbench.org/Speedometer/
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(
+ m_frame->document()->lifecycle());
+
+ const SelectionInDOMTree& selection = this->selection().selectionInDOMTree();
+ switch (selection.selectionTypeWithLegacyGranularity()) {
+ case NoSelection:
+ m_selectionState = SelectionState::HaveNotStartedSelection;
+ return;
+ case CaretSelection:
+ m_selectionState = SelectionState::PlacedCaret;
+ return;
+ case RangeSelection:
+ m_selectionState = SelectionState::ExtendedSelection;
+ return;
+ }
+ NOTREACHED() << "We should handle all SelectionType" << selection;
}
FrameSelection& SelectionController::selection() const {
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | third_party/WebKit/Source/core/editing/SelectionTemplate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698