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

Side by Side Diff: Source/core/rendering/RenderBoxClipper.cpp

Issue 732093002: Move RenderBoxClipper to core/paint/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « Source/core/rendering/RenderBoxClipper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/rendering/RenderBoxClipper.h"
7
8 #include "core/rendering/PaintInfo.h"
9 #include "core/rendering/RenderBox.h"
10 #include "core/rendering/RenderLayer.h"
11
12 namespace blink {
13
14 RenderBoxClipper::RenderBoxClipper(RenderBox& box, PaintInfo& paintInfo, const L ayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior)
15 : m_pushedClip(false)
16 , m_accumulatedOffset(accumulatedOffset)
17 , m_paintInfo(paintInfo)
18 , m_originalPhase(paintInfo.phase)
19 , m_box(box)
20 {
21 if (m_paintInfo.phase == PaintPhaseBlockBackground || m_paintInfo.phase == P aintPhaseSelfOutline || m_paintInfo.phase == PaintPhaseMask)
22 return;
23
24 bool isControlClip = m_box.hasControlClip();
25 bool isOverflowClip = m_box.hasOverflowClip() && !m_box.layer()->isSelfPaint ingLayer();
26
27 if (!isControlClip && !isOverflowClip)
28 return;
29
30 LayoutRect clipRect = isControlClip ? m_box.controlClipRect(m_accumulatedOff set) : m_box.overflowClipRect(m_accumulatedOffset);
31 RoundedRect clipRoundedRect(0, 0, 0, 0);
32 bool hasBorderRadius = m_box.style()->hasBorderRadius();
33 if (hasBorderRadius)
34 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(m_a ccumulatedOffset, m_box.size()));
35
36 if (contentsClipBehavior == SkipContentsClipIfPossible) {
37 LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect();
38 if (contentsVisualOverflow.isEmpty())
39 return;
40
41 LayoutRect conservativeClipRect = clipRect;
42 if (hasBorderRadius)
43 conservativeClipRect.intersect(clipRoundedRect.radiusCenterRect());
44 conservativeClipRect.moveBy(-m_accumulatedOffset);
45 if (m_box.hasLayer())
46 conservativeClipRect.move(m_box.scrolledContentOffset());
47 if (conservativeClipRect.contains(contentsVisualOverflow))
48 return;
49 }
50
51 if (m_paintInfo.phase == PaintPhaseOutline) {
52 m_paintInfo.phase = PaintPhaseChildOutlines;
53 } else if (m_paintInfo.phase == PaintPhaseChildBlockBackground) {
54 m_paintInfo.phase = PaintPhaseBlockBackground;
55 m_box.paintObject(m_paintInfo, m_accumulatedOffset);
56 m_paintInfo.phase = PaintPhaseChildBlockBackgrounds;
57 }
58 m_paintInfo.context->save();
59 if (hasBorderRadius)
60 m_paintInfo.context->clipRoundedRect(clipRoundedRect);
61 m_paintInfo.context->clip(pixelSnappedIntRect(clipRect));
62 m_pushedClip = true;
63 }
64
65 RenderBoxClipper::~RenderBoxClipper()
66 {
67 if (!m_pushedClip)
68 return;
69
70 ASSERT(m_box.hasControlClip() || (m_box.hasOverflowClip() && !m_box.layer()- >isSelfPaintingLayer()));
71
72 m_paintInfo.context->restore();
73 if (m_originalPhase == PaintPhaseOutline) {
74 m_paintInfo.phase = PaintPhaseSelfOutline;
75 m_box.paintObject(m_paintInfo, m_accumulatedOffset);
76 m_paintInfo.phase = m_originalPhase;
77 } else if (m_originalPhase == PaintPhaseChildBlockBackground) {
78 m_paintInfo.phase = m_originalPhase;
79 }
80 }
81
82 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBoxClipper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698