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

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

Issue 1088613002: CTM-independent BackgroundBleedBackgroundOverBorder implementation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: expectations Created 5 years, 8 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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/paint/BoxPainter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/BoxDecorationData.h" 6 #include "core/paint/BoxDecorationData.h"
7 7
8 #include "core/layout/LayoutBox.h" 8 #include "core/layout/LayoutBox.h"
9 #include "core/style/BorderEdge.h" 9 #include "core/style/BorderEdge.h"
10 #include "core/style/ComputedStyle.h" 10 #include "core/style/ComputedStyle.h"
(...skipping 20 matching lines...) Expand all
31 31
32 if (!hasBackground) 32 if (!hasBackground)
33 return BackgroundBleedNone; 33 return BackgroundBleedNone;
34 34
35 if (!hasBorder || !layoutBox.style()->hasBorderRadius() || layoutBox.canRend erBorderImage()) { 35 if (!hasBorder || !layoutBox.style()->hasBorderRadius() || layoutBox.canRend erBorderImage()) {
36 if (layoutBox.backgroundShouldAlwaysBeClipped()) 36 if (layoutBox.backgroundShouldAlwaysBeClipped())
37 return BackgroundBleedClipBackground; 37 return BackgroundBleedClipBackground;
38 return BackgroundBleedNone; 38 return BackgroundBleedNone;
39 } 39 }
40 40
41 // If display lists are enabled (via Slimming Paint), then simply clip the b ackground and do not
42 // perform advanced bleed-avoidance heuristics. These heuristics are not cor rect in the presence
43 // of impl-side rasterization or layerization, since the actual pixel-relati ve scaling and rotation
44 // of the content is not known to Blink.
45 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
46 return BackgroundBleedClipBackground;
47
48 // FIXME: See crbug.com/382491. getCTM does not accurately reflect the scale at the time content is 41 // FIXME: See crbug.com/382491. getCTM does not accurately reflect the scale at the time content is
49 // rasterized, and should not be relied on to make decisions about bleeding. 42 // rasterized, and should not be relied on to make decisions about bleeding.
50 AffineTransform ctm = context->getCTM(); 43 AffineTransform ctm = context->getCTM();
chrishtr 2015/04/13 20:40:11 Please factor this code into borderObscuresBackgro
f(malita) 2015/04/13 21:17:59 Done.
51 FloatSize contextScaling(static_cast<float>(ctm.xScale()), static_cast<float >(ctm.yScale())); 44 FloatSize contextScaling(static_cast<float>(ctm.xScale()), static_cast<float >(ctm.yScale()));
52 45
53 // Because RoundedRect uses IntRect internally the inset applied by the 46 // Because RoundedRect uses IntRect internally the inset applied by the
54 // BackgroundBleedShrinkBackground strategy cannot be less than one integer 47 // BackgroundBleedShrinkBackground strategy cannot be less than one integer
55 // layout coordinate, even with subpixel layout enabled. To take that into 48 // layout coordinate, even with subpixel layout enabled. To take that into
56 // account, we clamp the contextScaling to 1.0 for the following test so 49 // account, we clamp the contextScaling to 1.0 for the following test so
57 // that borderObscuresBackgroundEdge can only return true if the border 50 // that borderObscuresBackgroundEdge can only return true if the border
58 // widths are greater than 2 in both layout coordinates and screen 51 // widths are greater than 2 in both layout coordinates and screen
59 // coordinates. 52 // coordinates.
60 // This precaution will become obsolete if RoundedRect is ever promoted to 53 // This precaution will become obsolete if RoundedRect is ever promoted to
61 // a sub-pixel representation. 54 // a sub-pixel representation.
62 if (contextScaling.width() > 1) 55 if (contextScaling.width() > 1)
63 contextScaling.setWidth(1); 56 contextScaling.setWidth(1);
64 if (contextScaling.height() > 1) 57 if (contextScaling.height() > 1)
65 contextScaling.setHeight(1); 58 contextScaling.setHeight(1);
66 59
67 if (borderObscuresBackgroundEdge(*layoutBox.style(), contextScaling)) 60 // If display lists are enabled (via Slimming Paint), then BackgroundBleedSh rinkBackground is not
61 // usable as is relies on device-space heuristics. These heuristics are not correct in the presence
62 // of impl-side rasterization or layerization, since the actual pixel-relati ve scaling and rotation
63 // of the content is not known to Blink.
64 if (!RuntimeEnabledFeatures::slimmingPaintEnabled() && borderObscuresBackgro undEdge(*layoutBox.style(), contextScaling))
chrishtr 2015/04/13 20:40:11 Why not just do it unconditionally? It's not slimm
f(malita) 2015/04/13 21:17:59 Not sure I follow here: BackgroundBleedShrinkBackg
68 return BackgroundBleedShrinkBackground; 65 return BackgroundBleedShrinkBackground;
66
69 if (!hasAppearance && layoutBox.style()->borderObscuresBackground() && layou tBox.backgroundHasOpaqueTopLayer()) 67 if (!hasAppearance && layoutBox.style()->borderObscuresBackground() && layou tBox.backgroundHasOpaqueTopLayer())
70 return BackgroundBleedBackgroundOverBorder; 68 return BackgroundBleedBackgroundOverBorder;
chrishtr 2015/04/13 20:40:11 I know it's not blocking slimming paint, but is it
f(malita) 2015/04/13 21:17:59 (are you mixing these fine enum names maybe?) Thi
71 69
72 return BackgroundBleedClipBackground; 70 return BackgroundBleedClipBackground;
73 } 71 }
74 72
75 bool BoxDecorationData::borderObscuresBackgroundEdge(const ComputedStyle& style, const FloatSize& contextScale) const 73 bool BoxDecorationData::borderObscuresBackgroundEdge(const ComputedStyle& style, const FloatSize& contextScale) const
76 { 74 {
77 BorderEdge edges[4]; 75 BorderEdge edges[4];
78 style.getBorderEdgeInfo(edges); 76 style.getBorderEdgeInfo(edges);
79 77
80 for (int i = BSTop; i <= BSLeft; ++i) { 78 for (int i = BSTop; i <= BSLeft; ++i) {
81 const BorderEdge& currEdge = edges[i]; 79 const BorderEdge& currEdge = edges[i];
82 // FIXME: for vertical text 80 // FIXME: for vertical text
83 float axisScale = (i == BSTop || i == BSBottom) ? contextScale.height() : contextScale.width(); 81 float axisScale = (i == BSTop || i == BSBottom) ? contextScale.height() : contextScale.width();
84 if (!currEdge.obscuresBackgroundEdge(axisScale)) 82 if (!currEdge.obscuresBackgroundEdge(axisScale))
85 return false; 83 return false;
86 } 84 }
87 85
88 return true; 86 return true;
89 } 87 }
90 88
91 } // namespace blink 89 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/paint/BoxPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698