Commit 22daad5b authored by yosin@chromium.org's avatar yosin@chromium.org

Move a member function atEditingBoundary() out from PositionAlgorithm<Strategy> template class

This patch moves a member function |atEditingBoundary()| in
|PositionAlgorithm<Strategy>| template class as static function inside
"Position.cpp" to simplify |PositionAlgorithm| class for improving code halth.

BUG=518738
TEST=n/a; no behavior changes

Review URL: https://codereview.chromium.org/1288553007

git-svn-id: svn://svn.chromium.org/blink/trunk@200814 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 42ccdfeb
......@@ -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;
......
......@@ -182,8 +182,6 @@ public:
bool atFirstEditingPositionForNode() const;
bool atLastEditingPositionForNode() const;
// Returns true if the visually equivalent positions around have different editability
bool atEditingBoundary() const;
Node* parentEditingBoundary() const;
bool atStartOfTree() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment