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

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

Issue 2653523003: Make DOMSelection cache Range (Closed)
Patch Set: update Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/DOMSelection.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/SelectionEditor.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
index 8206ecf15d3debae364272601af153a1bff8911d..4ec809ba7503bc9fcf819fad86fa64c6c39130f4 100644
--- a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
@@ -25,6 +25,7 @@
#include "core/editing/SelectionEditor.h"
+#include "core/editing/DOMSelection.h"
#include "core/editing/EditingUtilities.h"
#include "core/editing/Editor.h"
#include "core/editing/SelectionAdjuster.h"
@@ -80,11 +81,24 @@ SelectionEditor::visibleSelection<EditingInFlatTreeStrategy>() const {
return m_selectionInFlatTree;
}
+static void markDOMSelectionDirty(const VisibleSelection& selection) {
+ if (selection.isNone())
+ return;
+
+ selection.start().anchorNode()->treeScope().getSelection()->markRangeDirty();
yosin_UTC9 2017/01/27 10:19:34 We want to have |TreeScope::getSelectionIfExists()
+ if (selection.isCaret())
+ return;
+
+ selection.end().anchorNode()->treeScope().getSelection()->markRangeDirty();
+}
+
void SelectionEditor::setVisibleSelection(
const VisibleSelection& newSelection,
FrameSelection::SetSelectionOptions options) {
DCHECK(newSelection.isValidFor(document())) << newSelection;
resetLogicalRange();
+ markDOMSelectionDirty(m_selection);
+
m_selection = newSelection;
if (options & FrameSelection::DoNotAdjustInFlatTree) {
m_selectionInFlatTree.setWithoutValidation(
@@ -95,6 +109,8 @@ void SelectionEditor::setVisibleSelection(
SelectionAdjuster::adjustSelectionInFlatTree(&m_selectionInFlatTree,
m_selection);
+
+ markDOMSelectionDirty(m_selection);
}
void SelectionEditor::setVisibleSelection(
@@ -103,9 +119,13 @@ void SelectionEditor::setVisibleSelection(
DCHECK(newSelection.isValidFor(document())) << newSelection;
DCHECK(!(options & FrameSelection::DoNotAdjustInFlatTree));
resetLogicalRange();
+ markDOMSelectionDirty(m_selection);
+
m_selectionInFlatTree = newSelection;
SelectionAdjuster::adjustSelectionInDOMTree(&m_selection,
m_selectionInFlatTree);
+
+ markDOMSelectionDirty(m_selection);
}
void SelectionEditor::setWithoutValidation(const Position& base,
@@ -115,9 +135,12 @@ void SelectionEditor::setWithoutValidation(const Position& base,
DCHECK_EQ(base.document(), document());
if (extent.isNotNull())
DCHECK_EQ(extent.document(), document());
+ markDOMSelectionDirty(m_selection);
+
m_selection.setWithoutValidation(base, extent);
m_selectionInFlatTree.setWithoutValidation(toPositionInFlatTree(base),
toPositionInFlatTree(extent));
+ markDOMSelectionDirty(m_selection);
}
void SelectionEditor::documentAttached(Document* document) {
« no previous file with comments | « third_party/WebKit/Source/core/editing/DOMSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698