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

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

Issue 2845773002: Make TextDecoration an enum class. (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 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 } 1729 }
1730 FontWeight ComputedStyle::GetFontWeight() const { 1730 FontWeight ComputedStyle::GetFontWeight() const {
1731 return GetFontDescription().Weight(); 1731 return GetFontDescription().Weight();
1732 } 1732 }
1733 FontStretch ComputedStyle::GetFontStretch() const { 1733 FontStretch ComputedStyle::GetFontStretch() const {
1734 return GetFontDescription().Stretch(); 1734 return GetFontDescription().Stretch();
1735 } 1735 }
1736 1736
1737 TextDecoration ComputedStyle::TextDecorationsInEffect() const { 1737 TextDecoration ComputedStyle::TextDecorationsInEffect() const {
1738 if (HasSimpleUnderlineInternal()) 1738 if (HasSimpleUnderlineInternal())
1739 return kTextDecorationUnderline; 1739 return TextDecoration::kUnderline;
1740 if (!rare_inherited_data_->applied_text_decorations_) 1740 if (!rare_inherited_data_->applied_text_decorations_)
1741 return kTextDecorationNone; 1741 return TextDecoration::kNone;
1742 1742
1743 int decorations = 0; 1743 TextDecoration decorations = TextDecoration::kNone;
1744 1744
1745 const Vector<AppliedTextDecoration>& applied = AppliedTextDecorations(); 1745 const Vector<AppliedTextDecoration>& applied = AppliedTextDecorations();
1746 1746
1747 for (size_t i = 0; i < applied.size(); ++i) 1747 for (size_t i = 0; i < applied.size(); ++i)
1748 decorations |= applied[i].Lines(); 1748 decorations |= applied[i].Lines();
1749 1749
1750 return static_cast<TextDecoration>(decorations); 1750 return decorations;
1751 } 1751 }
1752 1752
1753 const Vector<AppliedTextDecoration>& ComputedStyle::AppliedTextDecorations() 1753 const Vector<AppliedTextDecoration>& ComputedStyle::AppliedTextDecorations()
1754 const { 1754 const {
1755 if (HasSimpleUnderlineInternal()) { 1755 if (HasSimpleUnderlineInternal()) {
1756 DEFINE_STATIC_LOCAL( 1756 DEFINE_STATIC_LOCAL(
1757 Vector<AppliedTextDecoration>, underline, 1757 Vector<AppliedTextDecoration>, underline,
1758 (1, AppliedTextDecoration( 1758 (1, AppliedTextDecoration(
1759 kTextDecorationUnderline, kTextDecorationStyleSolid, 1759 TextDecoration::kUnderline, kTextDecorationStyleSolid,
1760 VisitedDependentColor(CSSPropertyTextDecorationColor)))); 1760 VisitedDependentColor(CSSPropertyTextDecorationColor))));
1761 // Since we only have one of these in memory, just update the color before 1761 // Since we only have one of these in memory, just update the color before
1762 // returning. 1762 // returning.
1763 underline.at(0).SetColor( 1763 underline.at(0).SetColor(
1764 VisitedDependentColor(CSSPropertyTextDecorationColor)); 1764 VisitedDependentColor(CSSPropertyTextDecorationColor));
1765 return underline; 1765 return underline;
1766 } 1766 }
1767 if (!rare_inherited_data_->applied_text_decorations_) { 1767 if (!rare_inherited_data_->applied_text_decorations_) {
1768 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); 1768 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ());
1769 return empty; 1769 return empty;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 if (!list->HasOneRef()) 2032 if (!list->HasOneRef())
2033 list = list->Copy(); 2033 list = list->Copy();
2034 2034
2035 for (size_t i = 0; i < list->size(); ++i) 2035 for (size_t i = 0; i < list->size(); ++i)
2036 list->at(i).SetColor(override_color); 2036 list->at(i).SetColor(override_color);
2037 } 2037 }
2038 2038
2039 void ComputedStyle::ApplyTextDecorations( 2039 void ComputedStyle::ApplyTextDecorations(
2040 const Color& parent_text_decoration_color, 2040 const Color& parent_text_decoration_color,
2041 bool override_existing_colors) { 2041 bool override_existing_colors) {
2042 if (GetTextDecoration() == kTextDecorationNone && 2042 if (GetTextDecoration() == TextDecoration::kNone &&
2043 !HasSimpleUnderlineInternal() && 2043 !HasSimpleUnderlineInternal() &&
2044 !rare_inherited_data_->applied_text_decorations_) 2044 !rare_inherited_data_->applied_text_decorations_)
2045 return; 2045 return;
2046 2046
2047 // If there are any color changes or decorations set by this element, stop 2047 // If there are any color changes or decorations set by this element, stop
2048 // using m_hasSimpleUnderline. 2048 // using m_hasSimpleUnderline.
2049 Color current_text_decoration_color = 2049 Color current_text_decoration_color =
2050 VisitedDependentColor(CSSPropertyTextDecorationColor); 2050 VisitedDependentColor(CSSPropertyTextDecorationColor);
2051 if (HasSimpleUnderlineInternal() && 2051 if (HasSimpleUnderlineInternal() &&
2052 (GetTextDecoration() != kTextDecorationNone || 2052 (GetTextDecoration() != TextDecoration::kNone ||
2053 current_text_decoration_color != parent_text_decoration_color)) { 2053 current_text_decoration_color != parent_text_decoration_color)) {
2054 SetHasSimpleUnderlineInternal(false); 2054 SetHasSimpleUnderlineInternal(false);
2055 AddAppliedTextDecoration(AppliedTextDecoration( 2055 AddAppliedTextDecoration(AppliedTextDecoration(
2056 kTextDecorationUnderline, kTextDecorationStyleSolid, 2056 TextDecoration::kUnderline, kTextDecorationStyleSolid,
2057 parent_text_decoration_color)); 2057 parent_text_decoration_color));
2058 } 2058 }
2059 if (override_existing_colors && 2059 if (override_existing_colors &&
2060 rare_inherited_data_->applied_text_decorations_) 2060 rare_inherited_data_->applied_text_decorations_)
2061 OverrideTextDecorationColors(current_text_decoration_color); 2061 OverrideTextDecorationColors(current_text_decoration_color);
2062 if (GetTextDecoration() == kTextDecorationNone) 2062 if (GetTextDecoration() == TextDecoration::kNone)
2063 return; 2063 return;
2064 DCHECK(!HasSimpleUnderlineInternal()); 2064 DCHECK(!HasSimpleUnderlineInternal());
2065 // To save memory, we don't use AppliedTextDecoration objects in the common 2065 // To save memory, we don't use AppliedTextDecoration objects in the common
2066 // case of a single simple underline of currentColor. 2066 // case of a single simple underline of currentColor.
2067 TextDecoration decoration_lines = GetTextDecoration(); 2067 TextDecoration decoration_lines = GetTextDecoration();
2068 TextDecorationStyle decoration_style = GetTextDecorationStyle(); 2068 TextDecorationStyle decoration_style = GetTextDecorationStyle();
2069 bool is_simple_underline = decoration_lines == kTextDecorationUnderline && 2069 bool is_simple_underline = decoration_lines == TextDecoration::kUnderline &&
2070 decoration_style == kTextDecorationStyleSolid && 2070 decoration_style == kTextDecorationStyleSolid &&
2071 TextDecorationColor().IsCurrentColor(); 2071 TextDecorationColor().IsCurrentColor();
2072 if (is_simple_underline && !rare_inherited_data_->applied_text_decorations_) { 2072 if (is_simple_underline && !rare_inherited_data_->applied_text_decorations_) {
2073 SetHasSimpleUnderlineInternal(true); 2073 SetHasSimpleUnderlineInternal(true);
2074 return; 2074 return;
2075 } 2075 }
2076 2076
2077 AddAppliedTextDecoration(AppliedTextDecoration( 2077 AddAppliedTextDecoration(AppliedTextDecoration(
2078 decoration_lines, decoration_style, current_text_decoration_color)); 2078 decoration_lines, decoration_style, current_text_decoration_color));
2079 } 2079 }
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 if (value < 0) 2528 if (value < 0)
2529 fvalue -= 0.5f; 2529 fvalue -= 0.5f;
2530 else 2530 else
2531 fvalue += 0.5f; 2531 fvalue += 0.5f;
2532 } 2532 }
2533 2533
2534 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2534 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2535 } 2535 }
2536 2536
2537 } // namespace blink 2537 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | third_party/WebKit/Source/core/style/ComputedStyleConstants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698