Index: Source/core/editing/VisibleSelection.cpp |
diff --git a/Source/core/editing/VisibleSelection.cpp b/Source/core/editing/VisibleSelection.cpp |
index 6b6982979fdd86aba65f6d986805ba45c184622b..f31895ce4abbe68255c104cdadbbababce1109cf 100644 |
--- a/Source/core/editing/VisibleSelection.cpp |
+++ b/Source/core/editing/VisibleSelection.cpp |
@@ -20,9 +20,9 @@ |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
- |
+ |
#include "config.h" |
#include "core/editing/VisibleSelection.h" |
@@ -154,18 +154,18 @@ PassRefPtr<Range> VisibleSelection::toNormalizedRange() const |
if (isCaret()) { |
// If the selection is a caret, move the range start upstream. This helps us match |
// the conventions of text editors tested, which make style determinations based |
- // on the character before the caret, if any. |
+ // on the character before the caret, if any. |
s = m_start.upstream().parentAnchoredEquivalent(); |
e = s; |
} else { |
// If the selection is a range, select the minimum range that encompasses the selection. |
- // Again, this is to match the conventions of text editors tested, which make style |
- // determinations based on the first character of the selection. |
- // For instance, this operation helps to make sure that the "X" selected below is the |
- // only thing selected. The range should not be allowed to "leak" out to the end of the |
- // previous text node, or to the beginning of the next text node, each of which has a |
+ // Again, this is to match the conventions of text editors tested, which make style |
+ // determinations based on the first character of the selection. |
+ // For instance, this operation helps to make sure that the "X" selected below is the |
+ // only thing selected. The range should not be allowed to "leak" out to the end of the |
+ // previous text node, or to the beginning of the next text node, each of which has a |
// different style. |
- // |
+ // |
// On a treasure map, <b>X</b> marks the spot. |
// ^ selected |
// |
@@ -302,15 +302,15 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text |
side = RightWordIfOnBoundary; |
if (isEndOfEditableOrNonEditableContent(originalEnd) || (isEndOfLine(originalEnd) && !isStartOfLine(originalEnd) && !isEndOfParagraph(originalEnd))) |
side = LeftWordIfOnBoundary; |
- |
+ |
VisiblePosition wordEnd(endOfWord(originalEnd, side)); |
VisiblePosition end(wordEnd); |
- |
+ |
if (isEndOfParagraph(originalEnd) && !isEmptyTableCell(m_start.deprecatedNode())) { |
- // Select the paragraph break (the space from the end of a paragraph to the start of |
+ // Select the paragraph break (the space from the end of a paragraph to the start of |
// the next one) to match TextEdit. |
end = wordEnd.next(); |
- |
+ |
if (Node* table = isFirstPositionAfterTable(end)) { |
// 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. |
@@ -319,12 +319,12 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text |
else |
end = wordEnd; |
} |
- |
+ |
if (end.isNull()) |
end = wordEnd; |
- |
+ |
} |
- |
+ |
m_end = end.deepEquivalent(); |
break; |
} |
@@ -336,7 +336,7 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text |
case LineGranularity: { |
m_start = startOfLine(VisiblePosition(m_start, m_affinity)).deepEquivalent(); |
VisiblePosition end = endOfLine(VisiblePosition(m_end, m_affinity)); |
- // If the end of this line is at the end of a paragraph, include the space |
+ // If the end of this line is at the end of a paragraph, include the space |
// after the end of the line in the selection. |
if (isEndOfParagraph(end)) { |
VisiblePosition next = end.next(); |
@@ -356,11 +356,11 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text |
pos = pos.previous(); |
m_start = startOfParagraph(pos).deepEquivalent(); |
VisiblePosition visibleParagraphEnd = endOfParagraph(VisiblePosition(m_end, m_affinity)); |
- |
+ |
// Include the "paragraph break" (the space from the end of this paragraph to the start |
// of the next one) in the selection. |
VisiblePosition end(visibleParagraphEnd.next()); |
- |
+ |
if (Node* table = isFirstPositionAfterTable(end)) { |
// 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. |
@@ -370,10 +370,10 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text |
else |
end = visibleParagraphEnd; |
} |
- |
+ |
if (end.isNull()) |
end = visibleParagraphEnd; |
- |
+ |
m_end = end.deepEquivalent(); |
break; |
} |
@@ -390,7 +390,7 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text |
m_end = endOfSentence(VisiblePosition(m_end, m_affinity)).deepEquivalent(); |
break; |
} |
- |
+ |
// Make sure we do not have a dangling start or end. |
if (m_start.isNull()) |
m_start = m_end; |
@@ -426,7 +426,7 @@ void VisibleSelection::validate(TextGranularity granularity) |
// This is a somewhat arbitrary choice, but experience shows that it is |
// useful to make to make the selection "canonical" (if only for |
// purposes of comparing selections). This is an ideal point of the code |
- // to do this operation, since all selection changes that result in a RANGE |
+ // to do this operation, since all selection changes that result in a RANGE |
// come through here before anyone uses it. |
// FIXME: Canonicalizing is good, but haven't we already done it (when we |
// set these two positions to VisiblePosition deepEquivalent()s above)? |
@@ -487,7 +487,7 @@ static Position adjustPositionForStart(const Position& currentPosition, Node* en |
TreeScope* treeScope = endContainerNode->treeScope(); |
ASSERT(currentPosition.containerNode()->treeScope() != treeScope); |
- |
+ |
if (Node* ancestor = treeScope->ancestorInThisScope(currentPosition.containerNode())) { |
if (ancestor->contains(endContainerNode)) |
return positionBeforeNode(ancestor); |
@@ -527,13 +527,13 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() |
Node* baseRoot = highestEditableRoot(m_base); |
Node* startRoot = highestEditableRoot(m_start); |
Node* endRoot = highestEditableRoot(m_end); |
- |
+ |
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) |
return; |
- |
+ |
// The selection is based in editable content. |
if (baseRoot) { |
// If the start is outside the base's editable root, cap it at the start of that root. |
@@ -560,12 +560,12 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() |
} else { |
// FIXME: Non-editable pieces inside editable content should be atomic, in the same way that editable |
// pieces in non-editable content are atomic. |
- |
- // The selection ends in editable content or non-editable content inside a different editable ancestor, |
+ |
+ // 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.containerNode()); |
if (endRoot || endEditableAncestor != baseEditableAncestor) { |
- |
+ |
Position p = previousVisuallyDistinctCandidate(m_end); |
Node* shadowAncestor = endRoot ? endRoot->shadowHost() : 0; |
if (p.isNull() && shadowAncestor) |
@@ -591,9 +591,9 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() |
m_end = previous.deepEquivalent(); |
} |
- // The selection starts in editable content or non-editable content inside a different editable ancestor, |
+ // 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.containerNode()); |
+ Node* startEditableAncestor = lowestEditableAncestor(m_start.containerNode()); |
if (startRoot || startEditableAncestor != baseEditableAncestor) { |
Position p = nextVisuallyDistinctCandidate(m_start); |
Node* shadowAncestor = startRoot ? startRoot->shadowHost() : 0; |
@@ -607,7 +607,7 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() |
p = positionBeforeNode(shadowAncestor); |
} |
VisiblePosition next(p); |
- |
+ |
if (next.isNull()) { |
// The selection crosses an Editing boundary. This is a |
// programmer error in the editing code. Happy debugging! |
@@ -620,7 +620,7 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() |
m_start = next.deepEquivalent(); |
} |
} |
- |
+ |
// Correct the extent if necessary. |
if (baseEditableAncestor != lowestEditableAncestor(m_extent.containerNode())) |
m_extent = m_baseIsFirst ? m_end : m_start; |