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

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

Issue 2886383002: Move StyleRareInheritedData.h to a nested class in ComputedStyle. (Closed)
Patch Set: Rebase 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
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 12 matching lines...) Expand all
23 * 23 *
24 */ 24 */
25 25
26 #ifndef ComputedStyle_h 26 #ifndef ComputedStyle_h
27 #define ComputedStyle_h 27 #define ComputedStyle_h
28 28
29 #include <memory> 29 #include <memory>
30 #include "core/CSSPropertyNames.h" 30 #include "core/CSSPropertyNames.h"
31 #include "core/ComputedStyleBase.h" 31 #include "core/ComputedStyleBase.h"
32 #include "core/CoreExport.h" 32 #include "core/CoreExport.h"
33 #include "core/css/StyleAutoColor.h"
34 #include "core/css/StyleColor.h"
35 #include "core/layout/LayoutTheme.h"
36 #include "core/style/AppliedTextDecoration.h"
37 #include "core/style/AppliedTextDecorationList.h"
33 #include "core/style/BorderValue.h" 38 #include "core/style/BorderValue.h"
34 #include "core/style/ComputedStyleConstants.h" 39 #include "core/style/ComputedStyleConstants.h"
35 #include "core/style/CounterDirectives.h" 40 #include "core/style/CounterDirectives.h"
41 #include "core/style/CursorData.h"
42 #include "core/style/CursorList.h"
36 #include "core/style/DataRef.h" 43 #include "core/style/DataRef.h"
37 #include "core/style/LineClampValue.h" 44 #include "core/style/LineClampValue.h"
38 #include "core/style/NinePieceImage.h" 45 #include "core/style/NinePieceImage.h"
46 #include "core/style/QuotesData.h"
39 #include "core/style/SVGComputedStyle.h" 47 #include "core/style/SVGComputedStyle.h"
48 #include "core/style/ShadowData.h"
49 #include "core/style/ShadowList.h"
40 #include "core/style/StyleContentAlignmentData.h" 50 #include "core/style/StyleContentAlignmentData.h"
41 #include "core/style/StyleDeprecatedFlexibleBoxData.h" 51 #include "core/style/StyleDeprecatedFlexibleBoxData.h"
42 #include "core/style/StyleDifference.h" 52 #include "core/style/StyleDifference.h"
43 #include "core/style/StyleFilterData.h" 53 #include "core/style/StyleFilterData.h"
44 #include "core/style/StyleFlexibleBoxData.h" 54 #include "core/style/StyleFlexibleBoxData.h"
45 #include "core/style/StyleGridData.h" 55 #include "core/style/StyleGridData.h"
46 #include "core/style/StyleGridItemData.h" 56 #include "core/style/StyleGridItemData.h"
57 #include "core/style/StyleImage.h"
58 #include "core/style/StyleInheritedVariables.h"
47 #include "core/style/StyleMultiColData.h" 59 #include "core/style/StyleMultiColData.h"
48 #include "core/style/StyleOffsetRotation.h" 60 #include "core/style/StyleOffsetRotation.h"
49 #include "core/style/StyleRareInheritedData.h"
50 #include "core/style/StyleRareNonInheritedData.h" 61 #include "core/style/StyleRareNonInheritedData.h"
51 #include "core/style/StyleReflection.h" 62 #include "core/style/StyleReflection.h"
52 #include "core/style/StyleSelfAlignmentData.h" 63 #include "core/style/StyleSelfAlignmentData.h"
53 #include "core/style/StyleTransformData.h" 64 #include "core/style/StyleTransformData.h"
54 #include "core/style/StyleWillChangeData.h" 65 #include "core/style/StyleWillChangeData.h"
66 #include "core/style/TextSizeAdjust.h"
55 #include "core/style/TransformOrigin.h" 67 #include "core/style/TransformOrigin.h"
56 #include "platform/Length.h" 68 #include "platform/Length.h"
57 #include "platform/LengthBox.h" 69 #include "platform/LengthBox.h"
58 #include "platform/LengthPoint.h" 70 #include "platform/LengthPoint.h"
59 #include "platform/LengthSize.h" 71 #include "platform/LengthSize.h"
60 #include "platform/RuntimeEnabledFeatures.h" 72 #include "platform/RuntimeEnabledFeatures.h"
61 #include "platform/ThemeTypes.h" 73 #include "platform/ThemeTypes.h"
62 #include "platform/fonts/Font.h" 74 #include "platform/fonts/Font.h"
63 #include "platform/fonts/FontDescription.h" 75 #include "platform/fonts/FontDescription.h"
64 #include "platform/geometry/FloatRoundedRect.h" 76 #include "platform/geometry/FloatRoundedRect.h"
65 #include "platform/geometry/LayoutRectOutsets.h" 77 #include "platform/geometry/LayoutRectOutsets.h"
66 #include "platform/graphics/Color.h" 78 #include "platform/graphics/Color.h"
67 #include "platform/graphics/TouchAction.h" 79 #include "platform/graphics/TouchAction.h"
80 #include "platform/heap/Handle.h"
68 #include "platform/scroll/ScrollTypes.h" 81 #include "platform/scroll/ScrollTypes.h"
82 #include "platform/text/TabSize.h"
69 #include "platform/text/TextDirection.h" 83 #include "platform/text/TextDirection.h"
70 #include "platform/text/UnicodeBidi.h" 84 #include "platform/text/UnicodeBidi.h"
71 #include "platform/transforms/TransformOperations.h" 85 #include "platform/transforms/TransformOperations.h"
72 #include "platform/wtf/Forward.h" 86 #include "platform/wtf/Forward.h"
73 #include "platform/wtf/LeakAnnotations.h" 87 #include "platform/wtf/LeakAnnotations.h"
88 #include "platform/wtf/PassRefPtr.h"
74 #include "platform/wtf/RefCounted.h" 89 #include "platform/wtf/RefCounted.h"
90 #include "platform/wtf/RefVector.h"
75 #include "platform/wtf/Vector.h" 91 #include "platform/wtf/Vector.h"
92 #include "platform/wtf/text/AtomicString.h"
76 93
77 template <typename T, typename U> 94 template <typename T, typename U>
78 inline bool compareEqual(const T& t, const U& u) { 95 inline bool compareEqual(const T& t, const U& u) {
79 return t == static_cast<T>(u); 96 return t == static_cast<T>(u);
80 } 97 }
81 98
82 template <typename T> 99 template <typename T>
83 inline bool compareEqual(const T& a, const T& b) { 100 inline bool compareEqual(const T& a, const T& b) {
84 return a == b; 101 return a == b;
85 } 102 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 friend class ColorPropertyFunctions; 188 friend class ColorPropertyFunctions;
172 189
173 // FIXME: When we stop resolving currentColor at style time, these can be 190 // FIXME: When we stop resolving currentColor at style time, these can be
174 // removed. 191 // removed.
175 friend class CSSToStyleMap; 192 friend class CSSToStyleMap;
176 friend class FilterOperationResolver; 193 friend class FilterOperationResolver;
177 friend class StyleBuilderConverter; 194 friend class StyleBuilderConverter;
178 friend class StyleResolverState; 195 friend class StyleResolverState;
179 friend class StyleResolver; 196 friend class StyleResolver;
180 197
198 private:
199 // This struct is for rarely used inherited CSS3, CSS2, and WebKit-specific
200 // properties. By grouping them together, we save space, and only allocate
201 // this object when someone actually uses one of these properties.
202 class StyleRareInheritedData
203 : public RefCountedCopyable<StyleRareInheritedData> {
204 public:
205 static PassRefPtr<StyleRareInheritedData> Create() {
206 return AdoptRef(new StyleRareInheritedData);
207 }
208 PassRefPtr<StyleRareInheritedData> Copy() const {
209 return AdoptRef(new StyleRareInheritedData(*this));
210 }
211
212 bool operator==(const StyleRareInheritedData& other) const {
213 return text_stroke_color_ == other.text_stroke_color_ &&
214 text_stroke_width_ == other.text_stroke_width_ &&
215 text_fill_color_ == other.text_fill_color_ &&
216 text_emphasis_color_ == other.text_emphasis_color_ &&
217 caret_color_ == other.caret_color_ &&
218 visited_link_text_stroke_color_ ==
219 other.visited_link_text_stroke_color_ &&
220 visited_link_text_fill_color_ ==
221 other.visited_link_text_fill_color_ &&
222 visited_link_text_emphasis_color_ ==
223 other.visited_link_text_emphasis_color_ &&
224 visited_link_caret_color_ == other.visited_link_caret_color_ &&
225 tap_highlight_color_ == other.tap_highlight_color_ &&
226 DataEquivalent(text_shadow_, other.text_shadow_) &&
227 highlight_ == other.highlight_ &&
228 DataEquivalent(cursor_data_, other.cursor_data_) &&
229 text_indent_ == other.text_indent_ &&
230 effective_zoom_ == other.effective_zoom_ &&
231 widows_ == other.widows_ && orphans_ == other.orphans_ &&
232 text_stroke_color_is_current_color_ ==
233 other.text_stroke_color_is_current_color_ &&
234 text_fill_color_is_current_color_ ==
235 other.text_fill_color_is_current_color_ &&
236 text_emphasis_color_is_current_color_ ==
237 other.text_emphasis_color_is_current_color_ &&
238 caret_color_is_current_color_ ==
239 other.caret_color_is_current_color_ &&
240 caret_color_is_auto_ == other.caret_color_is_auto_ &&
241 visited_link_text_stroke_color_is_current_color_ ==
242 other.visited_link_text_stroke_color_is_current_color_ &&
243 visited_link_text_fill_color_is_current_color_ ==
244 other.visited_link_text_fill_color_is_current_color_ &&
245 visited_link_text_emphasis_color_is_current_color_ ==
246 other.visited_link_text_emphasis_color_is_current_color_ &&
247 visited_link_caret_color_is_current_color_ ==
248 other.visited_link_caret_color_is_current_color_ &&
249 visited_link_caret_color_is_auto_ ==
250 other.visited_link_caret_color_is_auto_ &&
251 text_security_ == other.text_security_ &&
252 user_modify_ == other.user_modify_ &&
253 word_break_ == other.word_break_ &&
254 overflow_wrap_ == other.overflow_wrap_ &&
255 line_break_ == other.line_break_ &&
256 user_select_ == other.user_select_ && speak_ == other.speak_ &&
257 hyphens_ == other.hyphens_ &&
258 hyphenation_limit_before_ == other.hyphenation_limit_before_ &&
259 hyphenation_limit_after_ == other.hyphenation_limit_after_ &&
260 hyphenation_limit_lines_ == other.hyphenation_limit_lines_ &&
261 text_emphasis_fill_ == other.text_emphasis_fill_ &&
262 text_emphasis_mark_ == other.text_emphasis_mark_ &&
263 text_emphasis_position_ == other.text_emphasis_position_ &&
264 text_align_last_ == other.text_align_last_ &&
265 text_justify_ == other.text_justify_ &&
266 text_orientation_ == other.text_orientation_ &&
267 text_combine_ == other.text_combine_ &&
268 text_indent_line_ == other.text_indent_line_ &&
269 text_indent_type_ == other.text_indent_type_ &&
270 subtree_will_change_contents_ ==
271 other.subtree_will_change_contents_ &&
272 self_or_ancestor_has_dir_auto_attribute_ ==
273 other.self_or_ancestor_has_dir_auto_attribute_ &&
274 respect_image_orientation_ == other.respect_image_orientation_ &&
275 subtree_is_sticky_ == other.subtree_is_sticky_ &&
276 hyphenation_string_ == other.hyphenation_string_ &&
277 line_height_step_ == other.line_height_step_ &&
278 text_emphasis_custom_mark_ == other.text_emphasis_custom_mark_ &&
279 DataEquivalent(quotes_, other.quotes_) &&
280 tab_size_ == other.tab_size_ &&
281 image_rendering_ == other.image_rendering_ &&
282 text_underline_position_ == other.text_underline_position_ &&
283 text_decoration_skip_ == other.text_decoration_skip_ &&
284 ruby_position_ == other.ruby_position_ &&
285 DataEquivalent(list_style_image_, other.list_style_image_) &&
286 DataEquivalent(applied_text_decorations_,
287 other.applied_text_decorations_) &&
288 DataEquivalent(variables_, other.variables_) &&
289 text_size_adjust_ == other.text_size_adjust_;
290 }
291 bool operator!=(const StyleRareInheritedData& o) const {
292 return !(*this == o);
293 }
294
295 Persistent<StyleImage> list_style_image_;
296
297 Color text_stroke_color_;
298 float text_stroke_width_;
299 Color text_fill_color_;
300 Color text_emphasis_color_;
301 Color caret_color_;
302
303 Color visited_link_text_stroke_color_;
304 Color visited_link_text_fill_color_;
305 Color visited_link_text_emphasis_color_;
306 Color visited_link_caret_color_;
307
308 RefPtr<ShadowList>
309 text_shadow_; // Our text shadow information for shadowed text drawing.
310 AtomicString
311 highlight_; // Apple-specific extension for custom highlight rendering.
312
313 Persistent<CursorList> cursor_data_;
314
315 Length text_indent_;
316 float effective_zoom_;
317
318 // Paged media properties.
319 short widows_;
320 short orphans_;
321
322 unsigned text_stroke_color_is_current_color_ : 1;
323 unsigned text_fill_color_is_current_color_ : 1;
324 unsigned text_emphasis_color_is_current_color_ : 1;
325 unsigned caret_color_is_current_color_ : 1;
326 unsigned caret_color_is_auto_ : 1;
327 unsigned visited_link_text_stroke_color_is_current_color_ : 1;
328 unsigned visited_link_text_fill_color_is_current_color_ : 1;
329 unsigned visited_link_text_emphasis_color_is_current_color_ : 1;
330 unsigned visited_link_caret_color_is_current_color_ : 1;
331 unsigned visited_link_caret_color_is_auto_ : 1;
332
333 unsigned text_security_ : 2; // ETextSecurity
334 unsigned user_modify_ : 2; // EUserModify (editing)
335 unsigned word_break_ : 2; // EWordBreak
336 unsigned overflow_wrap_ : 1; // EOverflowWrap
337 unsigned line_break_ : 3; // LineBreak
338 unsigned user_select_ : 2; // EUserSelect
339 unsigned speak_ : 3; // ESpeak
340 unsigned hyphens_ : 2; // Hyphens
341 unsigned text_emphasis_fill_ : 1; // TextEmphasisFill
342 unsigned text_emphasis_mark_ : 3; // TextEmphasisMark
343 unsigned text_emphasis_position_ : 1; // TextEmphasisPosition
344 unsigned text_align_last_ : 3; // TextAlignLast
345 unsigned text_justify_ : 2; // TextJustify
346 unsigned text_orientation_ : 2; // TextOrientation
347 unsigned text_combine_ : 1; // CSS3 text-combine-upright properties
348 unsigned text_indent_line_ : 1; // TextIndentEachLine
349 unsigned text_indent_type_ : 1; // TextIndentHanging
350 // CSS Image Values Level 3
351 unsigned image_rendering_ : 3; // EImageRendering
352 unsigned text_underline_position_ : 1; // TextUnderlinePosition
353 unsigned text_decoration_skip_ : 3; // TextDecorationSkip
354 unsigned ruby_position_ : 1; // RubyPosition
355
356 // Though will-change is not itself an inherited property, the intent
357 // expressed by 'will-change: contents' includes descendants.
358 unsigned subtree_will_change_contents_ : 1;
359
360 unsigned self_or_ancestor_has_dir_auto_attribute_ : 1;
361
362 unsigned respect_image_orientation_ : 1;
363
364 // Though position: sticky is not itself an inherited property, being a
365 // descendent of a sticky element changes some document lifecycle logic.
366 unsigned subtree_is_sticky_ : 1;
367
368 AtomicString hyphenation_string_;
369 short hyphenation_limit_before_;
370 short hyphenation_limit_after_;
371 short hyphenation_limit_lines_;
372
373 uint8_t line_height_step_;
374
375 AtomicString text_emphasis_custom_mark_;
376 RefPtr<QuotesData> quotes_;
377
378 Color tap_highlight_color_;
379
380 RefPtr<AppliedTextDecorationList> applied_text_decorations_;
381 TabSize tab_size_;
382
383 RefPtr<StyleInheritedVariables> variables_;
384 TextSizeAdjust text_size_adjust_;
385
386 private:
387 StyleRareInheritedData()
388 : list_style_image_(nullptr),
389 text_stroke_width_(0),
390 text_indent_(Length(kFixed)),
391 effective_zoom_(1.0),
392 widows_(2),
393 orphans_(2),
394 text_stroke_color_is_current_color_(true),
395 text_fill_color_is_current_color_(true),
396 text_emphasis_color_is_current_color_(true),
397 caret_color_is_current_color_(false),
398 caret_color_is_auto_(true),
399 visited_link_text_stroke_color_is_current_color_(true),
400 visited_link_text_fill_color_is_current_color_(true),
401 visited_link_text_emphasis_color_is_current_color_(true),
402 visited_link_caret_color_is_current_color_(false),
403 visited_link_caret_color_is_auto_(true),
404 text_security_(static_cast<unsigned>(ETextSecurity::kNone)),
405 user_modify_(static_cast<unsigned>(EUserModify::kReadOnly)),
406 word_break_(static_cast<unsigned>(EWordBreak::kNormal)),
407 overflow_wrap_(static_cast<unsigned>(EOverflowWrap::kNormal)),
408 line_break_(static_cast<unsigned>(LineBreak::kAuto)),
409 user_select_(static_cast<unsigned>(EUserSelect::kText)),
410 speak_(static_cast<unsigned>(ESpeak::kNormal)),
411 hyphens_(static_cast<unsigned>(Hyphens::kManual)),
412 text_emphasis_fill_(kTextEmphasisFillFilled),
413 text_emphasis_mark_(kTextEmphasisMarkNone),
414 text_emphasis_position_(kTextEmphasisPositionOver),
415 text_align_last_(kTextAlignLastAuto),
416 text_justify_(kTextJustifyAuto),
417 text_orientation_(kTextOrientationMixed),
418 text_combine_(kTextCombineNone),
419 text_indent_line_(kTextIndentFirstLine),
420 text_indent_type_(kTextIndentNormal),
421 image_rendering_(kImageRenderingAuto),
422 text_underline_position_(kTextUnderlinePositionAuto),
423 text_decoration_skip_(kTextDecorationSkipObjects),
424 ruby_position_(kRubyPositionBefore),
425 subtree_will_change_contents_(false),
426 self_or_ancestor_has_dir_auto_attribute_(false),
427 respect_image_orientation_(false),
428 subtree_is_sticky_(false),
429 hyphenation_limit_before_(-1),
430 hyphenation_limit_after_(-1),
431 hyphenation_limit_lines_(-1),
432 line_height_step_(0),
433 tap_highlight_color_(LayoutTheme::TapHighlightColor()),
434 tab_size_(TabSize(8)),
435 text_size_adjust_(TextSizeAdjust::AdjustAuto()) {}
436
437 StyleRareInheritedData(const StyleRareInheritedData&) = default;
438 };
439
181 protected: 440 protected:
182 // non-inherited attributes 441 // non-inherited attributes
183 DataRef<StyleRareNonInheritedData> rare_non_inherited_data_; 442 DataRef<StyleRareNonInheritedData> rare_non_inherited_data_;
184 443
185 // inherited attributes 444 // inherited attributes
186 DataRef<StyleRareInheritedData> rare_inherited_data_; 445 DataRef<StyleRareInheritedData> rare_inherited_data_;
187 446
188 // list of associated pseudo styles 447 // list of associated pseudo styles
189 std::unique_ptr<PseudoStyleCache> cached_pseudo_styles_; 448 std::unique_ptr<PseudoStyleCache> cached_pseudo_styles_;
190 449
(...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after
3766 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 4025 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
3767 } 4026 }
3768 4027
3769 inline bool ComputedStyle::HasPseudoElementStyle() const { 4028 inline bool ComputedStyle::HasPseudoElementStyle() const {
3770 return PseudoBitsInternal() & kElementPseudoIdMask; 4029 return PseudoBitsInternal() & kElementPseudoIdMask;
3771 } 4030 }
3772 4031
3773 } // namespace blink 4032 } // namespace blink
3774 4033
3775 #endif // ComputedStyle_h 4034 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/BUILD.gn ('k') | third_party/WebKit/Source/core/style/StyleRareInheritedData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698