OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 * rights reserved. | 6 * rights reserved. |
7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 class StyleImage; | 145 class StyleImage; |
146 class StylePath; | 146 class StylePath; |
147 class StyleResolver; | 147 class StyleResolver; |
148 class TransformationMatrix; | 148 class TransformationMatrix; |
149 class TranslateTransformOperation; | 149 class TranslateTransformOperation; |
150 | 150 |
151 class ContentData; | 151 class ContentData; |
152 | 152 |
153 typedef Vector<RefPtr<ComputedStyle>, 4> PseudoStyleCache; | 153 typedef Vector<RefPtr<ComputedStyle>, 4> PseudoStyleCache; |
154 | 154 |
155 // ComputedStyle stores the final style for an element and provides the | 155 // ComputedStyle stores the computed value [1] for every CSS property on an |
156 // interface between the style engine and the rest of Blink. | 156 // element and provides the interface between the style engine and the rest of |
| 157 // Blink. It acts as a container where the computed value of every CSS property |
| 158 // can be stored and retrieved: |
157 // | 159 // |
158 // It contains all the resolved styles for an element, and is densely packed and | 160 // auto style = ComputedStyle::Create(); |
159 // optimized for memory and performance. Enums and small fields are packed in | 161 // style->SetDisplay(EDisplay::kNone); //'display' keyword property |
160 // bit fields, while large fields are stored in pointers and shared where not | 162 // style->Display(); |
161 // modified from their parent value (see the DataRef class). | |
162 // | 163 // |
163 // Currently, ComputedStyle is hand-written and ComputedStyleBase is generated. | 164 // In addition to storing the computed value of every CSS property, |
164 // Over time, methods will be moved to ComputedStyleBase and the generator will | 165 // ComputedStyle also contains various internal style information. Examples |
165 // be expanded to handle more and more types of properties. Eventually, all | 166 // include cached_pseudo_styles_ (for storing pseudo element styles), unique_ |
166 // methods will be on ComputedStyleBase (with custom methods defined in a class | 167 // (for style sharing) and has_simple_underline_ (cached indicator flag of |
167 // such as ComputedStyleBase.cpp) and ComputedStyle will be removed. | 168 // text-decoration). These are stored on ComputedStyle for two reasons: |
| 169 // |
| 170 // 1) They share the same lifetime as ComputedStyle, so it is convenient to |
| 171 // store them in the same object rather than a separate object that have to be |
| 172 // passed around as well. |
| 173 // |
| 174 // 2) Many of these data members can be packed as bit fields, so we use less |
| 175 // memory by packing them in this object with other bit fields. |
| 176 // |
| 177 // STORAGE: |
| 178 // |
| 179 // ComputedStyle is optimized for memory and performance. The data is not |
| 180 // actually stored directly in ComputedStyle, but rather in a generated parent |
| 181 // class ComputedStyleBase. This separation of concerns allows us to optimise |
| 182 // the memory layout without affecting users of ComputedStyle. ComputedStyle |
| 183 // inherits from ComputedStyleBase, which in turn takes ComputedStyle as a |
| 184 // template argument so that ComputedStyleBase can access methods declared on |
| 185 // ComputedStyle. For more about the memory layout, there is documentation in |
| 186 // ComputedStyleBase and make_computed_style_base.py. |
| 187 // |
| 188 // INTERFACE: |
| 189 // |
| 190 // For most CSS properties, ComputedStyle provides a consistent interface which |
| 191 // includes a getter, setter, initial method (the computed value when the |
| 192 // property is to 'initial'), and resetter (that resets the computed value to |
| 193 // its initial value). Exceptions include vertical-align, which has a separate |
| 194 // set of accessors for its length and its keyword components. Apart from |
| 195 // accessors, ComputedStyle also has a wealth of helper functions. |
| 196 // |
| 197 // Because ComputedStyleBase defines simple accessors to every CSS property, |
| 198 // ComputedStyle inherits these and so they are not redeclared in this file. |
| 199 // This means that the interface to ComputedStyle is split between this file and |
| 200 // ComputedStyleBase.h. |
| 201 // |
| 202 // [1] https://developer.mozilla.org/en-US/docs/Web/CSS/computed_value |
| 203 // |
| 204 // NOTE: |
| 205 // |
| 206 // Currently, some properties are stored in ComputedStyle and some in |
| 207 // ComputedStyleBase. Eventually, the storage of all properties (except SVG |
| 208 // ones) will be in ComputedStyleBase. |
168 class CORE_EXPORT ComputedStyle : public ComputedStyleBase<ComputedStyle>, | 209 class CORE_EXPORT ComputedStyle : public ComputedStyleBase<ComputedStyle>, |
169 public RefCounted<ComputedStyle> { | 210 public RefCounted<ComputedStyle> { |
170 // Used by Web Animations CSS. Sets the color styles. | 211 // Used by Web Animations CSS. Sets the color styles. |
171 friend class AnimatedStyleBuilder; | 212 friend class AnimatedStyleBuilder; |
172 // Used by Web Animations CSS. Gets visited and unvisited colors separately. | 213 // Used by Web Animations CSS. Gets visited and unvisited colors separately. |
173 friend class CSSAnimatableValueFactory; | 214 friend class CSSAnimatableValueFactory; |
174 // Used by CSS animations. We can't allow them to animate based off visited | 215 // Used by CSS animations. We can't allow them to animate based off visited |
175 // colors. | 216 // colors. |
176 friend class CSSPropertyEquality; | 217 friend class CSSPropertyEquality; |
177 // Editing has to only reveal unvisited info. | 218 // Editing has to only reveal unvisited info. |
(...skipping 3567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3745 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); | 3786 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); |
3746 } | 3787 } |
3747 | 3788 |
3748 inline bool ComputedStyle::HasPseudoElementStyle() const { | 3789 inline bool ComputedStyle::HasPseudoElementStyle() const { |
3749 return PseudoBitsInternal() & kElementPseudoIdMask; | 3790 return PseudoBitsInternal() & kElementPseudoIdMask; |
3750 } | 3791 } |
3751 | 3792 |
3752 } // namespace blink | 3793 } // namespace blink |
3753 | 3794 |
3754 #endif // ComputedStyle_h | 3795 #endif // ComputedStyle_h |
OLD | NEW |