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

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

Issue 2845463003: Rename StyleInheritedData members. (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) 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 rare_non_inherited_data_.Access()->flexible_box_.Init(); 122 rare_non_inherited_data_.Access()->flexible_box_.Init();
123 rare_non_inherited_data_.Access()->multi_col_.Init(); 123 rare_non_inherited_data_.Access()->multi_col_.Init();
124 rare_non_inherited_data_.Access()->transform_.Init(); 124 rare_non_inherited_data_.Access()->transform_.Init();
125 rare_non_inherited_data_.Access()->will_change_.Init(); 125 rare_non_inherited_data_.Access()->will_change_.Init();
126 rare_non_inherited_data_.Access()->filter_.Init(); 126 rare_non_inherited_data_.Access()->filter_.Init();
127 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); 127 rare_non_inherited_data_.Access()->backdrop_filter_.Init();
128 rare_non_inherited_data_.Access()->grid_.Init(); 128 rare_non_inherited_data_.Access()->grid_.Init();
129 rare_non_inherited_data_.Access()->grid_item_.Init(); 129 rare_non_inherited_data_.Access()->grid_item_.Init();
130 rare_non_inherited_data_.Access()->scroll_snap_.Init(); 130 rare_non_inherited_data_.Access()->scroll_snap_.Init();
131 rare_inherited_data_.Init(); 131 rare_inherited_data_.Init();
132 style_inherited_data_.Init(); 132 inherited_data_.Init();
133 svg_style_.Init(); 133 svg_style_.Init();
134 } 134 }
135 135
136 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) 136 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
137 : ComputedStyleBase(o), 137 : ComputedStyleBase(o),
138 RefCounted<ComputedStyle>(), 138 RefCounted<ComputedStyle>(),
139 box_data_(o.box_data_), 139 box_data_(o.box_data_),
140 visual_data_(o.visual_data_), 140 visual_data_(o.visual_data_),
141 background_data_(o.background_data_), 141 background_data_(o.background_data_),
142 rare_non_inherited_data_(o.rare_non_inherited_data_), 142 rare_non_inherited_data_(o.rare_non_inherited_data_),
143 rare_inherited_data_(o.rare_inherited_data_), 143 rare_inherited_data_(o.rare_inherited_data_),
144 style_inherited_data_(o.style_inherited_data_), 144 inherited_data_(o.inherited_data_),
145 svg_style_(o.svg_style_) {} 145 svg_style_(o.svg_style_) {}
146 146
147 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, 147 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style,
148 const ComputedStyle& new_style) { 148 const ComputedStyle& new_style) {
149 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. 149 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle.
150 if (!old_style.HasAnyPublicPseudoStyles() && 150 if (!old_style.HasAnyPublicPseudoStyles() &&
151 !new_style.HasAnyPublicPseudoStyles()) 151 !new_style.HasAnyPublicPseudoStyles())
152 return kNoChange; 152 return kNoChange;
153 for (PseudoId pseudo_id = kFirstPublicPseudoId; 153 for (PseudoId pseudo_id = kFirstPublicPseudoId;
154 pseudo_id < kFirstInternalPseudoId; 154 pseudo_id < kFirstInternalPseudoId;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary); 317 ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary);
318 if (is_at_shadow_boundary == kAtShadowBoundary) { 318 if (is_at_shadow_boundary == kAtShadowBoundary) {
319 // Even if surrounding content is user-editable, shadow DOM should act as a 319 // Even if surrounding content is user-editable, shadow DOM should act as a
320 // single unit, and not necessarily be editable 320 // single unit, and not necessarily be editable
321 EUserModify current_user_modify = UserModify(); 321 EUserModify current_user_modify = UserModify();
322 rare_inherited_data_ = inherit_parent.rare_inherited_data_; 322 rare_inherited_data_ = inherit_parent.rare_inherited_data_;
323 SetUserModify(current_user_modify); 323 SetUserModify(current_user_modify);
324 } else { 324 } else {
325 rare_inherited_data_ = inherit_parent.rare_inherited_data_; 325 rare_inherited_data_ = inherit_parent.rare_inherited_data_;
326 } 326 }
327 style_inherited_data_ = inherit_parent.style_inherited_data_; 327 inherited_data_ = inherit_parent.inherited_data_;
328 if (svg_style_ != inherit_parent.svg_style_) 328 if (svg_style_ != inherit_parent.svg_style_)
329 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); 329 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get());
330 } 330 }
331 331
332 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { 332 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) {
333 ComputedStyleBase::CopyNonInheritedFromCached(other); 333 ComputedStyleBase::CopyNonInheritedFromCached(other);
334 box_data_ = other.box_data_; 334 box_data_ = other.box_data_;
335 visual_data_ = other.visual_data_; 335 visual_data_ = other.visual_data_;
336 background_data_ = other.background_data_; 336 background_data_ = other.background_data_;
337 rare_non_inherited_data_ = other.rare_non_inherited_data_; 337 rare_non_inherited_data_ = other.rare_non_inherited_data_;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 bool ComputedStyle::IndependentInheritedEqual( 458 bool ComputedStyle::IndependentInheritedEqual(
459 const ComputedStyle& other) const { 459 const ComputedStyle& other) const {
460 return ComputedStyleBase::IndependentInheritedEqual(other); 460 return ComputedStyleBase::IndependentInheritedEqual(other);
461 } 461 }
462 462
463 bool ComputedStyle::NonIndependentInheritedEqual( 463 bool ComputedStyle::NonIndependentInheritedEqual(
464 const ComputedStyle& other) const { 464 const ComputedStyle& other) const {
465 return ComputedStyleBase::NonIndependentInheritedEqual(other) && 465 return ComputedStyleBase::NonIndependentInheritedEqual(other) &&
466 style_inherited_data_ == other.style_inherited_data_ && 466 inherited_data_ == other.inherited_data_ &&
467 svg_style_->InheritedEqual(*other.svg_style_) && 467 svg_style_->InheritedEqual(*other.svg_style_) &&
468 rare_inherited_data_ == other.rare_inherited_data_; 468 rare_inherited_data_ == other.rare_inherited_data_;
469 } 469 }
470 470
471 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { 471 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const {
472 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); 472 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts();
473 } 473 }
474 474
475 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { 475 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const {
476 // compare everything except the pseudoStyle pointer 476 // compare everything except the pseudoStyle pointer
477 return ComputedStyleBase::NonInheritedEqual(other) && 477 return ComputedStyleBase::NonInheritedEqual(other) &&
478 OriginalDisplay() == 478 OriginalDisplay() ==
479 other.OriginalDisplay() && // Not generated in ComputedStyleBase 479 other.OriginalDisplay() && // Not generated in ComputedStyleBase
480 VerticalAlign() == other.VerticalAlign() && // Not generated in 480 VerticalAlign() == other.VerticalAlign() && // Not generated in
481 // ComputedStyleBase 481 // ComputedStyleBase
482 box_data_ == other.box_data_ && 482 box_data_ == other.box_data_ &&
483 visual_data_ == other.visual_data_ && 483 visual_data_ == other.visual_data_ &&
484 background_data_ == other.background_data_ && 484 background_data_ == other.background_data_ &&
485 rare_non_inherited_data_ == other.rare_non_inherited_data_ && 485 rare_non_inherited_data_ == other.rare_non_inherited_data_ &&
486 svg_style_->NonInheritedEqual(*other.svg_style_); 486 svg_style_->NonInheritedEqual(*other.svg_style_);
487 } 487 }
488 488
489 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { 489 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const {
490 // This is a fast check that only looks if the data structures are shared. 490 // This is a fast check that only looks if the data structures are shared.
491 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method? 491 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method?
492 return ComputedStyleBase::InheritedEqual(other) && 492 return ComputedStyleBase::InheritedEqual(other) &&
493 style_inherited_data_.Get() == other.style_inherited_data_.Get() && 493 inherited_data_.Get() == other.inherited_data_.Get() &&
494 svg_style_.Get() == other.svg_style_.Get() && 494 svg_style_.Get() == other.svg_style_.Get() &&
495 rare_inherited_data_.Get() == other.rare_inherited_data_.Get(); 495 rare_inherited_data_.Get() == other.rare_inherited_data_.Get();
496 } 496 }
497 497
498 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, 498 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a,
499 const ComputedStyle& b) { 499 const ComputedStyle& b) {
500 // If top or bottom become auto/non-auto then it means we either have to solve 500 // If top or bottom become auto/non-auto then it means we either have to solve
501 // height based on the content or stop doing so 501 // height based on the content or stop doing so
502 // (http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height) 502 // (http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height)
503 // - either way requires a layout. 503 // - either way requires a layout.
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 748
749 if (!rare_inherited_data_->ShadowDataEquivalent( 749 if (!rare_inherited_data_->ShadowDataEquivalent(
750 *other.rare_inherited_data_.Get())) 750 *other.rare_inherited_data_.Get()))
751 return true; 751 return true;
752 752
753 if (!rare_inherited_data_->QuotesDataEquivalent( 753 if (!rare_inherited_data_->QuotesDataEquivalent(
754 *other.rare_inherited_data_.Get())) 754 *other.rare_inherited_data_.Get()))
755 return true; 755 return true;
756 } 756 }
757 757
758 if (style_inherited_data_->text_autosizing_multiplier != 758 if (inherited_data_->text_autosizing_multiplier_ !=
759 other.style_inherited_data_->text_autosizing_multiplier) 759 other.inherited_data_->text_autosizing_multiplier_)
760 return true; 760 return true;
761 761
762 if (style_inherited_data_->font.LoadingCustomFonts() != 762 if (inherited_data_->font_.LoadingCustomFonts() !=
763 other.style_inherited_data_->font.LoadingCustomFonts()) 763 other.inherited_data_->font_.LoadingCustomFonts())
764 return true; 764 return true;
765 765
766 if (style_inherited_data_.Get() != other.style_inherited_data_.Get()) { 766 if (inherited_data_.Get() != other.inherited_data_.Get()) {
767 if (style_inherited_data_->line_height != 767 if (inherited_data_->line_height_ != other.inherited_data_->line_height_ ||
768 other.style_inherited_data_->line_height || 768 inherited_data_->font_ != other.inherited_data_->font_ ||
769 style_inherited_data_->font != other.style_inherited_data_->font || 769 inherited_data_->horizontal_border_spacing_ !=
770 style_inherited_data_->horizontal_border_spacing != 770 other.inherited_data_->horizontal_border_spacing_ ||
771 other.style_inherited_data_->horizontal_border_spacing || 771 inherited_data_->vertical_border_spacing_ !=
772 style_inherited_data_->vertical_border_spacing != 772 other.inherited_data_->vertical_border_spacing_)
773 other.style_inherited_data_->vertical_border_spacing)
774 return true; 773 return true;
775 } 774 }
776 775
777 if (BoxDirection() != other.BoxDirection() || 776 if (BoxDirection() != other.BoxDirection() ||
778 RtlOrdering() != other.RtlOrdering() || 777 RtlOrdering() != other.RtlOrdering() ||
779 GetTextAlign() != other.GetTextAlign() || 778 GetTextAlign() != other.GetTextAlign() ||
780 TextTransform() != other.TextTransform() || 779 TextTransform() != other.TextTransform() ||
781 Direction() != other.Direction() || WhiteSpace() != other.WhiteSpace() || 780 Direction() != other.Direction() || WhiteSpace() != other.WhiteSpace() ||
782 GetWritingMode() != other.GetWritingMode()) 781 GetWritingMode() != other.GetWritingMode())
783 return true; 782 return true;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 1045
1047 if (!rare_non_inherited_data_->outline_.VisuallyEqual( 1046 if (!rare_non_inherited_data_->outline_.VisuallyEqual(
1048 other.rare_non_inherited_data_->outline_)) 1047 other.rare_non_inherited_data_->outline_))
1049 diff.SetNeedsRecomputeOverflow(); 1048 diff.SetNeedsRecomputeOverflow();
1050 } 1049 }
1051 1050
1052 if (!Border().VisualOverflowEqual(other.Border())) 1051 if (!Border().VisualOverflowEqual(other.Border()))
1053 diff.SetNeedsRecomputeOverflow(); 1052 diff.SetNeedsRecomputeOverflow();
1054 1053
1055 if (!diff.NeedsFullPaintInvalidation()) { 1054 if (!diff.NeedsFullPaintInvalidation()) {
1056 if (style_inherited_data_->color != other.style_inherited_data_->color || 1055 if (inherited_data_->color_ != other.inherited_data_->color_ ||
1057 style_inherited_data_->visited_link_color != 1056 inherited_data_->visited_link_color_ !=
1058 other.style_inherited_data_->visited_link_color || 1057 other.inherited_data_->visited_link_color_ ||
1059 HasSimpleUnderlineInternal() != other.HasSimpleUnderlineInternal() || 1058 HasSimpleUnderlineInternal() != other.HasSimpleUnderlineInternal() ||
1060 visual_data_->text_decoration != other.visual_data_->text_decoration) { 1059 visual_data_->text_decoration != other.visual_data_->text_decoration) {
1061 diff.SetTextDecorationOrColorChanged(); 1060 diff.SetTextDecorationOrColorChanged();
1062 } else if (rare_non_inherited_data_.Get() != 1061 } else if (rare_non_inherited_data_.Get() !=
1063 other.rare_non_inherited_data_.Get() && 1062 other.rare_non_inherited_data_.Get() &&
1064 (rare_non_inherited_data_->text_decoration_style_ != 1063 (rare_non_inherited_data_->text_decoration_style_ !=
1065 other.rare_non_inherited_data_->text_decoration_style_ || 1064 other.rare_non_inherited_data_->text_decoration_style_ ||
1066 rare_non_inherited_data_->text_decoration_color_ != 1065 rare_non_inherited_data_->text_decoration_color_ !=
1067 other.rare_non_inherited_data_->text_decoration_color_ || 1066 other.rare_non_inherited_data_->text_decoration_color_ ||
1068 rare_non_inherited_data_->visited_link_text_decoration_color_ != 1067 rare_non_inherited_data_->visited_link_text_decoration_color_ !=
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 1423
1425 StyleImage* ComputedStyle::ListStyleImage() const { 1424 StyleImage* ComputedStyle::ListStyleImage() const {
1426 return rare_inherited_data_->list_style_image.Get(); 1425 return rare_inherited_data_->list_style_image.Get();
1427 } 1426 }
1428 void ComputedStyle::SetListStyleImage(StyleImage* v) { 1427 void ComputedStyle::SetListStyleImage(StyleImage* v) {
1429 if (rare_inherited_data_->list_style_image != v) 1428 if (rare_inherited_data_->list_style_image != v)
1430 rare_inherited_data_.Access()->list_style_image = v; 1429 rare_inherited_data_.Access()->list_style_image = v;
1431 } 1430 }
1432 1431
1433 Color ComputedStyle::GetColor() const { 1432 Color ComputedStyle::GetColor() const {
1434 return style_inherited_data_->color; 1433 return inherited_data_->color_;
1435 } 1434 }
1436 Color ComputedStyle::VisitedLinkColor() const { 1435 Color ComputedStyle::VisitedLinkColor() const {
1437 return style_inherited_data_->visited_link_color; 1436 return inherited_data_->visited_link_color_;
1438 } 1437 }
1439 void ComputedStyle::SetColor(const Color& v) { 1438 void ComputedStyle::SetColor(const Color& v) {
1440 SET_VAR(style_inherited_data_, color, v); 1439 SET_VAR(inherited_data_, color_, v);
1441 } 1440 }
1442 void ComputedStyle::SetVisitedLinkColor(const Color& v) { 1441 void ComputedStyle::SetVisitedLinkColor(const Color& v) {
1443 SET_VAR(style_inherited_data_, visited_link_color, v); 1442 SET_VAR(inherited_data_, visited_link_color_, v);
1444 } 1443 }
1445 1444
1446 short ComputedStyle::HorizontalBorderSpacing() const { 1445 short ComputedStyle::HorizontalBorderSpacing() const {
1447 return style_inherited_data_->horizontal_border_spacing; 1446 return inherited_data_->horizontal_border_spacing_;
1448 } 1447 }
1449 short ComputedStyle::VerticalBorderSpacing() const { 1448 short ComputedStyle::VerticalBorderSpacing() const {
1450 return style_inherited_data_->vertical_border_spacing; 1449 return inherited_data_->vertical_border_spacing_;
1451 } 1450 }
1452 void ComputedStyle::SetHorizontalBorderSpacing(short v) { 1451 void ComputedStyle::SetHorizontalBorderSpacing(short v) {
1453 SET_VAR(style_inherited_data_, horizontal_border_spacing, v); 1452 SET_VAR(inherited_data_, horizontal_border_spacing_, v);
1454 } 1453 }
1455 void ComputedStyle::SetVerticalBorderSpacing(short v) { 1454 void ComputedStyle::SetVerticalBorderSpacing(short v) {
1456 SET_VAR(style_inherited_data_, vertical_border_spacing, v); 1455 SET_VAR(inherited_data_, vertical_border_spacing_, v);
1457 } 1456 }
1458 1457
1459 FloatRoundedRect ComputedStyle::GetRoundedBorderFor( 1458 FloatRoundedRect ComputedStyle::GetRoundedBorderFor(
1460 const LayoutRect& border_rect, 1459 const LayoutRect& border_rect,
1461 bool include_logical_left_edge, 1460 bool include_logical_left_edge,
1462 bool include_logical_right_edge) const { 1461 bool include_logical_right_edge) const {
1463 FloatRoundedRect rounded_rect(PixelSnappedIntRect(border_rect)); 1462 FloatRoundedRect rounded_rect(PixelSnappedIntRect(border_rect));
1464 if (HasBorderRadius()) { 1463 if (HasBorderRadius()) {
1465 FloatRoundedRect::Radii radii = CalcRadiiFor(Border(), border_rect.Size()); 1464 FloatRoundedRect::Radii radii = CalcRadiiFor(Border(), border_rect.Size());
1466 rounded_rect.IncludeLogicalEdges(radii, IsHorizontalWritingMode(), 1465 rounded_rect.IncludeLogicalEdges(radii, IsHorizontalWritingMode(),
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 } 1669 }
1671 1670
1672 CSSTransitionData& ComputedStyle::AccessTransitions() { 1671 CSSTransitionData& ComputedStyle::AccessTransitions() {
1673 if (!rare_non_inherited_data_.Access()->transitions_) 1672 if (!rare_non_inherited_data_.Access()->transitions_)
1674 rare_non_inherited_data_.Access()->transitions_ = 1673 rare_non_inherited_data_.Access()->transitions_ =
1675 CSSTransitionData::Create(); 1674 CSSTransitionData::Create();
1676 return *rare_non_inherited_data_->transitions_; 1675 return *rare_non_inherited_data_->transitions_;
1677 } 1676 }
1678 1677
1679 const Font& ComputedStyle::GetFont() const { 1678 const Font& ComputedStyle::GetFont() const {
1680 return style_inherited_data_->font; 1679 return inherited_data_->font_;
1681 } 1680 }
1682 const FontDescription& ComputedStyle::GetFontDescription() const { 1681 const FontDescription& ComputedStyle::GetFontDescription() const {
1683 return style_inherited_data_->font.GetFontDescription(); 1682 return inherited_data_->font_.GetFontDescription();
1684 } 1683 }
1685 float ComputedStyle::SpecifiedFontSize() const { 1684 float ComputedStyle::SpecifiedFontSize() const {
1686 return GetFontDescription().SpecifiedSize(); 1685 return GetFontDescription().SpecifiedSize();
1687 } 1686 }
1688 float ComputedStyle::ComputedFontSize() const { 1687 float ComputedStyle::ComputedFontSize() const {
1689 return GetFontDescription().ComputedSize(); 1688 return GetFontDescription().ComputedSize();
1690 } 1689 }
1691 LayoutUnit ComputedStyle::ComputedFontSizeAsFixed() const { 1690 LayoutUnit ComputedStyle::ComputedFontSizeAsFixed() const {
1692 return LayoutUnit::FromFloatRound(GetFontDescription().ComputedSize()); 1691 return LayoutUnit::FromFloatRound(GetFontDescription().ComputedSize());
1693 } 1692 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 } 1866 }
1868 1867
1869 float ComputedStyle::WordSpacing() const { 1868 float ComputedStyle::WordSpacing() const {
1870 return GetFontDescription().WordSpacing(); 1869 return GetFontDescription().WordSpacing();
1871 } 1870 }
1872 float ComputedStyle::LetterSpacing() const { 1871 float ComputedStyle::LetterSpacing() const {
1873 return GetFontDescription().LetterSpacing(); 1872 return GetFontDescription().LetterSpacing();
1874 } 1873 }
1875 1874
1876 bool ComputedStyle::SetFontDescription(const FontDescription& v) { 1875 bool ComputedStyle::SetFontDescription(const FontDescription& v) {
1877 if (style_inherited_data_->font.GetFontDescription() != v) { 1876 if (inherited_data_->font_.GetFontDescription() != v) {
1878 style_inherited_data_.Access()->font = Font(v); 1877 inherited_data_.Access()->font_ = Font(v);
1879 return true; 1878 return true;
1880 } 1879 }
1881 return false; 1880 return false;
1882 } 1881 }
1883 1882
1884 void ComputedStyle::SetFont(const Font& font) { 1883 void ComputedStyle::SetFont(const Font& font) {
1885 style_inherited_data_.Access()->font = font; 1884 inherited_data_.Access()->font_ = font;
1886 } 1885 }
1887 1886
1888 bool ComputedStyle::HasIdenticalAscentDescentAndLineGap( 1887 bool ComputedStyle::HasIdenticalAscentDescentAndLineGap(
1889 const ComputedStyle& other) const { 1888 const ComputedStyle& other) const {
1890 const SimpleFontData* font_data = GetFont().PrimaryFont(); 1889 const SimpleFontData* font_data = GetFont().PrimaryFont();
1891 const SimpleFontData* other_font_data = other.GetFont().PrimaryFont(); 1890 const SimpleFontData* other_font_data = other.GetFont().PrimaryFont();
1892 return font_data && other_font_data && 1891 return font_data && other_font_data &&
1893 font_data->GetFontMetrics().HasIdenticalAscentDescentAndLineGap( 1892 font_data->GetFontMetrics().HasIdenticalAscentDescentAndLineGap(
1894 other_font_data->GetFontMetrics()); 1893 other_font_data->GetFontMetrics());
1895 } 1894 }
1896 1895
1897 const Length& ComputedStyle::SpecifiedLineHeight() const { 1896 const Length& ComputedStyle::SpecifiedLineHeight() const {
1898 return style_inherited_data_->line_height; 1897 return inherited_data_->line_height_;
1899 } 1898 }
1900 Length ComputedStyle::LineHeight() const { 1899 Length ComputedStyle::LineHeight() const {
1901 const Length& lh = style_inherited_data_->line_height; 1900 const Length& lh = inherited_data_->line_height_;
1902 // Unlike getFontDescription().computedSize() and hence fontSize(), this is 1901 // Unlike getFontDescription().computedSize() and hence fontSize(), this is
1903 // recalculated on demand as we only store the specified line height. 1902 // recalculated on demand as we only store the specified line height.
1904 // FIXME: Should consider scaling the fixed part of any calc expressions 1903 // FIXME: Should consider scaling the fixed part of any calc expressions
1905 // too, though this involves messily poking into CalcExpressionLength. 1904 // too, though this involves messily poking into CalcExpressionLength.
1906 if (lh.IsFixed()) { 1905 if (lh.IsFixed()) {
1907 float multiplier = TextAutosizingMultiplier(); 1906 float multiplier = TextAutosizingMultiplier();
1908 return Length( 1907 return Length(
1909 TextAutosizer::ComputeAutosizedFontSize(lh.Value(), multiplier), 1908 TextAutosizer::ComputeAutosizedFontSize(lh.Value(), multiplier),
1910 kFixed); 1909 kFixed);
1911 } 1910 }
1912 1911
1913 return lh; 1912 return lh;
1914 } 1913 }
1915 1914
1916 void ComputedStyle::SetLineHeight(const Length& specified_line_height) { 1915 void ComputedStyle::SetLineHeight(const Length& specified_line_height) {
1917 SET_VAR(style_inherited_data_, line_height, specified_line_height); 1916 SET_VAR(inherited_data_, line_height_, specified_line_height);
1918 } 1917 }
1919 1918
1920 int ComputedStyle::ComputedLineHeight() const { 1919 int ComputedStyle::ComputedLineHeight() const {
1921 const Length& lh = LineHeight(); 1920 const Length& lh = LineHeight();
1922 1921
1923 // Negative value means the line height is not set. Use the font's built-in 1922 // Negative value means the line height is not set. Use the font's built-in
1924 // spacing, if avalible. 1923 // spacing, if avalible.
1925 if (lh.IsNegative() && GetFont().PrimaryFont()) 1924 if (lh.IsNegative() && GetFont().PrimaryFont())
1926 return GetFont().PrimaryFont()->GetFontMetrics().LineSpacing(); 1925 return GetFont().PrimaryFont()->GetFontMetrics().LineSpacing();
1927 1926
(...skipping 27 matching lines...) Expand all
1955 1954
1956 void ComputedStyle::SetLetterSpacing(float letter_spacing) { 1955 void ComputedStyle::SetLetterSpacing(float letter_spacing) {
1957 FontSelector* current_font_selector = GetFont().GetFontSelector(); 1956 FontSelector* current_font_selector = GetFont().GetFontSelector();
1958 FontDescription desc(GetFontDescription()); 1957 FontDescription desc(GetFontDescription());
1959 desc.SetLetterSpacing(letter_spacing); 1958 desc.SetLetterSpacing(letter_spacing);
1960 SetFontDescription(desc); 1959 SetFontDescription(desc);
1961 GetFont().Update(current_font_selector); 1960 GetFont().Update(current_font_selector);
1962 } 1961 }
1963 1962
1964 void ComputedStyle::SetTextAutosizingMultiplier(float multiplier) { 1963 void ComputedStyle::SetTextAutosizingMultiplier(float multiplier) {
1965 SET_VAR(style_inherited_data_, text_autosizing_multiplier, multiplier); 1964 SET_VAR(inherited_data_, text_autosizing_multiplier_, multiplier);
1966 1965
1967 float size = SpecifiedFontSize(); 1966 float size = SpecifiedFontSize();
1968 1967
1969 DCHECK(std::isfinite(size)); 1968 DCHECK(std::isfinite(size));
1970 if (!std::isfinite(size) || size < 0) 1969 if (!std::isfinite(size) || size < 0)
1971 size = 0; 1970 size = 0;
1972 else 1971 else
1973 size = std::min(kMaximumAllowedFontSize, size); 1972 size = std::min(kMaximumAllowedFontSize, size);
1974 1973
1975 FontSelector* current_font_selector = GetFont().GetFontSelector(); 1974 FontSelector* current_font_selector = GetFont().GetFontSelector();
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 if (value < 0) 2499 if (value < 0)
2501 fvalue -= 0.5f; 2500 fvalue -= 0.5f;
2502 else 2501 else
2503 fvalue += 0.5f; 2502 fvalue += 0.5f;
2504 } 2503 }
2505 2504
2506 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2505 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2507 } 2506 }
2508 2507
2509 } // namespace blink 2508 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | third_party/WebKit/Source/core/style/StyleInheritedData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698