fix wrong clipping of overflow scroll acceleration
authoryounghwan cho <yhwan.cho@samsung.com>
Fri, 26 Apr 2013 08:41:55 +0000 (17:41 +0900)
committerHeejin Chung <heejin.r.chung@samsung.com>
Wed, 8 May 2013 05:12:48 +0000 (14:12 +0900)
[Title] fix wrong clipping of overflow scroll acceleration
[Issue#] ORANGE-271
[Problem] orange-cineday : in film detailed view the offscreen UI elements don't seem be redered properly eg "notes presse"
[Cause] all the parent layer's clip goes to the child
[Solution] apply the partial patch of "https://bugs.webkit.org/show_bug.cgi?id=91117" to ignore wrong overflow clip

Change-Id: I61429e132a7bbb270459877a52c24a55c0ba9fcf

Source/WTF/wtf/Platform.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h

index e33de84..8e72f9e 100644 (file)
@@ -745,6 +745,9 @@ com) : Patch to do not adjust cover rect as fixed pixel size*/
 #define ENABLE_TIZEN_EVAS_GL_DIRECT_RENDERING 1 /* Hyowon Kim(hw1008.kim@samsung.com) */
 #if ENABLE(OVERFLOW_SCROLLING)
 #define ENABLE_TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION 1 /* ChangSeok Oh(midow.oh@samsung.com) : Accelerated CSS overflow:scroll elements */
+#if ENABLE (TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
+#define ENABLE_TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING 1 /* Younghwan Cho (yhwan.cho@samsung.com) : patch for wrong clipping from 'Bug 91117 - Add support for compositing the contents of overflow:scroll areas', test-code */
+#endif
 #define ENABLE_TIZEN_INPUT_BOX_SCROLL 1 /* Prathmesh Manurkar(prathmesh.m@samsung.com) : Added for scrolling contents of input box */
 #endif
 #if ENABLE(TIZEN_WEBKIT2)
index e949980..9de8b33 100755 (executable)
@@ -3056,7 +3056,12 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* context,
         // Make sure the parent's clip rects have been calculated.
         ClipRect clipRect = paintDirtyRect;
         if (parent()) {
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+            clipRect = backgroundClipRect(rootLayer, region, (paintFlags & PaintLayerTemporaryClipRects) ? TemporaryClipRects : PaintingClipRects,
+                IgnoreOverlayScrollbarSize, (paintFlags & PaintLayerPaintingOverflowContents) ? IgnoreOverflowClip : RespectOverflowClip);
+#else
             clipRect = backgroundClipRect(rootLayer, region, (paintFlags & PaintLayerTemporaryClipRects) ? TemporaryClipRects : PaintingClipRects);
+#endif
             clipRect.intersect(paintDirtyRect);
         
             // Push the parent coordinate space's clip.
@@ -3183,8 +3188,12 @@ void RenderLayer::paintLayerContents(RenderLayer* rootLayer, GraphicsContext* co
     if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
         calculateRects(rootLayer, region, (localPaintFlags & PaintLayerTemporaryClipRects) ? TemporaryClipRects : PaintingClipRects, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+            , IgnoreOverlayScrollbarSize, localPaintFlags & PaintLayerPaintingOverflowContents ? IgnoreOverflowClip : RespectOverflowClip
+#else
             , IgnoreOverlayScrollbarSize, paintFlags & PaintLayerPaintingOverflowContents
 #endif
+#endif
             );
         paintOffset = toPoint(layerBounds.location() - renderBoxLocation());
     }
@@ -3204,6 +3213,9 @@ void RenderLayer::paintLayerContents(RenderLayer* rootLayer, GraphicsContext* co
         performOverlapTests(*overlapTestRequests, rootLayer, this);
 
     // We want to paint our layer, but only if we intersect the damage rect.
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    if (this != rootLayer || !(localPaintFlags & PaintLayerPaintingOverflowContents))
+#endif
     shouldPaintContent &= intersectsDamageRect(layerBounds, damageRect.rect(), rootLayer);
 
     if (localPaintFlags & PaintLayerPaintingCompositingBackgroundPhase) {
@@ -3961,11 +3973,18 @@ RenderLayer* RenderLayer::hitTestChildLayerColumns(RenderLayer* childLayer, Rend
     return 0;
 }
 
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+void RenderLayer::updateClipRects(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, OverlayScrollbarSizeRelevancy relevancy, ShouldRespectOverflowClip respectOverflowClip)
+#else
 void RenderLayer::updateClipRects(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, OverlayScrollbarSizeRelevancy relevancy)
+#endif
 {
     ASSERT(clipRectsType < NumCachedClipRectsTypes);
     if (m_clipRectsCache && m_clipRectsCache->m_clipRects[clipRectsType]) {
         ASSERT(rootLayer == m_clipRectsCache->m_clipRectsRoot[clipRectsType]);
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+        ASSERT(m_clipRectsCache->m_respectingOverflowClip[clipRectsType] == (respectOverflowClip == RespectOverflowClip));
+#endif
         return; // We have the correct cached value.
     }
     
@@ -3973,10 +3992,18 @@ void RenderLayer::updateClipRects(const RenderLayer* rootLayer, RenderRegion* re
     // examine the parent.  We want to cache clip rects with us as the root.
     RenderLayer* parentLayer = rootLayer != this ? parent() : 0;
     if (parentLayer)
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+        parentLayer->updateClipRects(rootLayer, region, clipRectsType, relevancy, respectOverflowClip);
+#else
         parentLayer->updateClipRects(rootLayer, region, clipRectsType, relevancy);
+#endif
 
     ClipRects clipRects;
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    calculateClipRects(rootLayer, region, clipRectsType, clipRects, relevancy, respectOverflowClip);
+#else
     calculateClipRects(rootLayer, region, clipRectsType, clipRects, relevancy);
+#endif
 
     if (!m_clipRectsCache)
         m_clipRectsCache = adoptPtr(new ClipRectsCache);
@@ -3987,11 +4014,19 @@ void RenderLayer::updateClipRects(const RenderLayer* rootLayer, RenderRegion* re
         m_clipRectsCache->m_clipRects[clipRectsType] = ClipRects::create(clipRects);
 
 #ifndef NDEBUG
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    m_clipRectsCache->m_respectingOverflowClip[clipRectsType] = respectOverflowClip == RespectOverflowClip;
+#else
     m_clipRectsCache->m_clipRectsRoot[clipRectsType] = rootLayer;
 #endif
+#endif
 }
 
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+void RenderLayer::calculateClipRects(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, ClipRects& clipRects, OverlayScrollbarSizeRelevancy relevancy, ShouldRespectOverflowClip respectOverflowClip) const
+#else
 void RenderLayer::calculateClipRects(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, ClipRects& clipRects, OverlayScrollbarSizeRelevancy relevancy) const
+#endif
 {
     if (!parent()) {
         // The root layer's clip rect is always infinite.
@@ -4010,7 +4045,11 @@ void RenderLayer::calculateClipRects(const RenderLayer* rootLayer, RenderRegion*
         if (useCached && parentLayer->clipRects(clipRectsType))
             clipRects = *parentLayer->clipRects(clipRectsType);
         else
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+            parentLayer->calculateClipRects(rootLayer, region, clipRectsType, clipRects, IgnoreOverlayScrollbarSize, respectOverflowClip);
+#else
             parentLayer->calculateClipRects(rootLayer, region, clipRectsType, clipRects);
+#endif
     } else
         clipRects.reset(PaintInfo::infiniteRect());
 
@@ -4027,7 +4066,11 @@ void RenderLayer::calculateClipRects(const RenderLayer* rootLayer, RenderRegion*
         clipRects.setOverflowClipRect(clipRects.posClipRect());
     
     // Update the clip rects that will be passed to child layers.
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    if ((renderer()->hasOverflowClip() && (respectOverflowClip == RespectOverflowClip || this != rootLayer)) || renderer()->hasClip()) {
+#else
     if (renderer()->hasClipOrOverflowClip()) {
+#endif
         // This layer establishes a clip of some kind.
 
         // This offset cannot use convertToLayerCoords, because sometimes our rootLayer may be across
@@ -4058,15 +4101,27 @@ void RenderLayer::calculateClipRects(const RenderLayer* rootLayer, RenderRegion*
     }
 }
 
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+void RenderLayer::parentClipRects(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, ClipRects& clipRects, OverlayScrollbarSizeRelevancy relevancy, ShouldRespectOverflowClip respectOverflowClip) const
+#else
 void RenderLayer::parentClipRects(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, ClipRects& clipRects, OverlayScrollbarSizeRelevancy relevancy) const
+#endif
 {
     ASSERT(parent());
     if (clipRectsType == TemporaryClipRects) {
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+        parent()->calculateClipRects(rootLayer, region, clipRectsType, clipRects, relevancy, respectOverflowClip);
+#else
         parent()->calculateClipRects(rootLayer, region, clipRectsType, clipRects, relevancy);
+#endif
         return;
     }
 
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    parent()->updateClipRects(rootLayer, region, clipRectsType, relevancy, respectOverflowClip);
+#else
     parent()->updateClipRects(rootLayer, region, clipRectsType, relevancy);
+#endif
     clipRects = *parent()->clipRects(clipRectsType);
 }
 
@@ -4081,11 +4136,19 @@ static inline ClipRect backgroundClipRectForPosition(const ClipRects& parentRect
     return parentRects.overflowClipRect();
 }
 
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+ClipRect RenderLayer::backgroundClipRect(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, OverlayScrollbarSizeRelevancy relevancy, ShouldRespectOverflowClip respectOverflowClip) const
+#else
 ClipRect RenderLayer::backgroundClipRect(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, OverlayScrollbarSizeRelevancy relevancy) const
+#endif
 {
     ASSERT(parent());
     ClipRects parentRects;
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    parentClipRects(rootLayer, region, clipRectsType, parentRects, relevancy, respectOverflowClip);
+#else
     parentClipRects(rootLayer, region, clipRectsType, parentRects, relevancy);
+#endif
     ClipRect backgroundClipRect = backgroundClipRectForPosition(parentRects, renderer()->style()->position());
     RenderView* view = renderer()->view();
     ASSERT(view);
@@ -4115,6 +4178,9 @@ bool RenderLayer::hasOverflowAncestor() const
 void RenderLayer::calculateRects(const RenderLayer* rootLayer, RenderRegion* region, ClipRectsType clipRectsType, const LayoutRect& paintDirtyRect, LayoutRect& layerBounds,
                                  ClipRect& backgroundRect, ClipRect& foregroundRect, ClipRect& outlineRect, OverlayScrollbarSizeRelevancy relevancy
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+                                , ShouldRespectOverflowClip respectOverflowClip
+#endif
                                 , bool dontClipToOverflow
 #endif
                                  ) const
@@ -4128,7 +4194,11 @@ void RenderLayer::calculateRects(const RenderLayer* rootLayer, RenderRegion* reg
         || hasOverflowAncestor()) { // parent with overflow set
         backgroundRect = paintDirtyRect;
     } else {
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+        backgroundRect = backgroundClipRect(rootLayer, region, clipRectsType, relevancy, respectOverflowClip);
+#else
         backgroundRect = backgroundClipRect(rootLayer, region, clipRectsType, relevancy);
+#endif
         backgroundRect.intersect(paintDirtyRect);
     }
 #else
@@ -4151,6 +4221,9 @@ void RenderLayer::calculateRects(const RenderLayer* rootLayer, RenderRegion* reg
         // This layer establishes a clip of some kind.
         if (renderer()->hasOverflowClip()
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+            && (this != rootLayer || respectOverflowClip == RespectOverflowClip)
+#endif
             && !dontClipToOverflow
 #endif
                 ) {
@@ -4184,9 +4257,16 @@ void RenderLayer::calculateRects(const RenderLayer* rootLayer, RenderRegion* reg
                 boxShadow = boxShadow->next();
             } while (boxShadow);
             // FIXME: fix for dontClipToOverflow
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+            if (this != rootLayer || respectOverflowClip == RespectOverflowClip)
+#endif
             backgroundRect.intersect(overflow);
         } else
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+            if (this != rootLayer || respectOverflowClip == RespectOverflowClip)
+#else
             if (!dontClipToOverflow)
+#endif
             backgroundRect.intersect(layerBounds);
 #else
         if (renderBox()->hasVisualOverflow()) {
@@ -4214,7 +4294,12 @@ LayoutRect RenderLayer::childrenClipRect() const
     RenderLayer* clippingRootLayer = clippingRootForPainting();
     LayoutRect layerBounds;
     ClipRect backgroundRect, foregroundRect, outlineRect;
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    // Need to use temporary clip rects, because the value of 'dontClipToOverflow' may be different from the painting path (<rdar://problem/11844909>).
+    calculateRects(clippingRootLayer, 0, TemporaryClipRects, renderView->unscaledDocumentRect(), layerBounds, backgroundRect, foregroundRect, outlineRect);
+#else
     calculateRects(clippingRootLayer, 0, PaintingClipRects, renderView->unscaledDocumentRect(), layerBounds, backgroundRect, foregroundRect, outlineRect);
+#endif
     return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregroundRect.rect())).enclosingBoundingBox();
 }
 
index 621ccf5..021c9ff 100755 (executable)
@@ -230,14 +230,25 @@ struct ClipRectsCache {
     ClipRectsCache()
     {
 #ifndef NDEBUG
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+        for (int i = 0; i < NumCachedClipRectsTypes; ++i) {
+#else
         for (int i = 0; i < NumCachedClipRectsTypes; ++i)
+#endif
             m_clipRectsRoot[i] = 0;
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+            m_respectingOverflowClip[i] = false;
+        }
+#endif
 #endif
     }
 
     RefPtr<ClipRects> m_clipRects[NumCachedClipRectsTypes];
 #ifndef NDEBUG
     const RenderLayer* m_clipRectsRoot[NumCachedClipRectsTypes];
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    bool m_respectingOverflowClip[NumCachedClipRectsTypes];
+#endif
 #endif
 };
 
@@ -522,6 +533,10 @@ public:
     bool hitTest(const HitTestRequest&, const HitTestPoint&, HitTestResult&);
     void paintOverlayScrollbars(GraphicsContext*, const LayoutRect& damageRect, PaintBehavior, RenderObject* paintingRoot);
 
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    enum ShouldRespectOverflowClip { IgnoreOverflowClip, RespectOverflowClip };
+#endif
+
     // This method figures out our layerBounds in coordinates relative to
     // |rootLayer}.  It also computes our background and foreground clip rects
     // for painting/event handling.
@@ -529,14 +544,25 @@ public:
                         ClipRect& backgroundRect, ClipRect& foregroundRect, ClipRect& outlineRect,
                         OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+                        , ShouldRespectOverflowClip = RespectOverflowClip
+#endif
                         , bool dontClipToOverflow = false
 #endif
                         ) const;
     // Compute and cache clip rects computed with the given layer as the root
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    void updateClipRects(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, ShouldRespectOverflowClip = RespectOverflowClip);
+#else
     void updateClipRects(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize);
+#endif
     // Compute and return the clip rects. If useCached is true, will used previously computed clip rects on ancestors
     // (rather than computing them all from scratch up the parent chain).
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    void calculateClipRects(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, ClipRects&, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, ShouldRespectOverflowClip = RespectOverflowClip) const;
+#else
     void calculateClipRects(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, ClipRects&, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
+#endif
 
     ClipRects* clipRects(ClipRectsType type) const { ASSERT(type < NumCachedClipRectsTypes); return m_clipRectsCache ? m_clipRectsCache->m_clipRects[type].get() : 0; }
 
@@ -837,8 +863,13 @@ private:
     void updateOrRemoveFilterEffect();
 #endif
 
+#if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_FIX_WRONG_CLIPPING)
+    void parentClipRects(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, ClipRects&, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, ShouldRespectOverflowClip = RespectOverflowClip) const;
+    ClipRect backgroundClipRect(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, ShouldRespectOverflowClip = RespectOverflowClip) const;
+#else
     void parentClipRects(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, ClipRects&, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
     ClipRect backgroundClipRect(const RenderLayer* rootLayer, RenderRegion*, ClipRectsType, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
+#endif
     LayoutRect paintingExtent(const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, PaintBehavior);
 
     RenderLayer* enclosingTransformedAncestor() const;