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

Move parentEditingBoundary() to VisibileUnits.cpp from Position.cpp.

This patch moves |parentEditingBoundary()| to "VisibleUnits.{cpp,h}" from
"Position.{cpp,h}" with |nonShadowBoundaryParentNode()| which is used only by
|parentEditingBoundary()| to cleanup "Position.{cpp,h}" for improving code
health, since |parentEditingBoundary()| is used only in "VisibleUnits.cpp".

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

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

git-svn-id: svn://svn.chromium.org/blink/trunk@200907 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 787aa757
......@@ -462,41 +462,6 @@ static bool atEditingBoundary(const PositionAlgorithm<Strategy> positions)
&& prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableStyle();
}
template <typename Strategy>
static ContainerNode* nonShadowBoundaryParentNode(Node* node)
{
ContainerNode* parent = Strategy::parent(*node);
return parent && !parent->isShadowRoot() ? parent : nullptr;
}
template <typename Strategy>
static Node* parentEditingBoundaryAlgorithm(const PositionAlgorithm<Strategy>& position)
{
Node* const anchorNode = position.anchorNode();
if (!anchorNode)
return nullptr;
Node* documentElement = anchorNode->document().documentElement();
if (!documentElement)
return nullptr;
Node* boundary = position.computeContainerNode();
while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>(boundary) && anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->hasEditableStyle())
boundary = nonShadowBoundaryParentNode<Strategy>(boundary);
return boundary;
}
Node* parentEditingBoundary(const Position& position)
{
return parentEditingBoundaryAlgorithm<EditingStrategy>(position);
}
Node* parentEditingBoundary(const PositionInComposedTree& position)
{
return parentEditingBoundaryAlgorithm<EditingInComposedTreeStrategy>(position);
}
template <typename Strategy>
bool PositionAlgorithm<Strategy>::atStartOfTree() const
{
......
......@@ -235,11 +235,6 @@ extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionAlgorithm<EditingInCom
using Position = PositionAlgorithm<EditingStrategy>;
using PositionInComposedTree = PositionAlgorithm<EditingInComposedTreeStrategy>;
// TODO(yosin) We should make |parentEditingBoundary()| as static function
// in "VisibleUnits.cpp", since it is used only there.
CORE_EXPORT Node* parentEditingBoundary(const Position&);
CORE_EXPORT Node* parentEditingBoundary(const PositionInComposedTree&);
template <typename Strategy>
bool operator==(const PositionAlgorithm<Strategy>& a, const PositionAlgorithm<Strategy>& b)
{
......
......@@ -455,6 +455,30 @@ VisiblePosition rightWordPosition(const VisiblePosition& visiblePosition, bool s
return rightWordBreak;
}
template <typename Strategy>
static ContainerNode* nonShadowBoundaryParentNode(Node* node)
{
ContainerNode* parent = Strategy::parent(*node);
return parent && !parent->isShadowRoot() ? parent : nullptr;
}
template <typename Strategy>
static Node* parentEditingBoundary(const PositionAlgorithm<Strategy>& position)
{
Node* const anchorNode = position.anchorNode();
if (!anchorNode)
return nullptr;
Node* documentElement = anchorNode->document().documentElement();
if (!documentElement)
return nullptr;
Node* boundary = position.computeContainerNode();
while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>(boundary) && anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->hasEditableStyle())
boundary = nonShadowBoundaryParentNode<Strategy>(boundary);
return boundary;
}
enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext };
......
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