[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 06:37:01 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit b02467a3b8366dcec9f93369aa00b6419846976d
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Sep 8 09:48:48 2002 +0000

    	Landing the new layer system and turning it on for painting of
    	all types of positioned blocks (and for painting the root
    	and HTML layers as well).
    
    	Event handling is not yet using the new layer system, so you
    	may see oddities like DHTML menus now displaying correctly but
    	events not working (since the event code may still be stacking
    	incorrectly and think the DHTML is behind other content).
    
            * khtml/css/cssstyleselector.cpp:
            * khtml/rendering/render_box.cpp:
            (RenderBox::setStyle):
            (RenderBox::calcHeight):
            (RenderBox::calcAbsoluteHorizontal):
            * khtml/rendering/render_container.cpp:
            (RenderContainer::addChild):
            (RenderContainer::removeChildNode):
            * khtml/rendering/render_flow.cpp:
            (RenderFlow::setStyle):
            (RenderFlow::printObject):
            (RenderFlow::printSpecialObjects):
            (RenderFlow::layout):
            (RenderFlow::layoutSpecialObjects):
            (RenderFlow::layoutBlockChildren):
            (RenderFlow::insertSpecialObject):
            * khtml/rendering/render_flow.h:
            * khtml/rendering/render_html.cpp:
            (RenderHtml::layout):
            * khtml/rendering/render_image.cpp:
            (RenderImage::printObject):
            * khtml/rendering/render_layer.cpp:
            (RenderLayer::updateLayerPosition):
            (RenderLayer::enclosingAncestor):
            (RenderLayer::addChild):
            (RenderLayer::convertToLayerCoords):
            (RenderLayer::paint):
            (RenderLayer::constructZTree):
            (RenderLayer::RenderZTreeNode::constructLayerList):
            * khtml/rendering/render_layer.h:
            * khtml/rendering/render_replaced.cpp:
            (RenderReplaced::print):
            (RenderWidget::printObject):
            * khtml/rendering/render_root.cpp:
            (RenderRoot::calcHeight):
            (RenderRoot::layout):
            (RenderRoot::printObject):
            * khtml/rendering/render_root.h:
            * khtml/rendering/render_style.cpp:
            (StyleBoxData::StyleBoxData):
            (StyleBoxData::operator==):
            * khtml/rendering/render_style.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge drawRect:withPainter:]):
            * kwq/qt/qrect.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1994 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 4b00d14..1ee73a2 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,60 @@
+2002-09-08  David Hyatt  <hyatt at apple.com>
+
+	Landing the new layer system and turning it on for painting of
+	all types of positioned blocks (and for painting the root
+	and HTML layers as well).
+
+	Event handling is not yet using the new layer system, so you
+	may see oddities like DHTML menus now displaying correctly but
+	events not working (since the event code may still be stacking
+	incorrectly and think the DHTML is behind other content).
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::setStyle):
+        (RenderBox::calcHeight):
+        (RenderBox::calcAbsoluteHorizontal):
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::addChild):
+        (RenderContainer::removeChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        (RenderFlow::printObject):
+        (RenderFlow::printSpecialObjects):
+        (RenderFlow::layout):
+        (RenderFlow::layoutSpecialObjects):
+        (RenderFlow::layoutBlockChildren):
+        (RenderFlow::insertSpecialObject):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_html.cpp:
+        (RenderHtml::layout):
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::printObject):
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::updateLayerPosition):
+        (RenderLayer::enclosingAncestor):
+        (RenderLayer::addChild):
+        (RenderLayer::convertToLayerCoords):
+        (RenderLayer::paint):
+        (RenderLayer::constructZTree):
+        (RenderLayer::RenderZTreeNode::constructLayerList):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_replaced.cpp:
+        (RenderReplaced::print):
+        (RenderWidget::printObject):
+        * khtml/rendering/render_root.cpp:
+        (RenderRoot::calcHeight):
+        (RenderRoot::layout):
+        (RenderRoot::printObject):
+        * khtml/rendering/render_root.h:
+        * khtml/rendering/render_style.cpp:
+        (StyleBoxData::StyleBoxData):
+        (StyleBoxData::operator==):
+        * khtml/rendering/render_style.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge drawRect:withPainter:]):
+        * kwq/qt/qrect.h:
+
 2002-09-06  Maciej Stachowiak  <mjs at apple.com>
 
         Fix another instance of the same problem:
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 4b00d14..1ee73a2 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,60 @@
+2002-09-08  David Hyatt  <hyatt at apple.com>
+
+	Landing the new layer system and turning it on for painting of
+	all types of positioned blocks (and for painting the root
+	and HTML layers as well).
+
+	Event handling is not yet using the new layer system, so you
+	may see oddities like DHTML menus now displaying correctly but
+	events not working (since the event code may still be stacking
+	incorrectly and think the DHTML is behind other content).
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::setStyle):
+        (RenderBox::calcHeight):
+        (RenderBox::calcAbsoluteHorizontal):
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::addChild):
+        (RenderContainer::removeChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        (RenderFlow::printObject):
+        (RenderFlow::printSpecialObjects):
+        (RenderFlow::layout):
+        (RenderFlow::layoutSpecialObjects):
+        (RenderFlow::layoutBlockChildren):
+        (RenderFlow::insertSpecialObject):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_html.cpp:
+        (RenderHtml::layout):
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::printObject):
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::updateLayerPosition):
+        (RenderLayer::enclosingAncestor):
+        (RenderLayer::addChild):
+        (RenderLayer::convertToLayerCoords):
+        (RenderLayer::paint):
+        (RenderLayer::constructZTree):
+        (RenderLayer::RenderZTreeNode::constructLayerList):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_replaced.cpp:
+        (RenderReplaced::print):
+        (RenderWidget::printObject):
+        * khtml/rendering/render_root.cpp:
+        (RenderRoot::calcHeight):
+        (RenderRoot::layout):
+        (RenderRoot::printObject):
+        * khtml/rendering/render_root.h:
+        * khtml/rendering/render_style.cpp:
+        (StyleBoxData::StyleBoxData):
+        (StyleBoxData::operator==):
+        * khtml/rendering/render_style.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge drawRect:withPainter:]):
+        * kwq/qt/qrect.h:
+
 2002-09-06  Maciej Stachowiak  <mjs at apple.com>
 
         Fix another instance of the same problem:
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 4b00d14..1ee73a2 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,60 @@
+2002-09-08  David Hyatt  <hyatt at apple.com>
+
+	Landing the new layer system and turning it on for painting of
+	all types of positioned blocks (and for painting the root
+	and HTML layers as well).
+
+	Event handling is not yet using the new layer system, so you
+	may see oddities like DHTML menus now displaying correctly but
+	events not working (since the event code may still be stacking
+	incorrectly and think the DHTML is behind other content).
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::setStyle):
+        (RenderBox::calcHeight):
+        (RenderBox::calcAbsoluteHorizontal):
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::addChild):
+        (RenderContainer::removeChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        (RenderFlow::printObject):
+        (RenderFlow::printSpecialObjects):
+        (RenderFlow::layout):
+        (RenderFlow::layoutSpecialObjects):
+        (RenderFlow::layoutBlockChildren):
+        (RenderFlow::insertSpecialObject):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_html.cpp:
+        (RenderHtml::layout):
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::printObject):
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::updateLayerPosition):
+        (RenderLayer::enclosingAncestor):
+        (RenderLayer::addChild):
+        (RenderLayer::convertToLayerCoords):
+        (RenderLayer::paint):
+        (RenderLayer::constructZTree):
+        (RenderLayer::RenderZTreeNode::constructLayerList):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_replaced.cpp:
+        (RenderReplaced::print):
+        (RenderWidget::printObject):
+        * khtml/rendering/render_root.cpp:
+        (RenderRoot::calcHeight):
+        (RenderRoot::layout):
+        (RenderRoot::printObject):
+        * khtml/rendering/render_root.h:
+        * khtml/rendering/render_style.cpp:
+        (StyleBoxData::StyleBoxData):
+        (StyleBoxData::operator==):
+        * khtml/rendering/render_style.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge drawRect:withPainter:]):
+        * kwq/qt/qrect.h:
+
 2002-09-06  Maciej Stachowiak  <mjs at apple.com>
 
         Fix another instance of the same problem:
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 51c0eae..0479a49 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -2317,18 +2317,26 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         break;
     case CSS_PROP_Z_INDEX:
     {
-	int z_index = 0;
-        if(value->cssValueType() == CSSValue::CSS_INHERIT)
-       {
+        int z_index = 0;
+        if(value->cssValueType() == CSSValue::CSS_INHERIT) {
             if(!parentNode) return;
             z_index = parentStyle->zIndex();
         } else {
-            if(!primitiveValue ||
-               primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
+            if (!primitiveValue)
                 return;
-	    z_index = (int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
-	}
-        style->setZIndex( z_index );
+
+            if (primitiveValue->getIdent() == CSS_VAL_AUTO) {
+                style->setHasAutoZIndex();
+                return;
+            }
+            
+            if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
+                return; // Error case.
+            
+            z_index = (int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+        }
+        
+        style->setZIndex(z_index);
         return;
     }
 
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index 441d432..a4d25b3 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -80,8 +80,11 @@ void RenderBox::setStyle(RenderStyle *_style)
         if(_style->isFloating()) {
             setFloating(true);
         } else {
-            if(_style->position() == RELATIVE)
+            if(_style->position() == RELATIVE) {
                 setRelPositioned(true);
+                if (!m_layer)
+                    m_layer = new RenderLayer(this);
+            }
         }
     }
 }
@@ -599,8 +602,21 @@ void RenderBox::calcHeight()
             if (h.isFixed())
                 fh = h.value + borderTop() + paddingTop() + borderBottom() + paddingBottom();
             else if (h.isPercent()) {
+                // Handle a common case: nested 100% height <div>s.
+                // This is kind of a one-off hack rather than doing it right.
+                // Makes dbaron's z-index root bg testcases work. Bad dave. - dwh
+                RenderObject* cb = containingBlock();
                 Length ch = containingBlock()->style()->height();
-                if (ch.isFixed())
+                while (cb && !cb->isTableCell() && ch.isPercent() && ch.value == 100) {
+                    cb = cb->containingBlock();
+                    ch = cb->style()->height();
+                }
+
+                if (cb->isRoot()) {
+                    static_cast<RenderRoot*>(cb)->calcHeight();
+                    fh = h.width(cb->height()) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
+                }
+                else if (ch.isFixed())
                     fh = h.width(ch.value) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
             }
             if (fh!=-1)
@@ -876,7 +892,6 @@ void RenderBox::calcAbsoluteHorizontal()
     m_marginLeft = ml;
     m_marginRight = mr;
     m_x = l + ml + containingBlock()->borderLeft();
-
 //    printf("h: w=%d, l=%d, r=%d, ml=%d, mr=%d\n",w,l,r,ml,mr);
 }
 
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index d8df692..05918c2 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -137,9 +137,9 @@ void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild
 
     // Keep our layer hierarchy updated.
     if (newChild->layer()) {
-        RenderObject* ancestor = (newChild->isPositioned()) ? newChild->containingBlock() : this;
-        ancestor->enclosingLayer()->addChild(newChild->layer());
-        ancestor->setHasChildLayers(true);
+        newChild->layer()->enclosingAncestor()->addChild(newChild->layer());
+        if (!newChild->isPositioned())
+            setHasChildLayers(true);
     }
 }
 
@@ -148,11 +148,9 @@ RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
     KHTMLAssert(oldChild->parent() == this);
 
     // Keep our layer hierarchy updated.
-    if (oldChild->layer()) {
-        RenderObject* ancestor = (oldChild->isPositioned()) ? oldChild->containingBlock() : this;
-        ancestor->enclosingLayer()->removeChild(oldChild->layer());
-    }
-    
+    if (oldChild->layer())
+        oldChild->layer()->enclosingAncestor()->removeChild(oldChild->layer());
+   
     // if oldChild is the start or end of the selection, then clear the selection to
     // avoid problems of invalid pointers
 
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index 05a1023..5bcc857 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -70,9 +70,15 @@ void RenderFlow::setStyle(RenderStyle *_style)
 
     RenderBox::setStyle(_style);
 
-    if(isPositioned())
+    if(isPositioned()) {
         setInline(false);
+        if (!m_layer)
+            m_layer = new RenderLayer(this);
+    }
 
+    if (isRelPositioned() && !m_layer)
+        m_layer = new RenderLayer(this);
+    
     if(isFloating() || !style()->display() == INLINE)
         setInline(false);
 
@@ -141,42 +147,35 @@ void RenderFlow::printObject(QPainter *p, int _x, int _y,
 #ifdef DEBUG_LAYOUT
 //    kdDebug( 6040 ) << renderName() << "(RenderFlow) " << this << " ::printObject() w/h = (" << width() << "/" << height() << ")" << endl;
 #endif
-    // add offset for relative positioning
-    if(isRelPositioned())
-        relativePositionOffset(_tx, _ty);
-
-
+    
     // 1. print background, borders etc
     if(hasSpecialObjects() && !isInline() && style()->visibility() == VISIBLE )
         printBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
 
-
     bool clipped = false;
     // overflow: hidden
     if (style()->overflow()==OHIDDEN || style()->jsClipMode() ) {
         calcClip(p, _tx, _ty);
-	clipped = true;
+        clipped = true;
     }
 
-
-
     // 2. print contents
     RenderObject *child = firstChild();
     while(child != 0)
     {
-        if(!child->isFloating() && !child->isPositioned() && !child->isRelPositioned())
+        if(!child->layer() && !child->isFloating())
             child->print(p, _x, _y, _w, _h, _tx, _ty);
         child = child->nextSibling();
     }
 
     // 3. print floats and other non-flow objects
     if(specialObjects)
-	printSpecialObjects( p,  _x, _y, _w, _h, _tx , _ty);
+        printSpecialObjects( p,  _x, _y, _w, _h, _tx , _ty);
 
     // overflow: hidden
     // restore clip region
     if ( clipped ) {
-	p->restore();
+        p->restore();
     }
 
     if(!isInline() && !childrenInline() && style()->outlineWidth())
@@ -202,11 +201,9 @@ void RenderFlow::printSpecialObjects( QPainter *p, int x, int y, int w, int h, i
     for ( ; (r = it.current()); ++it ) {
         // A special object may be registered with several different objects... so we only print the
         // object if we are its containing block
-       if ((r->node->isPositioned() || r->node->isRelPositioned()) && r->node->containingBlock() == this)
-           r->node->print(p, x, y, w, h, tx , ty);
-       else if ( ( r->node->isFloating() && !r->noPaint ) ) {
-	    r->node->print(p, x, y, w, h, tx + r->left - r->node->xPos() + r->node->marginLeft(),
-			   ty + r->startY - r->node->yPos() + r->node->marginTop() );
+        if ( ( r->node->isFloating() && !r->noPaint ) ) {
+           r->node->print(p, x, y, w, h, tx + r->left - r->node->xPos() + r->node->marginLeft(),
+                          ty + r->startY - r->node->yPos() + r->node->marginTop() );
  	}
 #ifdef FLOAT_DEBUG
 	p->save();
@@ -302,6 +299,13 @@ void RenderFlow::layout()
 
     //kdDebug() << renderName() << " layout width=" << m_width << " height=" << m_height << endl;
 
+    RenderLayer* l = layer();
+    if (l) {
+        l->setWidth(m_width);
+        l->setHeight(m_height);
+        l->updateLayerPosition();
+    }
+      
     setLayouted();
 }
 
@@ -314,13 +318,11 @@ void RenderFlow::layoutSpecialObjects( bool relayoutChildren )
         for ( ; (r = it.current()); ++it ) {
             //kdDebug(6040) << "   have a positioned object" << endl;
             if (r->type == SpecialObject::Positioned) {
-		if ( relayoutChildren ) {
-		    r->node->setLayouted( false );
-		}
-		if ( !r->node->layouted() )
-		    r->node->layout();
-	    }
-            // We don't lay out relative positioned objects here.  They get a layout during the normal flow - dwh
+                if ( relayoutChildren )
+                    r->node->setLayouted( false );
+                if ( !r->node->layouted() )
+                    r->node->layout();
+            }
         }
         specialObjects->sort();
     }
@@ -395,27 +397,13 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
 //         kdDebug( 6040 ) << t.elapsed() << endl;
         // ### might be some layouts are done two times... FIX that.
 
-        if (child->isPositioned() || child->isRelPositioned())
+        if (child->isPositioned())
         {
             static_cast<RenderFlow*>(child->containingBlock())->insertSpecialObject(child);
 	    //kdDebug() << "RenderFlow::layoutBlockChildren inserting positioned into " << child->containingBlock()->renderName() << endl;
             
-            // Absolute positioned objects aren't part of the flow, but relative objects are.
-            // Both types of positioned objects have to be painted after all normal flow objects though,
-            // and relative objects can even paint on top of absolute positioned objects if they occur later in
-            // the content model (or have a higher z-index). -dwh
-            //
-            // A simple example:
-            /* <div style="width:317px;height:381px;background-color:red;position: absolute;"></div>
-               <div style="background-color: green; color: white; position: relative; height: 30px;">
-                    This text should be clearly visible.
-               </div> 
-               </div>
-            */
-            if (child->isPositioned()) {
-                child = child->nextSibling();
-                continue;
-            }
+            child = child->nextSibling();
+            continue;
         } else if ( child->isReplaced() ) {
             if ( !child->layouted() )
                 child->layout();
@@ -557,14 +545,10 @@ void RenderFlow::insertSpecialObject(RenderObject *o)
 
     SpecialObject *newObj;
     if (o->isPositioned()) {
-	// positioned object
-	newObj = new SpecialObject(SpecialObject::Positioned);
+        // positioned object
+        newObj = new SpecialObject(SpecialObject::Positioned);
         setOverhangingContents();
     }
-    else if (o->isRelPositioned()) {
-        // relative positioned object.
-        newObj = new SpecialObject(SpecialObject::RelPositioned);
-    }
     else if (o->isFloating()) {
 	// floating object
 	if ( !o->layouted() )
diff --git a/WebCore/khtml/rendering/render_flow.h b/WebCore/khtml/rendering/render_flow.h
index 3d0a054..7c9465a 100644
--- a/WebCore/khtml/rendering/render_flow.h
+++ b/WebCore/khtml/rendering/render_flow.h
@@ -138,9 +138,8 @@ protected:
         enum Type {
             FloatLeft,
             FloatRight,
-            Positioned,
-            RelPositioned
-	};
+            Positioned
+        };
 
         SpecialObject(Type _type) {
 	    node = 0;
diff --git a/WebCore/khtml/rendering/render_html.cpp b/WebCore/khtml/rendering/render_html.cpp
index 9c5056c..551ecab 100644
--- a/WebCore/khtml/rendering/render_html.cpp
+++ b/WebCore/khtml/rendering/render_html.cpp
@@ -121,6 +121,9 @@ void RenderHtml::layout()
     if( m_height + margins < lp )
 	m_height = lp - margins;
 
+    layer()->setHeight(m_height);
+    layer()->setWidth(m_width);
+    
     //kdDebug(0) << "docHeight = " << m_height << endl;
 }
 
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index 3ac0d34..8e1daeb 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -181,10 +181,6 @@ void RenderImage::setPixmap( const QPixmap &p, const QRect& r, CachedImage *o)
 
 void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, int /*_h*/, int _tx, int _ty)
 {
-    // add offset for relative positioning
-    if(isRelPositioned())
-        relativePositionOffset(_tx, _ty);
-
     int cWidth = contentWidth();
     int cHeight = contentHeight();
     int leftBorder = borderLeft();
diff --git a/WebCore/khtml/rendering/render_layer.cpp b/WebCore/khtml/rendering/render_layer.cpp
index 07424a6..12e3077 100644
--- a/WebCore/khtml/rendering/render_layer.cpp
+++ b/WebCore/khtml/rendering/render_layer.cpp
@@ -24,7 +24,7 @@
 #include <kdebug.h>
 #include <assert.h>
 #include "khtmlview.h"
-#include "render_object.h"
+#include "render_box.h"
 
 using namespace DOM;
 using namespace khtml;
@@ -54,28 +54,51 @@ void RenderLayer::updateLayerPosition()
     int x = m_object->xPos();
     int y = m_object->yPos();
 
-    RenderObject* curr = m_object->parent();
-    while (curr && !curr->layer()) {
-        x += curr->xPos();
-        y += curr->yPos();
+    if (!m_object->isPositioned()) {
+        // We must adjust our position by walking up the render tree looking for the
+        // nearest enclosing object with a layer.
+        RenderObject* curr = m_object->parent();
+        while (curr && !curr->layer()) {
+            x += curr->xPos();
+            y += curr->yPos();
+            curr = curr->parent();
+        }
     }
 
+    if (m_object->isRelPositioned())
+        static_cast<RenderBox*>(m_object)->relativePositionOffset(x, y);
+    
     setPos(x,y);
 }
 
-void RenderLayer::addChild(RenderLayer *child, RenderLayer *beforeChild)
+RenderLayer*
+RenderLayer::enclosingAncestor()
 {
-    if (!beforeChild)
-        setLastChild(child);
-        
-    if(beforeChild == firstChild()) // Handles the null case too.
+    RenderObject* o = m_object->parent();
+    if (m_object->isPositioned()) {
+        if (m_object->style()->position() == FIXED) {
+            while (o && o->style()->position() == STATIC && !o->isHtml() && !o->isRoot())
+                o = o->parent();
+        }
+        else
+            o = m_object->containingBlock();
+    }
+    
+    return o->enclosingLayer();
+}
+
+void RenderLayer::addChild(RenderLayer *child)
+{
+    if (!firstChild()) {
         setFirstChild(child);
+        setLastChild(child);
+    } else {
+        RenderLayer* last = lastChild();
+        setLastChild(child);
+        child->setPreviousSibling(last);
+        last->setNextSibling(child);
+    }
 
-    RenderLayer* prev = beforeChild ? beforeChild->previousSibling() : 0;
-    child->setNextSibling(beforeChild);
-    if (beforeChild) beforeChild->setPreviousSibling(child);
-    if(prev) prev->setNextSibling(child);
-    child->setPreviousSibling(prev);
     child->setParent(this);
 }
 
@@ -104,8 +127,17 @@ RenderLayer::convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y)
 {
     x = xPos();
     y = yPos();
-    if (ancestorLayer == this) return;
-    
+    if (ancestorLayer == this)
+        return;
+    if (m_object->style()->position() == FIXED) {
+        // Add in the offset of the view.  We can obtain this by calling
+        // absolutePosition() on the RenderRoot.
+        int xOff, yOff;
+        m_object->absolutePosition(xOff, yOff, true);
+        x += xOff;
+        y += yOff;
+        return;
+    }
     for (RenderLayer* current = parent(); current && current != ancestorLayer;
          current = current->parent()) {
         x += current->xPos();
@@ -113,10 +145,39 @@ RenderLayer::convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y)
     }
 }
 
+void
+RenderLayer::paint(QPainter *p, int x, int y, int w, int h, int tx, int ty)
+{
+    // Create the z-tree of layers that should be displayed.
+    RenderLayer::RenderZTreeNode* node = constructZTree(QRect(x, y, w, h), this);
+    if (!node)
+        return;
+
+    // Flatten the tree into a back-to-front list for painting.
+    QPtrVector<RenderLayer::RenderLayerElement> layerList;
+    constructLayerList(node, &layerList);
+
+    // Walk the list and paint each layer, adding in the appropriate offset.
+    uint count = layerList.count();
+    for (uint i = 0; i < count; i++) {
+        RenderLayer::RenderLayerElement* elt = layerList.at(i);
+
+        // Elements add in their own positions as a translation factor.  This forces
+        // us to subtract that out, so that when it's added back in, we get the right
+        // bounds.  This is really disgusting (that print only sets up the right paint
+        // position after you call into it). -dwh
+        //printf("Painting layer at %d %d\n", elt->absBounds.x(), elt->absBounds.y());
+        
+        elt->layer->renderer()->print(p, x, y, w, h,
+                                      tx + elt->absBounds.x() - elt->layer->renderer()->xPos(),
+                                      ty + elt->absBounds.y() - elt->layer->renderer()->yPos());
+    }
+    delete node;
+}
+
 RenderLayer::RenderZTreeNode*
 RenderLayer::constructZTree(const QRect& damageRect, 
-                            RenderLayer* rootLayer, 
-                            RenderLayer* paintingLayer)
+                            RenderLayer* rootLayer)
 {
     // This variable stores the result we will hand back.
     RenderLayer::RenderZTreeNode* returnNode = 0;
@@ -128,36 +189,35 @@ RenderLayer::constructZTree(const QRect& damageRect,
     
     // Compute this layer's absolute position, so that we can compare it with our
     // damage rect and avoid repainting the layer if it falls outside that rect.
-    // If we have overhanging contents, we can't just bail, since we may need to paint
-    // our child layers (they may fall outside our bounds and therefore might still
-    // intersect the damage rect).
+    // An exception to this rule is the root layer, which always paints (hence the
+    // m_parent null check below).
     int x, y;
     convertToLayerCoords(rootLayer, x, y);
     QRect layerBounds(x, y, width(), height());
-    if (!layerBounds.intersects(damageRect) && !m_object->overhangingContents())
-        return 0;
-    
-    // Compute our coordinates relative to the layer being painted.
-    convertToLayerCoords(paintingLayer, x, y);
-
+     
     returnNode = new RenderLayer::RenderZTreeNode(this);
     
     // Walk our list of child layers looking only for those layers that have a 
     // non-negative z-index (a z-index >= 0).
+    RenderZTreeNode* lastChildNode = 0;
     for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) {
         if (child->zIndex() < 0)
             continue; // Ignore negative z-indices in this first pass.
 
-        RenderZTreeNode* childNode = child->constructZTree(damageRect, rootLayer, paintingLayer);
+        RenderZTreeNode* childNode = child->constructZTree(damageRect, rootLayer);
         if (childNode) {
             // Put the new node into the tree at the front of the parent's list.
-            childNode->next = returnNode->child;
-            returnNode->child = childNode;
+            if (lastChildNode)
+                lastChildNode->next = childNode;
+            else
+                returnNode->child = childNode;
+            lastChildNode = childNode;
         }
     }
 
-    // Now add a leaf node for ourselves, but only if we overlap the damage rect.
-    if (layerBounds.intersects(damageRect)) {
+    // Now add a leaf node for ourselves, but only if we intersect the damage
+    // rect.
+    if (!m_parent || layerBounds.intersects(damageRect)) {
         RenderLayerElement* layerElt = new RenderLayerElement(this, layerBounds, x, y);
         if (returnNode->child) {
             RenderZTreeNode* leaf = new RenderZTreeNode(layerElt);
@@ -173,7 +233,7 @@ RenderLayer::constructZTree(const QRect& damageRect,
         if (child->zIndex() >= 0)
             continue; // Ignore non-negative z-indices in this second pass.
 
-        RenderZTreeNode* childNode = child->constructZTree(damageRect, rootLayer, paintingLayer);
+        RenderZTreeNode* childNode = child->constructZTree(damageRect, rootLayer);
         if (childNode) {
             // Deal with the case where all our children views had negative z-indices.
             // Demote our leaf node and make a new interior node that can hold these
@@ -277,7 +337,10 @@ static void sortByZOrder(QPtrVector<RenderLayer::RenderLayerElement>* buffer,
 void RenderLayer::RenderZTreeNode::constructLayerList(QPtrVector<RenderLayerElement>* mergeTmpBuffer,
                                                       QPtrVector<RenderLayerElement>* buffer)
 {
-    bool autoZIndex = layer->hasAutoZIndex();
+    // The root always establishes a stacking context.  We could add a rule for this
+    // to the UA sheet, but this code guarantees that nobody can do anything wacky
+    // in CSS to prevent the root from establishing a stacking context.
+    bool autoZIndex = layer->parent() ? layer->hasAutoZIndex() : false;
     int explicitZIndex = layer->zIndex();
 
     if (layerElement) {
@@ -285,7 +348,7 @@ void RenderLayer::RenderZTreeNode::constructLayerList(QPtrVector<RenderLayerElem
         // the buffer.
         if (buffer->count() == buffer->size())
             // Resize by a power of 2.
-            buffer->resize(2*buffer->size());
+            buffer->resize(2*(buffer->size()+1));
         
         buffer->insert(buffer->count(), layerElement);
         layerElement->zindex = explicitZIndex;
@@ -293,7 +356,7 @@ void RenderLayer::RenderZTreeNode::constructLayerList(QPtrVector<RenderLayerElem
     }
 
     uint startIndex = buffer->count();
-    for (RenderZTreeNode* current = child; child; child = child->next)
+    for (RenderZTreeNode* current = child; current; current = current->next)
         current->constructLayerList(mergeTmpBuffer, buffer);
     uint endIndex = buffer->count();
 
diff --git a/WebCore/khtml/rendering/render_layer.h b/WebCore/khtml/rendering/render_layer.h
index b14f420..b333337 100644
--- a/WebCore/khtml/rendering/render_layer.h
+++ b/WebCore/khtml/rendering/render_layer.h
@@ -55,24 +55,41 @@ public:
     RenderLayer *firstChild() const { return m_first; }
     RenderLayer *lastChild() const { return m_last; }
 
-    void addChild(RenderLayer *newChild, RenderLayer *beforeChild = 0);
+    void addChild(RenderLayer *newChild);
     RenderLayer* removeChild(RenderLayer *oldChild);
 
+    RenderLayer* root() {
+        RenderLayer* curr = this;
+        while (curr->parent()) curr = curr->parent();
+        return curr;
+    }
+    
     int xPos() const { return m_x; }
     int yPos() const { return m_y; }
     short width() const { return m_width; }
     int height() const { return m_height; }
- 
-    void setWidth( int width ) { m_width = width; }
-    void setHeight( int height ) { m_height = height; }
+
+    void setWidth( int width ) {
+        m_width = width;
+    }
+    void setHeight( int height ) {
+        m_height = height;
+    }
+    void setPos( int xPos, int yPos ) {
+        m_x = xPos;
+        m_y = yPos;
+    }
     
-    void setPos( int xPos, int yPos ) { m_x = xPos; m_y = yPos; }
     void updateLayerPosition();
     
+    RenderLayer* enclosingAncestor();
+    
     void convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y);
     
     bool hasAutoZIndex() { return renderer()->style()->hasAutoZIndex(); }
     int zIndex() { return renderer()->style()->zIndex(); }
+
+    void paint(QPainter *p, int x, int y, int w, int h, int tx, int ty);
     
 public:
     // Z-Index Implementation Notes
@@ -176,8 +193,7 @@ private:
     // +-------> L(L6)
     //
     RenderZTreeNode* constructZTree(const QRect& damageRect, 
-                                    RenderLayer* rootLayer,
-                                    RenderLayer* paintingLayer);
+                                    RenderLayer* rootLayer);
 
     // Once the z-tree has been constructed, we call constructLayerList
     // to produce a flattened layer list for rendering/event handling.
diff --git a/WebCore/khtml/rendering/render_replaced.cpp b/WebCore/khtml/rendering/render_replaced.cpp
index f3566cb..9f42afe 100644
--- a/WebCore/khtml/rendering/render_replaced.cpp
+++ b/WebCore/khtml/rendering/render_replaced.cpp
@@ -59,7 +59,8 @@ void RenderReplaced::print( QPainter *p, int _x, int _y, int _w, int _h,
     _tx += m_x;
     _ty += m_y;
 
-    if((_ty > _y + _h) || (_ty + m_height < _y)) return;
+    if((_ty > _y + _h) || (_ty + m_height < _y))
+        return;
 
     if(hasSpecialObjects()) printBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
 
@@ -241,10 +242,6 @@ void RenderWidget::printObject(QPainter* /*p*/, int, int, int, int, int _tx, int
 	return;
     }
 
-    // add offset for relative positioning
-    if(isRelPositioned())
-	relativePositionOffset(_tx, _ty);
-
     int xPos = _tx+borderLeft()+paddingLeft();
     int yPos = _ty+borderTop()+paddingTop();
 
diff --git a/WebCore/khtml/rendering/render_root.cpp b/WebCore/khtml/rendering/render_root.cpp
index 63f07e0..54f773e 100644
--- a/WebCore/khtml/rendering/render_root.cpp
+++ b/WebCore/khtml/rendering/render_root.cpp
@@ -69,6 +69,18 @@ RenderRoot::~RenderRoot()
 {
 }
 
+void RenderRoot::calcHeight()
+{
+    if (!m_printingMode && m_view)
+    {
+        m_height = m_view->visibleHeight();
+    }
+    else if (!m_view)
+    {
+        m_height = m_rootHeight;
+    }    
+}
+
 void RenderRoot::calcWidth()
 {
     // the width gets set by KHTMLView::print when printing to a printer.
@@ -144,21 +156,24 @@ void RenderRoot::layout()
 
     if (!m_printingMode && m_view)
     {
-       m_height = m_view->visibleHeight();
-       m_width = m_view->visibleWidth();
+        m_height = m_view->visibleHeight();
+        m_width = m_view->visibleWidth();
     }
     else if (!m_view)
     {
         m_height = m_rootHeight;
         m_width = m_rootWidth;
     }
-
+    
     // ### we could maybe do the call below better and only pass true if the docsize changed.
     layoutSpecialObjects( true );
 #ifdef SPEED_DEBUG
     kdDebug() << "RenderRoot::end time used=" << qt.elapsed() << endl;
 #endif
 
+    layer()->setHeight(m_height);
+    layer()->setWidth(m_width);
+    
     setLayouted();
     //kdDebug(0) << "root: height = " << m_height << endl;
 }
@@ -186,10 +201,6 @@ void RenderRoot::printObject(QPainter *p, int _x, int _y,
 #ifdef DEBUG_LAYOUT
     kdDebug( 6040 ) << renderName() << "(RenderFlow) " << this << " ::printObject() w/h = (" << width() << "/" << height() << ")" << endl;
 #endif
-    // add offset for relative positioning
-    if(isRelPositioned())
-        relativePositionOffset(_tx, _ty);
-
     // 1. print background, borders etc
     if(hasSpecialObjects() && !isInline())
         printBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
@@ -197,7 +208,7 @@ void RenderRoot::printObject(QPainter *p, int _x, int _y,
     // 2. print contents
     RenderObject *child = firstChild();
     while(child != 0) {
-        if(!child->isFloating() && !child->isPositioned()) {
+        if(!child->layer() && !child->isFloating()) {
             child->print(p, _x, _y, _w, _h, _tx, _ty);
         }
         child = child->nextSibling();
diff --git a/WebCore/khtml/rendering/render_root.h b/WebCore/khtml/rendering/render_root.h
index 7761e0c..0535011 100644
--- a/WebCore/khtml/rendering/render_root.h
+++ b/WebCore/khtml/rendering/render_root.h
@@ -42,6 +42,7 @@ public:
 
     virtual void layout();
     virtual void calcWidth();
+    virtual void calcHeight();
     virtual void calcMinMaxWidth();
     virtual bool absolutePosition(int &xPos, int&yPos, bool f = false);
     virtual void close();
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index b30f6e8..749d80f 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -56,7 +56,7 @@ StyleBoxData::StyleBoxData(const StyleBoxData& o )
       width( o.width ), height( o.height ),
       min_width( o.min_width ), max_width( o.max_width ),
       min_height ( o.min_height ), max_height( o.max_height ),
-      z_index( o.z_index )
+      z_index( o.z_index ), z_auto( o.z_auto )
 {
 }
 
@@ -69,7 +69,8 @@ bool StyleBoxData::operator==(const StyleBoxData& o) const
 	    max_width == o.max_width &&
 	    min_height == o.min_height &&
 	    max_height == o.max_height &&
-	    z_index == o.z_index;
+	    z_index == o.z_index &&
+        z_auto == o.z_auto;
 }
 
 StyleVisualData::StyleVisualData()
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 5c60321..7e6f7ba 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -882,6 +882,7 @@ public:
     void setFlowAroundFloats(bool b=true) {  noninherited_flags._flowAroundFloats = b; }
 
     bool hasAutoZIndex() { return box->z_auto; }
+    void setHasAutoZIndex() { SET_VAR(box, z_auto, true) }
     int zIndex() const { return box->z_index; }
     void setZIndex(int v) { SET_VAR(box, z_auto, false); SET_VAR(box,z_index,v) }
 
diff --git a/WebCore/kwq/KWQRect.h b/WebCore/kwq/KWQRect.h
index 8ae969b..1154812 100644
--- a/WebCore/kwq/KWQRect.h
+++ b/WebCore/kwq/KWQRect.h
@@ -53,6 +53,8 @@ public:
 
     QPoint topLeft() const;
     QSize size() const;
+    void setX(int x) { xp = x; }
+    void setY(int y) { yp = y; }
     void setWidth(int width) { w = width; }
     void setHeight(int height) { h = height; }
     QRect intersect(const QRect &) const;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 59b9295..8266636 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -216,15 +216,14 @@ using khtml::RenderPart;
 - (void)drawRect:(NSRect)rect withPainter:(QPainter *)p
 {
     RenderObject *renderer = part->impl->renderer();
-        
+
 #ifdef DEBUG_DRAWING
     [[NSColor redColor] set];
     [NSBezierPath fillRect:[part->impl->view()->getView() visibleRect]];
 #endif
 
-    if (renderer) {
-        renderer->print(p, (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height, 0, 0);
-    }
+    if (renderer && renderer->layer())
+        renderer->layer()->paint(p, (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height, 0, 0);
 }
 
 - (void)drawRect:(NSRect)rect
diff --git a/WebCore/kwq/qt/qrect.h b/WebCore/kwq/qt/qrect.h
index 8ae969b..1154812 100644
--- a/WebCore/kwq/qt/qrect.h
+++ b/WebCore/kwq/qt/qrect.h
@@ -53,6 +53,8 @@ public:
 
     QPoint topLeft() const;
     QSize size() const;
+    void setX(int x) { xp = x; }
+    void setY(int y) { yp = y; }
     void setWidth(int width) { w = width; }
     void setHeight(int height) { h = height; }
     QRect intersect(const QRect &) const;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list