Commit ed9fa2dc authored by yosin's avatar yosin Committed by Commit bot

Move VisibleSelection::nonBoundaryShadowTreeRootNode() to FrameSelection.cpp

This patch moves a member function |nonBoundaryShadowTreeRootNode()| in
|VisibleSelection| to "FrameSelection.cpp", where only the place uses it,
to simplify |VisibleSelection| class for improving code health.

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

Review-Url: https://codereview.chromium.org/2023793002
Cr-Commit-Position: refs/heads/master@{#396783}
parent 8dbe47eb
......@@ -798,6 +798,13 @@ void FrameSelection::selectFrameElementInParentIfFullySelected()
toLocalFrame(parent)->selection().setSelection(newSelection);
}
// Returns a shadow tree node for legacy shadow trees, a child of the
// ShadowRoot node for new shadow trees, or 0 for non-shadow trees.
static Node* nonBoundaryShadowTreeRootNode(const Position& position)
{
return position.anchorNode() && !position.anchorNode()->isShadowRoot() ? position.anchorNode()->nonBoundaryShadowTreeRootNode() : nullptr;
}
void FrameSelection::selectAll()
{
Document* document = m_frame->document();
......@@ -814,12 +821,12 @@ void FrameSelection::selectAll()
Node* selectStartTarget = nullptr;
if (isContentEditable()) {
root = highestEditableRoot(selection().start());
if (Node* shadowRoot = selection().nonBoundaryShadowTreeRootNode())
if (Node* shadowRoot = nonBoundaryShadowTreeRootNode(selection().start()))
selectStartTarget = shadowRoot->shadowHost();
else
selectStartTarget = root;
} else {
root = selection().nonBoundaryShadowTreeRootNode();
root = nonBoundaryShadowTreeRootNode(selection().start());
if (root) {
selectStartTarget = root->shadowHost();
} else {
......
......@@ -757,12 +757,6 @@ Element* VisibleSelectionTemplate<Strategy>::rootEditableElement() const
return rootEditableElementOf(start());
}
template <typename Strategy>
Node* VisibleSelectionTemplate<Strategy>::nonBoundaryShadowTreeRootNode() const
{
return start().anchorNode() && !start().anchorNode()->isShadowRoot() ? start().anchorNode()->nonBoundaryShadowTreeRootNode() : 0;
}
VisibleSelectionChangeObserver::VisibleSelectionChangeObserver()
{
}
......
......@@ -125,9 +125,6 @@ public:
bool isContentEditable() const;
bool hasEditableStyle() const;
bool isContentRichlyEditable() const;
// Returns a shadow tree node for legacy shadow trees, a child of the
// ShadowRoot node for new shadow trees, or 0 for non-shadow trees.
Node* nonBoundaryShadowTreeRootNode() const;
bool isValidFor(const Document&) const;
void setWithoutValidation(const PositionTemplate<Strategy>&, const PositionTemplate<Strategy>&);
......
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