| Index: third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| index c61a043bad9605da78f450c00abfe3cf294885fb..113c340ccda4173bebe19761a72a09062f70d9f1 100644
|
| --- a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| @@ -111,30 +111,6 @@ static SelectionType computeSelectionType(const PositionTemplate<Strategy>& star
|
| }
|
|
|
| template <typename Strategy>
|
| -VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate(
|
| - const PositionTemplate<Strategy>& base,
|
| - const PositionTemplate<Strategy>& extent,
|
| - const PositionTemplate<Strategy>& start,
|
| - const PositionTemplate<Strategy>& end,
|
| - TextAffinity affinity,
|
| - bool isDirectional)
|
| - : m_base(base)
|
| - , m_extent(extent)
|
| - , m_start(start)
|
| - , m_end(end)
|
| - , m_affinity(affinity)
|
| - , m_changeObserver(nullptr) // Observer is associated with only one VisibleSelection, so this should not be copied.
|
| - , m_selectionType(computeSelectionType(start, end))
|
| - , m_baseIsFirst(base.isNull() || base.compareTo(extent) <= 0)
|
| - , m_isDirectional(isDirectional)
|
| -{
|
| - ASSERT(base.isNull() == extent.isNull());
|
| - ASSERT(base.isNull() == start.isNull());
|
| - ASSERT(base.isNull() == end.isNull());
|
| - ASSERT(start.isNull() || start.compareTo(end) <= 0);
|
| -}
|
| -
|
| -template <typename Strategy>
|
| VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate(const VisibleSelectionTemplate<Strategy>& other)
|
| : m_base(other.m_base)
|
| , m_extent(other.m_extent)
|
| @@ -165,12 +141,6 @@ VisibleSelectionTemplate<Strategy>& VisibleSelectionTemplate<Strategy>::operator
|
| return *this;
|
| }
|
|
|
| -template <typename Strategy>
|
| -VisibleSelectionTemplate<Strategy> VisibleSelectionTemplate<Strategy>::createWithoutValidation(const PositionTemplate<Strategy>& base, const PositionTemplate<Strategy>& extent, const PositionTemplate<Strategy>& start, const PositionTemplate<Strategy>& end, TextAffinity affinity, bool isDirectional)
|
| -{
|
| - return VisibleSelectionTemplate<Strategy>(base, extent, start, end, affinity, isDirectional);
|
| -}
|
| -
|
| #if !ENABLE(OILPAN)
|
| template <typename Strategy>
|
| VisibleSelectionTemplate<Strategy>::~VisibleSelectionTemplate()
|
| @@ -743,46 +713,58 @@ static Position adjustPositionForStart(const Position& currentPosition, Node* en
|
| return Position();
|
| }
|
|
|
| -static VisibleSelection computeSelectionToAvoidCrossingShadowBoundaries(const VisibleSelection& selection)
|
| +// TODO(yosin): We should move
|
| +// |SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries()| to
|
| +// "SelectionAdjuster.cpp"
|
| +void SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries(VisibleSelection* selection)
|
| {
|
| // Note: |m_selectionType| isn't computed yet.
|
| - ASSERT(selection.base().isNotNull());
|
| - ASSERT(selection.extent().isNotNull());
|
| - ASSERT(selection.start().isNotNull());
|
| - ASSERT(selection.end().isNotNull());
|
| + ASSERT(selection->base().isNotNull());
|
| + ASSERT(selection->extent().isNotNull());
|
| + ASSERT(selection->start().isNotNull());
|
| + ASSERT(selection->end().isNotNull());
|
|
|
| // TODO(hajimehoshi): Checking treeScope is wrong when a node is
|
| // distributed, but we leave it as it is for backward compatibility.
|
| - if (selection.start().anchorNode()->treeScope() == selection.end().anchorNode()->treeScope())
|
| - return selection;
|
| + if (selection->start().anchorNode()->treeScope() == selection->end().anchorNode()->treeScope())
|
| + return;
|
|
|
| - if (selection.isBaseFirst()) {
|
| - const Position newEnd = adjustPositionForEnd(selection.end(), selection.start().computeContainerNode());
|
| - return VisibleSelection::createWithoutValidation(selection.base(), newEnd, selection.start(), newEnd, selection.affinity(), selection.isDirectional());
|
| + if (selection->isBaseFirst()) {
|
| + const Position& newEnd = adjustPositionForEnd(selection->end(), selection->start().computeContainerNode());
|
| + selection->m_extent = newEnd;
|
| + selection->m_end = newEnd;
|
| + return;
|
| }
|
|
|
| - const Position newStart = adjustPositionForStart(selection.start(), selection.end().computeContainerNode());
|
| - return VisibleSelection::createWithoutValidation(selection.base(), newStart, newStart, selection.end(), selection.affinity(), selection.isDirectional());
|
| + const Position& newStart = adjustPositionForStart(selection->start(), selection->end().computeContainerNode());
|
| + selection->m_extent = newStart;
|
| + selection->m_start = newStart;
|
| }
|
|
|
| +// TODO(yosin): We should move
|
| +// |SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries()| to
|
| +// "SelectionAdjuster.cpp"
|
| // This function is called twice. The first is called when |m_start| and |m_end|
|
| // or |m_extent| are same, and the second when |m_start| and |m_end| are changed
|
| // after downstream/upstream.
|
| -static VisibleSelectionInComposedTree computeSelectionToAvoidCrossingShadowBoundaries(const VisibleSelectionInComposedTree& selection)
|
| +void SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries(VisibleSelectionInComposedTree* selection)
|
| {
|
| - Node* shadowHostStart = enclosingShadowHostForStart(selection.start());
|
| - Node* shadowHostEnd = enclosingShadowHostForEnd(selection.end());
|
| + Node* const shadowHostStart = enclosingShadowHostForStart(selection->start());
|
| + Node* const shadowHostEnd = enclosingShadowHostForEnd(selection->end());
|
| if (shadowHostStart == shadowHostEnd)
|
| - return selection;
|
| + return;
|
|
|
| - if (selection.isBaseFirst()) {
|
| - Node* shadowHost = shadowHostStart ? shadowHostStart : shadowHostEnd;
|
| - const PositionInComposedTree newEnd = adjustPositionInComposedTreeForEnd(selection.end(), shadowHost);
|
| - return VisibleSelectionInComposedTree::createWithoutValidation(selection.base(), newEnd, selection.start(), newEnd, selection.affinity(), selection.isDirectional());
|
| + if (selection->isBaseFirst()) {
|
| + Node* const shadowHost = shadowHostStart ? shadowHostStart : shadowHostEnd;
|
| + const PositionInComposedTree& newEnd = adjustPositionInComposedTreeForEnd(selection->end(), shadowHost);
|
| + selection->m_extent = newEnd;
|
| + selection->m_end = newEnd;
|
| + return;
|
| }
|
| - Node* shadowHost = shadowHostEnd ? shadowHostEnd : shadowHostStart;
|
| - const PositionInComposedTree newStart = adjustPositionInComposedTreeForStart(selection.start(), shadowHost);
|
| - return VisibleSelectionInComposedTree::createWithoutValidation(selection.base(), newStart, newStart, selection.end(), selection.affinity(), selection.isDirectional());
|
| + Node* const shadowHost = shadowHostEnd ? shadowHostEnd : shadowHostStart;
|
| + const PositionInComposedTree& newStart = adjustPositionInComposedTreeForStart(selection->start(), shadowHost);
|
| + selection->m_extent = newStart;
|
| + selection->m_start = newStart;
|
| }
|
|
|
| template <typename Strategy>
|
| @@ -790,7 +772,7 @@ void VisibleSelectionTemplate<Strategy>::adjustSelectionToAvoidCrossingShadowBou
|
| {
|
| if (m_base.isNull() || m_start.isNull() || m_base.isNull())
|
| return;
|
| - *this = computeSelectionToAvoidCrossingShadowBoundaries(*this);
|
| + SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries(this);
|
| }
|
|
|
| static Element* lowestEditableAncestor(Node* node)
|
|
|