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

Side by Side Diff: Source/core/style/BorderEdge.cpp

Issue 1173663003: BoxBorderPainter should use computed color alpha (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | « Source/core/style/BorderEdge.h ('k') | Source/core/style/ComputedStyle.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/style/BorderEdge.h" 6 #include "core/style/BorderEdge.h"
7 7
8 namespace blink { 8 namespace blink {
9 9
10 BorderEdge::BorderEdge(int edgeWidth, const Color& edgeColor, EBorderStyle edgeS tyle, bool edgeIsTransparent, bool edgeIsPresent) 10 BorderEdge::BorderEdge(int edgeWidth, const Color& edgeColor, EBorderStyle edgeS tyle, bool edgeIsPresent)
11 : width(edgeWidth) 11 : width(edgeWidth)
12 , color(edgeColor) 12 , color(edgeColor)
13 , isTransparent(edgeIsTransparent)
14 , isPresent(edgeIsPresent) 13 , isPresent(edgeIsPresent)
15 , style(edgeStyle) 14 , style(edgeStyle)
16 { 15 {
17 if (style == DOUBLE && edgeWidth < 3) 16 if (style == DOUBLE && edgeWidth < 3)
18 style = SOLID; 17 style = SOLID;
19 } 18 }
20 19
21 BorderEdge::BorderEdge() 20 BorderEdge::BorderEdge()
22 : width(0) 21 : width(0)
23 , isTransparent(false)
24 , isPresent(false) 22 , isPresent(false)
25 , style(BHIDDEN) 23 , style(BHIDDEN)
26 { 24 {
27 } 25 }
28 26
29 bool BorderEdge::hasVisibleColorAndStyle() const 27 bool BorderEdge::hasVisibleColorAndStyle() const
30 { 28 {
31 return style > BHIDDEN && !isTransparent; 29 return style > BHIDDEN && color.alpha() > 0;
32 } 30 }
33 31
34 bool BorderEdge::shouldRender() const 32 bool BorderEdge::shouldRender() const
35 { 33 {
36 return isPresent && width && hasVisibleColorAndStyle(); 34 return isPresent && width && hasVisibleColorAndStyle();
37 } 35 }
38 36
39 bool BorderEdge::presentButInvisible() const 37 bool BorderEdge::presentButInvisible() const
40 { 38 {
41 return usedWidth() && !hasVisibleColorAndStyle(); 39 return usedWidth() && !hasVisibleColorAndStyle();
42 } 40 }
43 41
44 bool BorderEdge::obscuresBackgroundEdge() const 42 bool BorderEdge::obscuresBackgroundEdge() const
45 { 43 {
46 if (!isPresent || isTransparent || color.hasAlpha() || style == BHIDDEN) 44 if (!isPresent || color.hasAlpha() || style == BHIDDEN)
47 return false; 45 return false;
48 46
49 if (style == DOTTED || style == DASHED) 47 if (style == DOTTED || style == DASHED)
50 return false; 48 return false;
51 49
52 return true; 50 return true;
53 } 51 }
54 52
55 bool BorderEdge::obscuresBackground() const 53 bool BorderEdge::obscuresBackground() const
56 { 54 {
57 if (!isPresent || isTransparent || color.hasAlpha() || style == BHIDDEN) 55 if (!isPresent || color.hasAlpha() || style == BHIDDEN)
58 return false; 56 return false;
59 57
60 if (style == DOTTED || style == DASHED || style == DOUBLE) 58 if (style == DOTTED || style == DASHED || style == DOUBLE)
61 return false; 59 return false;
62 60
63 return true; 61 return true;
64 } 62 }
65 63
66 int BorderEdge::usedWidth() const 64 int BorderEdge::usedWidth() const
67 { 65 {
68 return isPresent ? width : 0; 66 return isPresent ? width : 0;
69 } 67 }
70 68
71 int BorderEdge::getDoubleBorderStripeWidth(DoubleBorderStripe stripe) const 69 int BorderEdge::getDoubleBorderStripeWidth(DoubleBorderStripe stripe) const
72 { 70 {
73 ASSERT(stripe == DoubleBorderStripeOuter || stripe == DoubleBorderStripeInne r); 71 ASSERT(stripe == DoubleBorderStripeOuter || stripe == DoubleBorderStripeInne r);
74 72
75 // We need certain integer rounding results. 73 // We need certain integer rounding results.
76 return stripe == DoubleBorderStripeOuter 74 return stripe == DoubleBorderStripeOuter
77 ? (usedWidth() + 1) / 3 75 ? (usedWidth() + 1) / 3
78 : (usedWidth() * 2 + 1) / 3; 76 : (usedWidth() * 2 + 1) / 3;
79 } 77 }
80 78
81 bool BorderEdge::sharesColorWith(const BorderEdge& other) const 79 bool BorderEdge::sharesColorWith(const BorderEdge& other) const
82 { 80 {
83 return color == other.color; 81 return color == other.color;
84 } 82 }
85 83
86 } // namespace blink 84 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/style/BorderEdge.h ('k') | Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698