Chromium Code Reviews| 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..6c1d5230cb9fe73c565ccdd93a8aba9a1cf72155 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,26 @@ SelectionEditor::visibleSelection<EditingInFlatTreeStrategy>() const { |
| return m_selectionInFlatTree; |
| } |
| +static void MarkDOMSelectionDirty(const VisibleSelection& selection) { |
|
tkent
2017/01/25 07:59:12
Mark -> mark
yoichio
2017/01/27 08:33:04
Done.
|
| + if (selection.isNone()) |
| + return; |
| + |
| + DCHECK(selection.start().anchorNode()); |
| + selection.start().anchorNode()->treeScope().getSelection()->markRangeDirty(); |
| + if (selection.isCaret()) |
| + return; |
| + |
| + DCHECK(selection.end().anchorNode()); |
| + 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 +111,8 @@ void SelectionEditor::setVisibleSelection( |
| SelectionAdjuster::adjustSelectionInFlatTree(&m_selectionInFlatTree, |
| m_selection); |
| + |
| + MarkDOMSelectionDirty(m_selection); |
| } |
| void SelectionEditor::setVisibleSelection( |
| @@ -103,9 +121,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 +137,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) { |