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

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelection.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/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index a30f178610c8eede18e70b4fa4cfe6f76ee7b721..ffb32c4502d6a4fbaf62e14b340882515fcb2f23 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -230,21 +230,16 @@ void FrameSelection::setSelection(const SelectionInDOMTree& passedSelection,
m_selectionEditor->setSelection(newSelection);
scheduleVisualUpdateForPaintInvalidationIfNeeded();
- // TODO(yosin): The use of updateStyleAndLayoutIgnorePendingStylesheets
- // needs to be audited. see http://crbug.com/590369 for more details.
- document().updateStyleAndLayoutIgnorePendingStylesheets();
-
const Document& currentDocument = document();
// TODO(yosin): We should get rid of unsued |options| for
// |Editor::respondToChangedSelection()|.
// Note: Since, setting focus can modify DOM tree, we should use
// |oldSelection| before setting focus
m_frame->editor().respondToChangedSelection(
- createVisibleSelection(oldSelectionInDOMTree).start(), options);
+ oldSelectionInDOMTree.computeStartPosition(), options);
DCHECK_EQ(currentDocument, document());
- if (!computeVisibleSelectionInDOMTree().isNone() &&
- !(options & DoNotSetFocus)) {
+ if (!selectionInDOMTree().isNone() && !(options & DoNotSetFocus)) {
setFocusedNodeIfNeeded();
// |setFocusedNodeIfNeeded()| dispatches sync events "FocusOut" and
// "FocusIn", |m_frame| may associate to another document.
@@ -786,8 +781,10 @@ void FrameSelection::selectFrameElementInParentIfFullySelected() {
// Check if the selection contains the entire frame contents; if not, then
// there is nothing to do.
- if (!isRange())
+ if (selectionInDOMTree().selectionTypeWithLegacyGranularity() !=
+ RangeSelection) {
return;
+ }
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
@@ -936,10 +933,13 @@ bool FrameSelection::isInPasswordField() const {
}
void FrameSelection::notifyAccessibilityForSelectionChange() {
- if (selection().start().isNotNull() && selection().end().isNotNull()) {
- if (AXObjectCache* cache = document().existingAXObjectCache())
- cache->selectionChanged(selection().start().computeContainerNode());
- }
+ if (selectionInDOMTree().isNone())
+ return;
+ AXObjectCache* cache = document().existingAXObjectCache();
+ if (!cache)
+ return;
+ const Position& start = selectionInDOMTree().computeStartPosition();
+ cache->selectionChanged(start.computeContainerNode());
}
void FrameSelection::notifyCompositorForSelectionChange() {
@@ -1045,8 +1045,11 @@ void FrameSelection::updateAppearance() {
void FrameSelection::notifyLayoutObjectOfSelectionChange(
EUserTriggered userTriggered) {
- if (TextControlElement* textControl = enclosingTextControl(start()))
- textControl->selectionChanged(userTriggered == UserTriggered);
+ TextControlElement* textControl =
+ enclosingTextControl(selectionInDOMTree().base());
+ if (!textControl)
+ return;
+ textControl->selectionChanged(userTriggered == UserTriggered);
}
// Helper function that tells whether a particular node is an element that has

Powered by Google App Engine
This is Rietveld 408576698