LayoutTests:
authorantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jun 2006 23:19:33 +0000 (23:19 +0000)
committerantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jun 2006 23:19:33 +0000 (23:19 +0000)
        Reviewed by Hyatt

        http://bugzilla.opendarwin.org/show_bug.cgi?id=9314

        * fast/block/positioning/relative-overflow-block-expected.checksum: Added.
        * fast/block/positioning/relative-overflow-block-expected.png: Added.
        * fast/block/positioning/relative-overflow-block-expected.txt: Added.
        * fast/block/positioning/relative-overflow-block.html: Added.
        * fast/block/positioning/relative-overflow-replaced-expected.checksum: Added.
        * fast/block/positioning/relative-overflow-replaced-expected.png: Added.
        * fast/block/positioning/relative-overflow-replaced-expected.txt: Added.
        * fast/block/positioning/relative-overflow-replaced-float-expected.checksum: Added.
        * fast/block/positioning/relative-overflow-replaced-float-expected.png: Added.
        * fast/block/positioning/relative-overflow-replaced-float-expected.txt: Added.
        * fast/block/positioning/relative-overflow-replaced-float.html: Added.
        * fast/block/positioning/relative-overflow-replaced.html: Added.

WebCore:

        Reviewed by Hyatt.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=9314
        Relative positioned block size doesnt update root layer size

        - take relative positioning into account in leftmost/rightmost/lowestPosition()
        - ignore zero width/height boxes in leftmost/rightmost/lowestPosition()
        - split relativePositionOffset() to x and y functions

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::absolutePosition):
        (WebCore::RenderBox::relativePositionOffsetX):
        (WebCore::RenderBox::relativePositionOffsetY):
        (WebCore::RenderBox::lowestPosition):
        (WebCore::RenderBox::rightmostPosition):
        (WebCore::RenderBox::leftmostPosition):
        * rendering/RenderBox.h:
        * rendering/RenderFlow.cpp:
        (WebCore::RenderFlow::lowestPosition):
        (WebCore::RenderFlow::rightmostPosition):
        (WebCore::RenderFlow::leftmostPosition):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::updateLayerPosition):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::offsetLeft):
        (WebCore::RenderObject::offsetTop):

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/block/positioning/relative-overflow-block-expected.checksum [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-block-expected.png [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-block-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-block.html [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.checksum [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.png [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.checksum [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.png [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced-float.html [new file with mode: 0644]
LayoutTests/fast/block/positioning/relative-overflow-replaced.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderBox.h
WebCore/rendering/RenderFlow.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderObject.cpp

index 73d2bf1fafc815b920d77084a982e33e97f15a0b..249333ae403d0497a68bce91a06fc44b4648c7f3 100644 (file)
@@ -1,3 +1,22 @@
+2006-06-13  Antti Koivisto  <koivisto@iki.fi>
+
+        Reviewed by Hyatt
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9314
+
+        * fast/block/positioning/relative-overflow-block-expected.checksum: Added.
+        * fast/block/positioning/relative-overflow-block-expected.png: Added.
+        * fast/block/positioning/relative-overflow-block-expected.txt: Added.
+        * fast/block/positioning/relative-overflow-block.html: Added.
+        * fast/block/positioning/relative-overflow-replaced-expected.checksum: Added.
+        * fast/block/positioning/relative-overflow-replaced-expected.png: Added.
+        * fast/block/positioning/relative-overflow-replaced-expected.txt: Added.
+        * fast/block/positioning/relative-overflow-replaced-float-expected.checksum: Added.
+        * fast/block/positioning/relative-overflow-replaced-float-expected.png: Added.
+        * fast/block/positioning/relative-overflow-replaced-float-expected.txt: Added.
+        * fast/block/positioning/relative-overflow-replaced-float.html: Added.
+        * fast/block/positioning/relative-overflow-replaced.html: Added.
+
 2006-06-13  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Dave Hyatt.
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-block-expected.checksum b/LayoutTests/fast/block/positioning/relative-overflow-block-expected.checksum
new file mode 100644 (file)
index 0000000..24b5634
--- /dev/null
@@ -0,0 +1 @@
+c52303c7188babb248eb5c7293502200
\ No newline at end of file
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-block-expected.png b/LayoutTests/fast/block/positioning/relative-overflow-block-expected.png
new file mode 100644 (file)
index 0000000..84ebd36
Binary files /dev/null and b/LayoutTests/fast/block/positioning/relative-overflow-block-expected.png differ
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-block-expected.txt b/LayoutTests/fast/block/positioning/relative-overflow-block-expected.txt
new file mode 100644 (file)
index 0000000..66731ae
--- /dev/null
@@ -0,0 +1,12 @@
+layer at (0,0) size 814x850
+  RenderView at (0,0) size 785x585
+layer at (0,0) size 785x600
+  RenderBlock {HTML} at (0,0) size 785x600
+    RenderBody {BODY} at (8,8) size 769x584
+      RenderText {#text} at (0,0) size 762x36
+        text run at (0,0) width 762: "Document canvas should be big enough to fit both blue and red (relative positioned) rectangles (ie. have scrollbars if they"
+        text run at (0,18) width 131: "don't fit to the view) "
+layer at (8,44) size 506x506
+  RenderBlock (positioned) {DIV} at (8,44) size 504x504 [border: (2px solid #0000FF)]
+layer at (310,346) size 504x504
+  RenderBlock (relative positioned) {DIV} at (2,2) size 504x504 [border: (2px solid #FF0000)]
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-block.html b/LayoutTests/fast/block/positioning/relative-overflow-block.html
new file mode 100644 (file)
index 0000000..f895342
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+<body>
+Document canvas should be big enough to fit both blue and red (relative positioned) rectangles (ie. have scrollbars if they don't fit to the view)
+<div style="width: 500px; height: 500px; position: absolute; border: 2px solid blue;">
+<div style="width: 500px; height: 500px; left: 300px; top:300px; position: relative; border: 2px solid red;">
+</div>
+</div>
\ No newline at end of file
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.checksum b/LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.checksum
new file mode 100644 (file)
index 0000000..32f8a9d
--- /dev/null
@@ -0,0 +1 @@
+2ff0091c8d44cd27d5c366745c066f07
\ No newline at end of file
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.png b/LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.png
new file mode 100644 (file)
index 0000000..8335742
Binary files /dev/null and b/LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.png differ
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.txt b/LayoutTests/fast/block/positioning/relative-overflow-replaced-expected.txt
new file mode 100644 (file)
index 0000000..27bdcd0
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 1108x1108
+  RenderView at (0,0) size 785x585
+layer at (0,0) size 785x600
+  RenderBlock {HTML} at (0,0) size 785x600
+    RenderBody {BODY} at (8,8) size 769x584
+      RenderText {#text} at (100,86) size 743x36
+        text run at (100,86) width 643: " The image should be 1000px over to the right and bottom, which should cause horizontal and vertical"
+        text run at (0,104) width 126: "scrollbars to appear."
+      RenderText {#text} at (0,0) size 0x0
+layer at (1008,1008) size 100x100
+  RenderImage {IMG} at (0,0) size 100x100 [bgcolor=#00FF00]
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.checksum b/LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.checksum
new file mode 100644 (file)
index 0000000..5186494
--- /dev/null
@@ -0,0 +1 @@
+1f3a86bc9a6aebd0ac54c0d3a2e60fe2
\ No newline at end of file
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.png b/LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.png
new file mode 100644 (file)
index 0000000..e9b171e
Binary files /dev/null and b/LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.png differ
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.txt b/LayoutTests/fast/block/positioning/relative-overflow-replaced-float-expected.txt
new file mode 100644 (file)
index 0000000..3310d69
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 1108x1108
+  RenderView at (0,0) size 785x585
+layer at (0,0) size 785x600
+  RenderBlock {HTML} at (0,0) size 785x600
+    RenderBody {BODY} at (8,8) size 769x584
+      RenderText {#text} at (100,0) size 639x36
+        text run at (100,0) width 639: "The image should be 1000px over to the right and bottom, which should cause horizontal and vertical"
+        text run at (100,18) width 126: "scrollbars to appear."
+      RenderText {#text} at (0,0) size 0x0
+layer at (1008,1008) size 100x100
+  RenderImage {IMG} at (0,0) size 100x100 [bgcolor=#00FF00]
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced-float.html b/LayoutTests/fast/block/positioning/relative-overflow-replaced-float.html
new file mode 100644 (file)
index 0000000..a6db01b
--- /dev/null
@@ -0,0 +1,5 @@
+<html>
+<body>
+<img style="float:left;position:relative;left:1000px;top:1000px;height:100px;width:100px;background-color:lime">
+The image should be 1000px over to the right and bottom, which should cause horizontal and vertical scrollbars to appear.
+</body>
diff --git a/LayoutTests/fast/block/positioning/relative-overflow-replaced.html b/LayoutTests/fast/block/positioning/relative-overflow-replaced.html
new file mode 100644 (file)
index 0000000..964f662
--- /dev/null
@@ -0,0 +1,5 @@
+<html>
+<body>
+<img style="position:relative;left:1000px;top:1000px;height:100px;width:100px;background-color:lime">
+The image should be 1000px over to the right and bottom, which should cause horizontal and vertical scrollbars to appear.
+</body>
index 56f619e869123e55fea55875b5c317ec0bffb8ce..408c197d0944b0719f039a6c4f32d2d9a8df0523 100644 (file)
@@ -1,3 +1,32 @@
+2006-06-13  Antti Koivisto  <koivisto@iki.fi>
+
+        Reviewed by Hyatt.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9314
+        Relative positioned block size doesnt update root layer size
+
+        - take relative positioning into account in leftmost/rightmost/lowestPosition()
+        - ignore zero width/height boxes in leftmost/rightmost/lowestPosition()
+        - split relativePositionOffset() to x and y functions
+        
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::absolutePosition):
+        (WebCore::RenderBox::relativePositionOffsetX):
+        (WebCore::RenderBox::relativePositionOffsetY):
+        (WebCore::RenderBox::lowestPosition):
+        (WebCore::RenderBox::rightmostPosition):
+        (WebCore::RenderBox::leftmostPosition):
+        * rendering/RenderBox.h:
+        * rendering/RenderFlow.cpp:
+        (WebCore::RenderFlow::lowestPosition):
+        (WebCore::RenderFlow::rightmostPosition):
+        (WebCore::RenderFlow::leftmostPosition):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPosition):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::offsetLeft):
+        (WebCore::RenderObject::offsetTop):
+
 2006-06-13  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Dave Hyatt.
index b1280f441ba4b01db28d92e0f8b7f28bac712c47..8403da28e842fcab05b898f5fb3a068b211893ba 100644 (file)
@@ -762,8 +762,10 @@ bool RenderBox::absolutePosition(int &xPos, int &yPos, bool f)
             yPos += m_y;
         }
 
-        if (isRelPositioned())
-            relativePositionOffset(xPos, yPos);
+        if (isRelPositioned()) {
+            xPos += relativePositionOffsetX();
+            yPos += relativePositionOffsetY();            
+        }
 
         return true;
     }
@@ -933,24 +935,32 @@ void RenderBox::repaintDuringLayoutIfMoved(int oldX, int oldY)
     }
 }
 
-void RenderBox::relativePositionOffset(int &tx, int &ty)
+int RenderBox::relativePositionOffsetX() const
 {
+    int tx = 0;
     if(!style()->left().isAuto())
-        tx += style()->left().calcValue(containingBlockWidth());
+        tx = style()->left().calcValue(containingBlockWidth());
     else if(!style()->right().isAuto())
-        tx -= style()->right().calcValue(containingBlockWidth());
+        tx = -style()->right().calcValue(containingBlockWidth());
+    return tx;
+}
+
+int RenderBox::relativePositionOffsetY() const
+{
+    int ty = 0;
     if(!style()->top().isAuto())
     {
         if (!style()->top().isPercent()
                 || containingBlock()->style()->height().isFixed())
-            ty += style()->top().calcValue(containingBlockHeight());
+            ty = style()->top().calcValue(containingBlockHeight());
     }
     else if(!style()->bottom().isAuto())
     {
         if (!style()->bottom().isPercent()
                 || containingBlock()->style()->height().isFixed())
-            ty -= style()->bottom().calcValue(containingBlockHeight());
+            ty = -style()->bottom().calcValue(containingBlockHeight());
     }
+    return ty;
 }
 
 void RenderBox::calcWidth()
@@ -2365,17 +2375,32 @@ IntRect RenderBox::caretRect(int offset, EAffinity affinity, int* extraWidthToEn
 
 int RenderBox::lowestPosition(bool includeOverflowInterior, bool includeSelf) const
 {
-    return includeSelf ? m_height : 0;
+    if (!includeSelf || !m_width)
+        return 0;
+    int bottom = m_height;
+    if (isRelPositioned())
+        bottom += relativePositionOffsetY();
+    return bottom;
 }
 
 int RenderBox::rightmostPosition(bool includeOverflowInterior, bool includeSelf) const
 {
-    return includeSelf ? m_width : 0;
+    if (!includeSelf || !m_height)
+        return 0;
+    int right = m_width;
+    if (isRelPositioned())
+        right += relativePositionOffsetX();
+    return right;
 }
 
 int RenderBox::leftmostPosition(bool includeOverflowInterior, bool includeSelf) const
 {
-    return includeSelf ? 0 : m_width;
+    if (!includeSelf || !m_height)
+        return m_width;
+    int left = 0;
+    if (isRelPositioned())
+        left += relativePositionOffsetX();
+    return left;
 }
 
 }
index 844fb2db7d7597949f56603843f67130d425cc28..71d11ada9a97bb78dad981cc8c0700aeeb5ed23d 100644 (file)
@@ -132,7 +132,8 @@ public:
     
     void calcVerticalMargins();
 
-    void relativePositionOffset(int &tx, int &ty);
+    int relativePositionOffsetX() const;
+    int relativePositionOffsetY() const;
 
     virtual RenderLayer* layer() const { return m_layer; }
     
index b9c1ad7811332997f0e852cd4b15551f15f11de2..c92c94de4cb36fbd29a00425de4ce50d94361b92 100644 (file)
@@ -516,7 +516,7 @@ int
 RenderFlow::lowestPosition(bool includeOverflowInterior, bool includeSelf) const
 {
     assert(!isInlineFlow());
-    int bottom = RenderContainer::lowestPosition(includeOverflowInterior, includeSelf);
+    int bottom = includeSelf && m_width > 0 ? m_height : 0;
     if (!includeOverflowInterior && hasOverflowClip())
         return bottom;
 
@@ -530,6 +530,9 @@ RenderFlow::lowestPosition(bool includeOverflowInterior, bool includeSelf) const
             bottom = max(bottom, lp);
         }
     }
+    if (isRelPositioned())
+        bottom += relativePositionOffsetY();         
     
     return bottom;
 }
@@ -537,7 +540,7 @@ RenderFlow::lowestPosition(bool includeOverflowInterior, bool includeSelf) const
 int RenderFlow::rightmostPosition(bool includeOverflowInterior, bool includeSelf) const
 {
     assert(!isInlineFlow());
-    int right = RenderContainer::rightmostPosition(includeOverflowInterior, includeSelf);
+    int right = includeSelf && m_height > 0 ? m_width : 0;
     if (!includeOverflowInterior && hasOverflowClip())
         return right;
 
@@ -552,13 +555,16 @@ int RenderFlow::rightmostPosition(bool includeOverflowInterior, bool includeSelf
         }
     }
     
+    if (isRelPositioned())
+        right += relativePositionOffsetX();
+    
     return right;
 }
 
 int RenderFlow::leftmostPosition(bool includeOverflowInterior, bool includeSelf) const
 {
     assert(!isInlineFlow());
-    int left = RenderContainer::leftmostPosition(includeOverflowInterior, includeSelf);
+    int left = includeSelf && m_height > 0 ? 0 : m_width;
     if (!includeOverflowInterior && hasOverflowClip())
         return left;
     
@@ -573,6 +579,9 @@ int RenderFlow::leftmostPosition(bool includeOverflowInterior, bool includeSelf)
         }
     }
     
+    if (isRelPositioned())
+        left += relativePositionOffsetX(); 
+        
     return left;
 }
 
index f57b27105bd8523259943c37795c6368a9516847..8aeb96bbedc90f63cf38280089aad9b2fadff76f 100644 (file)
@@ -263,7 +263,8 @@ void RenderLayer::updateLayerPosition()
 
     m_relX = m_relY = 0;
     if (m_object->isRelPositioned()) {
-        static_cast<RenderBox*>(m_object)->relativePositionOffset(m_relX, m_relY);
+        m_relX = static_cast<RenderBox*>(m_object)->relativePositionOffsetX();
+        m_relY = static_cast<RenderBox*>(m_object)->relativePositionOffsetY();
         x += m_relX; y += m_relY;
     }
     
index c4cade75f7c598b9a175a5178040656037196af9..6ba2a06329f401855e5dce3eae26bd452bbfc09d 100644 (file)
@@ -549,10 +549,8 @@ int RenderObject::offsetLeft() const
 {
     int x = xPos();
     if (!isPositioned()) {
-        if (isRelPositioned()) {
-            int y = 0;
-            ((RenderBox*)this)->relativePositionOffset(x, y);
-        }
+        if (isRelPositioned())
+            x += ((RenderBox*)this)->relativePositionOffsetX();
         
         RenderObject* offsetPar = offsetParent();
         RenderObject* curr = parent();
@@ -568,10 +566,8 @@ int RenderObject::offsetTop() const
 {
     int y = yPos();
     if (!isPositioned()) {
-        if (isRelPositioned()) {
-            int x = 0;
-            ((RenderBox*)this)->relativePositionOffset(x, y);
-        }
+        if (isRelPositioned())
+            y += ((RenderBox*)this)->relativePositionOffsetY();
         RenderObject* offsetPar = offsetParent();
         RenderObject* curr = parent();
         while (curr && curr != offsetPar) {