| 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[5]; | 75 void* data_refs[6]; |
| 76 unsigned bitfields_[4]; | 76 unsigned bitfields_[4]; |
| 77 } base_; | 77 } base_; |
| 78 | 78 |
| 79 void* data_refs[2]; | 79 void* data_refs[1]; |
| 80 void* own_ptrs[1]; | 80 void* own_ptrs[1]; |
| 81 void* data_ref_svg_style; | 81 void* data_ref_svg_style; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // If this fails, the packing algorithm in make_computed_style_base.py has | 84 // If this fails, the packing algorithm in make_computed_style_base.py has |
| 85 // failed to produce the optimal packed size. To fix, update the algorithm to | 85 // failed to produce the optimal packed size. To fix, update the algorithm to |
| 86 // ensure that the buckets are placed so that each takes up at most 1 word. | 86 // ensure that the buckets are placed so that each takes up at most 1 word. |
| 87 ASSERT_SIZE(ComputedStyleBase<ComputedStyle>, SameSizeAsComputedStyleBase); | 87 ASSERT_SIZE(ComputedStyleBase<ComputedStyle>, SameSizeAsComputedStyleBase); |
| 88 | 88 |
| 89 // If this assert fails, it means that size of ComputedStyle has changed. Please | 89 // If this assert fails, it means that size of ComputedStyle has changed. Please |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init(); | 131 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init(); |
| 132 rare_non_inherited_data_.Access()->flexible_box_.Init(); | 132 rare_non_inherited_data_.Access()->flexible_box_.Init(); |
| 133 rare_non_inherited_data_.Access()->multi_col_.Init(); | 133 rare_non_inherited_data_.Access()->multi_col_.Init(); |
| 134 rare_non_inherited_data_.Access()->transform_.Init(); | 134 rare_non_inherited_data_.Access()->transform_.Init(); |
| 135 rare_non_inherited_data_.Access()->will_change_.Init(); | 135 rare_non_inherited_data_.Access()->will_change_.Init(); |
| 136 rare_non_inherited_data_.Access()->filter_.Init(); | 136 rare_non_inherited_data_.Access()->filter_.Init(); |
| 137 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); | 137 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); |
| 138 rare_non_inherited_data_.Access()->grid_.Init(); | 138 rare_non_inherited_data_.Access()->grid_.Init(); |
| 139 rare_non_inherited_data_.Access()->grid_item_.Init(); | 139 rare_non_inherited_data_.Access()->grid_item_.Init(); |
| 140 rare_non_inherited_data_.Access()->scroll_snap_.Init(); | 140 rare_non_inherited_data_.Access()->scroll_snap_.Init(); |
| 141 rare_inherited_data_.Init(); | |
| 142 svg_style_.Init(); | 141 svg_style_.Init(); |
| 143 } | 142 } |
| 144 | 143 |
| 145 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) | 144 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) |
| 146 : ComputedStyleBase(o), | 145 : ComputedStyleBase(o), |
| 147 RefCounted<ComputedStyle>(), | 146 RefCounted<ComputedStyle>(), |
| 148 rare_non_inherited_data_(o.rare_non_inherited_data_), | 147 rare_non_inherited_data_(o.rare_non_inherited_data_), |
| 149 rare_inherited_data_(o.rare_inherited_data_), | |
| 150 svg_style_(o.svg_style_) {} | 148 svg_style_(o.svg_style_) {} |
| 151 | 149 |
| 152 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, | 150 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, |
| 153 const ComputedStyle& new_style) { | 151 const ComputedStyle& new_style) { |
| 154 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. | 152 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. |
| 155 if (!old_style.HasAnyPublicPseudoStyles() && | 153 if (!old_style.HasAnyPublicPseudoStyles() && |
| 156 !new_style.HasAnyPublicPseudoStyles()) | 154 !new_style.HasAnyPublicPseudoStyles()) |
| 157 return kNoChange; | 155 return kNoChange; |
| 158 for (PseudoId pseudo_id = kFirstPublicPseudoId; | 156 for (PseudoId pseudo_id = kFirstPublicPseudoId; |
| 159 pseudo_id < kFirstInternalPseudoId; | 157 pseudo_id < kFirstInternalPseudoId; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 const StyleContentAlignmentData& normal_value_behavior) const { | 313 const StyleContentAlignmentData& normal_value_behavior) const { |
| 316 return ResolvedContentAlignmentDistribution(AlignContent(), | 314 return ResolvedContentAlignmentDistribution(AlignContent(), |
| 317 normal_value_behavior); | 315 normal_value_behavior); |
| 318 } | 316 } |
| 319 | 317 |
| 320 void ComputedStyle::InheritFrom(const ComputedStyle& inherit_parent, | 318 void ComputedStyle::InheritFrom(const ComputedStyle& inherit_parent, |
| 321 IsAtShadowBoundary is_at_shadow_boundary) { | 319 IsAtShadowBoundary is_at_shadow_boundary) { |
| 322 EUserModify current_user_modify = UserModify(); | 320 EUserModify current_user_modify = UserModify(); |
| 323 | 321 |
| 324 ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary); | 322 ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary); |
| 325 rare_inherited_data_ = inherit_parent.rare_inherited_data_; | |
| 326 if (svg_style_ != inherit_parent.svg_style_) | 323 if (svg_style_ != inherit_parent.svg_style_) |
| 327 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); | 324 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); |
| 328 | 325 |
| 329 if (is_at_shadow_boundary == kAtShadowBoundary) { | 326 if (is_at_shadow_boundary == kAtShadowBoundary) { |
| 330 // Even if surrounding content is user-editable, shadow DOM should act as a | 327 // Even if surrounding content is user-editable, shadow DOM should act as a |
| 331 // single unit, and not necessarily be editable | 328 // single unit, and not necessarily be editable |
| 332 SetUserModify(current_user_modify); | 329 SetUserModify(current_user_modify); |
| 333 } | 330 } |
| 334 } | 331 } |
| 335 | 332 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } | 452 } |
| 456 | 453 |
| 457 bool ComputedStyle::IndependentInheritedEqual( | 454 bool ComputedStyle::IndependentInheritedEqual( |
| 458 const ComputedStyle& other) const { | 455 const ComputedStyle& other) const { |
| 459 return ComputedStyleBase::IndependentInheritedEqual(other); | 456 return ComputedStyleBase::IndependentInheritedEqual(other); |
| 460 } | 457 } |
| 461 | 458 |
| 462 bool ComputedStyle::NonIndependentInheritedEqual( | 459 bool ComputedStyle::NonIndependentInheritedEqual( |
| 463 const ComputedStyle& other) const { | 460 const ComputedStyle& other) const { |
| 464 return ComputedStyleBase::NonIndependentInheritedEqual(other) && | 461 return ComputedStyleBase::NonIndependentInheritedEqual(other) && |
| 465 svg_style_->InheritedEqual(*other.svg_style_) && | 462 svg_style_->InheritedEqual(*other.svg_style_); |
| 466 rare_inherited_data_ == other.rare_inherited_data_; | |
| 467 } | 463 } |
| 468 | 464 |
| 469 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { | 465 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { |
| 470 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); | 466 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); |
| 471 } | 467 } |
| 472 | 468 |
| 473 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { | 469 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { |
| 474 // compare everything except the pseudoStyle pointer | 470 // compare everything except the pseudoStyle pointer |
| 475 return ComputedStyleBase::NonInheritedEqual(other) && | 471 return ComputedStyleBase::NonInheritedEqual(other) && |
| 476 rare_non_inherited_data_ == other.rare_non_inherited_data_ && | 472 rare_non_inherited_data_ == other.rare_non_inherited_data_ && |
| 477 svg_style_->NonInheritedEqual(*other.svg_style_); | 473 svg_style_->NonInheritedEqual(*other.svg_style_); |
| 478 } | 474 } |
| 479 | 475 |
| 480 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { | 476 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { |
| 481 // This is a fast check that only looks if the data structures are shared. | 477 // This is a fast check that only looks if the data structures are shared. |
| 482 return ComputedStyleBase::InheritedDataShared(other) && | 478 return ComputedStyleBase::InheritedDataShared(other) && |
| 483 svg_style_.Get() == other.svg_style_.Get() && | 479 svg_style_.Get() == other.svg_style_.Get(); |
| 484 rare_inherited_data_.Get() == other.rare_inherited_data_.Get(); | |
| 485 } | 480 } |
| 486 | 481 |
| 487 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, | 482 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, |
| 488 const ComputedStyle& b) { | 483 const ComputedStyle& b) { |
| 489 // If top or bottom become auto/non-auto then it means we either have to solve | 484 // If top or bottom become auto/non-auto then it means we either have to solve |
| 490 // height based on the content or stop doing so | 485 // height based on the content or stop doing so |
| 491 // (http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height) | 486 // (http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height) |
| 492 // - either way requires a layout. | 487 // - either way requires a layout. |
| 493 return a.LogicalTop().IsAuto() != b.LogicalTop().IsAuto() || | 488 return a.LogicalTop().IsAuto() != b.LogicalTop().IsAuto() || |
| 494 a.LogicalBottom().IsAuto() != b.LogicalBottom().IsAuto(); | 489 a.LogicalBottom().IsAuto() != b.LogicalBottom().IsAuto(); |
| (...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 if (value < 0) | 2450 if (value < 0) |
| 2456 fvalue -= 0.5f; | 2451 fvalue -= 0.5f; |
| 2457 else | 2452 else |
| 2458 fvalue += 0.5f; | 2453 fvalue += 0.5f; |
| 2459 } | 2454 } |
| 2460 | 2455 |
| 2461 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2456 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
| 2462 } | 2457 } |
| 2463 | 2458 |
| 2464 } // namespace blink | 2459 } // namespace blink |
| OLD | NEW |