Commit d951679b authored by yosin@chromium.org's avatar yosin@chromium.org

Move a member function intersectsNode() out from VisibleSelection class

This patch moves a member function |intersectsNode()| out from
|VisibleSelection| class as a preparation of templatizing |VisibleSelection|
for introducing composed tree version of |VisibleSelection|.

This patch is a preparation of making selection to handle granularity for web
component, http://crrev.com/1277863002

BUG=513568
TEST=n/a; No behavior changes

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

git-svn-id: svn://svn.chromium.org/blink/trunk@201304 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b37c505b
......@@ -394,7 +394,7 @@ void FrameSelection::respondToNodeModification(Node& node, bool baseRemoved, boo
m_selection.setWithoutValidation(m_selection.start(), m_selection.end());
else
m_selection.setWithoutValidation(m_selection.end(), m_selection.start());
} else if (m_selection.intersectsNode(&node)) {
} else if (intersectsNode(m_selection, &node)) {
// If we did nothing here, when this node's layoutObject was destroyed, the rect that it
// occupied would be invalidated, but, selection gaps that change as a result of
// the removal wouldn't be invalidated.
......
......@@ -230,13 +230,15 @@ PassRefPtrWillBeRawPtr<Range> firstRangeOf(const VisibleSelection& selection)
return Range::create(*start.document(), start, end);
}
bool VisibleSelection::intersectsNode(Node* node) const
// TODO(yosin) We should move |intersectsNode()| to "FrameSelection.cpp".
bool intersectsNode(const VisibleSelection& selection, Node* node)
{
if (isNone())
if (selection.isNone())
return false;
Position start = m_start.parentAnchoredEquivalent();
Position end = m_end.parentAnchoredEquivalent();
Position start = selection.start().parentAnchoredEquivalent();
Position end = selection.end().parentAnchoredEquivalent();
TrackExceptionState exceptionState;
// TODO(yosin) We should avoid to use |Range::intersectsNode()|.
return Range::intersectsNode(node, start, end, exceptionState) && !exceptionState.hadException();
}
......
......@@ -153,8 +153,6 @@ public:
bool expandUsingGranularity(TextGranularity);
bool expandUsingGranularityInComposedTree(TextGranularity);
bool intersectsNode(Node*) const;
// TODO(yosin) Most callers probably don't want these functions, but
// are using them for historical reasons. |toNormalizedEphemeralRange()|
// contracts the range around text, and moves the caret most backward
......@@ -258,6 +256,9 @@ private:
// to return.
CORE_EXPORT PassRefPtrWillBeRawPtr<Range> firstRangeOf(const VisibleSelection&);
// TODO(yosin) We should move |intersectsNode()| to "FrameSelection.cpp".
bool intersectsNode(const VisibleSelection&, Node*);
} // namespace blink
#ifndef NDEBUG
......
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