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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 rare_non_inherited_data_ = other.rare_non_inherited_data_; | 340 rare_non_inherited_data_ = other.rare_non_inherited_data_; |
341 | 341 |
342 // The flags are copied one-by-one because they contain | 342 // The flags are copied one-by-one because they contain |
343 // bunch of stuff other than real style data. | 343 // bunch of stuff other than real style data. |
344 // See comments for each skipped flag below. | 344 // See comments for each skipped flag below. |
345 | 345 |
346 // These are not generated in ComputedStyleBase | 346 // These are not generated in ComputedStyleBase |
347 SetOriginalDisplay(other.OriginalDisplay()); | 347 SetOriginalDisplay(other.OriginalDisplay()); |
348 SetVerticalAlign(other.VerticalAlign()); | 348 SetVerticalAlign(other.VerticalAlign()); |
349 SetHasViewportUnits(other.HasViewportUnits()); | 349 SetHasViewportUnits(other.HasViewportUnits()); |
350 has_rem_units_ = other.HasRemUnits(); | 350 SetHasRemUnitsInternal(other.HasRemUnits()); |
351 | 351 |
352 // Correctly set during selector matching: | 352 // Correctly set during selector matching: |
353 // m_styleType | 353 // m_styleType |
354 // m_pseudoBits | 354 // m_pseudoBits |
355 | 355 |
356 // Set correctly while computing style for children: | 356 // Set correctly while computing style for children: |
357 // m_explicitInheritance | 357 // m_explicitInheritance |
358 | 358 |
359 // unique() styles are not cacheable. | 359 // unique() styles are not cacheable. |
360 DCHECK(!other.Unique()); | 360 DCHECK(!other.Unique()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 | 473 |
474 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { | 474 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { |
475 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); | 475 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); |
476 } | 476 } |
477 | 477 |
478 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { | 478 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { |
479 // compare everything except the pseudoStyle pointer | 479 // compare everything except the pseudoStyle pointer |
480 return ComputedStyleBase::NonInheritedEqual(other) && | 480 return ComputedStyleBase::NonInheritedEqual(other) && |
481 OriginalDisplay() == | 481 OriginalDisplay() == |
482 other.OriginalDisplay() && // Not generated in ComputedStyleBase | 482 other.OriginalDisplay() && // Not generated in ComputedStyleBase |
483 VerticalAlign() == | 483 VerticalAlign() == other.VerticalAlign() && // Not generated in |
suzyh_UTC10 (ex-contributor)
2017/04/20 00:30:46
Was this an auto-formatting change?
nainar
2017/04/20 03:06:16
Yup.
| |
484 other.VerticalAlign() && // Not generated in ComputedStyleBase | 484 // ComputedStyleBase |
485 box_ == other.box_ && | 485 box_ == other.box_ && |
486 visual_ == other.visual_ && background_ == other.background_ && | 486 visual_ == other.visual_ && background_ == other.background_ && |
487 surround_ == other.surround_ && | 487 surround_ == other.surround_ && |
488 rare_non_inherited_data_ == other.rare_non_inherited_data_ && | 488 rare_non_inherited_data_ == other.rare_non_inherited_data_ && |
489 svg_style_->NonInheritedEqual(*other.svg_style_); | 489 svg_style_->NonInheritedEqual(*other.svg_style_); |
490 } | 490 } |
491 | 491 |
492 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { | 492 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { |
493 // This is a fast check that only looks if the data structures are shared. | 493 // This is a fast check that only looks if the data structures are shared. |
494 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method? | 494 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method? |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1054 diff.SetNeedsRecomputeOverflow(); | 1054 diff.SetNeedsRecomputeOverflow(); |
1055 } | 1055 } |
1056 | 1056 |
1057 if (!surround_->border_.VisualOverflowEqual(other.surround_->border_)) | 1057 if (!surround_->border_.VisualOverflowEqual(other.surround_->border_)) |
1058 diff.SetNeedsRecomputeOverflow(); | 1058 diff.SetNeedsRecomputeOverflow(); |
1059 | 1059 |
1060 if (!diff.NeedsFullPaintInvalidation()) { | 1060 if (!diff.NeedsFullPaintInvalidation()) { |
1061 if (style_inherited_data_->color != other.style_inherited_data_->color || | 1061 if (style_inherited_data_->color != other.style_inherited_data_->color || |
1062 style_inherited_data_->visited_link_color != | 1062 style_inherited_data_->visited_link_color != |
1063 other.style_inherited_data_->visited_link_color || | 1063 other.style_inherited_data_->visited_link_color || |
1064 has_simple_underline_ != other.has_simple_underline_ || | 1064 HasSimpleUnderlineInternal() != other.HasSimpleUnderlineInternal() || |
1065 visual_->text_decoration != other.visual_->text_decoration) { | 1065 visual_->text_decoration != other.visual_->text_decoration) { |
1066 diff.SetTextDecorationOrColorChanged(); | 1066 diff.SetTextDecorationOrColorChanged(); |
1067 } else if (rare_non_inherited_data_.Get() != | 1067 } else if (rare_non_inherited_data_.Get() != |
1068 other.rare_non_inherited_data_.Get() && | 1068 other.rare_non_inherited_data_.Get() && |
1069 (rare_non_inherited_data_->text_decoration_style_ != | 1069 (rare_non_inherited_data_->text_decoration_style_ != |
1070 other.rare_non_inherited_data_->text_decoration_style_ || | 1070 other.rare_non_inherited_data_->text_decoration_style_ || |
1071 rare_non_inherited_data_->text_decoration_color_ != | 1071 rare_non_inherited_data_->text_decoration_color_ != |
1072 other.rare_non_inherited_data_->text_decoration_color_ || | 1072 other.rare_non_inherited_data_->text_decoration_color_ || |
1073 rare_non_inherited_data_->visited_link_text_decoration_color_ != | 1073 rare_non_inherited_data_->visited_link_text_decoration_color_ != |
1074 other.rare_non_inherited_data_ | 1074 other.rare_non_inherited_data_ |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1705 return GetFontDescription().HasSizeAdjust(); | 1705 return GetFontDescription().HasSizeAdjust(); |
1706 } | 1706 } |
1707 FontWeight ComputedStyle::GetFontWeight() const { | 1707 FontWeight ComputedStyle::GetFontWeight() const { |
1708 return GetFontDescription().Weight(); | 1708 return GetFontDescription().Weight(); |
1709 } | 1709 } |
1710 FontStretch ComputedStyle::GetFontStretch() const { | 1710 FontStretch ComputedStyle::GetFontStretch() const { |
1711 return GetFontDescription().Stretch(); | 1711 return GetFontDescription().Stretch(); |
1712 } | 1712 } |
1713 | 1713 |
1714 TextDecoration ComputedStyle::TextDecorationsInEffect() const { | 1714 TextDecoration ComputedStyle::TextDecorationsInEffect() const { |
1715 if (has_simple_underline_) | 1715 if (HasSimpleUnderlineInternal()) |
1716 return kTextDecorationUnderline; | 1716 return kTextDecorationUnderline; |
1717 if (!rare_inherited_data_->applied_text_decorations) | 1717 if (!rare_inherited_data_->applied_text_decorations) |
1718 return kTextDecorationNone; | 1718 return kTextDecorationNone; |
1719 | 1719 |
1720 int decorations = 0; | 1720 int decorations = 0; |
1721 | 1721 |
1722 const Vector<AppliedTextDecoration>& applied = AppliedTextDecorations(); | 1722 const Vector<AppliedTextDecoration>& applied = AppliedTextDecorations(); |
1723 | 1723 |
1724 for (size_t i = 0; i < applied.size(); ++i) | 1724 for (size_t i = 0; i < applied.size(); ++i) |
1725 decorations |= applied[i].Lines(); | 1725 decorations |= applied[i].Lines(); |
1726 | 1726 |
1727 return static_cast<TextDecoration>(decorations); | 1727 return static_cast<TextDecoration>(decorations); |
1728 } | 1728 } |
1729 | 1729 |
1730 const Vector<AppliedTextDecoration>& ComputedStyle::AppliedTextDecorations() | 1730 const Vector<AppliedTextDecoration>& ComputedStyle::AppliedTextDecorations() |
1731 const { | 1731 const { |
1732 if (has_simple_underline_) { | 1732 if (HasSimpleUnderlineInternal()) { |
1733 DEFINE_STATIC_LOCAL( | 1733 DEFINE_STATIC_LOCAL( |
1734 Vector<AppliedTextDecoration>, underline, | 1734 Vector<AppliedTextDecoration>, underline, |
1735 (1, AppliedTextDecoration( | 1735 (1, AppliedTextDecoration( |
1736 kTextDecorationUnderline, kTextDecorationStyleSolid, | 1736 kTextDecorationUnderline, kTextDecorationStyleSolid, |
1737 VisitedDependentColor(CSSPropertyTextDecorationColor)))); | 1737 VisitedDependentColor(CSSPropertyTextDecorationColor)))); |
1738 // Since we only have one of these in memory, just update the color before | 1738 // Since we only have one of these in memory, just update the color before |
1739 // returning. | 1739 // returning. |
1740 underline.at(0).SetColor( | 1740 underline.at(0).SetColor( |
1741 VisitedDependentColor(CSSPropertyTextDecorationColor)); | 1741 VisitedDependentColor(CSSPropertyTextDecorationColor)); |
1742 return underline; | 1742 return underline; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2009 if (!list->HasOneRef()) | 2009 if (!list->HasOneRef()) |
2010 list = list->Copy(); | 2010 list = list->Copy(); |
2011 | 2011 |
2012 for (size_t i = 0; i < list->size(); ++i) | 2012 for (size_t i = 0; i < list->size(); ++i) |
2013 list->at(i).SetColor(override_color); | 2013 list->at(i).SetColor(override_color); |
2014 } | 2014 } |
2015 | 2015 |
2016 void ComputedStyle::ApplyTextDecorations( | 2016 void ComputedStyle::ApplyTextDecorations( |
2017 const Color& parent_text_decoration_color, | 2017 const Color& parent_text_decoration_color, |
2018 bool override_existing_colors) { | 2018 bool override_existing_colors) { |
2019 if (GetTextDecoration() == kTextDecorationNone && !has_simple_underline_ && | 2019 if (GetTextDecoration() == kTextDecorationNone && |
2020 !HasSimpleUnderlineInternal() && | |
2020 !rare_inherited_data_->applied_text_decorations) | 2021 !rare_inherited_data_->applied_text_decorations) |
2021 return; | 2022 return; |
2022 | 2023 |
2023 // If there are any color changes or decorations set by this element, stop | 2024 // If there are any color changes or decorations set by this element, stop |
2024 // using m_hasSimpleUnderline. | 2025 // using m_hasSimpleUnderlineInternal. |
suzyh_UTC10 (ex-contributor)
2017/04/20 00:30:46
Was this intentional?
nainar
2017/04/20 03:06:16
Nope, reverted.
| |
2025 Color current_text_decoration_color = | 2026 Color current_text_decoration_color = |
2026 VisitedDependentColor(CSSPropertyTextDecorationColor); | 2027 VisitedDependentColor(CSSPropertyTextDecorationColor); |
2027 if (has_simple_underline_ && | 2028 if (HasSimpleUnderlineInternal() && |
2028 (GetTextDecoration() != kTextDecorationNone || | 2029 (GetTextDecoration() != kTextDecorationNone || |
2029 current_text_decoration_color != parent_text_decoration_color)) { | 2030 current_text_decoration_color != parent_text_decoration_color)) { |
2030 has_simple_underline_ = false; | 2031 SetHasSimpleUnderlineInternal(false); |
2031 AddAppliedTextDecoration(AppliedTextDecoration( | 2032 AddAppliedTextDecoration(AppliedTextDecoration( |
2032 kTextDecorationUnderline, kTextDecorationStyleSolid, | 2033 kTextDecorationUnderline, kTextDecorationStyleSolid, |
2033 parent_text_decoration_color)); | 2034 parent_text_decoration_color)); |
2034 } | 2035 } |
2035 if (override_existing_colors && | 2036 if (override_existing_colors && |
2036 rare_inherited_data_->applied_text_decorations) | 2037 rare_inherited_data_->applied_text_decorations) |
2037 OverrideTextDecorationColors(current_text_decoration_color); | 2038 OverrideTextDecorationColors(current_text_decoration_color); |
2038 if (GetTextDecoration() == kTextDecorationNone) | 2039 if (GetTextDecoration() == kTextDecorationNone) |
2039 return; | 2040 return; |
2040 DCHECK(!has_simple_underline_); | 2041 DCHECK(!HasSimpleUnderlineInternal()); |
2041 // To save memory, we don't use AppliedTextDecoration objects in the common | 2042 // To save memory, we don't use AppliedTextDecoration objects in the common |
2042 // case of a single simple underline of currentColor. | 2043 // case of a single simple underline of currentColor. |
2043 TextDecoration decoration_lines = GetTextDecoration(); | 2044 TextDecoration decoration_lines = GetTextDecoration(); |
2044 TextDecorationStyle decoration_style = GetTextDecorationStyle(); | 2045 TextDecorationStyle decoration_style = GetTextDecorationStyle(); |
2045 bool is_simple_underline = decoration_lines == kTextDecorationUnderline && | 2046 bool is_simple_underline = decoration_lines == kTextDecorationUnderline && |
2046 decoration_style == kTextDecorationStyleSolid && | 2047 decoration_style == kTextDecorationStyleSolid && |
2047 TextDecorationColor().IsCurrentColor(); | 2048 TextDecorationColor().IsCurrentColor(); |
2048 if (is_simple_underline && !rare_inherited_data_->applied_text_decorations) { | 2049 if (is_simple_underline && !rare_inherited_data_->applied_text_decorations) { |
2049 has_simple_underline_ = true; | 2050 SetHasSimpleUnderlineInternal(true); |
2050 return; | 2051 return; |
2051 } | 2052 } |
2052 | 2053 |
2053 AddAppliedTextDecoration(AppliedTextDecoration( | 2054 AddAppliedTextDecoration(AppliedTextDecoration( |
2054 decoration_lines, decoration_style, current_text_decoration_color)); | 2055 decoration_lines, decoration_style, current_text_decoration_color)); |
2055 } | 2056 } |
2056 | 2057 |
2057 void ComputedStyle::ClearAppliedTextDecorations() { | 2058 void ComputedStyle::ClearAppliedTextDecorations() { |
2058 has_simple_underline_ = false; | 2059 SetHasSimpleUnderlineInternal(false); |
2059 | 2060 |
2060 if (rare_inherited_data_->applied_text_decorations) | 2061 if (rare_inherited_data_->applied_text_decorations) |
2061 rare_inherited_data_.Access()->applied_text_decorations = nullptr; | 2062 rare_inherited_data_.Access()->applied_text_decorations = nullptr; |
2062 } | 2063 } |
2063 | 2064 |
2064 void ComputedStyle::RestoreParentTextDecorations( | 2065 void ComputedStyle::RestoreParentTextDecorations( |
2065 const ComputedStyle& parent_style) { | 2066 const ComputedStyle& parent_style) { |
2066 has_simple_underline_ = parent_style.has_simple_underline_; | 2067 SetHasSimpleUnderlineInternal(parent_style.HasSimpleUnderlineInternal()); |
2067 if (rare_inherited_data_->applied_text_decorations != | 2068 if (rare_inherited_data_->applied_text_decorations != |
2068 parent_style.rare_inherited_data_->applied_text_decorations) | 2069 parent_style.rare_inherited_data_->applied_text_decorations) |
2069 rare_inherited_data_.Access()->applied_text_decorations = | 2070 rare_inherited_data_.Access()->applied_text_decorations = |
2070 parent_style.rare_inherited_data_->applied_text_decorations; | 2071 parent_style.rare_inherited_data_->applied_text_decorations; |
2071 } | 2072 } |
2072 | 2073 |
2073 void ComputedStyle::ClearMultiCol() { | 2074 void ComputedStyle::ClearMultiCol() { |
2074 rare_non_inherited_data_.Access()->multi_col_ = nullptr; | 2075 rare_non_inherited_data_.Access()->multi_col_ = nullptr; |
2075 rare_non_inherited_data_.Access()->multi_col_.Init(); | 2076 rare_non_inherited_data_.Access()->multi_col_.Init(); |
2076 } | 2077 } |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2503 if (value < 0) | 2504 if (value < 0) |
2504 fvalue -= 0.5f; | 2505 fvalue -= 0.5f; |
2505 else | 2506 else |
2506 fvalue += 0.5f; | 2507 fvalue += 0.5f; |
2507 } | 2508 } |
2508 | 2509 |
2509 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2510 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
2510 } | 2511 } |
2511 | 2512 |
2512 } // namespace blink | 2513 } // namespace blink |
OLD | NEW |