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

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

Issue 2772233002: EXPERIMENT Make toPositionInFlatTree() to return null for DOM position not in flat tree (Closed)
Patch Set: 2017-03-27T18:24:23 Created 3 years, 9 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/Position.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 615c5d770b4043b30b15b649f011dc21ed370af3..ba0b25356aa4229361fdde825b0699768f6103b3 100644
--- a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
@@ -377,15 +377,22 @@ void SelectionEditor::updateCachedVisibleSelectionIfNeeded() const {
m_cachedVisibleSelectionInFlatTree = VisibleSelectionInFlatTree();
return;
}
- m_cachedVisibleSelectionInFlatTree = createVisibleSelection(
- SelectionInFlatTree::Builder()
- .setBaseAndExtent(toPositionInFlatTree(m_selection.base()),
- toPositionInFlatTree(m_selection.extent()))
- .setAffinity(m_selection.affinity())
- .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace())
- .setGranularity(m_selection.granularity())
- .setIsDirectional(m_selection.isDirectional())
- .build());
+ const PositionInFlatTree& base = toPositionInFlatTree(m_selection.base());
+ const PositionInFlatTree& extent = toPositionInFlatTree(m_selection.extent());
+ SelectionInFlatTree::Builder builder;
+ builder.setAffinity(m_selection.affinity())
+ .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace())
+ .setGranularity(m_selection.granularity())
+ .setIsDirectional(m_selection.isDirectional());
+ // TODO(editing-dev): Is it better to adjust base and extent if they are not
+ // in flat tree?
+ if (base.isNotNull() && extent.isNotNull())
+ builder.setBaseAndExtent(base, extent);
+ else if (base.isNotNull())
+ builder.collapse(base);
+ else if (extent.isNotNull())
+ builder.collapse(extent);
+ m_cachedVisibleSelectionInFlatTree = createVisibleSelection(builder.build());
Xiaocheng 2017/03/27 18:17:45 Is it fine if the cached VS and VSInFlatTree have
yosin_UTC9 2017/03/29 03:20:21 So far, we did adjustment in [1] which removed adj
Xiaocheng 2017/03/29 23:56:40 OK. So the type mismatch currently exists, and wil
}
void SelectionEditor::cacheRangeOfDocument(Range* range) {
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698