Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: Source/core/paint/BoxClipper.cpp

Issue 1284203004: Generate scroll/clip display item hierarchy for SPv2 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: stripped localPaintingInfo cleanup and fixed-pos workarounds Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/BoxClipper.h" 6 #include "core/paint/BoxClipper.h"
7 7
8 #include "core/layout/LayoutBox.h" 8 #include "core/layout/LayoutBox.h"
9 #include "core/paint/DeprecatedPaintLayer.h" 9 #include "core/paint/DeprecatedPaintLayer.h"
10 #include "core/paint/PaintInfo.h" 10 #include "core/paint/PaintInfo.h"
11 #include "platform/RuntimeEnabledFeatures.h" 11 #include "platform/RuntimeEnabledFeatures.h"
12 #include "platform/graphics/GraphicsLayer.h" 12 #include "platform/graphics/GraphicsLayer.h"
13 #include "platform/graphics/paint/ClipDisplayItem.h" 13 #include "platform/graphics/paint/ClipDisplayItem.h"
14 #include "platform/graphics/paint/DisplayItemList.h" 14 #include "platform/graphics/paint/DisplayItemList.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const L ayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior) 18 BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const L ayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior)
19 : m_box(box) 19 : m_box(box)
20 , m_paintInfo(paintInfo) 20 , m_paintInfo(paintInfo)
21 , m_clipType(DisplayItem::UninitializedType) 21 , m_clipType(DisplayItem::UninitializedType)
22 { 22 {
23 if (m_paintInfo.phase == PaintPhaseBlockBackground || m_paintInfo.phase == P aintPhaseSelfOutline || m_paintInfo.phase == PaintPhaseMask) 23 if (m_paintInfo.phase == PaintPhaseBlockBackground || m_paintInfo.phase == P aintPhaseSelfOutline || m_paintInfo.phase == PaintPhaseMask)
24 return; 24 return;
25 25
26 bool isControlClip = m_box.hasControlClip(); 26 bool isControlClip = m_box.hasControlClip();
27 bool isOverflowClip = m_box.hasOverflowClip() && !m_box.layer()->isSelfPaint ingLayer(); 27 bool isOverflowClip = m_box.hasOverflowClip() && (!m_box.layer()->isSelfPain tingLayer() || RuntimeEnabledFeatures::slimmingPaintV2Enabled());
chrishtr 2015/09/17 18:07:53 Why this change?
28 28
29 if (!isControlClip && !isOverflowClip) 29 if (!isControlClip && !isOverflowClip)
30 return; 30 return;
31 31
32 LayoutRect clipRect = isControlClip ? m_box.controlClipRect(accumulatedOffse t) : m_box.overflowClipRect(accumulatedOffset); 32 LayoutRect clipRect = isControlClip ? m_box.controlClipRect(accumulatedOffse t) : m_box.overflowClipRect(accumulatedOffset);
33 FloatRoundedRect clipRoundedRect(0, 0, 0, 0); 33 FloatRoundedRect clipRoundedRect(0, 0, 0, 0);
34 bool hasBorderRadius = m_box.style()->hasBorderRadius(); 34 bool hasBorderRadius = m_box.style()->hasBorderRadius();
35 if (hasBorderRadius) 35 if (hasBorderRadius)
36 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(acc umulatedOffset, m_box.size())); 36 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(acc umulatedOffset, m_box.size()));
37 37
38 if (contentsClipBehavior == SkipContentsClipIfPossible) { 38 if (contentsClipBehavior == SkipContentsClipIfPossible && !RuntimeEnabledFea tures::slimmingPaintV2Enabled()) {
chrishtr 2015/09/17 18:07:53 Is this change because we want to preserve clips i
39 LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect(); 39 LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect();
40 if (contentsVisualOverflow.isEmpty()) 40 if (contentsVisualOverflow.isEmpty())
41 return; 41 return;
42 42
43 LayoutRect conservativeClipRect = clipRect; 43 LayoutRect conservativeClipRect = clipRect;
44 if (hasBorderRadius) 44 if (hasBorderRadius)
45 conservativeClipRect.intersect(LayoutRect(clipRoundedRect.radiusCent erRect())); 45 conservativeClipRect.intersect(LayoutRect(clipRoundedRect.radiusCent erRect()));
46 conservativeClipRect.moveBy(-accumulatedOffset); 46 conservativeClipRect.moveBy(-accumulatedOffset);
47 if (m_box.hasLayer()) 47 if (m_box.hasLayer())
48 conservativeClipRect.move(m_box.scrolledContentOffset()); 48 conservativeClipRect.move(m_box.scrolledContentOffset());
49 if (conservativeClipRect.contains(contentsVisualOverflow)) 49 if (conservativeClipRect.contains(contentsVisualOverflow))
50 return; 50 return;
51 } 51 }
52 52
53 ASSERT(m_paintInfo.context->displayItemList()); 53 ASSERT(m_paintInfo.context->displayItemList());
54 if (!m_paintInfo.context->displayItemList()->displayItemConstructionIsDisabl ed()) { 54 if (!m_paintInfo.context->displayItemList()->displayItemConstructionIsDisabl ed()) {
55 m_clipType = m_paintInfo.displayItemTypeForClipping(); 55 m_clipType = m_paintInfo.displayItemTypeForClipping();
56 Vector<FloatRoundedRect> roundedRects; 56 Vector<FloatRoundedRect> roundedRects;
57 if (hasBorderRadius) 57 if (hasBorderRadius)
58 roundedRects.append(clipRoundedRect); 58 roundedRects.append(clipRoundedRect);
59 m_paintInfo.context->displayItemList()->createAndAppend<ClipDisplayItem> (m_box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects); 59 m_paintInfo.context->displayItemList()->createAndAppend<ClipDisplayItem> (m_box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects);
60 } 60 }
61 } 61 }
62 62
63 BoxClipper::~BoxClipper() 63 BoxClipper::~BoxClipper()
64 { 64 {
65 if (m_clipType == DisplayItem::UninitializedType) 65 if (m_clipType == DisplayItem::UninitializedType)
66 return; 66 return;
67 67
68 ASSERT(m_box.hasControlClip() || (m_box.hasOverflowClip() && !m_box.layer()- >isSelfPaintingLayer())); 68 ASSERT(m_box.hasControlClip() || (m_box.hasOverflowClip() && (!m_box.layer() ->isSelfPaintingLayer() || RuntimeEnabledFeatures::slimmingPaintV2Enabled())));
69 ASSERT(m_paintInfo.context->displayItemList()); 69 ASSERT(m_paintInfo.context->displayItemList());
70 if (!m_paintInfo.context->displayItemList()->displayItemConstructionIsDisabl ed()) { 70 if (!m_paintInfo.context->displayItemList()->displayItemConstructionIsDisabl ed()) {
71 if (m_paintInfo.context->displayItemList()->lastDisplayItemIsNoopBegin() ) 71 if (m_paintInfo.context->displayItemList()->lastDisplayItemIsNoopBegin() )
72 m_paintInfo.context->displayItemList()->removeLastDisplayItem(); 72 m_paintInfo.context->displayItemList()->removeLastDisplayItem();
73 else 73 else
74 m_paintInfo.context->displayItemList()->createAndAppend<EndClipDispl ayItem>(m_box, DisplayItem::clipTypeToEndClipType(m_clipType)); 74 m_paintInfo.context->displayItemList()->createAndAppend<EndClipDispl ayItem>(m_box, DisplayItem::clipTypeToEndClipType(m_clipType));
75 } 75 }
76 } 76 }
77 77
78 } // namespace blink 78 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698