OLD | NEW |
---|---|
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()); |
pdr.
2015/09/03 06:16:59
Should we return false from isSelfPaintingLayer wh
trchen
2015/09/04 06:10:14
Nope it affects painting order. Most of the time i
| |
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()) { |
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()); |
(...skipping 18 matching lines...) Expand all Loading... | |
67 ClipDisplayItem clipDisplayItem(m_box, m_clipType, pixelSnappedIntRect(c lipRect), roundedRects); | 67 ClipDisplayItem clipDisplayItem(m_box, m_clipType, pixelSnappedIntRect(c lipRect), roundedRects); |
68 clipDisplayItem.replay(*paintInfo.context); | 68 clipDisplayItem.replay(*paintInfo.context); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 BoxClipper::~BoxClipper() | 72 BoxClipper::~BoxClipper() |
73 { | 73 { |
74 if (m_clipType == DisplayItem::UninitializedType) | 74 if (m_clipType == DisplayItem::UninitializedType) |
75 return; | 75 return; |
76 | 76 |
77 ASSERT(m_box.hasControlClip() || (m_box.hasOverflowClip() && !m_box.layer()- >isSelfPaintingLayer())); | 77 ASSERT(m_box.hasControlClip() || (m_box.hasOverflowClip() && (!m_box.layer() ->isSelfPaintingLayer() || RuntimeEnabledFeatures::slimmingPaintV2Enabled()))); |
78 | 78 |
79 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 79 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
80 ASSERT(m_paintInfo.context->displayItemList()); | 80 ASSERT(m_paintInfo.context->displayItemList()); |
81 if (!m_paintInfo.context->displayItemList()->displayItemConstructionIsDi sabled()) { | 81 if (!m_paintInfo.context->displayItemList()->displayItemConstructionIsDi sabled()) { |
82 if (m_paintInfo.context->displayItemList()->lastDisplayItemIsNoopBeg in()) | 82 if (m_paintInfo.context->displayItemList()->lastDisplayItemIsNoopBeg in()) |
83 m_paintInfo.context->displayItemList()->removeLastDisplayItem(); | 83 m_paintInfo.context->displayItemList()->removeLastDisplayItem(); |
84 else | 84 else |
85 m_paintInfo.context->displayItemList()->createAndAppend<EndClipD isplayItem>(m_box, DisplayItem::clipTypeToEndClipType(m_clipType)); | 85 m_paintInfo.context->displayItemList()->createAndAppend<EndClipD isplayItem>(m_box, DisplayItem::clipTypeToEndClipType(m_clipType)); |
86 } | 86 } |
87 } else { | 87 } else { |
88 EndClipDisplayItem endClipDisplayItem(m_box, DisplayItem::clipTypeToEndC lipType(m_clipType)); | 88 EndClipDisplayItem endClipDisplayItem(m_box, DisplayItem::clipTypeToEndC lipType(m_clipType)); |
89 endClipDisplayItem.replay(*m_paintInfo.context); | 89 endClipDisplayItem.replay(*m_paintInfo.context); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 } // namespace blink | 93 } // namespace blink |
OLD | NEW |