OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google, Inc. | 2 * Copyright (C) 2013 Google, Inc. |
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
5 * All rights reserved. | 5 * All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 */ | 21 */ |
22 | 22 |
23 #ifndef CachedUAStyle_h | 23 #ifndef CachedUAStyle_h |
24 #define CachedUAStyle_h | 24 #define CachedUAStyle_h |
25 | 25 |
26 #include <memory> | 26 #include <memory> |
27 #include "core/style/ComputedStyle.h" | 27 #include "core/style/ComputedStyle.h" |
| 28 #include "platform/graphics/Color.h" |
28 #include "platform/wtf/Allocator.h" | 29 #include "platform/wtf/Allocator.h" |
29 #include "platform/wtf/Noncopyable.h" | 30 #include "platform/wtf/Noncopyable.h" |
30 #include "platform/wtf/PtrUtil.h" | 31 #include "platform/wtf/PtrUtil.h" |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 | 34 |
34 // LayoutTheme::AdjustStyle wants the background and borders | 35 // LayoutTheme::AdjustStyle wants the background and borders |
35 // as specified by the UA sheets, excluding any author rules. | 36 // as specified by the UA sheets, excluding any author rules. |
36 // We use this class to cache those values during | 37 // We use this class to cache those values during |
37 // ApplyMatchedProperties for later use during AdjustComputedStyle. | 38 // ApplyMatchedProperties for later use during AdjustComputedStyle. |
38 class CachedUAStyle { | 39 class CachedUAStyle { |
39 USING_FAST_MALLOC(CachedUAStyle); | 40 USING_FAST_MALLOC(CachedUAStyle); |
40 WTF_MAKE_NONCOPYABLE(CachedUAStyle); | 41 WTF_MAKE_NONCOPYABLE(CachedUAStyle); |
| 42 friend class ComputedStyle; |
41 | 43 |
42 public: | 44 public: |
43 static std::unique_ptr<CachedUAStyle> Create(const ComputedStyle* style) { | 45 static std::unique_ptr<CachedUAStyle> Create(const ComputedStyle* style) { |
44 return WTF::WrapUnique(new CachedUAStyle(style)); | 46 return WTF::WrapUnique(new CachedUAStyle(style)); |
45 } | 47 } |
46 | 48 |
| 49 bool BorderColorEquals(const ComputedStyle& other) const { |
| 50 return (border_left_color == other.BorderLeftColorInternal() && |
| 51 border_right_color == other.BorderRightColorInternal() && |
| 52 border_top_color == other.BorderTopColorInternal() && |
| 53 border_bottom_color == other.BorderBottomColorInternal()) && |
| 54 (border_left_color_is_current_color == |
| 55 other.BorderLeftColorIsCurrentColor() && |
| 56 border_right_color_is_current_color == |
| 57 other.BorderRightColorIsCurrentColor() && |
| 58 border_top_color_is_current_color == |
| 59 other.BorderTopColorIsCurrentColor() && |
| 60 border_bottom_color_is_current_color == |
| 61 other.BorderBottomColorIsCurrentColor()); |
| 62 } |
| 63 |
47 BorderData border; | 64 BorderData border; |
48 LengthSize top_left_; | 65 LengthSize top_left_; |
49 LengthSize top_right_; | 66 LengthSize top_right_; |
50 LengthSize bottom_left_; | 67 LengthSize bottom_left_; |
51 LengthSize bottom_right_; | 68 LengthSize bottom_right_; |
| 69 Color border_left_color; |
| 70 Color border_right_color; |
| 71 Color border_top_color; |
| 72 Color border_bottom_color; |
| 73 bool border_left_color_is_current_color; |
| 74 bool border_right_color_is_current_color; |
| 75 bool border_top_color_is_current_color; |
| 76 bool border_bottom_color_is_current_color; |
52 float border_left_width; | 77 float border_left_width; |
53 float border_right_width; | 78 float border_right_width; |
54 float border_top_width; | 79 float border_top_width; |
55 float border_bottom_width; | 80 float border_bottom_width; |
56 FillLayer background_layers; | 81 FillLayer background_layers; |
57 StyleColor background_color; | 82 StyleColor background_color; |
58 | 83 |
59 private: | 84 private: |
60 explicit CachedUAStyle(const ComputedStyle* style) | 85 explicit CachedUAStyle(const ComputedStyle* style) |
61 : border(style->Border()), | 86 : border(style->Border()), |
62 top_left_(style->BorderTopLeftRadius()), | 87 top_left_(style->BorderTopLeftRadius()), |
63 top_right_(style->BorderTopRightRadius()), | 88 top_right_(style->BorderTopRightRadius()), |
64 bottom_left_(style->BorderBottomLeftRadius()), | 89 bottom_left_(style->BorderBottomLeftRadius()), |
65 bottom_right_(style->BorderBottomRightRadius()), | 90 bottom_right_(style->BorderBottomRightRadius()), |
| 91 border_left_color(style->BorderLeftColorInternal()), |
| 92 border_right_color(style->BorderRightColorInternal()), |
| 93 border_top_color(style->BorderTopColorInternal()), |
| 94 border_bottom_color(style->BorderBottomColorInternal()), |
| 95 border_left_color_is_current_color( |
| 96 style->BorderLeftColorIsCurrentColor()), |
| 97 border_right_color_is_current_color( |
| 98 style->BorderRightColorIsCurrentColor()), |
| 99 border_top_color_is_current_color( |
| 100 style->BorderTopColorIsCurrentColor()), |
| 101 border_bottom_color_is_current_color( |
| 102 style->BorderBottomColorIsCurrentColor()), |
66 border_left_width(style->BorderLeftWidth()), | 103 border_left_width(style->BorderLeftWidth()), |
67 border_right_width(style->BorderRightWidth()), | 104 border_right_width(style->BorderRightWidth()), |
68 border_top_width(style->BorderTopWidth()), | 105 border_top_width(style->BorderTopWidth()), |
69 border_bottom_width(style->BorderBottomWidth()), | 106 border_bottom_width(style->BorderBottomWidth()), |
70 background_layers(style->BackgroundLayers()), | 107 background_layers(style->BackgroundLayers()), |
71 background_color(style->BackgroundColor()) {} | 108 background_color(style->BackgroundColor()) {} |
72 }; | 109 }; |
73 | 110 |
74 } // namespace blink | 111 } // namespace blink |
75 | 112 |
76 #endif // CachedUAStyle_h | 113 #endif // CachedUAStyle_h |
OLD | NEW |