2011-04-06 Naoki Takano <takano.naoki@gmail.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 07:22:26 +0000 (07:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 07:22:26 +0000 (07:22 +0000)
        Reviewed by Ryosuke Niwa.

        REGRESSION(r81328): Null pointer crash in canAppendNewLineFeed when selection isn't inside an editable element
        https://bugs.webkit.org/show_bug.cgi?id=57755

        * editing/execCommand/insert-line-break-onload-expected.txt: Added.
        * editing/execCommand/insert-line-break-onload.html: Added to check calling InsertLineBreak without any crash.
2011-04-06  Naoki Takano  <takano.naoki@gmail.com>

        Reviewed by Ryosuke Niwa.

        REGRESSION(r81328): Null pointer crash in canAppendNewLineFeed when selection isn't inside an editable element
        https://bugs.webkit.org/show_bug.cgi?id=57755

        Test: editing/execCommand/insert-line-break-onload.html

        * editing/TypingCommand.cpp:
        (WebCore::canAppendNewLineFeed): Added null pointer check for rootEditableElement().

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

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/insert-line-break-onload-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/insert-line-break-onload.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/TypingCommand.cpp

index e9f5b9d..7480072 100644 (file)
@@ -1,3 +1,13 @@
+2011-04-06  Naoki Takano  <takano.naoki@gmail.com>
+
+        Reviewed by Ryosuke Niwa.
+
+        REGRESSION(r81328): Null pointer crash in canAppendNewLineFeed when selection isn't inside an editable element
+        https://bugs.webkit.org/show_bug.cgi?id=57755
+
+        * editing/execCommand/insert-line-break-onload-expected.txt: Added.
+        * editing/execCommand/insert-line-break-onload.html: Added to check calling InsertLineBreak without any crash.
+
 2011-04-05  James Kozianski  <koz@chromium.org>
 
         [chromium] Rebaseline images after r82969
diff --git a/LayoutTests/editing/execCommand/insert-line-break-onload-expected.txt b/LayoutTests/editing/execCommand/insert-line-break-onload-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/editing/execCommand/insert-line-break-onload.html b/LayoutTests/editing/execCommand/insert-line-break-onload.html
new file mode 100644 (file)
index 0000000..73bccd9
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<html>
+<body onload="go()">
+Test InsertLineBreak is called correctly without any exception.
+<script>
+function go() {
+    document.designMode="on";
+    document.write("</");
+    document.getSelection().addRange(document.createRange());
+    document.execCommand("InsertLineBreak");
+
+    var result = "PASS";
+    if (window.layoutTestController) {
+        document.write("<html>" + result + "<html>");
+        layoutTestController.dumpAsText();
+    } else
+        document.write("<html>" + result + "<html>");
+}
+</script>
+</body>
+</html>
index f15f721..aa2d790 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-06  Naoki Takano  <takano.naoki@gmail.com>
+
+        Reviewed by Ryosuke Niwa.
+
+        REGRESSION(r81328): Null pointer crash in canAppendNewLineFeed when selection isn't inside an editable element
+        https://bugs.webkit.org/show_bug.cgi?id=57755
+
+        Test: editing/execCommand/insert-line-break-onload.html
+
+        * editing/TypingCommand.cpp:
+        (WebCore::canAppendNewLineFeed): Added null pointer check for rootEditableElement().
+
 2011-04-05  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Cameron Zwarich.
index aedda31..df150ee 100644 (file)
@@ -49,9 +49,13 @@ using namespace HTMLNames;
 
 static bool canAppendNewLineFeed(const VisibleSelection& selection)
 {
-    ExceptionCode ec = 0;
+    Node* node = selection.rootEditableElement();
+    if (!node)
+        return false;
+
     RefPtr<BeforeTextInsertedEvent> event = BeforeTextInsertedEvent::create(String("\n"));
-    selection.rootEditableElement()->dispatchEvent(event, ec);
+    ExceptionCode ec = 0;
+    node->dispatchEvent(event, ec);
     return event->text().length();
 }