| 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 e37a347e87db9bbc0c736e345b96ef097cd96830..38a234c905e28721c5b283f5cf9c790ed36ac974 100644
|
| --- a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| @@ -48,20 +48,23 @@ VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate()
|
| m_baseIsFirst(true),
|
| m_isDirectional(false),
|
| m_granularity(CharacterGranularity),
|
| - m_hasTrailingWhitespace(false) {}
|
| + m_hasTrailingWhitespace(false),
|
| + m_isHandleVisible(false) {}
|
|
|
| template <typename Strategy>
|
| VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate(
|
| const PositionTemplate<Strategy>& base,
|
| const PositionTemplate<Strategy>& extent,
|
| TextAffinity affinity,
|
| - bool isDirectional)
|
| + bool isDirectional,
|
| + bool isHandleVisible)
|
| : m_base(base),
|
| m_extent(extent),
|
| m_affinity(affinity),
|
| m_isDirectional(isDirectional),
|
| m_granularity(CharacterGranularity),
|
| - m_hasTrailingWhitespace(false) {
|
| + m_hasTrailingWhitespace(false),
|
| + m_isHandleVisible(isHandleVisible) {
|
| validate();
|
| }
|
|
|
| @@ -70,51 +73,62 @@ VisibleSelectionTemplate<Strategy> VisibleSelectionTemplate<Strategy>::create(
|
| const PositionTemplate<Strategy>& base,
|
| const PositionTemplate<Strategy>& extent,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| - return VisibleSelectionTemplate(base, extent, affinity, isDirectional);
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| + return VisibleSelectionTemplate(base, extent, affinity, isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelectionDeprecated(const Position& pos,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (pos.isNotNull())
|
| pos.document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| - return VisibleSelection::create(pos, pos, affinity, isDirectional);
|
| + return VisibleSelection::create(pos, pos, affinity, isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelectionDeprecated(const Position& base,
|
| const Position& extent,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (base.isNotNull())
|
| base.document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| if (extent.isNotNull())
|
| extent.document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| - return VisibleSelection::create(base, extent, affinity, isDirectional);
|
| + return VisibleSelection::create(base, extent, affinity, isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelectionDeprecated(
|
| const PositionWithAffinity& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (pos.isNotNull())
|
| pos.position().document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| return VisibleSelection::create(pos.position(), pos.position(),
|
| - pos.affinity(), isDirectional);
|
| + pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelectionDeprecated(const VisiblePosition& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (pos.isNotNull())
|
| pos.deepEquivalent()
|
| .document()
|
| ->updateStyleAndLayoutIgnorePendingStylesheets();
|
| return VisibleSelection::create(pos.deepEquivalent(), pos.deepEquivalent(),
|
| - pos.affinity(), isDirectional);
|
| + pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelectionDeprecated(const VisiblePosition& base,
|
| const VisiblePosition& extent,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (base.isNotNull())
|
| base.deepEquivalent()
|
| .document()
|
| @@ -125,67 +139,75 @@ VisibleSelection createVisibleSelectionDeprecated(const VisiblePosition& base,
|
| ->updateStyleAndLayoutIgnorePendingStylesheets();
|
| return VisibleSelection::create(base.deepEquivalent(),
|
| extent.deepEquivalent(), base.affinity(),
|
| - isDirectional);
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelectionDeprecated(const EphemeralRange& range,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (range.isNotNull())
|
| range.startPosition()
|
| .document()
|
| ->updateStyleAndLayoutIgnorePendingStylesheets();
|
| return VisibleSelection::create(range.startPosition(), range.endPosition(),
|
| - affinity, isDirectional);
|
| + affinity, isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
|
| const PositionInFlatTree& pos,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (pos.isNotNull())
|
| pos.document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| - return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional);
|
| + return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
|
| const PositionInFlatTree& base,
|
| const PositionInFlatTree& extent,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (base.isNotNull())
|
| base.document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| if (extent.isNotNull())
|
| extent.document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| return VisibleSelectionInFlatTree::create(base, extent, affinity,
|
| - isDirectional);
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
|
| const PositionInFlatTreeWithAffinity& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (pos.isNotNull())
|
| pos.position().document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| return VisibleSelectionInFlatTree::create(pos.position(), pos.position(),
|
| - pos.affinity(), isDirectional);
|
| + pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
|
| const VisiblePositionInFlatTree& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (pos.isNotNull())
|
| pos.deepEquivalent()
|
| .document()
|
| ->updateStyleAndLayoutIgnorePendingStylesheets();
|
| - return VisibleSelectionInFlatTree::create(pos.deepEquivalent(),
|
| - pos.deepEquivalent(),
|
| - pos.affinity(), isDirectional);
|
| + return VisibleSelectionInFlatTree::create(
|
| + pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
|
| const VisiblePositionInFlatTree& base,
|
| const VisiblePositionInFlatTree& extent,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (base.isNotNull())
|
| base.deepEquivalent()
|
| .document()
|
| @@ -194,134 +216,155 @@ VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
|
| extent.deepEquivalent()
|
| .document()
|
| ->updateStyleAndLayoutIgnorePendingStylesheets();
|
| - return VisibleSelectionInFlatTree::create(base.deepEquivalent(),
|
| - extent.deepEquivalent(),
|
| - base.affinity(), isDirectional);
|
| + return VisibleSelectionInFlatTree::create(
|
| + base.deepEquivalent(), extent.deepEquivalent(), base.affinity(),
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
|
| const EphemeralRangeInFlatTree& range,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| if (range.isNotNull())
|
| range.startPosition()
|
| .document()
|
| ->updateStyleAndLayoutIgnorePendingStylesheets();
|
| - return VisibleSelectionInFlatTree::create(
|
| - range.startPosition(), range.endPosition(), affinity, isDirectional);
|
| + return VisibleSelectionInFlatTree::create(range.startPosition(),
|
| + range.endPosition(), affinity,
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelection(const Position& pos,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(pos));
|
| - return VisibleSelection::create(pos, pos, affinity, isDirectional);
|
| + return VisibleSelection::create(pos, pos, affinity, isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelection(const Position& base,
|
| const Position& extent,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(base));
|
| DCHECK(!needsLayoutTreeUpdate(extent));
|
| // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
|
| // after all call sites have ensured that.
|
| - return VisibleSelection::create(base, extent, affinity, isDirectional);
|
| + return VisibleSelection::create(base, extent, affinity, isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelection(const PositionWithAffinity& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(pos.position()));
|
| return VisibleSelection::create(pos.position(), pos.position(),
|
| - pos.affinity(), isDirectional);
|
| + pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelection(const VisiblePosition& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(pos.isValid());
|
| return VisibleSelection::create(pos.deepEquivalent(), pos.deepEquivalent(),
|
| - pos.affinity(), isDirectional);
|
| + pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelection(const VisiblePosition& base,
|
| const VisiblePosition& extent,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(base.isValid());
|
| DCHECK(extent.isValid());
|
| // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
|
| // after all call sites have ensured that.
|
| return VisibleSelection::create(base.deepEquivalent(),
|
| extent.deepEquivalent(), base.affinity(),
|
| - isDirectional);
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelection createVisibleSelection(const EphemeralRange& range,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(range.startPosition()));
|
| DCHECK(!needsLayoutTreeUpdate(range.endPosition()));
|
| return VisibleSelection::create(range.startPosition(), range.endPosition(),
|
| - affinity, isDirectional);
|
| + affinity, isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelection(const PositionInFlatTree& pos,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(pos));
|
| - return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional);
|
| + return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelection(
|
| const PositionInFlatTree& base,
|
| const PositionInFlatTree& extent,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(base));
|
| DCHECK(!needsLayoutTreeUpdate(extent));
|
| // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
|
| // after all call sites have ensured that.
|
| return VisibleSelectionInFlatTree::create(base, extent, affinity,
|
| - isDirectional);
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelection(
|
| const PositionInFlatTreeWithAffinity& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(pos.position()));
|
| return VisibleSelectionInFlatTree::create(pos.position(), pos.position(),
|
| - pos.affinity(), isDirectional);
|
| + pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelection(
|
| const VisiblePositionInFlatTree& pos,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(pos.isValid());
|
| - return VisibleSelectionInFlatTree::create(pos.deepEquivalent(),
|
| - pos.deepEquivalent(),
|
| - pos.affinity(), isDirectional);
|
| + return VisibleSelectionInFlatTree::create(
|
| + pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity(), isDirectional,
|
| + isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelection(
|
| const VisiblePositionInFlatTree& base,
|
| const VisiblePositionInFlatTree& extent,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(base.isValid());
|
| DCHECK(extent.isValid());
|
| // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
|
| // after all call sites have ensured that.
|
| - return VisibleSelectionInFlatTree::create(base.deepEquivalent(),
|
| - extent.deepEquivalent(),
|
| - base.affinity(), isDirectional);
|
| + return VisibleSelectionInFlatTree::create(
|
| + base.deepEquivalent(), extent.deepEquivalent(), base.affinity(),
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| VisibleSelectionInFlatTree createVisibleSelection(
|
| const EphemeralRangeInFlatTree& range,
|
| TextAffinity affinity,
|
| - bool isDirectional) {
|
| + bool isDirectional,
|
| + bool isHandleVisible) {
|
| DCHECK(!needsLayoutTreeUpdate(range.startPosition()));
|
| DCHECK(!needsLayoutTreeUpdate(range.endPosition()));
|
| - return VisibleSelectionInFlatTree::create(
|
| - range.startPosition(), range.endPosition(), affinity, isDirectional);
|
| + return VisibleSelectionInFlatTree::create(range.startPosition(),
|
| + range.endPosition(), affinity,
|
| + isDirectional, isHandleVisible);
|
| }
|
|
|
| template <typename Strategy>
|
| @@ -356,7 +399,8 @@ VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate(
|
| m_baseIsFirst(other.m_baseIsFirst),
|
| m_isDirectional(other.m_isDirectional),
|
| m_granularity(other.m_granularity),
|
| - m_hasTrailingWhitespace(other.m_hasTrailingWhitespace) {}
|
| + m_hasTrailingWhitespace(other.m_hasTrailingWhitespace),
|
| + m_isHandleVisible(other.m_isHandleVisible) {}
|
|
|
| template <typename Strategy>
|
| VisibleSelectionTemplate<Strategy>& VisibleSelectionTemplate<Strategy>::
|
| @@ -371,6 +415,7 @@ operator=(const VisibleSelectionTemplate<Strategy>& other) {
|
| m_isDirectional = other.m_isDirectional;
|
| m_granularity = other.m_granularity;
|
| m_hasTrailingWhitespace = other.m_hasTrailingWhitespace;
|
| + m_isHandleVisible = other.m_isHandleVisible;
|
| return *this;
|
| }
|
|
|
| @@ -386,7 +431,7 @@ VisibleSelectionTemplate<Strategy>::selectionFromContentsOfNode(Node* node) {
|
| return VisibleSelectionTemplate::create(
|
| PositionTemplate<Strategy>::firstPositionInNode(node),
|
| PositionTemplate<Strategy>::lastPositionInNode(node), SelDefaultAffinity,
|
| - false);
|
| + false, false);
|
| }
|
|
|
| template <typename Strategy>
|
| @@ -1043,7 +1088,8 @@ static bool equalSelectionsAlgorithm(
|
| const VisibleSelectionTemplate<Strategy>& selection1,
|
| const VisibleSelectionTemplate<Strategy>& selection2) {
|
| if (selection1.affinity() != selection2.affinity() ||
|
| - selection1.isDirectional() != selection2.isDirectional())
|
| + selection1.isDirectional() != selection2.isDirectional() ||
|
| + selection1.isHandleVisible() != selection2.isHandleVisible())
|
| return false;
|
|
|
| if (selection1.isNone())
|
|
|