[webkit-changes] cvs commit: WebCore/khtml/rendering render_layer.cpp render_layer.h

David hyatt at opensource.apple.com
Mon Oct 17 00:29:23 PDT 2005


hyatt       05/10/17 00:29:22

  Modified:    .        ChangeLog
               khtml/rendering render_layer.cpp render_layer.h
  Log:
  	Fix for bugzilla bug 5283.  Make overflow layers lose to other kinds of
  	layers if z-index is equivalent.  Technically overflow isn't even supposed
  	to establish a stacking context, so the use of RenderLayer for overflow,
  	although elegant and simple, isn't correct.  This patch is essentially a hack
  	to make the common problem go away, but the deeper mistake remains.
  
          Reviewed by eseidel
  
          * khtml/rendering/render_layer.cpp:
          (khtml::RenderLayer::isTransparent):
          (khtml::RenderLayer::paintLayer):
          (khtml::isOverflowOnly):
          (khtml::compare):
          (khtml::sortByZOrder):
          * khtml/rendering/render_layer.h:
  
  Revision  Changes    Path
  1.246     +18 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.245
  retrieving revision 1.246
  diff -u -r1.245 -r1.246
  --- ChangeLog	17 Oct 2005 06:19:59 -0000	1.245
  +++ ChangeLog	17 Oct 2005 07:29:19 -0000	1.246
  @@ -1,3 +1,21 @@
  +2005-10-17  David Hyatt  <hyatt at apple.com>
  +
  +	Fix for bugzilla bug 5283.  Make overflow layers lose to other kinds of
  +	layers if z-index is equivalent.  Technically overflow isn't even supposed
  +	to establish a stacking context, so the use of RenderLayer for overflow,
  +	although elegant and simple, isn't correct.  This patch is essentially a hack
  +	to make the common problem go away, but the deeper mistake remains.
  +	
  +        Reviewed by eseidel
  +
  +        * khtml/rendering/render_layer.cpp:
  +        (khtml::RenderLayer::isTransparent):
  +        (khtml::RenderLayer::paintLayer):
  +        (khtml::isOverflowOnly):
  +        (khtml::compare):
  +        (khtml::sortByZOrder):
  +        * khtml/rendering/render_layer.h:
  +
   2005-10-16  David Hyatt  <hyatt at apple.com>
   
   	Clean up the deletion of anonymous boxes in the render tree.
  
  
  
  1.110     +24 -14    WebCore/khtml/rendering/render_layer.cpp
  
  Index: render_layer.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_layer.cpp,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- render_layer.cpp	13 Oct 2005 22:45:54 -0000	1.109
  +++ render_layer.cpp	17 Oct 2005 07:29:22 -0000	1.110
  @@ -297,9 +297,8 @@
       return curr;
   }
   
  -#if APPLE_CHANGES
   bool
  -RenderLayer::isTransparent()
  +RenderLayer::isTransparent() const
   {
       return m_object->style()->opacity() < 1.0f;
   }
  @@ -327,8 +326,6 @@
       }
   }
   
  -#endif
  -
   void* RenderLayer::operator new(size_t sz, RenderArena* renderArena) throw()
   {
       return renderArena->allocate(sz);
  @@ -882,10 +879,8 @@
       // Ensure our z-order lists are up-to-date.
       updateZOrderLists();
   
  -#if APPLE_CHANGES
       if (isTransparent())
           haveTransparency = true;
  -#endif
   
       // If this layer's renderer is a child of the paintingRoot, we render unconditionally, which
       // is done by passing a nil paintingRoot down to our renderer (as if no paintingRoot was ever set).
  @@ -899,11 +894,9 @@
       // We want to paint our layer, but only if we intersect the damage rect.
       bool shouldPaint = intersectsDamageRect(layerBounds, damageRect);
       if (shouldPaint && !selectionOnly && !damageRect.isEmpty()) {
  -#if APPLE_CHANGES
           // Begin transparency layers lazily now that we know we have to paint something.
           if (haveTransparency)
               beginTransparencyLayers(p);
  -#endif
           
           // Paint our background first, before painting any child layers.
           // Establish the clip used to paint our background.
  @@ -933,11 +926,9 @@
       
       // Now establish the appropriate clip and paint our child RenderObjects.
       if (shouldPaint && !clipRectToApply.isEmpty()) {
  -#if APPLE_CHANGES
           // Begin transparency layers lazily now that we know we have to paint something.
           if (haveTransparency)
               beginTransparencyLayers(p);
  -#endif
   
           // Set up the clip used when painting our children.
           setClip(p, paintDirtyRect, clipRectToApply);
  @@ -973,13 +964,11 @@
           }
       }
       
  -#if APPLE_CHANGES
       // End our transparency layer
       if (isTransparent() && m_usedTransparency) {
           p->endTransparencyLayer();
           m_usedTransparency = false;
       }
  -#endif
   }
   
   bool
  @@ -1323,6 +1312,27 @@
       }
   }
   
  +// Helpers for the sorting of layers by z-index.
  +static inline bool isOverflowOnly(const RenderLayer* layer)
  +{
  +    return layer->renderer()->hasOverflowClip() && 
  +           !layer->renderer()->isPositioned() &&
  +           !layer->renderer()->isRelPositioned() &&
  +           !layer->isTransparent();
  +}
  +
  +static inline bool compare(const RenderLayer* layer1, const RenderLayer* layer2)
  +{
  +    if (layer1->zIndex() == layer2->zIndex())
  +        // Layers that exist solely because of overflow clip do not technically establish a stacking context.
  +        // Our creation of RenderLayers for overflow regions is a convenience but is not really correct.  Overflow
  +        // content should have just painted where it occurred in the document.  Although we can't do that,
  +        // we will at least make sure that overflow layers lose to the other types of layers (positioned, relative positioned
  +        // and opacity).
  +        return isOverflowOnly(layer1) || !isOverflowOnly(layer2);
  +    return layer1->zIndex() < layer2->zIndex();
  +}
  +
   // Sort the buffer from lowest z-index to highest.  The common scenario will have
   // most z-indices equal, so we optimize for that case (i.e., the list will be mostly
   // sorted already).
  @@ -1340,7 +1350,7 @@
               for (uint j = start; j < i; j++) {
                   RenderLayer* elt = buffer->at(j);
                   RenderLayer* elt2 = buffer->at(j+1);
  -                if (elt->zIndex() > elt2->zIndex()) {
  +                if (!compare(elt, elt2)) {
                       sorted = false;
                       buffer->insert(j, elt2);
                       buffer->insert(j+1, elt);
  @@ -1361,7 +1371,7 @@
   
           // Handle the fast common case (of equal z-indices).  The list may already
           // be completely sorted.
  -        if (elt->zIndex() <= elt2->zIndex())
  +        if (compare(elt, elt2))
               return;
   
           // We have to merge sort.  Ensure our merge buffer is big enough to hold
  
  
  
  1.50      +1 -3      WebCore/khtml/rendering/render_layer.h
  
  Index: render_layer.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_layer.h,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- render_layer.h	13 Oct 2005 22:45:55 -0000	1.49
  +++ render_layer.h	17 Oct 2005 07:29:22 -0000	1.50
  @@ -187,11 +187,9 @@
       Marquee* marquee() const { return m_marquee; }
       void suspendMarquees();
   
  -#if APPLE_CHANGES
  -    bool isTransparent();
  +    bool isTransparent() const;
       RenderLayer* transparentAncestor();
       void beginTransparencyLayers(QPainter* p);
  -#endif
       
       RenderLayer* root() {
           RenderLayer* curr = this;
  
  
  



More information about the webkit-changes mailing list