Title: [192181] trunk
Revision
192181
Author
ddkil...@apple.com
Date
2015-11-09 14:43:18 -0800 (Mon, 09 Nov 2015)

Log Message

Fixed crash loading Mozilla layout test editor/libeditor/crashtests/431086-1.xhtml.
https://bugs.webkit.org/show_bug.cgi?id=150252
<rdar://problem/23149470>

Patch by Pranjal Jumde <pju...@apple.com> on 2015-11-09
Reviewed by Brent Fulgham.

* Source/WebCore/editing/ios/EditorIOS.mm
* Source/WebCore/editing/mac/EditorMac.mm
  In Editor::fontForSelection moved the node removal code, so that the
  node is only removed if style is not NULL.
* LayoutTests/editing/execCommand/150252.xhtml
* LayoutTests/editing/execCommand/150252_minimal.xhtml
* LayoutTests/editing/execCommand/150252-expected.txt
* LayoutTests/editing/execCommand/150252_minimal-expected.txt

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (192180 => 192181)


--- trunk/ChangeLog	2015-11-09 22:34:16 UTC (rev 192180)
+++ trunk/ChangeLog	2015-11-09 22:43:18 UTC (rev 192181)
@@ -1,3 +1,20 @@
+2015-11-09  Pranjal Jumde  <pju...@apple.com>
+
+        Fixed crash loading Mozilla layout test editor/libeditor/crashtests/431086-1.xhtml.
+        https://bugs.webkit.org/show_bug.cgi?id=150252
+        <rdar://problem/23149470>
+
+        Reviewed by Brent Fulgham.
+
+        * Source/WebCore/editing/ios/EditorIOS.mm
+        * Source/WebCore/editing/mac/EditorMac.mm
+          In Editor::fontForSelection moved the node removal code, so that the
+          node is only removed if style is not NULL.
+        * LayoutTests/editing/execCommand/150252.xhtml
+        * LayoutTests/editing/execCommand/150252_minimal.xhtml
+        * LayoutTests/editing/execCommand/150252-expected.txt
+        * LayoutTests/editing/execCommand/150252_minimal-expected.txt
+
 2015-11-06  Daniel Bates  <daba...@apple.com>
 
         Teach Makefile to build LayoutTestRelay when building for iOS Simulator

Added: trunk/LayoutTests/editing/execCommand/150252-expected.txt (0 => 192181)


--- trunk/LayoutTests/editing/execCommand/150252-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/150252-expected.txt	2015-11-09 22:43:18 UTC (rev 192181)
@@ -0,0 +1 @@
+This test passes if it doesn't crash. https://bugs.webkit.org/show_bug.cgi?id=150252

Added: trunk/LayoutTests/editing/execCommand/150252.xhtml (0 => 192181)


--- trunk/LayoutTests/editing/execCommand/150252.xhtml	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/150252.xhtml	2015-11-09 22:43:18 UTC (rev 192181)
@@ -0,0 +1,26 @@
+<div id="150252" xmlns="http://www.w3.org/1999/xhtml">
+
+<script type="text/_javascript_">
+
+function boom()
+{
+  if (window.testRunner)
+    testRunner.dumpAsText();
+
+  var r = document.documentElement;
+  r.style.position = "absolute";
+  r.contentEditable = "true";
+  r.focus();
+  r.contentEditable = "false";
+  r.focus();
+  r.contentEditable = "true";
+  document.execCommand("subscript", false, null);
+  r.contentEditable = "false";
+  document.getElementById("150252").innerHTML = "This test passes if it doesn't crash. https://bugs.webkit.org/show_bug.cgi?id=150252";
+}
+
+window.addEventListener("load", boom, false);
+
+</script>
+
+</div>

Added: trunk/LayoutTests/editing/execCommand/150252_minimal-expected.txt (0 => 192181)


--- trunk/LayoutTests/editing/execCommand/150252_minimal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/150252_minimal-expected.txt	2015-11-09 22:43:18 UTC (rev 192181)
@@ -0,0 +1 @@
+This test passes if it doesn't crash. https://bugs.webkit.org/show_bug.cgi?id=150252

Added: trunk/LayoutTests/editing/execCommand/150252_minimal.xhtml (0 => 192181)


--- trunk/LayoutTests/editing/execCommand/150252_minimal.xhtml	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/150252_minimal.xhtml	2015-11-09 22:43:18 UTC (rev 192181)
@@ -0,0 +1,15 @@
+<div id="150252" xmlns="http://www.w3.org/1999/xhtml">
+
+<script>
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+document.documentElement.contentEditable = "true";
+document.documentElement.focus();
+document.execCommand("superscript", false, null);
+document.getElementById("150252").innerHTML = "This test passes if it doesn't crash. https://bugs.webkit.org/show_bug.cgi?id=150252";
+
+</script>
+
+</div>

Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (192180 => 192181)


--- trunk/Source/WebCore/editing/ios/EditorIOS.mm	2015-11-09 22:34:16 UTC (rev 192180)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm	2015-11-09 22:43:18 UTC (rev 192181)
@@ -192,13 +192,13 @@
         RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
 
         const Font* result = nullptr;
-        if (style)
+        if (style) {
             result = &style->fontCascade().primaryFont();
-
-        if (nodeToRemove) {
-            ExceptionCode ec;
-            nodeToRemove->remove(ec);
-            ASSERT(!ec);
+            if (nodeToRemove) {
+                ExceptionCode ec;
+                nodeToRemove->remove(ec);
+                ASSERT(!ec);
+            }
         }
 
         return result;

Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (192180 => 192181)


--- trunk/Source/WebCore/editing/mac/EditorMac.mm	2015-11-09 22:34:16 UTC (rev 192180)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm	2015-11-09 22:43:18 UTC (rev 192181)
@@ -118,12 +118,12 @@
         RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
 
         const Font* result = nullptr;
-        if (style)
+        if (style) {
             result = &style->fontCascade().primaryFont();
+            if (nodeToRemove)
+                nodeToRemove->remove(ASSERT_NO_EXCEPTION);
+        }
 
-        if (nodeToRemove)
-            nodeToRemove->remove(ASSERT_NO_EXCEPTION);
-
         return result;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to