Unreviewed, rolling out r125751.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2012 08:54:22 +0000 (08:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2012 08:54:22 +0000 (08:54 +0000)
http://trac.webkit.org/changeset/125751
https://bugs.webkit.org/show_bug.cgi?id=94206

we shouldn't be rolling out this patch without a formal
review. (Requested by rniwa_ on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-08-16

* dom/CharacterData.cpp:
(WebCore::CharacterData::setDataAndUpdate):
* editing/FrameSelection.cpp:
(WebCore::updatePositionAfterAdoptingTextReplacement):
(WebCore::FrameSelection::textWasReplaced):
* editing/FrameSelection.h:
(FrameSelection):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@125760 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/CharacterData.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/FrameSelection.h

index 67d7bb4..e6091cf 100644 (file)
@@ -1,3 +1,20 @@
+2012-08-16  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r125751.
+        http://trac.webkit.org/changeset/125751
+        https://bugs.webkit.org/show_bug.cgi?id=94206
+
+        we shouldn't be rolling out this patch without a formal
+        review. (Requested by rniwa_ on #webkit).
+
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::setDataAndUpdate):
+        * editing/FrameSelection.cpp:
+        (WebCore::updatePositionAfterAdoptingTextReplacement):
+        (WebCore::FrameSelection::textWasReplaced):
+        * editing/FrameSelection.h:
+        (FrameSelection):
+
 2012-08-16  Marja Hölttä  <marja@chromium.org>
 
         FormController, FileInputType: Enable reading selected file names from document state
index a09415e..91f5ac7 100644 (file)
@@ -183,11 +183,14 @@ void CharacterData::setNodeValue(const String& nodeValue, ExceptionCode& ec)
 
 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength)
 {
-    if (document()->frame())
-        document()->frame()->selection()->textWillBeReplaced(this, offsetOfReplacedData, oldLength, newLength);
     String oldData = m_data;
     m_data = newData;
+
     updateRenderer(offsetOfReplacedData, oldLength);
+
+    if (document()->frame())
+        document()->frame()->selection()->textWasReplaced(this, offsetOfReplacedData, oldLength, newLength);
+
     document()->incDOMTreeVersion();
     dispatchModifiedEvent(oldData);
 }
index cc79a28..9ccaa96 100644 (file)
@@ -422,6 +422,8 @@ static void updatePositionAfterAdoptingTextReplacement(Position& position, Chara
     // (positionOffset > offset + oldLength) to avoid having a stale offset.
     if (positionOffset > offset + oldLength)
         position.moveToOffset(positionOffset - oldLength + newLength);
+
+    ASSERT(static_cast<unsigned>(position.offsetInContainerNode()) <= node->length());
 }
 
 static inline bool nodeIsDetachedFromDocument(Node* node)
@@ -431,7 +433,7 @@ static inline bool nodeIsDetachedFromDocument(Node* node)
     return highest->nodeType() == Node::DOCUMENT_FRAGMENT_NODE && !highest->isShadowRoot();
 }
 
-void FrameSelection::textWillBeReplaced(CharacterData* node, unsigned offset, unsigned oldLength, unsigned newLength)
+void FrameSelection::textWasReplaced(CharacterData* node, unsigned offset, unsigned oldLength, unsigned newLength)
 {
     // The fragment check is a performance optimization. See http://trac.webkit.org/changeset/30062.
     if (isNone() || !node || nodeIsDetachedFromDocument(node))
index ff79a98..4a58194 100644 (file)
@@ -204,7 +204,7 @@ public:
     void debugRenderer(RenderObject*, bool selected) const;
 
     void nodeWillBeRemoved(Node*);
-    void textWillBeReplaced(CharacterData*, unsigned offset, unsigned oldLength, unsigned newLength);
+    void textWasReplaced(CharacterData*, unsigned offset, unsigned oldLength, unsigned newLength);
 
     void setCaretVisible(bool caretIsVisible) { setCaretVisibility(caretIsVisible ? Visible : Hidden); }
     void clearCaretRectIfNeeded();