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

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

Issue 1490063002: Implement Paint Containment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge Created 5 years 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
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/PaintInfo.h" 9 #include "core/paint/PaintInfo.h"
10 #include "core/paint/PaintLayer.h" 10 #include "core/paint/PaintLayer.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/PaintController.h" 14 #include "platform/graphics/paint/PaintController.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 isOverflowOrContainmentClip = (m_box.hasOverflowClip() && !m_box.layer( )->isSelfPaintingLayer())
28 || m_box.style()->containsPaint();
28 29
29 if (!isControlClip && !isOverflowClip) 30 if (!isControlClip && !isOverflowOrContainmentClip)
30 return; 31 return;
31 32
32 LayoutRect clipRect = isControlClip ? m_box.controlClipRect(accumulatedOffse t) : m_box.overflowClipRect(accumulatedOffset); 33 LayoutRect clipRect = isControlClip ? m_box.controlClipRect(accumulatedOffse t) : m_box.overflowClipRect(accumulatedOffset);
33 FloatRoundedRect clipRoundedRect(0, 0, 0, 0); 34 FloatRoundedRect clipRoundedRect(0, 0, 0, 0);
34 bool hasBorderRadius = m_box.style()->hasBorderRadius(); 35 bool hasBorderRadius = m_box.style()->hasBorderRadius();
35 if (hasBorderRadius) 36 if (hasBorderRadius)
36 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(acc umulatedOffset, m_box.size())); 37 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(acc umulatedOffset, m_box.size()));
37 38
38 if (contentsClipBehavior == SkipContentsClipIfPossible) { 39 if (contentsClipBehavior == SkipContentsClipIfPossible) {
39 LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect(); 40 LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect();
(...skipping 17 matching lines...) Expand all
57 roundedRects.append(clipRoundedRect); 58 roundedRects.append(clipRoundedRect);
58 m_paintInfo.context.paintController().createAndAppend<ClipDisplayItem>(m _box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects); 59 m_paintInfo.context.paintController().createAndAppend<ClipDisplayItem>(m _box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects);
59 } 60 }
60 } 61 }
61 62
62 BoxClipper::~BoxClipper() 63 BoxClipper::~BoxClipper()
63 { 64 {
64 if (m_clipType == DisplayItem::UninitializedType) 65 if (m_clipType == DisplayItem::UninitializedType)
65 return; 66 return;
66 67
67 ASSERT(m_box.hasControlClip() || (m_box.hasOverflowClip() && !m_box.layer()- >isSelfPaintingLayer())); 68 ASSERT(m_box.hasControlClip() || (m_box.hasOverflowClip() && !m_box.layer()- >isSelfPaintingLayer()) || m_box.style()->containsPaint());
68 m_paintInfo.context.paintController().endItem<EndClipDisplayItem>(m_box, Dis playItem::clipTypeToEndClipType(m_clipType)); 69 m_paintInfo.context.paintController().endItem<EndClipDisplayItem>(m_box, Dis playItem::clipTypeToEndClipType(m_clipType));
69 } 70 }
70 71
71 } // namespace blink 72 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698