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

Side by Side 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 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 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 1044
1045 bool SelectionController::mouseDownMayStartSelect() const { 1045 bool SelectionController::mouseDownMayStartSelect() const {
1046 return m_mouseDownMayStartSelect; 1046 return m_mouseDownMayStartSelect;
1047 } 1047 }
1048 1048
1049 bool SelectionController::mouseDownWasSingleClickInSelection() const { 1049 bool SelectionController::mouseDownWasSingleClickInSelection() const {
1050 return m_mouseDownWasSingleClickInSelection; 1050 return m_mouseDownWasSingleClickInSelection;
1051 } 1051 }
1052 1052
1053 void SelectionController::notifySelectionChanged() { 1053 void SelectionController::notifySelectionChanged() {
1054 if (selection().getSelectionType() == SelectionType::RangeSelection) 1054 // To avoid regression on speedometer benchmark[1] test, we should not
1055 m_selectionState = SelectionState::ExtendedSelection; 1055 // update layout tree in this code block.
1056 else if (selection().getSelectionType() == SelectionType::CaretSelection) 1056 // [1] http://browserbench.org/Speedometer/
1057 m_selectionState = SelectionState::PlacedCaret; 1057 DocumentLifecycle::DisallowTransitionScope disallowTransition(
1058 else 1058 m_frame->document()->lifecycle());
1059 m_selectionState = SelectionState::HaveNotStartedSelection; 1059
1060 const SelectionInDOMTree& selection = this->selection().selectionInDOMTree();
1061 switch (selection.selectionTypeWithLegacyGranularity()) {
1062 case NoSelection:
1063 m_selectionState = SelectionState::HaveNotStartedSelection;
1064 return;
1065 case CaretSelection:
1066 m_selectionState = SelectionState::PlacedCaret;
1067 return;
1068 case RangeSelection:
1069 m_selectionState = SelectionState::ExtendedSelection;
1070 return;
1071 }
1072 NOTREACHED() << "We should handle all SelectionType" << selection;
1060 } 1073 }
1061 1074
1062 FrameSelection& SelectionController::selection() const { 1075 FrameSelection& SelectionController::selection() const {
1063 return m_frame->selection(); 1076 return m_frame->selection();
1064 } 1077 }
1065 1078
1066 bool isLinkSelection(const MouseEventWithHitTestResults& event) { 1079 bool isLinkSelection(const MouseEventWithHitTestResults& event) {
1067 return (event.event().modifiers() & WebInputEvent::Modifiers::AltKey) != 0 && 1080 return (event.event().modifiers() & WebInputEvent::Modifiers::AltKey) != 0 &&
1068 event.isOverLink(); 1081 event.isOverLink();
1069 } 1082 }
1070 1083
1071 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { 1084 bool isExtendingSelection(const MouseEventWithHitTestResults& event) {
1072 bool isMouseDownOnLinkOrImage = 1085 bool isMouseDownOnLinkOrImage =
1073 event.isOverLink() || event.hitTestResult().image(); 1086 event.isOverLink() || event.hitTestResult().image();
1074 return (event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) != 1087 return (event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) !=
1075 0 && 1088 0 &&
1076 !isMouseDownOnLinkOrImage; 1089 !isMouseDownOnLinkOrImage;
1077 } 1090 }
1078 1091
1079 } // namespace blink 1092 } // namespace blink
OLDNEW
« 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