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

David hyatt at opensource.apple.com
Mon Nov 7 15:24:20 PST 2005


hyatt       05/11/07 15:24:20

  Modified:    .        ChangeLog
               khtml/rendering render_object.cpp render_object.h
  Log:
  	Fix for sluggish loading of large pages due to excessive
  	repaints.  Large pages still need a lot of work while
  	loading, but this helps.
  
          Reviewed by darin
  
          * khtml/rendering/render_object.cpp:
          (RenderObject::mustRepaintBackgroundOrBorder):
          (RenderObject::repaintAfterLayoutIfNeeded):
          * khtml/rendering/render_object.h:
  
  Revision  Changes    Path
  1.344     +13 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.343
  retrieving revision 1.344
  diff -u -r1.343 -r1.344
  --- ChangeLog	7 Nov 2005 22:30:17 -0000	1.343
  +++ ChangeLog	7 Nov 2005 23:24:15 -0000	1.344
  @@ -1,3 +1,16 @@
  +2005-11-07  David Hyatt  <hyatt at apple.com>
  +
  +	Fix for sluggish loading of large pages due to excessive
  +	repaints.  Large pages still need a lot of work while
  +	loading, but this helps.
  +	
  +        Reviewed by darin
  +
  +        * khtml/rendering/render_object.cpp:
  +        (RenderObject::mustRepaintBackgroundOrBorder):
  +        (RenderObject::repaintAfterLayoutIfNeeded):
  +        * khtml/rendering/render_object.h:
  +
   2005-11-07  Antti Koivisto  <koivisto at iki.fi>
   
           Reviewed by Darin Adler.
  
  
  
  1.225     +60 -6     WebCore/khtml/rendering/render_object.cpp
  
  Index: render_object.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_object.cpp,v
  retrieving revision 1.224
  retrieving revision 1.225
  diff -u -r1.224 -r1.225
  --- render_object.cpp	2 Nov 2005 08:52:45 -0000	1.224
  +++ render_object.cpp	7 Nov 2005 23:24:19 -0000	1.225
  @@ -751,6 +751,39 @@
       return containingBlock()->contentHeight();
   }
   
  +bool RenderObject::mustRepaintBackgroundOrBorder() const
  +{
  +    // If we don't have a background/border, then nothing to do.
  +    if (!shouldPaintBackgroundOrBorder())
  +        return false;
  +    
  +    // Ok, let's check the background first.
  +    const BackgroundLayer* bgLayer = style()->backgroundLayers();
  +    if (bgLayer->next())
  +        return true; // Nobody will use multiple background layers without wanting fancy positioning.
  +    
  +    // Make sure we have a valid background image.
  +    CachedImage* bg = bgLayer->backgroundImage();
  +    bool shouldPaintBackgroundImage = bg && bg->pixmap_size() == bg->valid_rect().size() && !bg->isTransparent() && !bg->isErrorImage();
  +    
  +    // These are always percents or auto.
  +    if (shouldPaintBackgroundImage && 
  +        (bgLayer->backgroundXPosition().length() != 0 || bgLayer->backgroundYPosition().length() != 0))
  +        return true; // The background image will shift unpredictably if the size changes.
  +        
  +    // Background is ok.  Let's check border.
  +    if (style()->hasBorder()) {
  +        // Border images are not ok.
  +        CachedImage* borderImage = style()->borderImage().image();
  +        bool shouldPaintBorderImage = borderImage && borderImage->pixmap_size() == borderImage->valid_rect().size() && 
  +                                      !borderImage->isTransparent() && !borderImage->isErrorImage();
  +        if (shouldPaintBorderImage && borderImage->isLoaded())
  +            return true; // If the image hasn't loaded, we're still using the normal border style.
  +    }
  +
  +    return false;
  +}
  +
   void RenderObject::drawBorder(QPainter *p, int x1, int y1, int x2, int y2,
                                 BorderSide s, QColor c, const QColor& textcolor, EBorderStyle style,
                                 int adjbw1, int adjbw2, bool invalidisInvert)
  @@ -1388,18 +1421,39 @@
   
   bool RenderObject::repaintAfterLayoutIfNeeded(const QRect& oldBounds, const QRect& oldFullBounds)
   {
  +    RenderCanvas* c = canvas();
  +    if (c->printingMode())
  +        return false; // Don't repaint if we're printing.
  +            
       QRect newBounds, newFullBounds;
       getAbsoluteRepaintRectIncludingFloats(newBounds, newFullBounds);
  -    if (newBounds != oldBounds || selfNeedsLayout()) {
  -        RenderCanvas* c = canvas();
  -        if (c->printingMode())
  -            return false; // Don't repaint if we're printing.
  +    if (newBounds == oldBounds && !selfNeedsLayout())
  +        return false;
  +
  +    bool fullRepaint = selfNeedsLayout() || newBounds.x() != oldBounds.x() ||
  +                       newBounds.y() != oldBounds.y() || 
  +                       mustRepaintBackgroundOrBorder();
  +    if (fullRepaint) {
           c->repaintViewRectangle(oldFullBounds);
           if (newBounds != oldBounds)
               c->repaintViewRectangle(newFullBounds);
  -        return true;
  +    } else {
  +        // We didn't move, but we did change size.  Invalidate the delta, which will consist of possibly 
  +        // two rectangles (but typically only one).
  +        int width = abs(newBounds.width() - oldBounds.width());
  +        if (width)
  +            c->repaintViewRectangle(QRect(kMin(newBounds.x() + newBounds.width(), oldBounds.x() + oldBounds.width()),
  +                                    newBounds.y(), 
  +                                    width,
  +                                    kMax(newBounds.height(), oldBounds.height())));
  +        int height = abs(newBounds.height() - oldBounds.height());
  +        if (height)
  +            c->repaintViewRectangle(QRect(newBounds.x(),
  +                                          kMin(newBounds.y() + newBounds.height(), oldBounds.y() + oldBounds.height()),
  +                                          kMax(newBounds.width(), oldBounds.width()),
  +                                          height));
       }
  -    return false;
  +    return true;
   }
   
   void RenderObject::repaintDuringLayoutIfMoved(int x, int y)
  
  
  
  1.165     +1 -0      WebCore/khtml/rendering/render_object.h
  
  Index: render_object.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_object.h,v
  retrieving revision 1.164
  retrieving revision 1.165
  diff -u -r1.164 -r1.165
  --- render_object.h	19 Oct 2005 09:15:14 -0000	1.164
  +++ render_object.h	7 Nov 2005 23:24:19 -0000	1.165
  @@ -298,6 +298,7 @@
       bool isDragging() const;
       bool isReplaced() const { return m_replaced; } // a "replaced" element (see CSS)
       bool shouldPaintBackgroundOrBorder() const { return m_paintBackground; }
  +    bool mustRepaintBackgroundOrBorder() const;
       bool needsLayout() const   { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout; }
       bool selfNeedsLayout() const { return m_needsLayout; }
       bool posChildNeedsLayout() const { return m_posChildNeedsLayout; }
  
  
  



More information about the webkit-changes mailing list