LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2006 23:55:19 +0000 (23:55 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2006 23:55:19 +0000 (23:55 +0000)
        Reviewed by Darin.

        Test case for this fix:

        - fixed REGRESSION: offsetParent on element with no offset parent crashes

        * fast/dom/Element/null-offset-parent.html: Added.

WebCore:

        Reviewed by Darin.

        - fixed REGRESSION: offsetParent on element with no offset parent crashes

        * dom/Element.cpp:
        (WebCore::Element::offsetParent): Add missing null check.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/Element/null-offset-parent-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Element/null-offset-parent.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Element.cpp

index 9d352f77375bce9dc042cec084304157061482ed..a6e04354dfa60659491df245b6ca7664f8999711 100644 (file)
@@ -1,3 +1,13 @@
+2006-04-07  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+
+        Test case for this fix:
+        
+        - fixed REGRESSION: offsetParent on element with no offset parent crashes
+
+        * fast/dom/Element/null-offset-parent.html: Added.
+
 2006-04-07  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by adele
diff --git a/LayoutTests/fast/dom/Element/null-offset-parent-expected.txt b/LayoutTests/fast/dom/Element/null-offset-parent-expected.txt
new file mode 100644 (file)
index 0000000..c08cc34
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderText {TEXT} at (0,0) size 782x36
+        text run at (0,0) width 782: "This test verifies that JS access to offsetParent on an element that lacks one, such as the body, doesn't crash. If it didn't crash,"
+        text run at (0,18) width 58: "it passed."
+      RenderText {TEXT} at (0,0) size 0x0
diff --git a/LayoutTests/fast/dom/Element/null-offset-parent.html b/LayoutTests/fast/dom/Element/null-offset-parent.html
new file mode 100644 (file)
index 0000000..5ff0712
--- /dev/null
@@ -0,0 +1,4 @@
+<body onload="document.body.offsetParent">
+This test verifies that JS access to offsetParent on an element that
+lacks one, such as the body, doesn't crash. If it didn't crash, it passed.
+</body>
index 3110b0695a7bb2991ec1d0e04900bb318e87dddb..3cc6713f2b7cfae49671dfe4f49922234a40e617 100644 (file)
@@ -1,3 +1,12 @@
+2006-04-07  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+        
+        - fixed REGRESSION: offsetParent on element with no offset parent crashes
+
+        * dom/Element.cpp:
+        (WebCore::Element::offsetParent): Add missing null check.
+
 2006-04-07  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by adele
index 3918749d9dccd60fc979ebdb0ee8552b7b1f263b..dc01d58bef83c023aa8ca2af582305ab3a88bc71 100644 (file)
@@ -212,7 +212,8 @@ Element* Element::offsetParent()
 {
     document()->updateLayoutIgnorePendingStylesheets();
     if (RenderObject* rend = renderer())
-        return static_cast<Element*>(rend->offsetParent()->element());
+        if (RenderObject* offsetParent = rend->offsetParent())
+            return static_cast<Element*>(offsetParent->element());
     return 0;
 }