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

Side by Side Diff: third_party/WebKit/Source/core/style/CollapsedBorderValue.h

Issue 2842323002: Treat zero-width collapsed borders as invisible (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25 #ifndef CollapsedBorderValue_h
26 #define CollapsedBorderValue_h
27
28 #include "core/style/BorderValue.h"
29 #include "platform/wtf/Allocator.h"
30
31 namespace blink {
32
33 class CollapsedBorderValue {
34 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
35
36 public:
37 CollapsedBorderValue()
38 : color_(0),
39 width_(0),
40 style_(kBorderStyleNone),
41 precedence_(kBorderPrecedenceOff),
42 transparent_(false) {}
43
44 CollapsedBorderValue(const BorderValue& border,
45 const Color& color,
46 EBorderPrecedence precedence)
47 : color_(color),
48 width_(border.NonZero() ? border.Width() : 0),
49 style_(border.Style()),
50 precedence_(precedence),
51 transparent_(border.IsTransparent()) {}
52
53 unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; }
54 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); }
55 bool Exists() const { return precedence_ != kBorderPrecedenceOff; }
56 Color GetColor() const { return color_; }
57 bool IsTransparent() const { return transparent_; }
58 EBorderPrecedence Precedence() const {
59 return static_cast<EBorderPrecedence>(precedence_);
60 }
61
62 bool IsSameIgnoringColor(const CollapsedBorderValue& o) const {
63 return Width() == o.Width() && Style() == o.Style() &&
64 Precedence() == o.Precedence();
65 }
66
67 bool VisuallyEquals(const CollapsedBorderValue& o) const {
68 if (!IsVisible() && !o.IsVisible())
69 return true;
70 return GetColor() == o.GetColor() && IsTransparent() == o.IsTransparent() &&
71 IsSameIgnoringColor(o);
72 }
73
74 bool IsVisible() const {
75 return Style() > kBorderStyleHidden && !IsTransparent() && Exists();
76 }
77
78 bool ShouldPaint(
79 const CollapsedBorderValue& table_current_border_value) const {
80 return IsVisible() && IsSameIgnoringColor(table_current_border_value);
81 }
82
83 private:
84 Color color_;
85 unsigned width_ : 24;
86 unsigned style_ : 4; // EBorderStyle
87 unsigned precedence_ : 3; // EBorderPrecedence
88 unsigned transparent_ : 1;
89 };
90
91 } // namespace blink
92
93 #endif // CollapsedBorderValue_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/BUILD.gn ('k') | third_party/WebKit/Source/core/style/ComputedStyleConstants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698