[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:42:05 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 98ee7e4622d8522d761bd6de173e42d294f2e9f7
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed May 14 01:39:15 2003 +0000

    	Fix for 3256376, absolute positioned content that had to be
    	scrolled into view would not respond to events.  This is a
    	regression caused by fixing the size of the HTML element.
    
    	I stopped all of the updating of layer widths/heights in
    	setLayouted and in setWidth/Height of RenderBox and special-cased
    	the sizing of the RenderCanvas layer so that it always encloses
    	all content.
    
    	This patch also contains a fix for 3211915, left/top positions
    	not computed properly when auto or static.  The patch adds
    	staticX/Y member variables to RenderBox that holds the cached
    	values that can then be used by positioned elements to determine
    	their correct positions in the flow.  RenderStyles also now
    	remember both the original display of an element as well as
    	the mutated display (e.g., when an inline becomes a block
    	because of absolute positioning).
    
            Reviewed by darin (canvas fix) and kocienda (left/top fix)
    
            * khtml/css/cssstyleselector.cpp:
            * khtml/rendering/bidi.cpp:
            * khtml/rendering/render_block.cpp:
            * khtml/rendering/render_box.cpp:
            (RenderBox::RenderBox):
            (RenderBox::position):
            (RenderBox::setStaticX):
            (RenderBox::setStaticY):
            (RenderBox::calcAbsoluteHorizontal):
            (RenderBox::calcAbsoluteVertical):
            * khtml/rendering/render_box.h:
            * khtml/rendering/render_canvas.cpp:
            * khtml/rendering/render_flow.cpp:
            (RenderFlow::createInlineBox):
            * khtml/rendering/render_flow.h:
            * khtml/rendering/render_layer.cpp:
            (RenderLayer::updateLayerPosition):
            * khtml/rendering/render_line.cpp:
            (InlineFlowBox::placeBoxesHorizontally):
            (InlineFlowBox::adjustMaxAscentAndDescent):
            (InlineFlowBox::computeLogicalBoxHeights):
            (InlineFlowBox::placeBoxesVertically):
            (InlineFlowBox::shrinkBoxesWithNoTextChildren):
            * khtml/rendering/render_object.cpp:
            (RenderObject::hasStaticX):
            (RenderObject::hasStaticY):
            (RenderObject::setNeedsLayout):
            (RenderObject::createInlineBox):
            * khtml/rendering/render_object.h:
            * khtml/rendering/render_style.cpp:
            (RenderStyle::diff):
            * khtml/rendering/render_style.h:
            * khtml/rendering/render_text.cpp:
            (RenderText::createInlineBox):
            * khtml/rendering/render_text.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4367 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index d55b81c..3084481 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,61 @@
+2003-05-13  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3256376, absolute positioned content that had to be
+	scrolled into view would not respond to events.  This is a 
+	regression caused by fixing the size of the HTML element.
+
+	I stopped all of the updating of layer widths/heights in
+	setLayouted and in setWidth/Height of RenderBox and special-cased
+	the sizing of the RenderCanvas layer so that it always encloses
+	all content.
+
+	This patch also contains a fix for 3211915, left/top positions
+	not computed properly when auto or static.  The patch adds
+	staticX/Y member variables to RenderBox that holds the cached
+	values that can then be used by positioned elements to determine
+	their correct positions in the flow.  RenderStyles also now
+	remember both the original display of an element as well as
+	the mutated display (e.g., when an inline becomes a block
+	because of absolute positioning).
+	
+        Reviewed by darin (canvas fix) and kocienda (left/top fix)
+
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/rendering/bidi.cpp:
+        * khtml/rendering/render_block.cpp:
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::RenderBox):
+        (RenderBox::position):
+        (RenderBox::setStaticX):
+        (RenderBox::setStaticY):
+        (RenderBox::calcAbsoluteHorizontal):
+        (RenderBox::calcAbsoluteVertical):
+        * khtml/rendering/render_box.h:
+        * khtml/rendering/render_canvas.cpp:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::createInlineBox):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::updateLayerPosition):
+        * khtml/rendering/render_line.cpp:
+        (InlineFlowBox::placeBoxesHorizontally):
+        (InlineFlowBox::adjustMaxAscentAndDescent):
+        (InlineFlowBox::computeLogicalBoxHeights):
+        (InlineFlowBox::placeBoxesVertically):
+        (InlineFlowBox::shrinkBoxesWithNoTextChildren):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::hasStaticX):
+        (RenderObject::hasStaticY):
+        (RenderObject::setNeedsLayout):
+        (RenderObject::createInlineBox):
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_style.cpp:
+        (RenderStyle::diff):
+        * khtml/rendering/render_style.h:
+        * khtml/rendering/render_text.cpp:
+        (RenderText::createInlineBox):
+        * khtml/rendering/render_text.h:
+
 2003-05-13  Richard Williamson   <rjw at apple.com>
 
 	Fixed 3014661.  We now display (a lame Lemay) image
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index d55b81c..3084481 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,61 @@
+2003-05-13  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3256376, absolute positioned content that had to be
+	scrolled into view would not respond to events.  This is a 
+	regression caused by fixing the size of the HTML element.
+
+	I stopped all of the updating of layer widths/heights in
+	setLayouted and in setWidth/Height of RenderBox and special-cased
+	the sizing of the RenderCanvas layer so that it always encloses
+	all content.
+
+	This patch also contains a fix for 3211915, left/top positions
+	not computed properly when auto or static.  The patch adds
+	staticX/Y member variables to RenderBox that holds the cached
+	values that can then be used by positioned elements to determine
+	their correct positions in the flow.  RenderStyles also now
+	remember both the original display of an element as well as
+	the mutated display (e.g., when an inline becomes a block
+	because of absolute positioning).
+	
+        Reviewed by darin (canvas fix) and kocienda (left/top fix)
+
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/rendering/bidi.cpp:
+        * khtml/rendering/render_block.cpp:
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::RenderBox):
+        (RenderBox::position):
+        (RenderBox::setStaticX):
+        (RenderBox::setStaticY):
+        (RenderBox::calcAbsoluteHorizontal):
+        (RenderBox::calcAbsoluteVertical):
+        * khtml/rendering/render_box.h:
+        * khtml/rendering/render_canvas.cpp:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::createInlineBox):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::updateLayerPosition):
+        * khtml/rendering/render_line.cpp:
+        (InlineFlowBox::placeBoxesHorizontally):
+        (InlineFlowBox::adjustMaxAscentAndDescent):
+        (InlineFlowBox::computeLogicalBoxHeights):
+        (InlineFlowBox::placeBoxesVertically):
+        (InlineFlowBox::shrinkBoxesWithNoTextChildren):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::hasStaticX):
+        (RenderObject::hasStaticY):
+        (RenderObject::setNeedsLayout):
+        (RenderObject::createInlineBox):
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_style.cpp:
+        (RenderStyle::diff):
+        * khtml/rendering/render_style.h:
+        * khtml/rendering/render_text.cpp:
+        (RenderText::createInlineBox):
+        * khtml/rendering/render_text.h:
+
 2003-05-13  Richard Williamson   <rjw at apple.com>
 
 	Fixed 3014661.  We now display (a lame Lemay) image
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 4f0b5fc..6a35b84 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -472,7 +472,10 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e)
     }
 
     // Mutate the display to BLOCK or TABLE for certain cases, e.g., if someone attempts to
-    // position or float an inline, compact, or run-in.
+    // position or float an inline, compact, or run-in.  Cache the original display, since it
+    // may be needed for positioned elements that have to compute their static normal flow
+    // positions.
+    style->setOriginalDisplay(style->display());
     if (style->display() != NONE && style->display() != BLOCK && style->display() != TABLE &&
         (style->position() == ABSOLUTE || style->position() == FIXED || style->floating() != FNONE)) {
         if (style->display() == INLINE_TABLE)
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index 1b9a831..2b1b430 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -398,7 +398,8 @@ static void addMidpoint(const BidiIterator& midpoint)
 
 static void appendRunsForObject(int start, int end, RenderObject* obj)
 {
-    if (start > end || obj->isFloatingOrPositioned())
+    if (start > end || obj->isFloating() ||
+        (obj->isPositioned() && !obj->hasStaticX() && !obj->hasStaticY()))
         return;
 
     bool haveNextMidpoint = (smidpoints && sCurrMidpoint < sNumMidpoints);
@@ -552,7 +553,7 @@ InlineFlowBox* RenderBlock::createLineBoxes(RenderObject* obj)
     if (!box || box->isConstructed() || box->nextOnLine()) {
         // We need to make a new box for this render object.  Once
         // made, we need to place it at the end of the current line.
-        InlineBox* newBox = obj->createInlineBox();
+        InlineBox* newBox = obj->createInlineBox(false);
         KHTMLAssert(newBox->isInlineFlowBox());
         box = static_cast<InlineFlowBox*>(newBox);
         box->setFirstLineStyleBit(m_firstLine);
@@ -578,7 +579,7 @@ InlineFlowBox* RenderBlock::constructLine(const BidiIterator &start, const BidiI
     InlineFlowBox* parentBox = 0;
     for (BidiRun* r = sFirstBidiRun; r; r = r->nextRun) {
         // Create a box for our object.
-        r->box = r->obj->createInlineBox();
+        r->box = r->obj->createInlineBox(r->obj->isPositioned());
         
         // If we have no parent box yet, or if the run is not simply a sibling,
         // then we need to construct inline boxes as necessary to properly enclose the
@@ -618,6 +619,9 @@ void RenderBlock::computeHorizontalPositionsForLine(InlineFlowBox* lineBox, Bidi
     int totWidth = lineBox->getFlowSpacingWidth();
     BidiRun* r = 0;
     for (r = sFirstBidiRun; r; r = r->nextRun) {
+        if (r->obj->isPositioned())
+            continue; // Positioned objects are only participating to figure out their
+                      // correct static x position.  They have no effect on the width.
         if (r->obj->isText())
             r->box->setWidth(static_cast<RenderText *>(r->obj)->width(r->start, r->stop-r->start, m_firstLine));
         else if (!r->obj->isInlineFlow()) {
@@ -698,8 +702,16 @@ void RenderBlock::computeVerticalPositionsForLine(InlineFlowBox* lineBox)
         m_overflowHeight = bottomOfLine;
         
     // Now make sure we place replaced render objects correctly.
-    for (BidiRun* r = sFirstBidiRun; r; r = r->nextRun)
+    for (BidiRun* r = sFirstBidiRun; r; r = r->nextRun) {
+        // Align positioned boxes with the top of the line box.  This is
+        // a reasonable approximation of an appropriate y position.
+        if (r->obj->isPositioned())
+            r->box->setYPos(m_height);
+
+        // Position is used to properly position both replaced elements and
+        // to update the static normal flow x/y of positioned elements.
         r->obj->position(r->box, r->start, r->stop - r->start, r->level%2);
+    }
 }
 
 // collects one line of the paragraph and transforms it to visual order
@@ -1367,7 +1379,7 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start)
         if( start.obj->isFloatingOrPositioned() ) {
             RenderObject *o = start.obj;
             // add to special objects...
-            if(o->isFloating()) {
+            if (o->isFloating()) {
                 insertFloatingObject(o);
                 // check if it fits in the current line.
                 // If it does, position it now, otherwise, position
@@ -1377,8 +1389,14 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start)
                     width = lineWidth(m_height);
                 }
             }
-            else if (o->isPositioned())
-                o->containingBlock()->insertPositionedObject(o);
+            else if (o->isPositioned()) {
+                if (o->hasStaticX())
+                    o->setStaticX(style()->direction() == LTR ?
+                                  borderLeft()+paddingLeft() :
+                                  borderRight()+paddingRight());
+                if (o->hasStaticY())
+                    o->setStaticY(m_height);
+            }
         }
         
         adjustEmbeddding = true;
@@ -1453,8 +1471,36 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start)
                     width = lineWidth(m_height);
                 }
             }
-            else if (o->isPositioned())
-                o->containingBlock()->insertPositionedObject(o);
+            else if (o->isPositioned()) {
+                // If our original display wasn't an INLINE type, then we can
+                // go ahead and determine our static x position now.
+                bool isInlineType = o->style()->originalDisplay() == INLINE ||
+                                    o->style()->originalDisplay() == INLINE_TABLE;
+                bool needToSetStaticX = o->hasStaticX();
+                if (o->hasStaticX() && !isInlineType) {
+                    o->setStaticX(o->parent()->style()->direction() == LTR ?
+                                  borderLeft()+paddingLeft() :
+                                  borderRight()+paddingRight());
+                    needToSetStaticX = false;
+                }
+
+                // If our original display was an INLINE type, then we can go ahead
+                // and determine our static y position now.
+                bool needToSetStaticY = o->hasStaticY();
+                if (o->hasStaticY() && isInlineType) {
+                    o->setStaticY(m_height);
+                    needToSetStaticY = false;
+                }
+                
+                // If we're ignoring spaces, we have to stop and include this object and
+                // then start ignoring spaces again.
+                if (ignoringSpaces && (needToSetStaticX || needToSetStaticY)) {
+                    BidiIterator startMid = { 0, o, 0 };
+                    BidiIterator stopMid = { 0, o, 1 };
+                    addMidpoint(startMid); // Stop ignoring spaces.
+                    addMidpoint(stopMid); // Start ignoring again.
+                }
+            }
         } else if (o->isInlineFlow()) {
             // Only empty inlines matter.  We treat those similarly to replaced elements.
             KHTMLAssert(!o->firstChild());
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index e8d261d..cc961ee 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -545,9 +545,8 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
     int minHeight = m_height + toAdd;
     m_overflowHeight = m_height;
 
-    if( style()->direction() == RTL ) {
-        xPos = marginLeft() + m_width - paddingRight() - borderRight();
-    }
+    if( style()->direction() == RTL )
+        xPos = m_width - paddingRight() - borderRight();
 
     RenderObject *child = firstChild();
     RenderBlock *prevFlow = 0;
@@ -626,6 +625,18 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
         if (child->isPositioned())
         {
             child->containingBlock()->insertPositionedObject(child);
+            if (child->hasStaticX()) {
+                if (style()->direction() == LTR)
+                    child->setStaticX(xPos);
+                else
+                    child->setStaticX(borderRight()+paddingRight());
+            }
+            if (child->hasStaticY()) {
+                int yPosEstimate = m_height;
+                if (prevFlow)
+                    yPosEstimate += prevFlow->collapsedMarginBottom();
+                child->setStaticY(yPosEstimate);
+            }
             child = child->nextSibling();
             continue;
         } else if (child->isReplaced())
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index 9e299af..2176403 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -59,6 +59,8 @@ RenderBox::RenderBox(DOM::NodeImpl* node)
     m_marginBottom = 0;
     m_marginLeft = 0;
     m_marginRight = 0;
+    m_staticX = 0;
+    m_staticY = 0;
     m_layer = 0;
 }
 
@@ -500,7 +502,27 @@ bool RenderBox::absolutePosition(int &xPos, int &yPos, bool f)
 
 void RenderBox::position(InlineBox* box, int from, int len, bool reverse)
 {
-    if (isReplaced()) {
+    if (isPositioned()) {
+        // Cache the x position only if we were an INLINE type originally.
+        bool wasInline = style()->originalDisplay() == INLINE ||
+                         style()->originalDisplay() == INLINE_TABLE;
+        if (wasInline && hasStaticX()) {
+            // The value is cached in the xPos of the box.  We only need this value if
+            // our object was inline originally, since otherwise it would have ended up underneath
+            // the inlines.
+            m_staticX = box->xPos();
+        }
+        else if (!wasInline && hasStaticY())
+            // Our object was a block originally, so we make our normal flow position be
+            // just below the line box (as though all the inlines that came before us got
+            // wrapped in an anonymous block, which is what would have happened had we been
+            // in flow).  This value was cached in the yPos() of the box.
+            m_staticY = box->yPos();
+
+        // Nuke the box.
+        box->detach(renderArena());
+    }
+    else if (isReplaced()) {
         m_x = box->xPos();
         m_y = box->yPos();
 
@@ -886,6 +908,16 @@ void RenderBox::calcVerticalMargins()
     m_marginBottom = bm.minWidth(cw);
 }
 
+void RenderBox::setStaticX(short staticX)
+{
+    m_staticX = staticX;
+}
+
+void RenderBox::setStaticY(int staticY)
+{
+    m_staticY = staticY;
+}
+
 void RenderBox::calcAbsoluteHorizontal()
 {
     const int AUTO = -666666;
@@ -894,8 +926,9 @@ void RenderBox::calcAbsoluteHorizontal()
     int pab = borderLeft()+ borderRight()+ paddingLeft()+ paddingRight();
 
     l=r=ml=mr=w=AUTO;
-    cw = containingBlockWidth()
-        +containingBlock()->paddingLeft() +containingBlock()->paddingRight();
+
+    RenderBlock* cb = containingBlock();
+    cw = containingBlockWidth() + cb->paddingLeft() + cb->paddingRight();
 
     if(!style()->left().isVariable())
         l = style()->left().width(cw);
@@ -914,38 +947,28 @@ void RenderBox::calcAbsoluteHorizontal()
 //    printf("h1: w=%d, l=%d, r=%d, ml=%d, mr=%d\n",w,l,r,ml,mr);
 
     int static_distance=0;
-    if ((style()->direction()==LTR && (l==AUTO && r==AUTO ))
+    if ((parent()->style()->direction()==LTR && (l==AUTO && r==AUTO ))
             || style()->left().isStatic())
     {
-        // calc hypothetical location in the normal flow
-        // used for 1) left=static-position
-        //          2) left, right, width are all auto -> calc top -> 3.
-        //          3) precalc for case 2 below
-
-        // all positioned elements are blocks, so that
-        // would be at the left edge, but inset by our border/padding.
+        static_distance = m_staticX - cb->borderLeft(); // Should already have been set through layout of the parent().
         RenderObject* po = parent();
-        static_distance += po->borderLeft() + po->paddingLeft();
-        while (po && po!=containingBlock()) {
-            static_distance+=po->xPos();
-            po=po->parent();
-        }
+        for (; po && po != cb; po = po->parent())
+            static_distance += po->xPos();
 
         if (l==AUTO || style()->left().isStatic())
             l = static_distance;
     }
 
-    else if ((style()->direction()==RTL && (l==AUTO && r==AUTO ))
+    else if ((parent()->style()->direction()==RTL && (l==AUTO && r==AUTO ))
             || style()->right().isStatic())
     {
-            RenderObject* po = parent();
-
-            static_distance = cw - po->width();
-            static_distance -= po->borderRight() + po->paddingRight();
-            while (po && po!=containingBlock()) {
-                static_distance-=po->xPos();
-                po=po->parent();
-            }
+        RenderObject* po = parent();
+        RenderBlock* cb = containingBlock();
+        static_distance = m_staticX - cb->borderLeft(); // Should already have been set through layout of the parent().
+        while (po && po!=containingBlock()) {
+            static_distance+=po->xPos();
+            po=po->parent();
+        }
 
         if (r==AUTO || style()->right().isStatic())
             r = static_distance;
@@ -1037,7 +1060,7 @@ void RenderBox::calcAbsoluteHorizontal()
     m_width = w + pab;
     m_marginLeft = ml;
     m_marginRight = mr;
-    m_x = l + ml + containingBlock()->borderLeft();
+    m_x = l + ml + cb->borderLeft();
 //    printf("h: w=%d, l=%d, r=%d, ml=%d, mr=%d\n",w,l,r,ml,mr);
 }
 
@@ -1100,20 +1123,11 @@ void RenderBox::calcAbsoluteVertical()
         // used for 1) top=static-position
         //          2) top, bottom, height are all auto -> calc top -> 3.
         //          3) precalc for case 2 below
-
-        RenderObject* ro = previousSibling();
-        while ( ro && ro->isFloatingOrPositioned())
-            ro = ro->previousSibling();
-
+        static_top = m_staticY; // Should already have been set through layout of the parent().
         RenderObject* po = parent();
-        if (ro)
-            static_top = ro->yPos() + ro->marginBottom() + ro->height();
-        else
-            static_top += po->borderTop() + po->paddingTop();
-        
         for (; po && po != cb; po = po->parent())
             static_top += po->yPos();
-        
+
         if (h==AUTO || style()->top().isStatic())
             t = static_top;
     }
diff --git a/WebCore/khtml/rendering/render_box.h b/WebCore/khtml/rendering/render_box.h
index 2254335..1023b82 100644
--- a/WebCore/khtml/rendering/render_box.h
+++ b/WebCore/khtml/rendering/render_box.h
@@ -74,8 +74,8 @@ public:
     virtual short marginLeft() const { return m_marginLeft; }
     virtual short marginRight() const { return m_marginRight; }
 
-    virtual void setWidth( int width ) { m_width = width; if (m_layer) m_layer->setWidth(width); }
-    virtual void setHeight( int height ) { m_height = height; if (m_layer) m_layer->setHeight(height); }
+    virtual void setWidth( int width ) { m_width = width; }
+    virtual void setHeight( int height ) { m_height = height; }
 
     // This method is now public so that centered objects like tables that are
     // shifted right by left-aligned floats can recompute their left and
@@ -115,7 +115,10 @@ public:
     virtual void paintBackgroundExtended(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph,
                                          int _tx, int _ty, int w, int height,
                                          int bleft, int bright);
-    
+
+    virtual void setStaticX(short staticX);
+    virtual void setStaticY(int staticY);
+
 protected:
     virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
                                      int _w, int _h, int _tx, int _ty);
@@ -157,6 +160,10 @@ protected:
      * ( = the width of the element with line breaking disabled)
      */
     short m_maxWidth;
+
+    // Cached normal flow values for absolute positioned elements with static left/top values.
+    short m_staticX;
+    int m_staticY;
     
     // A pointer to our layer if we have one.  Currently only positioned elements
     // and floaters have layers.
diff --git a/WebCore/khtml/rendering/render_canvas.cpp b/WebCore/khtml/rendering/render_canvas.cpp
index e7bc9df..4813279 100644
--- a/WebCore/khtml/rendering/render_canvas.cpp
+++ b/WebCore/khtml/rendering/render_canvas.cpp
@@ -154,14 +154,17 @@ void RenderCanvas::layout()
 
     RenderBlock::layout();
 
-#ifdef APPLE_CHANGES
+    int docw = docWidth();
+    int doch = docHeight();
+
+#if APPLE_CHANGES
     // always do the resizeContents, since we need the view to change size for Cocoa builtin
     // pagination to work
-    m_view->resizeContents(docWidth(), docHeight());
+    m_view->resizeContents(docw, doch);
     if (!m_printingMode) {
 #else
     if (!m_printingMode) {
-        m_view->resizeContents(docWidth(), docHeight());
+        m_view->resizeContents(docw, doch);
 #endif
         setWidth( m_viewportWidth = m_view->visibleWidth() );
         setHeight(  m_viewportHeight = m_view->visibleHeight() );
@@ -174,8 +177,8 @@ void RenderCanvas::layout()
     kdDebug() << "RenderCanvas::end time used=" << qt.elapsed() << endl;
 #endif
 
-    layer()->setHeight(m_height);
-    layer()->setWidth(m_width);
+    layer()->setHeight(QMAX(doch, m_height));
+    layer()->setWidth(QMAX(docw, m_width));
 
     setNeedsLayout(false);
 }
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index a983154..99eac51 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -151,10 +151,10 @@ void RenderFlow::detach(RenderArena* renderArena)
     RenderBox::detach(renderArena);
 }
 
-InlineBox* RenderFlow::createInlineBox()
+InlineBox* RenderFlow::createInlineBox(bool makePlaceHolderBox)
 {
-    if (isReplaced()) // Inline tables and inline blocks.
-        return RenderBox::createInlineBox();
+    if (isReplaced() || makePlaceHolderBox)          // Inline tables and inline blocks
+        return RenderBox::createInlineBox(false);    // (or positioned element placeholders).
 
     InlineFlowBox* flowBox = 0;
     if (isInlineFlow())
diff --git a/WebCore/khtml/rendering/render_flow.h b/WebCore/khtml/rendering/render_flow.h
index ad4ba0e..c9029bb 100644
--- a/WebCore/khtml/rendering/render_flow.h
+++ b/WebCore/khtml/rendering/render_flow.h
@@ -62,7 +62,7 @@ public:
     InlineFlowBox* firstLineBox() const { return m_firstLineBox; }
     InlineFlowBox* lastLineBox() const { return m_lastLineBox; }
 
-    virtual InlineBox* createInlineBox();
+    virtual InlineBox* createInlineBox(bool makePlaceHolderBox);
 
     void paintLineBoxBackgroundBorder(QPainter *p, int _x, int _y,
                         int _w, int _h, int _tx, int _ty, PaintAction paintAction);
diff --git a/WebCore/khtml/rendering/render_layer.cpp b/WebCore/khtml/rendering/render_layer.cpp
index 4f2988e..9f44523 100644
--- a/WebCore/khtml/rendering/render_layer.cpp
+++ b/WebCore/khtml/rendering/render_layer.cpp
@@ -99,6 +99,11 @@ RenderLayer::~RenderLayer()
 
 void RenderLayer::updateLayerPosition()
 {
+    // The canvas is sized to the docWidth/Height over in RenderCanvas::layout, so we
+    // don't need to ever update our layer position here.
+    if (renderer()->isCanvas())
+        return;
+    
     int x = m_object->xPos();
     int y = m_object->yPos();
 
@@ -124,7 +129,7 @@ void RenderLayer::updateLayerPosition()
 
     setWidth(m_object->width());
     setHeight(m_object->height());
-    
+
     if (!m_object->style()->hidesOverflow()) {
         if (m_object->overflowWidth() > m_object->width())
             setWidth(m_object->overflowWidth());
diff --git a/WebCore/khtml/rendering/render_line.cpp b/WebCore/khtml/rendering/render_line.cpp
index 76791e4..52b7d37 100644
--- a/WebCore/khtml/rendering/render_line.cpp
+++ b/WebCore/khtml/rendering/render_line.cpp
@@ -233,6 +233,20 @@ int InlineFlowBox::placeBoxesHorizontally(int x)
             x += text->width();
         }
         else {
+            if (curr->object()->isPositioned()) {
+                if (curr->object()->parent()->style()->direction() == LTR)
+                    curr->setXPos(x);
+                else {
+                    // Our offset that we cache needs to be from the edge of the right border box and
+                    // not the left border box.  We have to subtract |x| from the width of the block
+                    // (which can be obtained by walking up to the root line box).
+                    InlineBox* root = this;
+                    while (!root->isRootInlineBox())
+                        root = root->parent();
+                    curr->setXPos(root->object()->width()-x);
+                }
+                continue; // The positioned object has no effect on the width.
+            }
             if (curr->object()->isInlineFlow()) {
                 InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr);
                 if (curr->object()->isCompact()) {
@@ -296,6 +310,8 @@ void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent,
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
         // The computed lineheight needs to be extended for the
         // positioned elements
+        if (curr->object()->isPositioned())
+            continue; // Positioned placeholders don't affect calculations.
         if (curr->yPos() == PositionTop || curr->yPos() == PositionBottom) {
             if (curr->yPos() == PositionTop) {
                 if (maxAscent + maxDescent < curr->height())
@@ -339,6 +355,9 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi
     }
     
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
+        if (curr->object()->isPositioned())
+            continue; // Positioned placeholders don't affect calculations.
+        
         curr->setHeight(curr->object()->lineHeight(m_firstLine));
         curr->setBaseline(curr->object()->baselinePosition(m_firstLine));
         curr->setYPos(curr->object()->verticalPositionHint(m_firstLine));
@@ -371,6 +390,9 @@ void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bo
         setYPos(y + maxAscent - baseline());// Place our root box.
     
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
+        if (curr->object()->isPositioned())
+            continue; // Positioned placeholders don't affect calculations.
+        
         // Adjust boxes to use their real box y/height and not the logical height (as dictated by
         // line-height).
         if (curr->isInlineFlowBox())
@@ -438,6 +460,9 @@ void InlineFlowBox::shrinkBoxesWithNoTextChildren(int topPos, int bottomPos)
 {
     // First shrink our kids.
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
+        if (curr->object()->isPositioned())
+            continue; // Positioned placeholders don't affect calculations.
+        
         if (curr->isInlineFlowBox())
             static_cast<InlineFlowBox*>(curr)->shrinkBoxesWithNoTextChildren(topPos, bottomPos);
     }
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index f938a6b..4abe353 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -385,6 +385,20 @@ RenderObject::scrollHeight() const
     return (style()->hidesOverflow() && layer()) ? layer()->scrollHeight() : clientHeight();
 }
 
+bool
+RenderObject::hasStaticX() const
+{
+    return (style()->left().isVariable() && style()->right().isVariable()) ||
+            style()->left().isStatic() ||
+            style()->right().isStatic();
+}
+
+bool
+RenderObject::hasStaticY() const
+{
+    return (style()->top().isVariable() && style()->bottom().isVariable()) || style()->top().isStatic();
+}
+
 void RenderObject::markAllDescendantsWithFloatsForLayout(RenderObject*)
 {
 }
@@ -392,15 +406,7 @@ void RenderObject::markAllDescendantsWithFloatsForLayout(RenderObject*)
 void RenderObject::setNeedsLayout(bool b) 
 {
     m_needsLayout = b;
-    if (!b) {
-        RenderLayer* l = layer();
-        if (l) {
-            l->setWidth(width());
-            l->setHeight(height());
-            l->updateLayerPosition();
-        }
-    }
-    else {
+    if (b) {
         RenderObject *o = container();
         RenderObject *root = this;
 
@@ -1514,7 +1520,7 @@ void RenderObject::removeLeftoverAnonymousBoxes()
 {
 }
 
-InlineBox* RenderObject::createInlineBox()
+InlineBox* RenderObject::createInlineBox(bool makePlaceHolderBox)
 {
     return new (renderArena()) InlineBox(this);
 }
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 3ab392f..8b178e3 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -128,6 +128,13 @@ public:
 
     virtual int getBaselineOfFirstLineBox() { return -1; } // Tables and blocks implement this.
     virtual InlineFlowBox* getFirstLineBox() { return 0; } // Tables and blocks implement this.
+
+    // Whether or not a positioned element requires normal flow x/y to be computed
+    // to determine its position.
+    bool hasStaticX() const;
+    bool hasStaticY() const;
+    virtual void setStaticX(short staticX) {};
+    virtual void setStaticY(int staticY) {};
     
     // RenderObject tree manipulation
     //////////////////////////////////////////
@@ -266,7 +273,7 @@ public:
 
     void scheduleRelayout(RenderObject* clippedObj = 0);
 
-    virtual InlineBox* createInlineBox();
+    virtual InlineBox* createInlineBox(bool makePlaceHolderBox);
     
     // for discussion of lineHeight see CSS2 spec
     virtual short lineHeight( bool firstLine ) const;
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index 0e1d577..2a17100 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -322,7 +322,7 @@ bool RenderStyle::inheritedNotEqual( RenderStyle *other ) const
 RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 {
     // we anyway assume they are the same
-// 	EDisplay _display : 5;
+// 	EDisplay _effectiveDisplay : 5;
 
     // NonVisible:
 // 	ECursor _cursor_style : 4;
@@ -350,6 +350,7 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
         !(inherited_flags._htmlHacks == other->inherited_flags._htmlHacks) ||
         !(noninherited_flags._position == other->noninherited_flags._position) ||
         !(noninherited_flags._floating == other->noninherited_flags._floating) ||
+        !(noninherited_flags._originalDisplay == other->noninherited_flags._originalDisplay) ||
          visual->colspan != other->visual->colspan ||
          visual->counter_increment != other->visual->counter_increment ||
          visual->counter_reset != other->visual->counter_reset)
@@ -364,7 +365,7 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 //     ETableLayout _table_layout : 1;
 //     EPosition _position : 2;
 //     EFloat _floating : 2;
-    if ( ((int)noninherited_flags._display) >= TABLE ) {
+    if ( ((int)noninherited_flags._effectiveDisplay) >= TABLE ) {
 	// Stupid gcc gives a compile error on
 	// a != other->b if a and b are bitflags. Using
 	// !(a== other->b) instead.
@@ -378,7 +379,7 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 // only for lists:
 // 	EListStyleType _list_style_type : 5 ;
 // 	EListStylePosition _list_style_position :1;
-    if (noninherited_flags._display == LIST_ITEM ) {
+    if (noninherited_flags._effectiveDisplay == LIST_ITEM ) {
 	if ( !(inherited_flags._list_style_type == other->inherited_flags._list_style_type) ||
 	     !(inherited_flags._list_style_position == other->inherited_flags._list_style_position) )
 	    return Layout;
@@ -403,7 +404,7 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 // only for inline:
 //     EVerticalAlign _vertical_align : 4;
 
-    if ( !(noninherited_flags._display == INLINE) &&
+    if ( !(noninherited_flags._effectiveDisplay == INLINE) &&
          !(noninherited_flags._vertical_align == other->noninherited_flags._vertical_align))
         return Layout;
 
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index af548e3..f630c04 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -547,15 +547,29 @@ protected:
 
 // don't inherit
     struct NonInheritedFlags {
-    // 32 bit non-inherited, don't add to the struct, or the operator will break.
-	bool operator==( const NonInheritedFlags &other ) const {
-	    return *((Q_UINT32 *)this) == *((Q_UINT32 *)&other);
-	}
-	bool operator!=( const NonInheritedFlags &other ) const {
-	    return *((Q_UINT32 *)this) != *((Q_UINT32 *)&other);
+        bool operator==( const NonInheritedFlags &other ) const {
+            return (_effectiveDisplay == other._effectiveDisplay) &&
+            (_originalDisplay == other._originalDisplay) &&
+            (_bg_repeat == other._bg_repeat) &&
+            (_overflow == other._overflow) &&
+            (_vertical_align == other._vertical_align) &&
+            (_clear == other._clear) &&
+            (_position == other._position) &&
+            (_floating == other._floating) &&
+            (_table_layout == other._table_layout) &&
+            (_flowAroundFloats == other._flowAroundFloats) &&
+            (_styleType == other._styleType) &&
+            (_affectedByHover == other._affectedByHover) &&
+            (_affectedByActive == other._affectedByActive) &&
+            (_unicodeBidi == other._unicodeBidi);
 	}
 
-        EDisplay _display : 5;
+        bool operator!=( const NonInheritedFlags &other ) const {
+            return !(*this == other);
+        }
+        
+        EDisplay _effectiveDisplay : 5;
+        EDisplay _originalDisplay : 5;
         EBackgroundRepeat _bg_repeat : 2;
         bool _bg_attachment : 1;
         EOverflow _overflow : 4 ;
@@ -612,7 +626,7 @@ protected:
 	inherited_flags._htmlHacks=false;
 	inherited_flags._unused = 0;
 
-	noninherited_flags._display = INLINE;
+	noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = INLINE;
 	noninherited_flags._bg_repeat = REPEAT;
 	noninherited_flags._bg_attachment = true;
 	noninherited_flags._overflow = OVISIBLE;
@@ -623,8 +637,8 @@ protected:
 	noninherited_flags._table_layout = TAUTO;
 	noninherited_flags._flowAroundFloats=false;
 	noninherited_flags._styleType = NOPSEUDO;
-    noninherited_flags._affectedByHover = false;
-    noninherited_flags._affectedByActive = false;
+        noninherited_flags._affectedByHover = false;
+        noninherited_flags._affectedByActive = false;
 	noninherited_flags._unicodeBidi = UBNormal;
     }
 
@@ -665,8 +679,9 @@ public:
     
 // attribute getter methods
 
-    EDisplay 	display() const { return noninherited_flags._display; }
-
+    EDisplay 	display() const { return noninherited_flags._effectiveDisplay; }
+    EDisplay    originalDisplay() const { return noninherited_flags._originalDisplay; }
+    
     Length  	left() const {  return surround->offset.left; }
     Length  	right() const {  return surround->offset.right; }
     Length  	top() const {  return surround->offset.top; }
@@ -787,7 +802,8 @@ public:
 
 // attribute setter methods
 
-    void setDisplay(EDisplay v) {  noninherited_flags._display = v; }
+    void setDisplay(EDisplay v) {  noninherited_flags._effectiveDisplay = v; }
+    void setOriginalDisplay(EDisplay v) {  noninherited_flags._originalDisplay = v; }
     void setPosition(EPosition v) {  noninherited_flags._position = v; }
     void setFloating(EFloat v) {  noninherited_flags._floating = v; }
 
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 151deae..f5046d3 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -1164,7 +1164,7 @@ short RenderText::baselinePosition( bool firstLine ) const
         ( lineHeight( firstLine ) - fm.height() ) / 2;
 }
 
-InlineBox* RenderText::createInlineBox()
+InlineBox* RenderText::createInlineBox(bool)
 {
     // FIXME: Either ditch the array or get this object into it.
     return new (renderArena()) TextRun(this);
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index 12595ac..0600d50 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -137,7 +137,7 @@ public:
     DOM::DOMString data() const { return str; }
     DOM::DOMStringImpl *string() const { return str; }
 
-    virtual InlineBox* createInlineBox();
+    virtual InlineBox* createInlineBox(bool);
     
     virtual void layout() {assert(false);}
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list