Title: [94881] branches/chromium/874
Revision
94881
Author
[email protected]
Date
2011-09-09 16:01:07 -0700 (Fri, 09 Sep 2011)

Log Message

Merge 94840 - Crashes in WebCore::ApplyStyleCommand.doApply()
https://bugs.webkit.org/show_bug.cgi?id=67765

Patch by Shinya Kawanaka <[email protected]> on 2011-09-09
Reviewed by Ryosuke Niwa.

WebCore::enclosingBlock may return null, but ApplyStyleCommand::applyBlockStyle did not check it. This patch make it to be checked.

Source/WebCore:

Test: editing/style/remove-format-without-enclosing-block.html

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyBlockStyle): Added null check.

LayoutTests:

* editing/style/remove-format-without-enclosing-block-expected.txt: Added.
* editing/style/remove-format-without-enclosing-block.html: Added.

[email protected]
BUG=95550
Review URL: http://codereview.chromium.org/7862013

Modified Paths

Added Paths

Diff

Copied: branches/chromium/874/LayoutTests/editing/style/remove-format-without-enclosing-block-expected.txt (from rev 94840, trunk/LayoutTests/editing/style/remove-format-without-enclosing-block-expected.txt) (0 => 94881)


--- branches/chromium/874/LayoutTests/editing/style/remove-format-without-enclosing-block-expected.txt	                        (rev 0)
+++ branches/chromium/874/LayoutTests/editing/style/remove-format-without-enclosing-block-expected.txt	2011-09-09 23:01:07 UTC (rev 94881)
@@ -0,0 +1,4 @@
+AexecCommand("RemoveFormat") was crashing when there is no enclosing block.
+The test has passed if it does not crash.
+
+PASS

Copied: branches/chromium/874/LayoutTests/editing/style/remove-format-without-enclosing-block.html (from rev 94840, trunk/LayoutTests/editing/style/remove-format-without-enclosing-block.html) (0 => 94881)


--- branches/chromium/874/LayoutTests/editing/style/remove-format-without-enclosing-block.html	                        (rev 0)
+++ branches/chromium/874/LayoutTests/editing/style/remove-format-without-enclosing-block.html	2011-09-09 23:01:07 UTC (rev 94881)
@@ -0,0 +1,12 @@
+<card id="edit" contentEditable="true">A<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+edit.focus();
+document.execCommand("SelectAll");
+document.execCommand("RemoveFormat");
+
+document.writeln('execCommand("RemoveFormat") was crashing when there is no enclosing block.<br>');
+document.writeln('The test has passed if it does not crash.<br><br>')
+document.writeln('PASS');
+</script>

Modified: branches/chromium/874/Source/WebCore/editing/ApplyStyleCommand.cpp (94880 => 94881)


--- branches/chromium/874/Source/WebCore/editing/ApplyStyleCommand.cpp	2011-09-09 22:51:44 UTC (rev 94880)
+++ branches/chromium/874/Source/WebCore/editing/ApplyStyleCommand.cpp	2011-09-09 23:01:07 UTC (rev 94881)
@@ -281,8 +281,8 @@
                 if (newBlock)
                     block = newBlock;
             }
-            ASSERT(block->isHTMLElement());
-            if (block->isHTMLElement()) {
+            ASSERT(!block || block->isHTMLElement());
+            if (block && block->isHTMLElement()) {
                 removeCSSStyle(style, toHTMLElement(block.get()));
                 if (!m_removeOnly)
                     addBlockStyle(styleChange, toHTMLElement(block.get()));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to