Chromium Code Reviews| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 class StyleInheritedData; | 130 class StyleInheritedData; |
| 131 class StylePath; | 131 class StylePath; |
| 132 class StyleResolver; | 132 class StyleResolver; |
| 133 class TransformationMatrix; | 133 class TransformationMatrix; |
| 134 class TranslateTransformOperation; | 134 class TranslateTransformOperation; |
| 135 | 135 |
| 136 class ContentData; | 136 class ContentData; |
| 137 | 137 |
| 138 typedef Vector<RefPtr<ComputedStyle>, 4> PseudoStyleCache; | 138 typedef Vector<RefPtr<ComputedStyle>, 4> PseudoStyleCache; |
| 139 | 139 |
| 140 // ComputedStyle stores the final style for an element and provides the | 140 // ComputedStyle stores the resolved style for an element and provides the |
|
nainar
2017/05/17 02:48:27
Define resolved here.
shend
2017/05/17 03:42:32
Done.
shend
2017/05/17 03:42:32
Should I explain the concept of computed/resolved
nainar
2017/05/17 03:48:43
If you can find a MDN link sure otherwise its ok.
| |
| 141 // interface between the style engine and the rest of Blink. | 141 // interface between the style engine and the rest of Blink. It acts as a |
| 142 // container where the computed value of every CSS property can be stored and | |
| 143 // retrieved: | |
| 142 // | 144 // |
| 143 // It contains all the resolved styles for an element, and is densely packed and | 145 // auto style = ComputedStyle::Create() style->SetDisplay(EDisplay::kNone); // |
|
nainar
2017/05/17 02:48:27
erroneous // at the end of this line?
shend
2017/05/17 03:42:32
Done
| |
| 144 // optimized for memory and performance. Enums and small fields are packed in | 146 // 'display' keyword property style->Display() |
| 145 // bit fields, while large fields are stored in pointers and shared where not | |
| 146 // modified from their parent value (see the DataRef class). | |
| 147 // | 147 // |
| 148 // Currently, ComputedStyle is hand-written and ComputedStyleBase is generated. | 148 // In addition to storing the computed value of every CSS property, |
| 149 // Over time, methods will be moved to ComputedStyleBase and the generator will | 149 // ComputedStyle also contains various internal style information. Examples |
| 150 // be expanded to handle more and more types of properties. Eventually, all | 150 // include pseudo element styles, unique_ (for style sharing) and |
|
nainar
2017/05/17 02:48:27
explain that PseudoStyleCache is where we store th
shend
2017/05/17 03:42:32
Done.
| |
| 151 // methods will be on ComputedStyleBase (with custom methods defined in a class | 151 // has_simple_underline_ (cached indicator flag of text-decoration). These are |
| 152 // such as ComputedStyleBase.cpp) and ComputedStyle will be removed. | 152 // stored on ComputedStyle for two reasons: |
| 153 // | |
| 154 // 1) They share the same lifetime as ComputedStyle, so it is convenient to | |
| 155 // store them in the same object rather than a separate object that have to be | |
| 156 // passed around as well. | |
| 157 // | |
| 158 // 2) Many of these data members can be packed as bit fields, so we use less | |
| 159 // memory by packing them in this object with other bit fields. | |
| 160 // | |
| 161 // For most CSS properties, ComputedStyle provides a consistent interface which | |
| 162 // includes a getter, setter, initial method (the computed value when the | |
| 163 // property is to 'initial'), and resetter (that resets the computed value to | |
| 164 // its initial value). Exceptions include vertical-align, which has a separate | |
| 165 // set of accessors for its length and its keyword components. Apart from | |
| 166 // accessors, ComputedStyle also has a wealth of helper functions. | |
| 167 // | |
| 168 // ComputedStyle is optimized for memory and performance. The data is not | |
|
shend
2017/05/17 03:42:32
Would headings be useful?
nainar
2017/05/17 03:48:43
Headings are always useful :)
| |
| 169 // actually stored directly in ComputedStyle, but rather in a generated parent | |
| 170 // class ComputedStyleBase. This separation of concerns allows us to optimise | |
| 171 // the memory layout without affecting users of ComputedStyle. ComputedStyle | |
| 172 // inherits from ComputedStyleBase, which in turn takes ComputedStyle as a | |
| 173 // template argument so that ComputedStyleBase can access methods declared on | |
| 174 // ComputedStyle. For more about the memory layout, there is documentation in | |
| 175 // ComputedStyleBase and make_computed_style_base.py. | |
| 176 // | |
| 177 // Because ComputedStyleBase defines simple accessors to every CSS property, | |
| 178 // ComputedStyle inherits these and so they are not redeclared in this file. | |
| 179 // This means that the interface to ComputedStyle is split between this file and | |
| 180 // ComputedStyleBase.h. | |
| 181 // | |
| 182 // Currently, some properties are stored in ComputedStyle and some in | |
| 183 // ComputedStyleBase. Eventually, the storage of all properties (except SVG | |
| 184 // ones) will be in ComputedStyleBase. | |
| 153 class CORE_EXPORT ComputedStyle : public ComputedStyleBase<ComputedStyle>, | 185 class CORE_EXPORT ComputedStyle : public ComputedStyleBase<ComputedStyle>, |
| 154 public RefCounted<ComputedStyle> { | 186 public RefCounted<ComputedStyle> { |
| 155 // Used by Web Animations CSS. Sets the color styles. | 187 // Used by Web Animations CSS. Sets the color styles. |
| 156 friend class AnimatedStyleBuilder; | 188 friend class AnimatedStyleBuilder; |
| 157 // Used by Web Animations CSS. Gets visited and unvisited colors separately. | 189 // Used by Web Animations CSS. Gets visited and unvisited colors separately. |
| 158 friend class CSSAnimatableValueFactory; | 190 friend class CSSAnimatableValueFactory; |
| 159 // Used by CSS animations. We can't allow them to animate based off visited | 191 // Used by CSS animations. We can't allow them to animate based off visited |
| 160 // colors. | 192 // colors. |
| 161 friend class CSSPropertyEquality; | 193 friend class CSSPropertyEquality; |
| 162 // Editing has to only reveal unvisited info. | 194 // Editing has to only reveal unvisited info. |
| (...skipping 3610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3773 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); | 3805 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); |
| 3774 } | 3806 } |
| 3775 | 3807 |
| 3776 inline bool ComputedStyle::HasPseudoElementStyle() const { | 3808 inline bool ComputedStyle::HasPseudoElementStyle() const { |
| 3777 return PseudoBitsInternal() & kElementPseudoIdMask; | 3809 return PseudoBitsInternal() & kElementPseudoIdMask; |
| 3778 } | 3810 } |
| 3779 | 3811 |
| 3780 } // namespace blink | 3812 } // namespace blink |
| 3781 | 3813 |
| 3782 #endif // ComputedStyle_h | 3814 #endif // ComputedStyle_h |
| OLD | NEW |