Fix for bug 10179, digg.com scrolls slowly. Improve fixed positioning
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Aug 2006 02:25:43 +0000 (02:25 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Aug 2006 02:25:43 +0000 (02:25 +0000)
        and fixed backgrounds so that a count of them is kept on the FrameView.
        This allows us to switch slow scrolling on and off as these objects come
        and go.

        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::adjustRenderStyle):
        (WebCore::CSSStyleSelector::applyProperty):
        * page/FrameView.cpp:
        (WebCore::FrameViewPrivate::reset):
        (WebCore::FrameView::layout):
        (WebCore::FrameView::useSlowRepaints):
        (WebCore::FrameView::setUseSlowRepaints):
        (WebCore::FrameView::addSlowRepaintObject):
        (WebCore::FrameView::removeSlowRepaintObject):
        * page/FrameView.h:
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::paintBackgroundExtended):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::setStyle):
        * rendering/RenderView.cpp:
        (WebCore::RenderView::paintBoxDecorations):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15722 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/css/cssstyleselector.cpp
WebCore/page/FrameView.cpp
WebCore/page/FrameView.h
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderView.cpp

index ce3e81d14cbe118964d7a60e7be75dff3afbf021..3321a990c662422cea0a04b2bce206a358b18d6c 100644 (file)
@@ -1,3 +1,28 @@
+2006-07-31  David Hyatt  <hyatt@apple.com>
+
+        Fix for bug 10179, digg.com scrolls slowly.  Improve fixed positioning
+        and fixed backgrounds so that a count of them is kept on the FrameView.
+        This allows us to switch slow scrolling on and off as these objects come
+        and go.
+
+        * css/cssstyleselector.cpp:
+        (WebCore::CSSStyleSelector::adjustRenderStyle):
+        (WebCore::CSSStyleSelector::applyProperty):
+        * page/FrameView.cpp:
+        (WebCore::FrameViewPrivate::reset):
+        (WebCore::FrameView::layout):
+        (WebCore::FrameView::useSlowRepaints):
+        (WebCore::FrameView::setUseSlowRepaints):
+        (WebCore::FrameView::addSlowRepaintObject):
+        (WebCore::FrameView::removeSlowRepaintObject):
+        * page/FrameView.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintBackgroundExtended):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::setStyle):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::paintBoxDecorations):
+
 2006-07-31  David Hyatt  <hyatt@apple.com>
 
         Begin disentangling of scrollbar logic in preparation for engine-implemented
index 7f054bca5ac0f4b9cb54cbfe450ba1c4d70b649b..ec429c9d425627b459acbfb185eb17890298ac5e 100644 (file)
@@ -1086,12 +1086,6 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
         else
             theme()->adjustStyle(this, style, e);
     }
-
-    // Only use slow repaints if we actually have a background image.
-    // FIXME: We only need to invalidate the fixed regions when scrolling.  It's total overkill to
-    // prevent the entire view from blitting on a scroll.
-    if (style->hasFixedBackgroundImage() && view)
-        view->useSlowRepaints();
 }
 
 void CSSStyleSelector::updateFont()
@@ -2211,18 +2205,17 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         switch(primitiveValue->getIdent())
         {
         case CSS_VAL_STATIC:
-            p = StaticPosition; break;
+            p = StaticPosition;
+            break;
         case CSS_VAL_RELATIVE:
-            p = RelativePosition; break;
+            p = RelativePosition;
+            break;
         case CSS_VAL_ABSOLUTE:
-            p = AbsolutePosition; break;
+            p = AbsolutePosition;
+            break;
         case CSS_VAL_FIXED:
-            {
-                if (view)
-                    view->useSlowRepaints();
-                p = FixedPosition;
-                break;
-            }
+            p = FixedPosition;
+            break;
         default:
             return;
         }
index b96ac7938d22479a83fc286b2a5ce840d4c75a6d..b50bf765dd3b16e9971be6ded210b7525c6a3dbd 100644 (file)
@@ -89,6 +89,7 @@ public:
         oldSubframe = 0;
         linkPressed = false;
         useSlowRepaints = false;
+        slowRepaintObjectCount = 0;
         dragTarget = 0;
         borderTouched = false;
         scrollBarMoved = false;
@@ -127,6 +128,7 @@ public:
     ScrollBarMode hmode;
     bool linkPressed;
     bool useSlowRepaints;
+    unsigned slowRepaintObjectCount;
     bool ignoreWheelEvents;
 
     int borderX, borderY;
@@ -512,7 +514,7 @@ void FrameView::layout(bool allowSubtree)
         scheduleRelayout();
         return;
     }
-    setStaticBackground(d->useSlowRepaints);
+    setStaticBackground(useSlowRepaints());
 
     if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
         updateOverflowStatus(visibleWidth() < contentsWidth(),
@@ -1019,12 +1021,31 @@ String FrameView::mediaType() const
     return d->m_mediaType;
 }
 
-void FrameView::useSlowRepaints()
+bool FrameView::useSlowRepaints() const
+{
+    return d->useSlowRepaints || d->slowRepaintObjectCount > 0;
+}
+
+void FrameView::setUseSlowRepaints()
 {
     d->useSlowRepaints = true;
     setStaticBackground(true);
 }
 
+void FrameView::addSlowRepaintObject()
+{
+    if (d->slowRepaintObjectCount == 0)
+        setStaticBackground(true);
+    d->slowRepaintObjectCount++;
+}
+
+void FrameView::removeSlowRepaintObject()
+{
+    d->slowRepaintObjectCount--;
+    if (d->slowRepaintObjectCount == 0)
+        setStaticBackground(d->useSlowRepaints);
+}
+
 void FrameView::setScrollBarsMode(ScrollBarMode mode)
 {
     d->vmode = mode;
index 17ccf4018b029f3a8730fcbb4c0d237c690524a5..e622f253f9913f179c567efcd7044c51c3aca56d 100644 (file)
@@ -207,7 +207,10 @@ private:
 
     void focusNextPrevNode(bool next);
 
-    void useSlowRepaints();
+    bool useSlowRepaints() const;
+    void setUseSlowRepaints();
+    void addSlowRepaintObject();
+    void removeSlowRepaintObject();
 
     void setIgnoreWheelEvents(bool e);
 
index 986b79258f13dcf5a484bfea31c0024ad5b2dc2c..bc6bed4e8655b7b9c789e1d28ef442992a3b4649 100644 (file)
@@ -499,7 +499,7 @@ void RenderBox::paintBackgroundExtended(GraphicsContext* p, const Color& c, cons
             isTransparent = view()->frameView()->isTransparent();
         
         if (isTransparent)
-            view()->frameView()->useSlowRepaints(); // The parent must show behind the child.
+            view()->frameView()->setUseSlowRepaints(); // The parent must show behind the child.
         else
             bgColor = Color::white;
     }
index 785d774c9f5728d448c57cab4c123805c3780fdb..7efa4ccb21838e20d37126db330fda73719791bd 100644 (file)
@@ -2128,6 +2128,19 @@ void RenderObject::setStyle(RenderStyle *style)
         m_hasOverflowClip = false;
     }
 
+    if (view()->frameView()) {
+        // FIXME: A better solution would be to only invalidate the fixed regions when scrolling.  It's overkill to
+        // prevent the entire view from blitting on a scroll.
+        bool oldStyleSlowScroll = style && (style->position() == FixedPosition || style->hasFixedBackgroundImage());
+        bool newStyleSlowScroll = m_style && (m_style->position() == FixedPosition || m_style->hasFixedBackgroundImage());
+        if (oldStyleSlowScroll != newStyleSlowScroll) {
+            if (oldStyleSlowScroll)
+                view()->frameView()->removeSlowRepaintObject();
+            if (newStyleSlowScroll)
+                view()->frameView()->addSlowRepaintObject();
+        }
+    }
+
     RenderStyle *oldStyle = m_style;
     m_style = style;
 
index 88d00ec35f70f33ff041199c21668033a98bff8f..8306c9f377620c2ed01b4bb47baa6a5f3e305aba 100644 (file)
@@ -188,7 +188,7 @@ void RenderView::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
     if (view() && elt) {
         RenderLayer* layer = elt->renderer()->enclosingLayer();
         if (layer->isTransparent() || layer->transparentAncestor())
-            frameView()->useSlowRepaints();
+            frameView()->setUseSlowRepaints();
     }
     
     if ((firstChild() && firstChild()->style()->visibility() == VISIBLE) || !view())
@@ -198,7 +198,7 @@ void RenderView::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
     // Only fill with white if we're the root document, since iframes/frames with
     // no background in the child document should show the parent's background.
     if (elt || view()->isTransparent())
-        frameView()->useSlowRepaints(); // The parent must show behind the child.
+        frameView()->setUseSlowRepaints(); // The parent must show behind the child.
     else
         i.p->fillRect(i.r, Color(Color::white));
 }