Chromium Code Reviews| Index: Source/core/editing/VisibleSelection.cpp |
| diff --git a/Source/core/editing/VisibleSelection.cpp b/Source/core/editing/VisibleSelection.cpp |
| index e2af65f288f30f88b8a931d7b27eadf21d6fa1c5..0b39efb9a635dfa0b11f3d2b5143a10a0a25a017 100644 |
| --- a/Source/core/editing/VisibleSelection.cpp |
| +++ b/Source/core/editing/VisibleSelection.cpp |
| @@ -159,6 +159,11 @@ VisibleSelection VisibleSelection::selectionFromContentsOfNode(Node* node) |
| return VisibleSelection(firstPositionInNode(node), lastPositionInNode(node), DOWNSTREAM); |
| } |
| +SelectionType VisibleSelection::selectionTypeInComposedTree() const |
| +{ |
| + return selectionType(m_startInComposedTree, m_endInComposedTree); |
| +} |
| + |
| void VisibleSelection::setBase(const Position& position) |
| { |
| Position oldBase = m_base; |
| @@ -349,6 +354,13 @@ bool VisibleSelection::expandUsingGranularity(TextGranularity granularity) |
| return true; |
| } |
| +bool VisibleSelection::expandUsingGranularityInComposedTree(TextGranularity granularity) |
| +{ |
| + m_base = toPositionInDOMTree(baseInComposedTree()); |
| + m_extent = toPositionInDOMTree(extentInComposedTree()); |
| + return expandUsingGranularity(granularity); |
|
yosin_UTC9
2015/06/23 13:45:01
We'll introduce composed tree version of |expandUs
|
| +} |
| + |
| static PassRefPtrWillBeRawPtr<Range> makeSearchRange(const Position& pos) |
| { |
| Node* node = pos.deprecatedNode(); |
| @@ -599,6 +611,17 @@ SelectionType VisibleSelection::selectionType(const Position& start, const Posit |
| return RangeSelection; |
| } |
| +SelectionType VisibleSelection::selectionType(const PositionInComposedTree& start, const PositionInComposedTree& end) |
| +{ |
| + if (start.isNull()) { |
| + ASSERT(end.isNull()); |
| + return NoSelection; |
| + } |
| + if (start == end || start.upstream() == end.upstream()) |
| + return CaretSelection; |
| + return RangeSelection; |
| +} |
| + |
| void VisibleSelection::updateSelectionType() |
| { |
| m_selectionType = selectionType(m_start, m_end); |
| @@ -773,6 +796,11 @@ void VisibleSelection::setWithoutValidation(const Position& base, const Position |
| didChange(); |
| } |
| +void VisibleSelection::setWithoutValidation(const PositionInComposedTree& base, const PositionInComposedTree& extent) |
| +{ |
| + setWithoutValidation(toPositionInDOMTree(base), toPositionInDOMTree(extent)); |
| +} |
| + |
| static PositionInComposedTree adjustPositionInComposedTreeForStart(const PositionInComposedTree& position, Node* shadowHost) |
| { |
| if (isEnclosedBy(position, *shadowHost)) { |
| @@ -1039,7 +1067,6 @@ PositionWithAffinity VisibleSelection::positionRespectingEditingBoundary(const L |
| return targetNode->layoutObject()->positionForPoint(selectionEndPoint); |
| } |
| - |
| bool VisibleSelection::isContentEditable() const |
| { |
| return isEditablePosition(start()); |
| @@ -1131,6 +1158,11 @@ bool VisibleSelection::InDOMTree::equalSelections(const VisibleSelection& select |
| return selection1 == selection2; |
| } |
| +bool VisibleSelection::InComposedTree::equalSelections(const VisibleSelection& a, const VisibleSelection& b) |
| +{ |
| + return a.startInComposedTree() == b.startInComposedTree() && a.endInComposedTree() == b.endInComposedTree() && a.affinity() == b.affinity() && a.isBaseFirst() == b.isBaseFirst() && a.isDirectional() == b.isDirectional(); |
| +} |
| + |
| #ifndef NDEBUG |
| void VisibleSelection::debugPosition(const char* message) const |