| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 RGBA32 color_; | 64 RGBA32 color_; |
| 65 unsigned bitfield_; | 65 unsigned bitfield_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); | 68 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); |
| 69 | 69 |
| 70 // Since different compilers/architectures pack ComputedStyle differently, | 70 // Since different compilers/architectures pack ComputedStyle differently, |
| 71 // re-create the same structure for an accurate size comparison. | 71 // re-create the same structure for an accurate size comparison. |
| 72 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { | 72 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
| 73 struct ComputedStyleBase { | 73 struct ComputedStyleBase { |
| 74 void* data_refs[4]; | 74 void* data_refs[5]; |
| 75 unsigned bitfields_[4]; | 75 unsigned bitfields_[4]; |
| 76 } base_; | 76 } base_; |
| 77 | 77 |
| 78 void* data_refs[3]; | 78 void* data_refs[2]; |
| 79 void* own_ptrs[1]; | 79 void* own_ptrs[1]; |
| 80 void* data_ref_svg_style; | 80 void* data_ref_svg_style; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // If this fails, the packing algorithm in make_computed_style_base.py has | 83 // If this fails, the packing algorithm in make_computed_style_base.py has |
| 84 // failed to produce the optimal packed size. To fix, update the algorithm to | 84 // failed to produce the optimal packed size. To fix, update the algorithm to |
| 85 // ensure that the buckets are placed so that each takes up at most 1 word. | 85 // ensure that the buckets are placed so that each takes up at most 1 word. |
| 86 ASSERT_SIZE(ComputedStyleBase<ComputedStyle>, SameSizeAsComputedStyleBase); | 86 ASSERT_SIZE(ComputedStyleBase<ComputedStyle>, SameSizeAsComputedStyleBase); |
| 87 | 87 |
| 88 // If this assert fails, it means that size of ComputedStyle has changed. Please | 88 // If this assert fails, it means that size of ComputedStyle has changed. Please |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 rare_non_inherited_data_.Access()->flexible_box_.Init(); | 124 rare_non_inherited_data_.Access()->flexible_box_.Init(); |
| 125 rare_non_inherited_data_.Access()->multi_col_.Init(); | 125 rare_non_inherited_data_.Access()->multi_col_.Init(); |
| 126 rare_non_inherited_data_.Access()->transform_.Init(); | 126 rare_non_inherited_data_.Access()->transform_.Init(); |
| 127 rare_non_inherited_data_.Access()->will_change_.Init(); | 127 rare_non_inherited_data_.Access()->will_change_.Init(); |
| 128 rare_non_inherited_data_.Access()->filter_.Init(); | 128 rare_non_inherited_data_.Access()->filter_.Init(); |
| 129 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); | 129 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); |
| 130 rare_non_inherited_data_.Access()->grid_.Init(); | 130 rare_non_inherited_data_.Access()->grid_.Init(); |
| 131 rare_non_inherited_data_.Access()->grid_item_.Init(); | 131 rare_non_inherited_data_.Access()->grid_item_.Init(); |
| 132 rare_non_inherited_data_.Access()->scroll_snap_.Init(); | 132 rare_non_inherited_data_.Access()->scroll_snap_.Init(); |
| 133 rare_inherited_data_.Init(); | 133 rare_inherited_data_.Init(); |
| 134 inherited_data_.Init(); | |
| 135 svg_style_.Init(); | 134 svg_style_.Init(); |
| 136 } | 135 } |
| 137 | 136 |
| 138 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) | 137 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) |
| 139 : ComputedStyleBase(o), | 138 : ComputedStyleBase(o), |
| 140 RefCounted<ComputedStyle>(), | 139 RefCounted<ComputedStyle>(), |
| 141 rare_non_inherited_data_(o.rare_non_inherited_data_), | 140 rare_non_inherited_data_(o.rare_non_inherited_data_), |
| 142 rare_inherited_data_(o.rare_inherited_data_), | 141 rare_inherited_data_(o.rare_inherited_data_), |
| 143 inherited_data_(o.inherited_data_), | |
| 144 svg_style_(o.svg_style_) {} | 142 svg_style_(o.svg_style_) {} |
| 145 | 143 |
| 146 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, | 144 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, |
| 147 const ComputedStyle& new_style) { | 145 const ComputedStyle& new_style) { |
| 148 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. | 146 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. |
| 149 if (!old_style.HasAnyPublicPseudoStyles() && | 147 if (!old_style.HasAnyPublicPseudoStyles() && |
| 150 !new_style.HasAnyPublicPseudoStyles()) | 148 !new_style.HasAnyPublicPseudoStyles()) |
| 151 return kNoChange; | 149 return kNoChange; |
| 152 for (PseudoId pseudo_id = kFirstPublicPseudoId; | 150 for (PseudoId pseudo_id = kFirstPublicPseudoId; |
| 153 pseudo_id < kFirstInternalPseudoId; | 151 pseudo_id < kFirstInternalPseudoId; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 return ResolvedContentAlignmentDistribution(AlignContent(), | 308 return ResolvedContentAlignmentDistribution(AlignContent(), |
| 311 normal_value_behavior); | 309 normal_value_behavior); |
| 312 } | 310 } |
| 313 | 311 |
| 314 void ComputedStyle::InheritFrom(const ComputedStyle& inherit_parent, | 312 void ComputedStyle::InheritFrom(const ComputedStyle& inherit_parent, |
| 315 IsAtShadowBoundary is_at_shadow_boundary) { | 313 IsAtShadowBoundary is_at_shadow_boundary) { |
| 316 EUserModify current_user_modify = UserModify(); | 314 EUserModify current_user_modify = UserModify(); |
| 317 | 315 |
| 318 ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary); | 316 ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary); |
| 319 rare_inherited_data_ = inherit_parent.rare_inherited_data_; | 317 rare_inherited_data_ = inherit_parent.rare_inherited_data_; |
| 320 inherited_data_ = inherit_parent.inherited_data_; | |
| 321 if (svg_style_ != inherit_parent.svg_style_) | 318 if (svg_style_ != inherit_parent.svg_style_) |
| 322 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); | 319 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); |
| 323 | 320 |
| 324 if (is_at_shadow_boundary == kAtShadowBoundary) { | 321 if (is_at_shadow_boundary == kAtShadowBoundary) { |
| 325 // Even if surrounding content is user-editable, shadow DOM should act as a | 322 // Even if surrounding content is user-editable, shadow DOM should act as a |
| 326 // single unit, and not necessarily be editable | 323 // single unit, and not necessarily be editable |
| 327 SetUserModify(current_user_modify); | 324 SetUserModify(current_user_modify); |
| 328 } | 325 } |
| 329 } | 326 } |
| 330 | 327 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 447 } |
| 451 | 448 |
| 452 bool ComputedStyle::IndependentInheritedEqual( | 449 bool ComputedStyle::IndependentInheritedEqual( |
| 453 const ComputedStyle& other) const { | 450 const ComputedStyle& other) const { |
| 454 return ComputedStyleBase::IndependentInheritedEqual(other); | 451 return ComputedStyleBase::IndependentInheritedEqual(other); |
| 455 } | 452 } |
| 456 | 453 |
| 457 bool ComputedStyle::NonIndependentInheritedEqual( | 454 bool ComputedStyle::NonIndependentInheritedEqual( |
| 458 const ComputedStyle& other) const { | 455 const ComputedStyle& other) const { |
| 459 return ComputedStyleBase::NonIndependentInheritedEqual(other) && | 456 return ComputedStyleBase::NonIndependentInheritedEqual(other) && |
| 460 inherited_data_ == other.inherited_data_ && | |
| 461 svg_style_->InheritedEqual(*other.svg_style_) && | 457 svg_style_->InheritedEqual(*other.svg_style_) && |
| 462 rare_inherited_data_ == other.rare_inherited_data_; | 458 rare_inherited_data_ == other.rare_inherited_data_; |
| 463 } | 459 } |
| 464 | 460 |
| 465 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { | 461 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { |
| 466 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); | 462 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); |
| 467 } | 463 } |
| 468 | 464 |
| 469 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { | 465 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { |
| 470 // compare everything except the pseudoStyle pointer | 466 // compare everything except the pseudoStyle pointer |
| 471 return ComputedStyleBase::NonInheritedEqual(other) && | 467 return ComputedStyleBase::NonInheritedEqual(other) && |
| 472 rare_non_inherited_data_ == other.rare_non_inherited_data_ && | 468 rare_non_inherited_data_ == other.rare_non_inherited_data_ && |
| 473 svg_style_->NonInheritedEqual(*other.svg_style_); | 469 svg_style_->NonInheritedEqual(*other.svg_style_); |
| 474 } | 470 } |
| 475 | 471 |
| 476 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { | 472 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { |
| 477 // This is a fast check that only looks if the data structures are shared. | 473 // This is a fast check that only looks if the data structures are shared. |
| 478 return ComputedStyleBase::InheritedDataShared(other) && | 474 return ComputedStyleBase::InheritedDataShared(other) && |
| 479 inherited_data_.Get() == other.inherited_data_.Get() && | |
| 480 svg_style_.Get() == other.svg_style_.Get() && | 475 svg_style_.Get() == other.svg_style_.Get() && |
| 481 rare_inherited_data_.Get() == other.rare_inherited_data_.Get(); | 476 rare_inherited_data_.Get() == other.rare_inherited_data_.Get(); |
| 482 } | 477 } |
| 483 | 478 |
| 484 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, | 479 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, |
| 485 const ComputedStyle& b) { | 480 const ComputedStyle& b) { |
| 486 // If top or bottom become auto/non-auto then it means we either have to solve | 481 // If top or bottom become auto/non-auto then it means we either have to solve |
| 487 // height based on the content or stop doing so | 482 // height based on the content or stop doing so |
| 488 // (http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height) | 483 // (http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height) |
| 489 // - either way requires a layout. | 484 // - either way requires a layout. |
| (...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2503 if (value < 0) | 2498 if (value < 0) |
| 2504 fvalue -= 0.5f; | 2499 fvalue -= 0.5f; |
| 2505 else | 2500 else |
| 2506 fvalue += 0.5f; | 2501 fvalue += 0.5f; |
| 2507 } | 2502 } |
| 2508 | 2503 |
| 2509 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2504 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
| 2510 } | 2505 } |
| 2511 | 2506 |
| 2512 } // namespace blink | 2507 } // namespace blink |
| OLD | NEW |