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 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1702 } | 1702 } |
1703 FontWeight ComputedStyle::GetFontWeight() const { | 1703 FontWeight ComputedStyle::GetFontWeight() const { |
1704 return GetFontDescription().Weight(); | 1704 return GetFontDescription().Weight(); |
1705 } | 1705 } |
1706 FontStretch ComputedStyle::GetFontStretch() const { | 1706 FontStretch ComputedStyle::GetFontStretch() const { |
1707 return GetFontDescription().Stretch(); | 1707 return GetFontDescription().Stretch(); |
1708 } | 1708 } |
1709 | 1709 |
1710 TextDecoration ComputedStyle::TextDecorationsInEffect() const { | 1710 TextDecoration ComputedStyle::TextDecorationsInEffect() const { |
1711 if (HasSimpleUnderlineInternal()) | 1711 if (HasSimpleUnderlineInternal()) |
1712 return kTextDecorationUnderline; | 1712 return TextDecoration::kUnderline; |
1713 if (!rare_inherited_data_->applied_text_decorations) | 1713 if (!rare_inherited_data_->applied_text_decorations) |
1714 return kTextDecorationNone; | 1714 return TextDecoration::kNone; |
1715 | 1715 |
1716 int decorations = 0; | 1716 TextDecoration decorations = TextDecoration::kNone; |
Bugs Nash
2017/04/27 00:02:23
yass
shend
2017/04/27 00:27:33
yes
| |
1717 | 1717 |
1718 const Vector<AppliedTextDecoration>& applied = AppliedTextDecorations(); | 1718 const Vector<AppliedTextDecoration>& applied = AppliedTextDecorations(); |
1719 | 1719 |
1720 for (size_t i = 0; i < applied.size(); ++i) | 1720 for (size_t i = 0; i < applied.size(); ++i) |
1721 decorations |= applied[i].Lines(); | 1721 decorations |= applied[i].Lines(); |
1722 | 1722 |
1723 return static_cast<TextDecoration>(decorations); | 1723 return decorations; |
1724 } | 1724 } |
1725 | 1725 |
1726 const Vector<AppliedTextDecoration>& ComputedStyle::AppliedTextDecorations() | 1726 const Vector<AppliedTextDecoration>& ComputedStyle::AppliedTextDecorations() |
1727 const { | 1727 const { |
1728 if (HasSimpleUnderlineInternal()) { | 1728 if (HasSimpleUnderlineInternal()) { |
1729 DEFINE_STATIC_LOCAL( | 1729 DEFINE_STATIC_LOCAL( |
1730 Vector<AppliedTextDecoration>, underline, | 1730 Vector<AppliedTextDecoration>, underline, |
1731 (1, AppliedTextDecoration( | 1731 (1, AppliedTextDecoration( |
1732 kTextDecorationUnderline, kTextDecorationStyleSolid, | 1732 TextDecoration::kUnderline, kTextDecorationStyleSolid, |
1733 VisitedDependentColor(CSSPropertyTextDecorationColor)))); | 1733 VisitedDependentColor(CSSPropertyTextDecorationColor)))); |
1734 // Since we only have one of these in memory, just update the color before | 1734 // Since we only have one of these in memory, just update the color before |
1735 // returning. | 1735 // returning. |
1736 underline.at(0).SetColor( | 1736 underline.at(0).SetColor( |
1737 VisitedDependentColor(CSSPropertyTextDecorationColor)); | 1737 VisitedDependentColor(CSSPropertyTextDecorationColor)); |
1738 return underline; | 1738 return underline; |
1739 } | 1739 } |
1740 if (!rare_inherited_data_->applied_text_decorations) { | 1740 if (!rare_inherited_data_->applied_text_decorations) { |
1741 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); | 1741 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); |
1742 return empty; | 1742 return empty; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2005 if (!list->HasOneRef()) | 2005 if (!list->HasOneRef()) |
2006 list = list->Copy(); | 2006 list = list->Copy(); |
2007 | 2007 |
2008 for (size_t i = 0; i < list->size(); ++i) | 2008 for (size_t i = 0; i < list->size(); ++i) |
2009 list->at(i).SetColor(override_color); | 2009 list->at(i).SetColor(override_color); |
2010 } | 2010 } |
2011 | 2011 |
2012 void ComputedStyle::ApplyTextDecorations( | 2012 void ComputedStyle::ApplyTextDecorations( |
2013 const Color& parent_text_decoration_color, | 2013 const Color& parent_text_decoration_color, |
2014 bool override_existing_colors) { | 2014 bool override_existing_colors) { |
2015 if (GetTextDecoration() == kTextDecorationNone && | 2015 if (GetTextDecoration() == TextDecoration::kNone && |
2016 !HasSimpleUnderlineInternal() && | 2016 !HasSimpleUnderlineInternal() && |
2017 !rare_inherited_data_->applied_text_decorations) | 2017 !rare_inherited_data_->applied_text_decorations) |
2018 return; | 2018 return; |
2019 | 2019 |
2020 // If there are any color changes or decorations set by this element, stop | 2020 // If there are any color changes or decorations set by this element, stop |
2021 // using m_hasSimpleUnderline. | 2021 // using m_hasSimpleUnderline. |
2022 Color current_text_decoration_color = | 2022 Color current_text_decoration_color = |
2023 VisitedDependentColor(CSSPropertyTextDecorationColor); | 2023 VisitedDependentColor(CSSPropertyTextDecorationColor); |
2024 if (HasSimpleUnderlineInternal() && | 2024 if (HasSimpleUnderlineInternal() && |
2025 (GetTextDecoration() != kTextDecorationNone || | 2025 (GetTextDecoration() != TextDecoration::kNone || |
2026 current_text_decoration_color != parent_text_decoration_color)) { | 2026 current_text_decoration_color != parent_text_decoration_color)) { |
2027 SetHasSimpleUnderlineInternal(false); | 2027 SetHasSimpleUnderlineInternal(false); |
2028 AddAppliedTextDecoration(AppliedTextDecoration( | 2028 AddAppliedTextDecoration(AppliedTextDecoration( |
2029 kTextDecorationUnderline, kTextDecorationStyleSolid, | 2029 TextDecoration::kUnderline, kTextDecorationStyleSolid, |
2030 parent_text_decoration_color)); | 2030 parent_text_decoration_color)); |
2031 } | 2031 } |
2032 if (override_existing_colors && | 2032 if (override_existing_colors && |
2033 rare_inherited_data_->applied_text_decorations) | 2033 rare_inherited_data_->applied_text_decorations) |
2034 OverrideTextDecorationColors(current_text_decoration_color); | 2034 OverrideTextDecorationColors(current_text_decoration_color); |
2035 if (GetTextDecoration() == kTextDecorationNone) | 2035 if (GetTextDecoration() == TextDecoration::kNone) |
2036 return; | 2036 return; |
2037 DCHECK(!HasSimpleUnderlineInternal()); | 2037 DCHECK(!HasSimpleUnderlineInternal()); |
2038 // To save memory, we don't use AppliedTextDecoration objects in the common | 2038 // To save memory, we don't use AppliedTextDecoration objects in the common |
2039 // case of a single simple underline of currentColor. | 2039 // case of a single simple underline of currentColor. |
2040 TextDecoration decoration_lines = GetTextDecoration(); | 2040 TextDecoration decoration_lines = GetTextDecoration(); |
2041 TextDecorationStyle decoration_style = GetTextDecorationStyle(); | 2041 TextDecorationStyle decoration_style = GetTextDecorationStyle(); |
2042 bool is_simple_underline = decoration_lines == kTextDecorationUnderline && | 2042 bool is_simple_underline = decoration_lines == TextDecoration::kUnderline && |
2043 decoration_style == kTextDecorationStyleSolid && | 2043 decoration_style == kTextDecorationStyleSolid && |
2044 TextDecorationColor().IsCurrentColor(); | 2044 TextDecorationColor().IsCurrentColor(); |
2045 if (is_simple_underline && !rare_inherited_data_->applied_text_decorations) { | 2045 if (is_simple_underline && !rare_inherited_data_->applied_text_decorations) { |
2046 SetHasSimpleUnderlineInternal(true); | 2046 SetHasSimpleUnderlineInternal(true); |
2047 return; | 2047 return; |
2048 } | 2048 } |
2049 | 2049 |
2050 AddAppliedTextDecoration(AppliedTextDecoration( | 2050 AddAppliedTextDecoration(AppliedTextDecoration( |
2051 decoration_lines, decoration_style, current_text_decoration_color)); | 2051 decoration_lines, decoration_style, current_text_decoration_color)); |
2052 } | 2052 } |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2500 if (value < 0) | 2500 if (value < 0) |
2501 fvalue -= 0.5f; | 2501 fvalue -= 0.5f; |
2502 else | 2502 else |
2503 fvalue += 0.5f; | 2503 fvalue += 0.5f; |
2504 } | 2504 } |
2505 | 2505 |
2506 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2506 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
2507 } | 2507 } |
2508 | 2508 |
2509 } // namespace blink | 2509 } // namespace blink |
OLD | NEW |