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

Unified Diff: Source/core/editing/Position.cpp

Issue 1288553007: Move a member function atEditingBoundary() out from PositionAlgorithm<Strategy> template class (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-19T14:22:58 Created 5 years, 4 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 | « Source/core/editing/Position.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/Position.cpp
diff --git a/Source/core/editing/Position.cpp b/Source/core/editing/Position.cpp
index b482d96831c976f9b4bf3b437591ae2f89f2c582..836f7f31f2133b2e4e2413c640aedc5aadb100d8 100644
--- a/Source/core/editing/Position.cpp
+++ b/Source/core/editing/Position.cpp
@@ -437,22 +437,24 @@ bool PositionAlgorithm<Strategy>::atLastEditingPositionForNode() const
return isAfterAnchorOrAfterChildren() || m_offset >= EditingStrategy::lastOffsetForEditing(anchorNode());
}
-// A position is considered at editing boundary if one of the following is true:
-// 1. It is the first position in the node and the next visually equivalent position
-// is non editable.
-// 2. It is the last position in the node and the previous visually equivalent position
-// is non editable.
-// 3. It is an editable position and both the next and previous visually equivalent
-// positions are both non editable.
+// Returns true if the visually equivalent positions around have different
+// editability. A position is considered at editing boundary if one of the
+// following is true:
+// 1. It is the first position in the node and the next visually equivalent
+// position is non editable.
+// 2. It is the last position in the node and the previous visually equivalent
+// position is non editable.
+// 3. It is an editable position and both the next and previous visually
+// equivalent positions are both non editable.
template <typename Strategy>
-bool PositionAlgorithm<Strategy>::atEditingBoundary() const
+static bool atEditingBoundary(const PositionAlgorithm<Strategy> positions)
{
- PositionAlgorithm<Strategy> nextPosition = downstream(CanCrossEditingBoundary);
- if (atFirstEditingPositionForNode() && nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableStyle())
+ PositionAlgorithm<Strategy> nextPosition = positions.downstream(CanCrossEditingBoundary);
+ if (positions.atFirstEditingPositionForNode() && nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableStyle())
return true;
- PositionAlgorithm<Strategy> prevPosition = upstream(CanCrossEditingBoundary);
- if (atLastEditingPositionForNode() && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableStyle())
+ PositionAlgorithm<Strategy> prevPosition = positions.upstream(CanCrossEditingBoundary);
+ if (positions.atLastEditingPositionForNode() && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableStyle())
return true;
return nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableStyle()
@@ -893,12 +895,12 @@ bool PositionAlgorithm<Strategy>::isCandidate() const
if (toLayoutBlock(layoutObject)->logicalHeight() || isHTMLBodyElement(*m_anchorNode)) {
if (!hasRenderedNonAnonymousDescendantsWithHeight(layoutObject))
return atFirstEditingPositionForNode() && !nodeIsUserSelectNone(anchorNode());
- return m_anchorNode->hasEditableStyle() && !nodeIsUserSelectNone(anchorNode()) && atEditingBoundary();
+ return m_anchorNode->hasEditableStyle() && !nodeIsUserSelectNone(anchorNode()) && atEditingBoundary(*this);
}
} else {
LocalFrame* frame = m_anchorNode->document().frame();
bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEnabled();
- return (caretBrowsing || m_anchorNode->hasEditableStyle()) && !nodeIsUserSelectNone(anchorNode()) && atEditingBoundary();
+ return (caretBrowsing || m_anchorNode->hasEditableStyle()) && !nodeIsUserSelectNone(anchorNode()) && atEditingBoundary(*this);
}
return false;
« no previous file with comments | « Source/core/editing/Position.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698