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

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

Issue 2153043002: Make "Undo" command to restore selection after validating with the latest Layout tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-21T19:03:31 Created 4 years, 5 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/VisibleSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
index e80e5046aa13b75856a0e93291600facbb0c51f8..579282738191c9087b14239a3928c1a4d92cf8df 100644
--- a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
@@ -730,23 +730,6 @@ Element* VisibleSelectionTemplate<Strategy>::rootEditableElement() const
}
template <typename Strategy>
-static bool isValidPosition(const PositionTemplate<Strategy>& position)
-{
- if (!position.isConnected())
- return false;
-
- if (!position.isOffsetInAnchor())
- return true;
-
- if (position.offsetInContainerNode() < 0)
- return false;
-
- const unsigned offset = static_cast<unsigned>(position.offsetInContainerNode());
- const unsigned nodeLength = position.anchorNode()->lengthOfContents();
- return offset <= nodeLength;
-}
-
-template <typename Strategy>
void VisibleSelectionTemplate<Strategy>::updateIfNeeded()
{
Document* document = m_base.document();
@@ -760,6 +743,8 @@ void VisibleSelectionTemplate<Strategy>::updateIfNeeded()
appendTrailingWhitespace();
}
+// TODO(yosin): Since |validatePositionsIfNeeded()| is called just one place,
+// we should move it to the call site.
template <typename Strategy>
void VisibleSelectionTemplate<Strategy>::validatePositionsIfNeeded()
{
@@ -767,9 +752,7 @@ void VisibleSelectionTemplate<Strategy>::validatePositionsIfNeeded()
*this = VisibleSelectionTemplate();
return;
}
- if (isValidPosition(m_base) && isValidPosition(m_extent) && isValidPosition(m_start) && isValidPosition(m_end))
- return;
- validate();
+ updateIfNeeded();
}
template <typename Strategy>

Powered by Google App Engine
This is Rietveld 408576698