<rdar://problem/9199518> Crash when focusing a styled editable element
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Mar 2011 01:32:21 +0000 (01:32 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Mar 2011 01:32:21 +0000 (01:32 +0000)
Reviewed by Darin Adler.

Source/WebCore:

Test: editing/deleting/delete-button-background-image-none.html

* editing/DeleteButtonController.cpp:
(WebCore::isDeletableElement): Check all background layers for background images.
* rendering/style/RenderStyle.h: Removed backgroundImage() as it was only used, incorrectly,
in the above function.

LayoutTests:

* editing/deleting/delete-button-background-image-none-expected.txt: Added.
* editing/deleting/delete-button-background-image-none.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/deleting/delete-button-background-image-none-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-button-background-image-none.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/DeleteButtonController.cpp
Source/WebCore/rendering/style/RenderStyle.h

index 457b948c0ee8d38277b207c7735edc826db11b4a..dfb53c0118967719d6b912b89b39597972161e0b 100644 (file)
@@ -1,3 +1,12 @@
+2011-03-30  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/9199518> Crash when focusing a styled editable element
+
+        * editing/deleting/delete-button-background-image-none-expected.txt: Added.
+        * editing/deleting/delete-button-background-image-none.html: Added.
+
 2011-03-30  Mihai Parparita  <mihaip@chromium.org>
 
         Fix expected svg/ failures for Chromium Snow Leopard.
diff --git a/LayoutTests/editing/deleting/delete-button-background-image-none-expected.txt b/LayoutTests/editing/deleting/delete-button-background-image-none-expected.txt
new file mode 100644 (file)
index 0000000..4fdde57
--- /dev/null
@@ -0,0 +1,3 @@
+The test passes if it does not crash.
+
+
diff --git a/LayoutTests/editing/deleting/delete-button-background-image-none.html b/LayoutTests/editing/deleting/delete-button-background-image-none.html
new file mode 100644 (file)
index 0000000..1821d05
--- /dev/null
@@ -0,0 +1,10 @@
+<p>\r
+    The test passes if it does not crash.\r
+</p>\r
+<div id="target" contenteditable style="background-image: none, url()"></div>\r
+<script>\r
+    if (window.layoutTestController)\r
+        layoutTestController.dumpAsText();\r
+\r
+    document.getElementById("target").focus();\r
+</script>       \r
index 790b7c6f433871762c88d07de5948e080de599aa..1ca0e06561cb791ee0006f1fafe6057746240cff 100644 (file)
@@ -1,3 +1,16 @@
+2011-03-30  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/9199518> Crash when focusing a styled editable element
+
+        Test: editing/deleting/delete-button-background-image-none.html
+
+        * editing/DeleteButtonController.cpp:
+        (WebCore::isDeletableElement): Check all background layers for background images.
+        * rendering/style/RenderStyle.h: Removed backgroundImage() as it was only used, incorrectly,
+        in the above function.
+
 2011-03-30  Martin Robinson  <mrobinson@igalia.com>
 
         Try once more to fix the EFL build.
index 332e68fe7dc03fe95d5024e2598ac7eda25f24db..7f57e820a5ad9e9efeb4087c98d3b4acff5863e1 100644 (file)
@@ -112,8 +112,12 @@ static bool isDeletableElement(const Node* node)
             return false;
 
         // Allow blocks that have background images
-        if (style->hasBackgroundImage() && style->backgroundImage()->canRender(1.0f))
-            return true;
+        if (style->hasBackgroundImage()) {
+            for (const FillLayer* background = style->backgroundLayers(); background; background = background->next()) {
+                if (background->image() && background->image()->canRender(1))
+                    return true;
+            }
+        }
 
         // Allow blocks with a minimum number of non-transparent borders
         unsigned visibleBorders = style->borderTop().isVisible() + style->borderBottom().isVisible() + style->borderLeft().isVisible() + style->borderRight().isVisible();
index d8c7e20a18e3a0d497bc60ca6f608d6a3665029e..8d2aa6a82672b25b7f8fe9851de2ded12156aabc 100644 (file)
@@ -563,7 +563,6 @@ public:
         return wordBreak() == BreakWordBreak || wordWrap() == BreakWordWrap;
     }
 
-    StyleImage* backgroundImage() const { return m_background->background().image(); }
     EFillRepeat backgroundRepeatX() const { return static_cast<EFillRepeat>(m_background->background().repeatX()); }
     EFillRepeat backgroundRepeatY() const { return static_cast<EFillRepeat>(m_background->background().repeatY()); }
     CompositeOperator backgroundComposite() const { return static_cast<CompositeOperator>(m_background->background().composite()); }