Title: [119705] trunk/Source/WebCore
- Revision
- 119705
- Author
- [email protected]
- Date
- 2012-06-07 04:45:20 -0700 (Thu, 07 Jun 2012)
Log Message
Incorrect data retrieved in calls to get selection data in client->textWillBeReplaced from CharacterData::setDataAndUpdate
https://bugs.webkit.org/show_bug.cgi?id=66120
Reviewed by Ryosuke Niwa.
Since FrameSelection::textWillBeReplaced was called before replacing text, updated Selection became
temporarily invalid. The invalid selection was set to updateSelection(), so client will have
invalid selection.
This patch makes calling updateSelection() after updating selection.
No new tests, it's too hard to create a correct test cases in DRT.
* dom/CharacterData.cpp:
(WebCore::CharacterData::setDataAndUpdate):
* editing/FrameSelection.cpp:
(WebCore::updatePositionAfterAdoptingTextReplacement):
(WebCore::FrameSelection::textWasReplaced):
* editing/FrameSelection.h:
(FrameSelection):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (119704 => 119705)
--- trunk/Source/WebCore/ChangeLog 2012-06-07 11:39:58 UTC (rev 119704)
+++ trunk/Source/WebCore/ChangeLog 2012-06-07 11:45:20 UTC (rev 119705)
@@ -1,3 +1,26 @@
+2012-06-07 Shinya Kawanaka <[email protected]>
+
+ Incorrect data retrieved in calls to get selection data in client->textWillBeReplaced from CharacterData::setDataAndUpdate
+ https://bugs.webkit.org/show_bug.cgi?id=66120
+
+ Reviewed by Ryosuke Niwa.
+
+ Since FrameSelection::textWillBeReplaced was called before replacing text, updated Selection became
+ temporarily invalid. The invalid selection was set to updateSelection(), so client will have
+ invalid selection.
+
+ This patch makes calling updateSelection() after updating selection.
+
+ No new tests, it's too hard to create a correct test cases in DRT.
+
+ * dom/CharacterData.cpp:
+ (WebCore::CharacterData::setDataAndUpdate):
+ * editing/FrameSelection.cpp:
+ (WebCore::updatePositionAfterAdoptingTextReplacement):
+ (WebCore::FrameSelection::textWasReplaced):
+ * editing/FrameSelection.h:
+ (FrameSelection):
+
2012-06-07 Li Yin <[email protected]>
FileAPI: If type consists of non-ASCII characters in Blob constructor, it should throw a SyntaxError.
Modified: trunk/Source/WebCore/dom/CharacterData.cpp (119704 => 119705)
--- trunk/Source/WebCore/dom/CharacterData.cpp 2012-06-07 11:39:58 UTC (rev 119704)
+++ trunk/Source/WebCore/dom/CharacterData.cpp 2012-06-07 11:45:20 UTC (rev 119705)
@@ -176,11 +176,14 @@
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);
}
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (119704 => 119705)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2012-06-07 11:39:58 UTC (rev 119704)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2012-06-07 11:45:20 UTC (rev 119705)
@@ -422,6 +422,8 @@
// (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 @@
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))
Modified: trunk/Source/WebCore/editing/FrameSelection.h (119704 => 119705)
--- trunk/Source/WebCore/editing/FrameSelection.h 2012-06-07 11:39:58 UTC (rev 119704)
+++ trunk/Source/WebCore/editing/FrameSelection.h 2012-06-07 11:45:20 UTC (rev 119705)
@@ -197,7 +197,7 @@
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();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes