OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 * Copyright (C) 2011 Adobe Systems Incorporated. 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. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 RGBA32 color_; | 65 RGBA32 color_; |
66 unsigned bitfield_; | 66 unsigned bitfield_; |
67 }; | 67 }; |
68 | 68 |
69 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); | 69 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); |
70 | 70 |
71 // Since different compilers/architectures pack ComputedStyle differently, | 71 // Since different compilers/architectures pack ComputedStyle differently, |
72 // re-create the same structure for an accurate size comparison. | 72 // re-create the same structure for an accurate size comparison. |
73 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { | 73 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
74 struct ComputedStyleBase { | 74 struct ComputedStyleBase { |
75 void* data_refs[6]; | 75 void* data_refs[7]; |
76 unsigned bitfields_[4]; | 76 unsigned bitfields_[4]; |
77 } base_; | 77 } base_; |
78 | 78 |
79 void* data_refs[1]; | |
80 void* own_ptrs[1]; | 79 void* own_ptrs[1]; |
81 void* data_ref_svg_style; | 80 void* data_ref_svg_style; |
82 }; | 81 }; |
83 | 82 |
84 // If this assert fails, it means that size of ComputedStyle has changed. Please | 83 // If this assert fails, it means that size of ComputedStyle has changed. Please |
85 // check that you really *do* what to increase the size of ComputedStyle, then | 84 // check that you really *do* what to increase the size of ComputedStyle, then |
86 // update the SameSizeAsComputedStyle struct to match the updated storage of | 85 // update the SameSizeAsComputedStyle struct to match the updated storage of |
87 // ComputedStyle. | 86 // ComputedStyle. |
88 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); | 87 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); |
89 | 88 |
(...skipping 25 matching lines...) Expand all Loading... |
115 new_style->SetDisplay(display); | 114 new_style->SetDisplay(display); |
116 return new_style; | 115 return new_style; |
117 } | 116 } |
118 | 117 |
119 RefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) { | 118 RefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) { |
120 return AdoptRef(new ComputedStyle(other)); | 119 return AdoptRef(new ComputedStyle(other)); |
121 } | 120 } |
122 | 121 |
123 ALWAYS_INLINE ComputedStyle::ComputedStyle() | 122 ALWAYS_INLINE ComputedStyle::ComputedStyle() |
124 : ComputedStyleBase(), RefCounted<ComputedStyle>() { | 123 : ComputedStyleBase(), RefCounted<ComputedStyle>() { |
125 rare_non_inherited_data_.Init(); | 124 // TODO(shend): Generate these. |
126 rare_non_inherited_data_.Access()->deprecated_flexible_box_data_.Init(); | 125 rare_non_inherited_data_.Access()->deprecated_flexible_box_data_.Init(); |
127 rare_non_inherited_data_.Access()->flexible_box_data_.Init(); | 126 rare_non_inherited_data_.Access()->flexible_box_data_.Init(); |
128 rare_non_inherited_data_.Access()->multi_col_data_.Init(); | 127 rare_non_inherited_data_.Access()->multi_col_data_.Init(); |
129 rare_non_inherited_data_.Access()->transform_data_.Init(); | 128 rare_non_inherited_data_.Access()->transform_data_.Init(); |
130 rare_non_inherited_data_.Access()->will_change_data_.Init(); | 129 rare_non_inherited_data_.Access()->will_change_data_.Init(); |
131 rare_non_inherited_data_.Access()->grid_data_.Init(); | 130 rare_non_inherited_data_.Access()->grid_data_.Init(); |
132 rare_non_inherited_data_.Access()->grid_item_data_.Init(); | 131 rare_non_inherited_data_.Access()->grid_item_data_.Init(); |
133 rare_non_inherited_data_.Access()->scroll_snap_data_.Init(); | 132 rare_non_inherited_data_.Access()->scroll_snap_data_.Init(); |
134 svg_style_.Init(); | 133 svg_style_.Init(); |
135 } | 134 } |
136 | 135 |
137 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) | 136 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) |
138 : ComputedStyleBase(o), | 137 : ComputedStyleBase(o), |
139 RefCounted<ComputedStyle>(), | 138 RefCounted<ComputedStyle>(), |
140 rare_non_inherited_data_(o.rare_non_inherited_data_), | |
141 svg_style_(o.svg_style_) {} | 139 svg_style_(o.svg_style_) {} |
142 | 140 |
143 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, | 141 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, |
144 const ComputedStyle& new_style) { | 142 const ComputedStyle& new_style) { |
145 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. | 143 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. |
146 if (!old_style.HasAnyPublicPseudoStyles() && | 144 if (!old_style.HasAnyPublicPseudoStyles() && |
147 !new_style.HasAnyPublicPseudoStyles()) | 145 !new_style.HasAnyPublicPseudoStyles()) |
148 return kNoChange; | 146 return kNoChange; |
149 for (PseudoId pseudo_id = kFirstPublicPseudoId; | 147 for (PseudoId pseudo_id = kFirstPublicPseudoId; |
150 pseudo_id < kFirstInternalPseudoId; | 148 pseudo_id < kFirstInternalPseudoId; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // Even if surrounding content is user-editable, shadow DOM should act as a | 308 // Even if surrounding content is user-editable, shadow DOM should act as a |
311 // single unit, and not necessarily be editable | 309 // single unit, and not necessarily be editable |
312 SetUserModify(current_user_modify); | 310 SetUserModify(current_user_modify); |
313 } | 311 } |
314 } | 312 } |
315 | 313 |
316 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { | 314 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { |
317 DCHECK(MatchedPropertiesCache::IsStyleCacheable(other)); | 315 DCHECK(MatchedPropertiesCache::IsStyleCacheable(other)); |
318 | 316 |
319 ComputedStyleBase::CopyNonInheritedFromCached(other); | 317 ComputedStyleBase::CopyNonInheritedFromCached(other); |
320 rare_non_inherited_data_ = other.rare_non_inherited_data_; | |
321 | 318 |
322 // The flags are copied one-by-one because they contain | 319 // The flags are copied one-by-one because they contain |
323 // bunch of stuff other than real style data. | 320 // bunch of stuff other than real style data. |
324 // See comments for each skipped flag below. | 321 // See comments for each skipped flag below. |
325 | 322 |
326 // Correctly set during selector matching: | 323 // Correctly set during selector matching: |
327 // m_styleType | 324 // m_styleType |
328 // m_pseudoBits | 325 // m_pseudoBits |
329 | 326 |
330 // Set correctly while computing style for children: | 327 // Set correctly while computing style for children: |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 svg_style_->InheritedEqual(*other.svg_style_); | 432 svg_style_->InheritedEqual(*other.svg_style_); |
436 } | 433 } |
437 | 434 |
438 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { | 435 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { |
439 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); | 436 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); |
440 } | 437 } |
441 | 438 |
442 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { | 439 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { |
443 // compare everything except the pseudoStyle pointer | 440 // compare everything except the pseudoStyle pointer |
444 return ComputedStyleBase::NonInheritedEqual(other) && | 441 return ComputedStyleBase::NonInheritedEqual(other) && |
445 rare_non_inherited_data_ == other.rare_non_inherited_data_ && | |
446 svg_style_->NonInheritedEqual(*other.svg_style_); | 442 svg_style_->NonInheritedEqual(*other.svg_style_); |
447 } | 443 } |
448 | 444 |
449 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { | 445 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { |
450 // This is a fast check that only looks if the data structures are shared. | 446 // This is a fast check that only looks if the data structures are shared. |
451 return ComputedStyleBase::InheritedDataShared(other) && | 447 return ComputedStyleBase::InheritedDataShared(other) && |
452 svg_style_.Get() == other.svg_style_.Get(); | 448 svg_style_.Get() == other.svg_style_.Get(); |
453 } | 449 } |
454 | 450 |
455 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, | 451 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, |
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 if (value < 0) | 2375 if (value < 0) |
2380 fvalue -= 0.5f; | 2376 fvalue -= 0.5f; |
2381 else | 2377 else |
2382 fvalue += 0.5f; | 2378 fvalue += 0.5f; |
2383 } | 2379 } |
2384 | 2380 |
2385 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2381 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
2386 } | 2382 } |
2387 | 2383 |
2388 } // namespace blink | 2384 } // namespace blink |
OLD | NEW |