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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return new_style; | 108 return new_style; |
109 } | 109 } |
110 | 110 |
111 PassRefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) { | 111 PassRefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) { |
112 return AdoptRef(new ComputedStyle(other)); | 112 return AdoptRef(new ComputedStyle(other)); |
113 } | 113 } |
114 | 114 |
115 ALWAYS_INLINE ComputedStyle::ComputedStyle() | 115 ALWAYS_INLINE ComputedStyle::ComputedStyle() |
116 : ComputedStyleBase(), RefCounted<ComputedStyle>() { | 116 : ComputedStyleBase(), RefCounted<ComputedStyle>() { |
117 box_data_.Init(); | 117 box_data_.Init(); |
118 visual_data_.Init(); | |
119 rare_non_inherited_data_.Init(); | 118 rare_non_inherited_data_.Init(); |
120 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init(); | 119 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init(); |
121 rare_non_inherited_data_.Access()->flexible_box_.Init(); | 120 rare_non_inherited_data_.Access()->flexible_box_.Init(); |
122 rare_non_inherited_data_.Access()->multi_col_.Init(); | 121 rare_non_inherited_data_.Access()->multi_col_.Init(); |
123 rare_non_inherited_data_.Access()->transform_.Init(); | 122 rare_non_inherited_data_.Access()->transform_.Init(); |
124 rare_non_inherited_data_.Access()->will_change_.Init(); | 123 rare_non_inherited_data_.Access()->will_change_.Init(); |
125 rare_non_inherited_data_.Access()->filter_.Init(); | 124 rare_non_inherited_data_.Access()->filter_.Init(); |
126 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); | 125 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); |
127 rare_non_inherited_data_.Access()->grid_.Init(); | 126 rare_non_inherited_data_.Access()->grid_.Init(); |
128 rare_non_inherited_data_.Access()->grid_item_.Init(); | 127 rare_non_inherited_data_.Access()->grid_item_.Init(); |
129 rare_non_inherited_data_.Access()->scroll_snap_.Init(); | 128 rare_non_inherited_data_.Access()->scroll_snap_.Init(); |
130 rare_inherited_data_.Init(); | 129 rare_inherited_data_.Init(); |
131 style_inherited_data_.Init(); | 130 style_inherited_data_.Init(); |
132 svg_style_.Init(); | 131 svg_style_.Init(); |
133 } | 132 } |
134 | 133 |
135 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) | 134 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) |
136 : ComputedStyleBase(o), | 135 : ComputedStyleBase(o), |
137 RefCounted<ComputedStyle>(), | 136 RefCounted<ComputedStyle>(), |
138 box_data_(o.box_data_), | 137 box_data_(o.box_data_), |
139 visual_data_(o.visual_data_), | |
140 rare_non_inherited_data_(o.rare_non_inherited_data_), | 138 rare_non_inherited_data_(o.rare_non_inherited_data_), |
141 rare_inherited_data_(o.rare_inherited_data_), | 139 rare_inherited_data_(o.rare_inherited_data_), |
142 style_inherited_data_(o.style_inherited_data_), | 140 style_inherited_data_(o.style_inherited_data_), |
143 svg_style_(o.svg_style_) {} | 141 svg_style_(o.svg_style_) {} |
144 | 142 |
145 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, | 143 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, |
146 const ComputedStyle& new_style) { | 144 const ComputedStyle& new_style) { |
147 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. | 145 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. |
148 if (!old_style.HasAnyPublicPseudoStyles() && | 146 if (!old_style.HasAnyPublicPseudoStyles() && |
149 !new_style.HasAnyPublicPseudoStyles()) | 147 !new_style.HasAnyPublicPseudoStyles()) |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 rare_inherited_data_ = inherit_parent.rare_inherited_data_; | 321 rare_inherited_data_ = inherit_parent.rare_inherited_data_; |
324 } | 322 } |
325 style_inherited_data_ = inherit_parent.style_inherited_data_; | 323 style_inherited_data_ = inherit_parent.style_inherited_data_; |
326 if (svg_style_ != inherit_parent.svg_style_) | 324 if (svg_style_ != inherit_parent.svg_style_) |
327 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); | 325 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); |
328 } | 326 } |
329 | 327 |
330 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { | 328 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { |
331 ComputedStyleBase::CopyNonInheritedFromCached(other); | 329 ComputedStyleBase::CopyNonInheritedFromCached(other); |
332 box_data_ = other.box_data_; | 330 box_data_ = other.box_data_; |
333 visual_data_ = other.visual_data_; | |
334 rare_non_inherited_data_ = other.rare_non_inherited_data_; | 331 rare_non_inherited_data_ = other.rare_non_inherited_data_; |
335 | 332 |
336 // The flags are copied one-by-one because they contain | 333 // The flags are copied one-by-one because they contain |
337 // bunch of stuff other than real style data. | 334 // bunch of stuff other than real style data. |
338 // See comments for each skipped flag below. | 335 // See comments for each skipped flag below. |
339 | 336 |
340 // These are not generated in ComputedStyleBase | 337 // These are not generated in ComputedStyleBase |
341 SetOriginalDisplay(other.OriginalDisplay()); | 338 SetOriginalDisplay(other.OriginalDisplay()); |
342 SetVerticalAlign(other.VerticalAlign()); | 339 SetVerticalAlign(other.VerticalAlign()); |
343 SetHasViewportUnits(other.HasViewportUnits()); | 340 SetHasViewportUnits(other.HasViewportUnits()); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 467 } |
471 | 468 |
472 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { | 469 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { |
473 // compare everything except the pseudoStyle pointer | 470 // compare everything except the pseudoStyle pointer |
474 return ComputedStyleBase::NonInheritedEqual(other) && | 471 return ComputedStyleBase::NonInheritedEqual(other) && |
475 OriginalDisplay() == | 472 OriginalDisplay() == |
476 other.OriginalDisplay() && // Not generated in ComputedStyleBase | 473 other.OriginalDisplay() && // Not generated in ComputedStyleBase |
477 VerticalAlign() == other.VerticalAlign() && // Not generated in | 474 VerticalAlign() == other.VerticalAlign() && // Not generated in |
478 // ComputedStyleBase | 475 // ComputedStyleBase |
479 box_data_ == other.box_data_ && | 476 box_data_ == other.box_data_ && |
480 visual_data_ == other.visual_data_ && | |
481 rare_non_inherited_data_ == other.rare_non_inherited_data_ && | 477 rare_non_inherited_data_ == other.rare_non_inherited_data_ && |
482 svg_style_->NonInheritedEqual(*other.svg_style_); | 478 svg_style_->NonInheritedEqual(*other.svg_style_); |
483 } | 479 } |
484 | 480 |
485 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { | 481 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { |
486 // This is a fast check that only looks if the data structures are shared. | 482 // This is a fast check that only looks if the data structures are shared. |
487 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method? | 483 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method? |
488 return ComputedStyleBase::InheritedEqual(other) && | 484 return ComputedStyleBase::InheritedEqual(other) && |
489 style_inherited_data_.Get() == other.style_inherited_data_.Get() && | 485 style_inherited_data_.Get() == other.style_inherited_data_.Get() && |
490 svg_style_.Get() == other.svg_style_.Get() && | 486 svg_style_.Get() == other.svg_style_.Get() && |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 } | 1042 } |
1047 | 1043 |
1048 if (!Border().VisualOverflowEqual(other.Border())) | 1044 if (!Border().VisualOverflowEqual(other.Border())) |
1049 diff.SetNeedsRecomputeOverflow(); | 1045 diff.SetNeedsRecomputeOverflow(); |
1050 | 1046 |
1051 if (!diff.NeedsFullPaintInvalidation()) { | 1047 if (!diff.NeedsFullPaintInvalidation()) { |
1052 if (style_inherited_data_->color != other.style_inherited_data_->color || | 1048 if (style_inherited_data_->color != other.style_inherited_data_->color || |
1053 style_inherited_data_->visited_link_color != | 1049 style_inherited_data_->visited_link_color != |
1054 other.style_inherited_data_->visited_link_color || | 1050 other.style_inherited_data_->visited_link_color || |
1055 HasSimpleUnderlineInternal() != other.HasSimpleUnderlineInternal() || | 1051 HasSimpleUnderlineInternal() != other.HasSimpleUnderlineInternal() || |
1056 visual_data_->text_decoration != other.visual_data_->text_decoration) { | 1052 visual_data_->text_decoration_ != |
| 1053 other.visual_data_->text_decoration_) { |
1057 diff.SetTextDecorationOrColorChanged(); | 1054 diff.SetTextDecorationOrColorChanged(); |
1058 } else if (rare_non_inherited_data_.Get() != | 1055 } else if (rare_non_inherited_data_.Get() != |
1059 other.rare_non_inherited_data_.Get() && | 1056 other.rare_non_inherited_data_.Get() && |
1060 (rare_non_inherited_data_->text_decoration_style_ != | 1057 (rare_non_inherited_data_->text_decoration_style_ != |
1061 other.rare_non_inherited_data_->text_decoration_style_ || | 1058 other.rare_non_inherited_data_->text_decoration_style_ || |
1062 rare_non_inherited_data_->text_decoration_color_ != | 1059 rare_non_inherited_data_->text_decoration_color_ != |
1063 other.rare_non_inherited_data_->text_decoration_color_ || | 1060 other.rare_non_inherited_data_->text_decoration_color_ || |
1064 rare_non_inherited_data_->visited_link_text_decoration_color_ != | 1061 rare_non_inherited_data_->visited_link_text_decoration_color_ != |
1065 other.rare_non_inherited_data_ | 1062 other.rare_non_inherited_data_ |
1066 ->visited_link_text_decoration_color_)) { | 1063 ->visited_link_text_decoration_color_)) { |
(...skipping 21 matching lines...) Expand all Loading... |
1088 rare_inherited_data_->applied_text_decorations != | 1085 rare_inherited_data_->applied_text_decorations != |
1089 other.rare_inherited_data_->applied_text_decorations || | 1086 other.rare_inherited_data_->applied_text_decorations || |
1090 rare_inherited_data_->CaretColor() != | 1087 rare_inherited_data_->CaretColor() != |
1091 other.rare_inherited_data_->CaretColor() || | 1088 other.rare_inherited_data_->CaretColor() || |
1092 rare_inherited_data_->VisitedLinkCaretColor() != | 1089 rare_inherited_data_->VisitedLinkCaretColor() != |
1093 other.rare_inherited_data_->VisitedLinkCaretColor())) { | 1090 other.rare_inherited_data_->VisitedLinkCaretColor())) { |
1094 diff.SetTextDecorationOrColorChanged(); | 1091 diff.SetTextDecorationOrColorChanged(); |
1095 } | 1092 } |
1096 } | 1093 } |
1097 | 1094 |
1098 bool has_clip = HasOutOfFlowPosition() && !visual_data_->has_auto_clip; | 1095 bool has_clip = HasOutOfFlowPosition() && !visual_data_->has_auto_clip_; |
1099 bool other_has_clip = | 1096 bool other_has_clip = |
1100 other.HasOutOfFlowPosition() && !other.visual_data_->has_auto_clip; | 1097 other.HasOutOfFlowPosition() && !other.visual_data_->has_auto_clip_; |
1101 if (has_clip != other_has_clip || | 1098 if (has_clip != other_has_clip || |
1102 (has_clip && visual_data_->clip != other.visual_data_->clip)) | 1099 (has_clip && visual_data_->clip_ != other.visual_data_->clip_)) |
1103 diff.SetCSSClipChanged(); | 1100 diff.SetCSSClipChanged(); |
1104 } | 1101 } |
1105 | 1102 |
1106 void ComputedStyle::AddPaintImage(StyleImage* image) { | 1103 void ComputedStyle::AddPaintImage(StyleImage* image) { |
1107 if (!rare_non_inherited_data_.Access()->paint_images_) { | 1104 if (!rare_non_inherited_data_.Access()->paint_images_) { |
1108 rare_non_inherited_data_.Access()->paint_images_ = | 1105 rare_non_inherited_data_.Access()->paint_images_ = |
1109 WTF::MakeUnique<Vector<Persistent<StyleImage>>>(); | 1106 WTF::MakeUnique<Vector<Persistent<StyleImage>>>(); |
1110 } | 1107 } |
1111 rare_non_inherited_data_.Access()->paint_images_->push_back(image); | 1108 rare_non_inherited_data_.Access()->paint_images_->push_back(image); |
1112 } | 1109 } |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 if (value < 0) | 2493 if (value < 0) |
2497 fvalue -= 0.5f; | 2494 fvalue -= 0.5f; |
2498 else | 2495 else |
2499 fvalue += 0.5f; | 2496 fvalue += 0.5f; |
2500 } | 2497 } |
2501 | 2498 |
2502 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2499 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
2503 } | 2500 } |
2504 | 2501 |
2505 } // namespace blink | 2502 } // namespace blink |
OLD | NEW |