Reviewed by John.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jan 2007 19:13:14 +0000 (19:13 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jan 2007 19:13:14 +0000 (19:13 +0000)
        - fixed <rdar://problem/4887416> REGRESSION (SearchField): Assertion failure in HTMLInputElement::setValueFromRenderer when editing via drag and drop (11846)
        http://bugs.webkit.org/show_bug.cgi?id=11846

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::doApply): Don't insert extra paragraph separators to avoid
        nesting blocks in plaintext mode, since that's not an issue under normal circumstances.
        * html/HTMLInputElement.h:
        * manual-tests/drag-move-in-search-field.html: Added.
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::subtreeHasChanged): constrain the value; we'd
        rather truncate it than end up with an illegal value here.

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

WebCore/ChangeLog
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/html/HTMLInputElement.h
WebCore/manual-tests/drag-move-in-search-field.html [new file with mode: 0644]
WebCore/rendering/RenderTextControl.cpp

index 97e8db8759b60b328bd62ecb408d75eaf21ee5b2..b62c6f8db5fc74e8159f92c24300524a71cd1eb6 100644 (file)
@@ -1,3 +1,19 @@
+2007-01-18  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by John.
+
+        - fixed <rdar://problem/4887416> REGRESSION (SearchField): Assertion failure in HTMLInputElement::setValueFromRenderer when editing via drag and drop (11846)
+        http://bugs.webkit.org/show_bug.cgi?id=11846
+        
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::doApply): Don't insert extra paragraph separators to avoid
+        nesting blocks in plaintext mode, since that's not an issue under normal circumstances.
+        * html/HTMLInputElement.h:
+        * manual-tests/drag-move-in-search-field.html: Added.
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::subtreeHasChanged): constrain the value; we'd
+        rather truncate it than end up with an illegal value here.
+
 2007-01-18  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Zack.
index d2d641f91c04e15cc11957e0c8dad24f8c8bba67..906083bf72a692b06da8daa181e25581d5421679 100644 (file)
@@ -458,7 +458,8 @@ void ReplaceSelectionCommand::doApply()
     if (selection.isNone() || !selection.start().node())
         return;
     
-    if (!selection.isContentRichlyEditable())
+    bool selectionIsPlainText = !selection.isContentRichlyEditable();
+    if (selectionIsPlainText)
         m_matchStyle = true;
     
     Element* currentRoot = selection.rootEditableElement();
@@ -481,7 +482,8 @@ void ReplaceSelectionCommand::doApply()
     
     if (selectionStartWasStartOfParagraph && selectionEndWasEndOfParagraph ||
         startBlock == currentRoot ||
-        startBlock && startBlock->renderer() && startBlock->renderer()->isListItem())
+        startBlock && startBlock->renderer() && startBlock->renderer()->isListItem() ||
+        selectionIsPlainText)
         m_preventNesting = false;
     
     Position insertionPos = selection.start();
index 87863203cc387fd4d987d2f18ecfc5c70473e453..1cdc129543dc48fb8a6485998a1fd93dd580bf20 100644 (file)
@@ -177,13 +177,14 @@ public:
     void addSearchResult();
     void onSearch();
 
+    String constrainValue(const String& proposedValue) const;
+
 protected:
     AtomicString m_name;
 
 private:
     void init();
     bool storesValueSeparateFromAttribute() const;
-    String constrainValue(const String& proposedValue) const;
     String constrainValue(const String& proposedValue, int maxLen) const;
     void recheckValue();
 
diff --git a/WebCore/manual-tests/drag-move-in-search-field.html b/WebCore/manual-tests/drag-move-in-search-field.html
new file mode 100644 (file)
index 0000000..4bb720a
--- /dev/null
@@ -0,0 +1,11 @@
+<p>Double-click the word "dolor" to select it, then drag the selection to
+between "lorem" and "ipsum". There should be no assertion failure in a
+debug build.</p>
+
+<input id="foo" type="search" value="lorem ipsum dolor">
+<script>
+function test()
+{
+
+}
+</script>
index ba62f4f2c3e2b8f51489f5cb5e79d99d5fd90aae..d72cf95af532b36f9969be15ace978feea2565f8 100644 (file)
@@ -467,7 +467,7 @@ void RenderTextControl::subtreeHasChanged()
             frame->textDidChangeInTextArea(element);
     } else {
         HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
-        input->setValueFromRenderer(text());
+        input->setValueFromRenderer(input->constrainValue(text()));
         if (m_cancelButton)
             updateCancelButtonVisibility(m_cancelButton->renderer()->style());