[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
rniwa at webkit.org
rniwa at webkit.org
Sun Feb 20 23:46:09 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit 175c44becccc7303eaff123c1fed735c6f02a4c6
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 25 02:21:49 2011 +0000
2011-01-24 Ryosuke Niwa <rniwa at webkit.org>
Reviewed by Eric Seidel.
Stop instantiating legacy editing positions in InsertTextCommand, MoveSelectionCommand,
ReplaceSelectionCommand, SelectionController, SpellChecker, TypingCommand, and markup.cpp
https://bugs.webkit.org/show_bug.cgi?id=52676
Stop instantiating legacy editing positions in the following files.
* editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::prepareForTextInsertion):
(WebCore::InsertTextCommand::performTrivialReplace):
(WebCore::InsertTextCommand::input):
(WebCore::InsertTextCommand::insertTab):
* editing/MoveSelectionCommand.cpp:
(WebCore::MoveSelectionCommand::doApply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds):
(WebCore::ReplaceSelectionCommand::mergeEndIfNeeded):
(WebCore::ReplaceSelectionCommand::doApply):
(WebCore::ReplaceSelectionCommand::shouldRemoveEndBR):
(WebCore::ReplaceSelectionCommand::performTrivialReplace):
* editing/SelectionController.cpp:
(WebCore::SelectionController::setSelectionFromNone):
* editing/SpellChecker.cpp:
(WebCore::SpellChecker::didCheck):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::makeEditableRootEmpty):
(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendText):
(WebCore::StyledMarkupAccumulator::serializeNodes):
(WebCore::highestAncestorToWrapMarkup):
(WebCore::createMarkup):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76560 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index d16f7f4..8e4c744 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2011-01-24 Ryosuke Niwa <rniwa at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Stop instantiating legacy editing positions in InsertTextCommand, MoveSelectionCommand,
+ ReplaceSelectionCommand, SelectionController, SpellChecker, TypingCommand, and markup.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=52676
+
+ Stop instantiating legacy editing positions in the following files.
+
+ * editing/InsertTextCommand.cpp:
+ (WebCore::InsertTextCommand::prepareForTextInsertion):
+ (WebCore::InsertTextCommand::performTrivialReplace):
+ (WebCore::InsertTextCommand::input):
+ (WebCore::InsertTextCommand::insertTab):
+ * editing/MoveSelectionCommand.cpp:
+ (WebCore::MoveSelectionCommand::doApply):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds):
+ (WebCore::ReplaceSelectionCommand::mergeEndIfNeeded):
+ (WebCore::ReplaceSelectionCommand::doApply):
+ (WebCore::ReplaceSelectionCommand::shouldRemoveEndBR):
+ (WebCore::ReplaceSelectionCommand::performTrivialReplace):
+ * editing/SelectionController.cpp:
+ (WebCore::SelectionController::setSelectionFromNone):
+ * editing/SpellChecker.cpp:
+ (WebCore::SpellChecker::didCheck):
+ * editing/TypingCommand.cpp:
+ (WebCore::TypingCommand::makeEditableRootEmpty):
+ (WebCore::TypingCommand::deleteKeyPressed):
+ (WebCore::TypingCommand::forwardDeleteKeyPressed):
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::appendText):
+ (WebCore::StyledMarkupAccumulator::serializeNodes):
+ (WebCore::highestAncestorToWrapMarkup):
+ (WebCore::createMarkup):
+
2011-01-24 Peter Kasting <pkasting at google.com>
Reviewed by Darin Adler.
diff --git a/Source/WebCore/editing/InsertTextCommand.cpp b/Source/WebCore/editing/InsertTextCommand.cpp
index 74a111a..e899db9 100644
--- a/Source/WebCore/editing/InsertTextCommand.cpp
+++ b/Source/WebCore/editing/InsertTextCommand.cpp
@@ -61,13 +61,13 @@ Position InsertTextCommand::prepareForTextInsertion(const Position& p)
if (!pos.node()->isTextNode()) {
RefPtr<Node> textNode = document()->createEditingTextNode("");
insertNodeAt(textNode.get(), pos);
- return Position(textNode.get(), 0);
+ return firstPositionInNode(textNode.get());
}
if (isTabSpanTextNode(pos.node())) {
RefPtr<Node> textNode = document()->createEditingTextNode("");
insertNodeAtTabSpanPosition(textNode.get(), pos);
- return Position(textNode.get(), 0);
+ return firstPositionInNode(textNode.get());
}
return pos;
@@ -83,23 +83,25 @@ bool InsertTextCommand::performTrivialReplace(const String& text, bool selectIns
if (text.contains('\t') || text.contains(' ') || text.contains('\n'))
return false;
- Position start = endingSelection().start();
- Position end = endingSelection().end();
-
- if (start.node() != end.node() || !start.node()->isTextNode() || isTabSpanTextNode(start.node()))
+ Position start = endingSelection().start().parentAnchoredEquivalent();
+ Position end = endingSelection().end().parentAnchoredEquivalent();
+ ASSERT(start.anchorType() == Position::PositionIsOffsetInAnchor);
+ ASSERT(end.anchorType() == Position::PositionIsOffsetInAnchor);
+
+ if (start.containerNode() != end.containerNode() || !start.containerNode()->isTextNode() || isTabSpanTextNode(start.containerNode()))
return false;
-
- replaceTextInNode(static_cast<Text*>(start.node()), start.deprecatedEditingOffset(), end.deprecatedEditingOffset() - start.deprecatedEditingOffset(), text);
-
- Position endPosition(start.node(), start.deprecatedEditingOffset() + text.length());
-
+
+ replaceTextInNode(static_cast<Text*>(start.containerNode()), start.offsetInContainerNode(), end.offsetInContainerNode() - start.offsetInContainerNode(), text);
+
+ Position endPosition(start.containerNode(), start.offsetInContainerNode() + text.length());
+
// We could have inserted a part of composed character sequence,
// so we are basically treating ending selection as a range to avoid validation.
// <http://bugs.webkit.org/show_bug.cgi?id=15781>
VisibleSelection forcedEndingSelection;
forcedEndingSelection.setWithoutValidation(start, endPosition);
setEndingSelection(forcedEndingSelection);
-
+
if (!selectInsertedText)
setEndingSelection(VisibleSelection(endingSelection().visibleEnd()));
@@ -170,7 +172,7 @@ void InsertTextCommand::input(const String& text, bool selectInsertedText, Rebal
int offset = startPosition.deprecatedEditingOffset();
insertTextIntoNode(textNode, offset, text);
- endPosition = Position(textNode, offset + text.length());
+ endPosition = Position(textNode, offset + text.length(), Position::PositionIsOffsetInAnchor);
if (whitespaceRebalance == RebalanceLeadingAndTrailingWhitespaces) {
// The insertion may require adjusting adjacent whitespace, if it is present.
@@ -213,7 +215,7 @@ Position InsertTextCommand::insertTab(const Position& pos)
// keep tabs coalesced in tab span
if (isTabSpanTextNode(node)) {
insertTextIntoNode(static_cast<Text *>(node), offset, "\t");
- return Position(node, offset + 1);
+ return Position(node, offset + 1, Position::PositionIsOffsetInAnchor);
}
// create new tab span
@@ -236,9 +238,9 @@ Position InsertTextCommand::insertTab(const Position& pos)
insertNodeBefore(spanNode, textNode);
}
}
-
+
// return the position following the new tab
- return Position(spanNode->lastChild(), caretMaxOffset(spanNode->lastChild()));
+ return lastPositionInNode(spanNode.get());
}
bool InsertTextCommand::isInsertTextCommand() const
diff --git a/Source/WebCore/editing/MoveSelectionCommand.cpp b/Source/WebCore/editing/MoveSelectionCommand.cpp
index 3a1cae0..0f23b29 100644
--- a/Source/WebCore/editing/MoveSelectionCommand.cpp
+++ b/Source/WebCore/editing/MoveSelectionCommand.cpp
@@ -39,25 +39,21 @@ MoveSelectionCommand::MoveSelectionCommand(PassRefPtr<DocumentFragment> fragment
void MoveSelectionCommand::doApply()
{
- VisibleSelection selection = endingSelection();
- ASSERT(selection.isNonOrphanedRange());
+ ASSERT(endingSelection().isNonOrphanedRange());
Position pos = m_position;
if (pos.isNull())
return;
-
+
// Update the position otherwise it may become invalid after the selection is deleted.
- Node *positionNode = m_position.node();
- int positionOffset = m_position.deprecatedEditingOffset();
- Position selectionEnd = selection.end();
- int selectionEndOffset = selectionEnd.deprecatedEditingOffset();
- if (selectionEnd.node() == positionNode && selectionEndOffset < positionOffset) {
- positionOffset -= selectionEndOffset;
- Position selectionStart = selection.start();
- if (selectionStart.node() == positionNode) {
- positionOffset += selectionStart.deprecatedEditingOffset();
- }
- pos = Position(positionNode, positionOffset);
+ Position selectionEnd = endingSelection().end();
+ if (pos.anchorType() == Position::PositionIsOffsetInAnchor && selectionEnd.anchorType() == Position::PositionIsOffsetInAnchor
+ && selectionEnd.containerNode() == pos.containerNode() && selectionEnd.offsetInContainerNode() < pos.offsetInContainerNode()) {
+ pos.moveToOffset(pos.offsetInContainerNode() - selectionEnd.offsetInContainerNode());
+
+ Position selectionStart = endingSelection().start();
+ if (selectionStart.anchorType() == Position::PositionIsOffsetInAnchor && selectionStart.containerNode() == pos.containerNode())
+ pos.moveToOffset(pos.offsetInContainerNode() + selectionStart.offsetInContainerNode());
}
deleteSelection(m_smartDelete);
@@ -70,11 +66,11 @@ void MoveSelectionCommand::doApply()
pos = endingSelection().start();
setEndingSelection(VisibleSelection(pos, endingSelection().affinity()));
- if (!positionNode->inDocument()) {
+ if (!pos.anchorNode()->inDocument()) {
// Document was modified out from under us.
return;
}
- applyCommandToComposite(ReplaceSelectionCommand::create(positionNode->document(), m_fragment, true, m_smartInsert));
+ applyCommandToComposite(ReplaceSelectionCommand::create(document(), m_fragment, true, m_smartInsert));
}
EditAction MoveSelectionCommand::editingAction() const
diff --git a/Source/WebCore/editing/ReplaceSelectionCommand.cpp b/Source/WebCore/editing/ReplaceSelectionCommand.cpp
index f47cb4e..08b047f 100644
--- a/Source/WebCore/editing/ReplaceSelectionCommand.cpp
+++ b/Source/WebCore/editing/ReplaceSelectionCommand.cpp
@@ -496,10 +496,10 @@ void ReplaceSelectionCommand::negateStyleRulesThatAffectAppearance()
void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds()
{
document()->updateLayoutIgnorePendingStylesheets();
- if (!m_lastLeafInserted->renderer() &&
- m_lastLeafInserted->isTextNode() &&
- !enclosingNodeWithTag(Position(m_lastLeafInserted.get(), 0), selectTag) &&
- !enclosingNodeWithTag(Position(m_lastLeafInserted.get(), 0), scriptTag)) {
+ if (!m_lastLeafInserted->renderer()
+ && m_lastLeafInserted->isTextNode()
+ && !enclosingNodeWithTag(firstPositionInOrBeforeNode(m_lastLeafInserted.get()), selectTag)
+ && !enclosingNodeWithTag(firstPositionInOrBeforeNode(m_lastLeafInserted.get()), scriptTag)) {
if (m_firstNodeInserted == m_lastLeafInserted) {
removeNode(m_lastLeafInserted.get());
m_lastLeafInserted = 0;
@@ -743,7 +743,7 @@ void ReplaceSelectionCommand::mergeEndIfNeeded()
if (endOfParagraph(startOfParagraphToMove) == destination) {
RefPtr<Node> placeholder = createBreakElement(document());
insertNodeBefore(placeholder, startOfParagraphToMove.deepEquivalent().node());
- destination = VisiblePosition(Position(placeholder.get(), 0));
+ destination = VisiblePosition(positionBeforeNode(placeholder.get()));
}
moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToMove), destination);
@@ -1045,7 +1045,7 @@ void ReplaceSelectionCommand::doApply()
if (isListItem(enclosingNode)) {
RefPtr<Node> newListItem = createListItemElement(document());
insertNodeAfter(newListItem, enclosingNode);
- setEndingSelection(VisiblePosition(Position(newListItem, 0)));
+ setEndingSelection(VisiblePosition(firstPositionInNode(newListItem.get())));
} else
// Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph
// block's style seems to annoy users.
@@ -1124,7 +1124,7 @@ bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR, const VisiblePositi
if (!endBR || !endBR->inDocument())
return false;
- VisiblePosition visiblePos(Position(endBR, 0));
+ VisiblePosition visiblePos(positionBeforeNode(endBR));
// Don't remove the br if nothing was inserted.
if (visiblePos.previous() == originalVisPosBeforeEndBR)
@@ -1261,7 +1261,7 @@ bool ReplaceSelectionCommand::performTrivialReplace(const ReplacementFragment& f
{
if (!fragment.firstChild() || fragment.firstChild() != fragment.lastChild() || !fragment.firstChild()->isTextNode())
return false;
-
+
// FIXME: Would be nice to handle smart replace in the fast path.
if (m_smartReplace || fragment.hasInterchangeNewlineAtStart() || fragment.hasInterchangeNewlineAtEnd())
return false;
@@ -1270,20 +1270,22 @@ bool ReplaceSelectionCommand::performTrivialReplace(const ReplacementFragment& f
// Our fragment creation code handles tabs, spaces, and newlines, so we don't have to worry about those here.
String text(textNode->data());
- Position start = endingSelection().start();
- Position end = endingSelection().end();
-
- if (start.anchorNode() != end.anchorNode() || !start.anchorNode()->isTextNode())
+ Position start = endingSelection().start().parentAnchoredEquivalent();
+ Position end = endingSelection().end().parentAnchoredEquivalent();
+ ASSERT(start.anchorType() == Position::PositionIsOffsetInAnchor);
+ ASSERT(end.anchorType() == Position::PositionIsOffsetInAnchor);
+
+ if (start.containerNode() != end.containerNode() || !start.containerNode()->isTextNode())
return false;
-
- replaceTextInNode(static_cast<Text*>(start.anchorNode()), start.offsetInContainerNode(), end.offsetInContainerNode() - start.offsetInContainerNode(), text);
-
- end = Position(start.anchorNode(), start.offsetInContainerNode() + text.length());
-
+
+ replaceTextInNode(static_cast<Text*>(start.containerNode()), start.offsetInContainerNode(), end.offsetInContainerNode() - start.offsetInContainerNode(), text);
+
+ end = Position(start.containerNode(), start.offsetInContainerNode() + text.length(), Position::PositionIsOffsetInAnchor);
+
VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, end);
-
+
setEndingSelection(selectionAfterReplace);
-
+
return true;
}
diff --git a/Source/WebCore/editing/SelectionController.cpp b/Source/WebCore/editing/SelectionController.cpp
index 564bf14..82d7af2 100644
--- a/Source/WebCore/editing/SelectionController.cpp
+++ b/Source/WebCore/editing/SelectionController.cpp
@@ -1774,7 +1774,7 @@ void SelectionController::setSelectionFromNone()
while (node && !node->hasTagName(bodyTag))
node = node->traverseNextNode();
if (node)
- setSelection(VisibleSelection(Position(node, 0), DOWNSTREAM));
+ setSelection(VisibleSelection(firstPositionInOrBeforeNode(node), DOWNSTREAM));
}
bool SelectionController::shouldChangeSelection(const VisibleSelection& newSelection) const
diff --git a/Source/WebCore/editing/SpellChecker.cpp b/Source/WebCore/editing/SpellChecker.cpp
index 1807474..f14a74d 100644
--- a/Source/WebCore/editing/SpellChecker.cpp
+++ b/Source/WebCore/editing/SpellChecker.cpp
@@ -141,7 +141,7 @@ void SpellChecker::didCheck(int sequence, const Vector<SpellCheckingResult>& res
}
int startOffset = 0;
- PositionIterator start = Position(m_requestNode, 0);
+ PositionIterator start = firstPositionInOrBeforeNode(m_requestNode.get());
for (size_t i = 0; i < results.size(); ++i) {
if (results[i].type() != DocumentMarker::Spelling && results[i].type() != DocumentMarker::Grammar)
continue;
diff --git a/Source/WebCore/editing/TypingCommand.cpp b/Source/WebCore/editing/TypingCommand.cpp
index 21d4314..9723c2d 100644
--- a/Source/WebCore/editing/TypingCommand.cpp
+++ b/Source/WebCore/editing/TypingCommand.cpp
@@ -436,7 +436,7 @@ bool TypingCommand::makeEditableRootEmpty()
removeNode(child);
addBlockPlaceholderIfNeeded(root);
- setEndingSelection(VisibleSelection(Position(root, 0), DOWNSTREAM));
+ setEndingSelection(VisibleSelection(firstPositionInNode(root), DOWNSTREAM));
return true;
}
@@ -495,7 +495,7 @@ void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
selection.modify(SelectionController::AlterationExtend, DirectionBackward, granularity);
// If the caret is just after a table, select the table and don't delete anything.
} else if (Node* table = isFirstPositionAfterTable(visibleStart)) {
- setEndingSelection(VisibleSelection(Position(table, 0), endingSelection().start(), DOWNSTREAM));
+ setEndingSelection(VisibleSelection(positionAfterNode(table), endingSelection().start(), DOWNSTREAM));
typingAddedToOpenCommand(DeleteKey);
return;
}
@@ -596,7 +596,7 @@ void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool ki
extraCharacters = selectionToDelete.end().deprecatedEditingOffset() - selectionToDelete.start().deprecatedEditingOffset();
else
extraCharacters = selectionToDelete.end().deprecatedEditingOffset();
- extent = Position(extent.node(), extent.deprecatedEditingOffset() + extraCharacters);
+ extent = Position(extent.node(), extent.deprecatedEditingOffset() + extraCharacters, Position::PositionIsOffsetInAnchor);
}
selectionAfterUndo.setWithoutValidation(startingSelection().start(), extent);
}
diff --git a/Source/WebCore/editing/markup.cpp b/Source/WebCore/editing/markup.cpp
index 4cbdcce..549c816 100644
--- a/Source/WebCore/editing/markup.cpp
+++ b/Source/WebCore/editing/markup.cpp
@@ -194,7 +194,7 @@ void StyledMarkupAccumulator::appendText(Vector<UChar>& out, Text* text)
return;
}
- bool useRenderedText = !enclosingNodeWithTag(Position(text, 0), selectTag);
+ bool useRenderedText = !enclosingNodeWithTag(firstPositionInNode(text), selectTag);
String content = useRenderedText ? renderedText(text, m_range) : stringValueForRange(text, m_range);
Vector<UChar> buffer;
appendCharactersReplacingEntities(buffer, content.characters(), content.length(), EntityMaskInPCDATA);
@@ -337,7 +337,7 @@ Node* StyledMarkupAccumulator::serializeNodes(Node* startNode, Node* pastEnd)
// Don't write out empty block containers that aren't fully selected.
continue;
- if (!n->renderer() && !enclosingNodeWithTag(Position(n, 0), selectTag)) {
+ if (!n->renderer() && !enclosingNodeWithTag(firstPositionInOrBeforeNode(n), selectTag)) {
next = n->traverseNextSibling();
// Don't skip over pastEnd.
if (pastEnd && pastEnd->isDescendantOf(n))
@@ -495,7 +495,7 @@ static Node* highestAncestorToWrapMarkup(const Range* range, Node* fullySelected
Node* checkAncestor = specialCommonAncestor ? specialCommonAncestor : commonAncestor;
if (checkAncestor->renderer()) {
- Node* newSpecialCommonAncestor = highestEnclosingNodeOfType(Position(checkAncestor, 0), &isElementPresentational);
+ Node* newSpecialCommonAncestor = highestEnclosingNodeOfType(firstPositionInNode(checkAncestor), &isElementPresentational);
if (newSpecialCommonAncestor)
specialCommonAncestor = newSpecialCommonAncestor;
}
@@ -509,7 +509,7 @@ static Node* highestAncestorToWrapMarkup(const Range* range, Node* fullySelected
if (!specialCommonAncestor && isTabSpanNode(commonAncestor))
specialCommonAncestor = commonAncestor;
- if (Node *enclosingAnchor = enclosingNodeWithTag(Position(specialCommonAncestor ? specialCommonAncestor : commonAncestor, 0), aTag))
+ if (Node *enclosingAnchor = enclosingNodeWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag))
specialCommonAncestor = enclosingAnchor;
if (shouldAnnotate == AnnotateForInterchange && fullySelectedRoot) {
@@ -579,7 +579,7 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
}
}
- Node* body = enclosingNodeWithTag(Position(commonAncestor, 0), bodyTag);
+ Node* body = enclosingNodeWithTag(firstPositionInNode(commonAncestor), bodyTag);
Node* fullySelectedRoot = 0;
// FIXME: Do this for all fully selected blocks, not just the body.
if (body && areRangesEqual(VisibleSelection::selectionFromContentsOfNode(body).toNormalizedRange().get(), range))
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list