Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Unified Diff: Source/core/editing/VisibleSelection.cpp

Issue 1202153004: Enable selection for the composed tree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename the flag Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/VisibleSelection.h ('k') | Source/core/layout/LayoutView.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
+
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
« no previous file with comments | « Source/core/editing/VisibleSelection.h ('k') | Source/core/layout/LayoutView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698