[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:38:24 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c206f008698e098d36f61e5959322d332a52507b
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 12 01:01:03 2002 +0000

    	Fix clipping to work with layers.  This fixes the marquee
    	(once again) on livepage.apple.com.
    
            * khtml/rendering/render_box.cpp:
            (RenderBox::getClipRect):
            * khtml/rendering/render_box.h:
            * khtml/rendering/render_container.cpp:
            (RenderContainer::addChild):
            (RenderContainer::removeChildNode):
            * khtml/rendering/render_flow.cpp:
            (RenderFlow::setStyle):
            (RenderFlow::printObject):
            * khtml/rendering/render_layer.cpp:
            (RenderLayer::enclosingPositionedAncestor):
            (RenderLayer::convertToLayerCoords):
            (RenderLayer::paint):
            (RenderLayer::constructZTree):
            * khtml/rendering/render_layer.h:
            * khtml/rendering/render_object.h:
            * khtml/rendering/render_replaced.cpp:
            (RenderReplaced::print):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2042 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 359582d..7632ea1 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,27 @@
+2002-09-11  David Hyatt  <hyatt at apple.com>
+
+	Fix clipping to work with layers.  This fixes the marquee
+	(once again) on livepage.apple.com.
+	
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::getClipRect):
+        * khtml/rendering/render_box.h:
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::addChild):
+        (RenderContainer::removeChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        (RenderFlow::printObject):
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::enclosingPositionedAncestor):
+        (RenderLayer::convertToLayerCoords):
+        (RenderLayer::paint):
+        (RenderLayer::constructZTree):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_replaced.cpp:
+        (RenderReplaced::print):
+
 2002-09-11  Darin Adler  <darin at apple.com>
 
         * kwq/KWQAssertions.h: Updated copy of the assertions macros (made by script).
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 359582d..7632ea1 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,27 @@
+2002-09-11  David Hyatt  <hyatt at apple.com>
+
+	Fix clipping to work with layers.  This fixes the marquee
+	(once again) on livepage.apple.com.
+	
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::getClipRect):
+        * khtml/rendering/render_box.h:
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::addChild):
+        (RenderContainer::removeChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        (RenderFlow::printObject):
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::enclosingPositionedAncestor):
+        (RenderLayer::convertToLayerCoords):
+        (RenderLayer::paint):
+        (RenderLayer::constructZTree):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_replaced.cpp:
+        (RenderReplaced::print):
+
 2002-09-11  Darin Adler  <darin at apple.com>
 
         * kwq/KWQAssertions.h: Updated copy of the assertions macros (made by script).
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 359582d..7632ea1 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,27 @@
+2002-09-11  David Hyatt  <hyatt at apple.com>
+
+	Fix clipping to work with layers.  This fixes the marquee
+	(once again) on livepage.apple.com.
+	
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::getClipRect):
+        * khtml/rendering/render_box.h:
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::addChild):
+        (RenderContainer::removeChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        (RenderFlow::printObject):
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::enclosingPositionedAncestor):
+        (RenderLayer::convertToLayerCoords):
+        (RenderLayer::paint):
+        (RenderLayer::constructZTree):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_replaced.cpp:
+        (RenderReplaced::print):
+
 2002-09-11  Darin Adler  <darin at apple.com>
 
         * kwq/KWQAssertions.h: Updated copy of the assertions macros (made by script).
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index b027ec1..d1a2ee7 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -311,7 +311,7 @@ void RenderBox::outlineBox(QPainter *p, int _tx, int _ty, const char *color)
 }
 
 
-void RenderBox::calcClip(QPainter* p, int tx, int ty)
+QRect RenderBox::getClipRect(int tx, int ty)
 {
     int bl=borderLeft(),bt=borderTop(),bb=borderBottom(),br=borderRight();
     int clipx = tx+bl;
@@ -344,19 +344,7 @@ void RenderBox::calcClip(QPainter* p, int tx, int ty)
     //kdDebug( 6040 ) << "setting clip("<<clipx<<","<<clipy<<","<<clipw<<","<<cliph<<")"<<endl;
 
     QRect cr(clipx,clipy,clipw,cliph);
-    cr = p->xForm(cr);
-#if APPLE_CHANGES
-    p->save();
-    p->addClip(cr);
-#else
-    QRegion creg(cr);
-    QRegion old = p->clipRegion();
-    if (!old.isNull())
-        creg = old.intersect(creg);
-
-    p->save();
-    p->setClipRegion(creg);
-#endif
+    return cr;
 }
 
 void RenderBox::close()
diff --git a/WebCore/khtml/rendering/render_box.h b/WebCore/khtml/rendering/render_box.h
index 6180ef7..5e76358 100644
--- a/WebCore/khtml/rendering/render_box.h
+++ b/WebCore/khtml/rendering/render_box.h
@@ -126,7 +126,7 @@ protected:
     void calcAbsoluteHorizontal();
     void calcAbsoluteVertical();
 
-    void calcClip(QPainter* p, int tx, int ty);
+    virtual QRect getClipRect(int tx, int ty);
 
     // the actual height of the contents + borders + padding
     int m_height;
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index 05918c2..ad5bd12 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -137,7 +137,7 @@ void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild
 
     // Keep our layer hierarchy updated.
     if (newChild->layer()) {
-        newChild->layer()->enclosingAncestor()->addChild(newChild->layer());
+        enclosingLayer()->addChild(newChild->layer());
         if (!newChild->isPositioned())
             setHasChildLayers(true);
     }
@@ -149,7 +149,7 @@ RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
 
     // Keep our layer hierarchy updated.
     if (oldChild->layer())
-        oldChild->layer()->enclosingAncestor()->removeChild(oldChild->layer());
+        enclosingLayer()->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 16b8ca9..d43b523 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -70,13 +70,10 @@ 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)
+    
+    if ((isPositioned() || isRelPositioned() || style()->overflow()==OHIDDEN) && !m_layer)
         m_layer = new RenderLayer(this);
     
     if(isFloating() || !style()->display() == INLINE)
@@ -152,13 +149,6 @@ void RenderFlow::printObject(QPainter *p, int _x, int _y,
     if(hasSpecialObjects() && !isInline() && style()->visibility() == VISIBLE )
         printBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
 
-    bool clipped = false;
-    // overflow: hidden
-    if (style()->overflow()==OHIDDEN || (isPositioned() && style()->hasClip())) {
-        calcClip(p, _tx, _ty);
-        clipped = true;
-    }
-
     // 2. print contents
     RenderObject *child = firstChild();
     while(child != 0)
@@ -172,12 +162,6 @@ void RenderFlow::printObject(QPainter *p, int _x, int _y,
     if(specialObjects)
         printSpecialObjects( p,  _x, _y, _w, _h, _tx , _ty);
 
-    // overflow: hidden
-    // restore clip region
-    if ( clipped ) {
-        p->restore();
-    }
-
     if(!isInline() && !childrenInline() && style()->outlineWidth())
         printOutline(p, _tx, _ty, width(), height(), style());
 
diff --git a/WebCore/khtml/rendering/render_layer.cpp b/WebCore/khtml/rendering/render_layer.cpp
index e0bef16..ea3c270 100644
--- a/WebCore/khtml/rendering/render_layer.cpp
+++ b/WebCore/khtml/rendering/render_layer.cpp
@@ -72,19 +72,14 @@ void RenderLayer::updateLayerPosition()
 }
 
 RenderLayer*
-RenderLayer::enclosingAncestor()
+RenderLayer::enclosingPositionedAncestor()
 {
-    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();
+    RenderLayer* curr = parent();
+    for ( ; curr && !curr->m_object->isRoot() && !curr->m_object->isHtml() &&
+         !curr->m_object->isPositioned() && !curr->m_object->isRelPositioned();
+         curr = curr->parent());
+         
+    return curr;
 }
 
 void RenderLayer::addChild(RenderLayer *child)
@@ -125,10 +120,9 @@ RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild)
 void 
 RenderLayer::convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y)
 {
-    x = xPos();
-    y = yPos();
     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.
@@ -138,11 +132,19 @@ RenderLayer::convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y)
         y += yOff;
         return;
     }
-    for (RenderLayer* current = parent(); current && current != ancestorLayer;
-         current = current->parent()) {
-        x += current->xPos();
-        y += current->yPos();
-    }
+ 
+    RenderLayer* parentLayer;
+    if (m_object->style()->position() == ABSOLUTE)
+        parentLayer = enclosingPositionedAncestor();
+    else
+        parentLayer = parent();
+    
+    if (!parentLayer) return;
+    
+    parentLayer->convertToLayerCoords(ancestorLayer, x, y);
+
+    x += xPos();
+    y += yPos();
 }
 
 void
@@ -158,6 +160,9 @@ RenderLayer::paint(QPainter *p, int x, int y, int w, int h)
     constructLayerList(node, &layerList);
 
     // Walk the list and paint each layer, adding in the appropriate offset.
+    QRect paintRect(x, y, w, h);
+    QRect currRect(paintRect);
+    
     uint count = layerList.count();
     for (uint i = 0; i < count; i++) {
         RenderLayer::RenderLayerElement* elt = layerList.at(i);
@@ -167,11 +172,36 @@ RenderLayer::paint(QPainter *p, int x, int y, int w, int h)
         // 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());
+    
+        if (elt->clipRect != currRect) {
+            if (currRect != paintRect)
+                p->restore(); // Pop the clip.
+            currRect = elt->clipRect;
+            if (currRect != paintRect) {
+                QRect clippedRect = p->xForm(currRect);
+#if APPLE_CHANGES
+                p->save();
+                p->addClip(clippedRect);
+#else
+                QRegion creg(cr);
+                QRegion old = p->clipRegion();
+                if (!old.isNull())
+                    creg = old.intersect(creg);
+            
+                p->save();
+                p->setClipRegion(creg);
+#endif
+            }
+        }
         
         elt->layer->renderer()->print(p, x, y, w, h,
                                       elt->absBounds.x() - elt->layer->renderer()->xPos(),
                                       elt->absBounds.y() - elt->layer->renderer()->yPos());
     }
+    
+    if (currRect != paintRect)
+        p->restore(); // Pop the clip.
+        
     delete node;
 }
 
@@ -210,7 +240,7 @@ RenderLayer::nodeAtPoint(RenderObject::NodeInfo& info, int x, int y)
 }
 
 RenderLayer::RenderZTreeNode*
-RenderLayer::constructZTree(const QRect& damageRect, 
+RenderLayer::constructZTree(QRect damageRect, 
                             RenderLayer* rootLayer,
                             bool eventProcessing)
 {
@@ -226,11 +256,21 @@ RenderLayer::constructZTree(const QRect& damageRect,
     // damage rect and avoid repainting the layer if it falls outside that rect.
     // An exception to this rule is the root layer, which always paints (hence the
     // m_parent null check below).
-    int x, y;
+    int x = 0;
+    int y = 0;
     convertToLayerCoords(rootLayer, x, y);
     QRect layerBounds(x, y, width(), height());
      
     returnNode = new RenderLayer::RenderZTreeNode(this);
+
+    // If we establish a clip rect, then we want to intersect that rect
+    // with the damage rect to form a new damage rect.
+    if (m_object->style()->overflow() == OHIDDEN || m_object->style()->hasClip()) {
+        QRect clipRect = m_object->getClipRect(x, y);
+        if (!clipRect.intersects(damageRect))
+            return 0; // We don't overlap at all. 
+        damageRect = damageRect.intersect(clipRect);
+    }
     
     // Walk our list of child layers looking only for those layers that have a 
     // non-negative z-index (a z-index >= 0).
@@ -258,7 +298,8 @@ RenderLayer::constructZTree(const QRect& damageRect,
     if (!m_parent || (renderer()->isInline() && !renderer()->isReplaced()) ||
         (eventProcessing && layerBounds.contains(x,y)) ||
         (!eventProcessing && layerBounds.intersects(damageRect))) {
-        RenderLayerElement* layerElt = new RenderLayerElement(this, layerBounds, x, y);
+        RenderLayerElement* layerElt = new RenderLayerElement(this, layerBounds, 
+                                                              damageRect, x, y);
         if (returnNode->child) {
             RenderZTreeNode* leaf = new RenderZTreeNode(layerElt);
             leaf->next = returnNode->child;
diff --git a/WebCore/khtml/rendering/render_layer.h b/WebCore/khtml/rendering/render_layer.h
index 6cb8b57..111e352 100644
--- a/WebCore/khtml/rendering/render_layer.h
+++ b/WebCore/khtml/rendering/render_layer.h
@@ -82,7 +82,9 @@ public:
     
     void updateLayerPosition();
     
-    RenderLayer* enclosingAncestor();
+    // Gets the nearest enclosing positioned ancestor layer (also includes
+    // the <html> layer and the root layer).
+    RenderLayer* enclosingPositionedAncestor();
     
     void convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y);
     
@@ -121,14 +123,15 @@ public:
     struct RenderLayerElement {
       RenderLayer* layer;
       QRect absBounds; // Our bounds in absolute coordinates relative to the root.
+      QRect clipRect; // Our clip rect.
       int zindex; // Temporary z-index used for processing and sorting.
       bool zauto; // Whether or not we are using auto z-indexing.
       int x; // The coords relative to the layer that will be using this list
              // to paint.
       int y;
 
-      RenderLayerElement(RenderLayer* l, const QRect& rect, int xpos, int ypos)
-          :layer(l), absBounds(rect), zindex(l->zIndex()), zauto(l->hasAutoZIndex()),
+      RenderLayerElement(RenderLayer* l, const QRect& rect, const QRect& clip, int xpos, int ypos)
+          :layer(l), absBounds(rect), clipRect(clip), zindex(l->zIndex()), zauto(l->hasAutoZIndex()),
           x(xpos), y(ypos) {}
     };
 
@@ -197,7 +200,7 @@ private:
     // +-------> L(L5)
     // +-------> L(L6)
     //
-    RenderZTreeNode* constructZTree(const QRect& damageRect, 
+    RenderZTreeNode* constructZTree(QRect damageRect, 
                                     RenderLayer* rootLayer,
                                     bool eventProcessing = false);
 
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index eabe71c..436585c 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -91,6 +91,8 @@ public:
     virtual void setHasChildLayers(bool hasLayers) { }
     virtual void positionChildLayers() { }
     
+    virtual QRect getClipRect(int tx, int ty) { return QRect(0,0,0,0); }
+    
     // RenderObject tree manipulation
     //////////////////////////////////////////
     virtual void addChild(RenderObject *newChild, RenderObject *beforeChild = 0);
diff --git a/WebCore/khtml/rendering/render_replaced.cpp b/WebCore/khtml/rendering/render_replaced.cpp
index 9683f23..e0d3c93 100644
--- a/WebCore/khtml/rendering/render_replaced.cpp
+++ b/WebCore/khtml/rendering/render_replaced.cpp
@@ -64,20 +64,7 @@ void RenderReplaced::print( QPainter *p, int _x, int _y, int _w, int _h,
 
     if(hasSpecialObjects()) printBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
 
-    // overflow: hidden
-    bool clipped = false;
-    if (style()->overflow()==OHIDDEN) {
-        calcClip(p, _tx, _ty);
-	clipped = true;
-    }
-
     printObject(p, _x, _y, _w, _h, _tx, _ty);
-
-    // overflow: hidden
-    // restore clip region
-    if ( clipped ) {
-	p->restore();
-    }
 }
 
 void RenderReplaced::calcMinMaxWidth()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list