summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/editing/VisibleSelection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/editing/VisibleSelection.cpp')
-rw-r--r--Source/WebCore/editing/VisibleSelection.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/Source/WebCore/editing/VisibleSelection.cpp b/Source/WebCore/editing/VisibleSelection.cpp
index 75531ca..5633c90 100644
--- a/Source/WebCore/editing/VisibleSelection.cpp
+++ b/Source/WebCore/editing/VisibleSelection.cpp
@@ -89,7 +89,8 @@ VisibleSelection::VisibleSelection(const Range* range, EAffinity affinity)
VisibleSelection VisibleSelection::selectionFromContentsOfNode(Node* node)
{
- return VisibleSelection(firstDeepEditingPositionForNode(node), lastDeepEditingPositionForNode(node), DOWNSTREAM);
+ ASSERT(!editingIgnoresContent(node));
+ return VisibleSelection(firstPositionInNode(node), lastPositionInNode(node), DOWNSTREAM);
}
void VisibleSelection::setBase(const Position& position)
@@ -172,8 +173,8 @@ PassRefPtr<Range> VisibleSelection::toNormalizedRange() const
s = s.parentAnchoredEquivalent();
e = e.parentAnchoredEquivalent();
}
-
- if (s.isNull() || e.isNull())
+
+ if (!s.containerNode() || !e.containerNode())
return 0;
// VisibleSelections are supposed to always be valid. This constructor will ASSERT
@@ -208,7 +209,7 @@ static PassRefPtr<Range> makeSearchRange(const Position& pos)
Position start(pos.parentAnchoredEquivalent());
searchRange->selectNodeContents(boundary, ec);
- searchRange->setStart(start.deprecatedNode(), start.deprecatedEditingOffset(), ec);
+ searchRange->setStart(start.containerNode(), start.offsetInContainerNode(), ec);
ASSERT(!ec);
if (ec)
@@ -217,9 +218,9 @@ static PassRefPtr<Range> makeSearchRange(const Position& pos)
return searchRange.release();
}
-bool VisibleSelection::isAll(StayInEditableContent stayInEditableContent) const
+bool VisibleSelection::isAll(EditingBoundaryCrossingRule rule) const
{
- return !shadowTreeRootNode() && visibleStart().previous(stayInEditableContent).isNull() && visibleEnd().next(stayInEditableContent).isNull();
+ return !shadowTreeRootNode() && visibleStart().previous(rule).isNull() && visibleEnd().next(rule).isNull();
}
void VisibleSelection::appendTrailingWhitespace()
@@ -305,7 +306,7 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
// The paragraph break after the last paragraph in the last cell of a block table ends
// at the start of the paragraph after the table.
if (isBlock(table))
- end = end.next(true);
+ end = end.next(CannotCrossEditingBoundary);
else
end = wordEnd;
}
@@ -355,7 +356,7 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
// The paragraph break after the last paragraph in the last cell of a block table ends
// at the start of the paragraph after the table, not at the position just after the table.
if (isBlock(table))
- end = end.next(true);
+ end = end.next(CannotCrossEditingBoundary);
// There is no parargraph break after the last paragraph in the last cell of an inline table.
else
end = visibleParagraphEnd;
@@ -457,7 +458,7 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
Node* startRoot = highestEditableRoot(m_start);
Node* endRoot = highestEditableRoot(m_end);
- Node* baseEditableAncestor = lowestEditableAncestor(m_base.deprecatedNode());
+ Node* baseEditableAncestor = lowestEditableAncestor(m_base.containerNode());
// The base, start and end are all in the same region. No adjustment necessary.
if (baseRoot == startRoot && baseRoot == endRoot)
@@ -492,19 +493,19 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
// The selection ends in editable content or non-editable content inside a different editable ancestor,
// move backward until non-editable content inside the same lowest editable ancestor is reached.
- Node* endEditableAncestor = lowestEditableAncestor(m_end.deprecatedNode());
+ Node* endEditableAncestor = lowestEditableAncestor(m_end.containerNode());
if (endRoot || endEditableAncestor != baseEditableAncestor) {
Position p = previousVisuallyDistinctCandidate(m_end);
Node* shadowAncestor = endRoot ? endRoot->shadowAncestorNode() : 0;
if (p.isNull() && endRoot && (shadowAncestor != endRoot))
- p = lastDeepEditingPositionForNode(shadowAncestor);
- while (p.isNotNull() && !(lowestEditableAncestor(p.deprecatedNode()) == baseEditableAncestor && !isEditablePosition(p))) {
+ p = positionAfterNode(shadowAncestor);
+ while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
Node* root = editableRootForPosition(p);
shadowAncestor = root ? root->shadowAncestorNode() : 0;
- p = isAtomicNode(p.deprecatedNode()) ? positionInParentBeforeNode(p.deprecatedNode()) : previousVisuallyDistinctCandidate(p);
+ p = isAtomicNode(p.containerNode()) ? positionInParentBeforeNode(p.containerNode()) : previousVisuallyDistinctCandidate(p);
if (p.isNull() && (shadowAncestor != root))
- p = lastDeepEditingPositionForNode(shadowAncestor);
+ p = positionAfterNode(shadowAncestor);
}
VisiblePosition previous(p);
@@ -522,16 +523,16 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
// The selection starts in editable content or non-editable content inside a different editable ancestor,
// move forward until non-editable content inside the same lowest editable ancestor is reached.
- Node* startEditableAncestor = lowestEditableAncestor(m_start.deprecatedNode());
+ Node* startEditableAncestor = lowestEditableAncestor(m_start.containerNode());
if (startRoot || startEditableAncestor != baseEditableAncestor) {
Position p = nextVisuallyDistinctCandidate(m_start);
Node* shadowAncestor = startRoot ? startRoot->shadowAncestorNode() : 0;
if (p.isNull() && startRoot && (shadowAncestor != startRoot))
p = positionBeforeNode(shadowAncestor);
- while (p.isNotNull() && !(lowestEditableAncestor(p.deprecatedNode()) == baseEditableAncestor && !isEditablePosition(p))) {
+ while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
Node* root = editableRootForPosition(p);
shadowAncestor = root ? root->shadowAncestorNode() : 0;
- p = isAtomicNode(p.deprecatedNode()) ? positionInParentAfterNode(p.deprecatedNode()) : nextVisuallyDistinctCandidate(p);
+ p = isAtomicNode(p.containerNode()) ? positionInParentAfterNode(p.containerNode()) : nextVisuallyDistinctCandidate(p);
if (p.isNull() && (shadowAncestor != root))
p = positionBeforeNode(shadowAncestor);
}
@@ -551,7 +552,7 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
}
// Correct the extent if necessary.
- if (baseEditableAncestor != lowestEditableAncestor(m_extent.deprecatedNode()))
+ if (baseEditableAncestor != lowestEditableAncestor(m_extent.containerNode()))
m_extent = m_baseIsFirst ? m_end : m_start;
}