| 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 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 diff.setNeedsRecomputeOverflow(); | 1092 diff.setNeedsRecomputeOverflow(); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 if (!m_surround->border.visualOverflowEqual(other.m_surround->border)) | 1095 if (!m_surround->border.visualOverflowEqual(other.m_surround->border)) |
| 1096 diff.setNeedsRecomputeOverflow(); | 1096 diff.setNeedsRecomputeOverflow(); |
| 1097 | 1097 |
| 1098 if (!diff.needsPaintInvalidation()) { | 1098 if (!diff.needsPaintInvalidation()) { |
| 1099 if (m_styleInheritedData->color != other.m_styleInheritedData->color || | 1099 if (m_styleInheritedData->color != other.m_styleInheritedData->color || |
| 1100 m_styleInheritedData->visitedLinkColor != | 1100 m_styleInheritedData->visitedLinkColor != |
| 1101 other.m_styleInheritedData->visitedLinkColor || | 1101 other.m_styleInheritedData->visitedLinkColor || |
| 1102 m_inheritedData.m_textUnderline != | 1102 m_inheritedData.m_hasSimpleUnderline != |
| 1103 other.m_inheritedData.m_textUnderline || | 1103 other.m_inheritedData.m_hasSimpleUnderline || |
| 1104 m_visual->textDecoration != other.m_visual->textDecoration) { | 1104 m_visual->textDecoration != other.m_visual->textDecoration) { |
| 1105 diff.setTextDecorationOrColorChanged(); | 1105 diff.setTextDecorationOrColorChanged(); |
| 1106 } else if (m_rareNonInheritedData.get() != | 1106 } else if (m_rareNonInheritedData.get() != |
| 1107 other.m_rareNonInheritedData.get() && | 1107 other.m_rareNonInheritedData.get() && |
| 1108 (m_rareNonInheritedData->m_textDecorationStyle != | 1108 (m_rareNonInheritedData->m_textDecorationStyle != |
| 1109 other.m_rareNonInheritedData->m_textDecorationStyle || | 1109 other.m_rareNonInheritedData->m_textDecorationStyle || |
| 1110 m_rareNonInheritedData->m_textDecorationColor != | 1110 m_rareNonInheritedData->m_textDecorationColor != |
| 1111 other.m_rareNonInheritedData->m_textDecorationColor || | 1111 other.m_rareNonInheritedData->m_textDecorationColor || |
| 1112 m_rareNonInheritedData->m_visitedLinkTextDecorationColor != | 1112 m_rareNonInheritedData->m_visitedLinkTextDecorationColor != |
| 1113 other.m_rareNonInheritedData | 1113 other.m_rareNonInheritedData |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 return getFontDescription().hasSizeAdjust(); | 1705 return getFontDescription().hasSizeAdjust(); |
| 1706 } | 1706 } |
| 1707 FontWeight ComputedStyle::fontWeight() const { | 1707 FontWeight ComputedStyle::fontWeight() const { |
| 1708 return getFontDescription().weight(); | 1708 return getFontDescription().weight(); |
| 1709 } | 1709 } |
| 1710 FontStretch ComputedStyle::fontStretch() const { | 1710 FontStretch ComputedStyle::fontStretch() 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 (m_inheritedData.m_hasSimpleUnderline) |
| 1716 return TextDecorationUnderline; |
| 1717 if (!m_rareInheritedData->appliedTextDecorations) |
| 1718 return TextDecorationNone; |
| 1719 |
| 1715 int decorations = 0; | 1720 int decorations = 0; |
| 1716 | 1721 |
| 1717 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); | 1722 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); |
| 1718 | 1723 |
| 1719 for (size_t i = 0; i < applied.size(); ++i) | 1724 for (size_t i = 0; i < applied.size(); ++i) |
| 1720 decorations |= applied[i].line(); | 1725 decorations |= applied[i].lines(); |
| 1721 | 1726 |
| 1722 return static_cast<TextDecoration>(decorations); | 1727 return static_cast<TextDecoration>(decorations); |
| 1723 } | 1728 } |
| 1724 | 1729 |
| 1725 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() | 1730 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() |
| 1726 const { | 1731 const { |
| 1727 if (!m_inheritedData.m_textUnderline && | 1732 if (m_inheritedData.m_hasSimpleUnderline) { |
| 1728 !m_rareInheritedData->appliedTextDecorations) { | 1733 DEFINE_STATIC_LOCAL( |
| 1734 Vector<AppliedTextDecoration>, underline, |
| 1735 (1, AppliedTextDecoration( |
| 1736 TextDecorationUnderline, TextDecorationStyleSolid, |
| 1737 visitedDependentColor(CSSPropertyTextDecorationColor)))); |
| 1738 // Since we only have one of these in memory, just update the color before |
| 1739 // returning. |
| 1740 underline.at(0).setColor( |
| 1741 visitedDependentColor(CSSPropertyTextDecorationColor)); |
| 1742 return underline; |
| 1743 } |
| 1744 if (!m_rareInheritedData->appliedTextDecorations) { |
| 1729 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); | 1745 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); |
| 1730 return empty; | 1746 return empty; |
| 1731 } | 1747 } |
| 1732 if (m_inheritedData.m_textUnderline) { | |
| 1733 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, | |
| 1734 (1, AppliedTextDecoration(TextDecorationUnderline))); | |
| 1735 return underline; | |
| 1736 } | |
| 1737 | 1748 |
| 1738 return m_rareInheritedData->appliedTextDecorations->vector(); | 1749 return m_rareInheritedData->appliedTextDecorations->vector(); |
| 1739 } | 1750 } |
| 1740 | 1751 |
| 1741 StyleInheritedVariables* ComputedStyle::inheritedVariables() const { | 1752 StyleInheritedVariables* ComputedStyle::inheritedVariables() const { |
| 1742 return m_rareInheritedData->variables.get(); | 1753 return m_rareInheritedData->variables.get(); |
| 1743 } | 1754 } |
| 1744 | 1755 |
| 1745 StyleNonInheritedVariables* ComputedStyle::nonInheritedVariables() const { | 1756 StyleNonInheritedVariables* ComputedStyle::nonInheritedVariables() const { |
| 1746 return m_rareNonInheritedData->m_variables.get(); | 1757 return m_rareNonInheritedData->m_variables.get(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 void ComputedStyle::addAppliedTextDecoration( | 1947 void ComputedStyle::addAppliedTextDecoration( |
| 1937 const AppliedTextDecoration& decoration) { | 1948 const AppliedTextDecoration& decoration) { |
| 1938 RefPtr<AppliedTextDecorationList>& list = | 1949 RefPtr<AppliedTextDecorationList>& list = |
| 1939 m_rareInheritedData.access()->appliedTextDecorations; | 1950 m_rareInheritedData.access()->appliedTextDecorations; |
| 1940 | 1951 |
| 1941 if (!list) | 1952 if (!list) |
| 1942 list = AppliedTextDecorationList::create(); | 1953 list = AppliedTextDecorationList::create(); |
| 1943 else if (!list->hasOneRef()) | 1954 else if (!list->hasOneRef()) |
| 1944 list = list->copy(); | 1955 list = list->copy(); |
| 1945 | 1956 |
| 1946 if (m_inheritedData.m_textUnderline) { | |
| 1947 m_inheritedData.m_textUnderline = false; | |
| 1948 list->append(AppliedTextDecoration(TextDecorationUnderline)); | |
| 1949 } | |
| 1950 | |
| 1951 list->append(decoration); | 1957 list->append(decoration); |
| 1952 } | 1958 } |
| 1953 | 1959 |
| 1954 void ComputedStyle::applyTextDecorations() { | 1960 void ComputedStyle::overrideTextDecorationColors(Color overrideColor) { |
| 1961 RefPtr<AppliedTextDecorationList>& list = |
| 1962 m_rareInheritedData.access()->appliedTextDecorations; |
| 1963 DCHECK(list); |
| 1964 if (!list->hasOneRef()) |
| 1965 list = list->copy(); |
| 1966 |
| 1967 for (size_t i = 0; i < list->size(); ++i) |
| 1968 list->at(i).setColor(overrideColor); |
| 1969 } |
| 1970 |
| 1971 void ComputedStyle::applyTextDecorations(const Color& parentTextDecorationColor, |
| 1972 bool overrideExistingColors) { |
| 1973 if (getTextDecoration() == TextDecorationNone && |
| 1974 !m_inheritedData.m_hasSimpleUnderline && |
| 1975 !m_rareInheritedData->appliedTextDecorations) |
| 1976 return; |
| 1977 |
| 1978 // If there are any color changes or decorations set by this element, stop |
| 1979 // using m_hasSimpleUnderline. |
| 1980 Color currentTextDecorationColor = |
| 1981 visitedDependentColor(CSSPropertyTextDecorationColor); |
| 1982 if (m_inheritedData.m_hasSimpleUnderline && |
| 1983 (getTextDecoration() != TextDecorationNone || |
| 1984 currentTextDecorationColor != parentTextDecorationColor)) { |
| 1985 m_inheritedData.m_hasSimpleUnderline = false; |
| 1986 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline, |
| 1987 TextDecorationStyleSolid, |
| 1988 parentTextDecorationColor)); |
| 1989 } |
| 1990 if (overrideExistingColors && m_rareInheritedData->appliedTextDecorations) |
| 1991 overrideTextDecorationColors(currentTextDecorationColor); |
| 1955 if (getTextDecoration() == TextDecorationNone) | 1992 if (getTextDecoration() == TextDecorationNone) |
| 1956 return; | 1993 return; |
| 1994 DCHECK(!m_inheritedData.m_hasSimpleUnderline); |
| 1995 // To save memory, we don't use AppliedTextDecoration objects in the common |
| 1996 // case of a single simple underline of currentColor. |
| 1997 TextDecoration decorationLines = getTextDecoration(); |
| 1998 TextDecorationStyle decorationStyle = getTextDecorationStyle(); |
| 1999 bool isSimpleUnderline = decorationLines == TextDecorationUnderline && |
| 2000 decorationStyle == TextDecorationStyleSolid && |
| 2001 textDecorationColor().isCurrentColor(); |
| 2002 if (isSimpleUnderline && !m_rareInheritedData->appliedTextDecorations) { |
| 2003 m_inheritedData.m_hasSimpleUnderline = true; |
| 2004 return; |
| 2005 } |
| 1957 | 2006 |
| 1958 TextDecorationStyle style = getTextDecorationStyle(); | 2007 addAppliedTextDecoration(AppliedTextDecoration( |
| 1959 StyleColor styleColor = | 2008 decorationLines, decorationStyle, currentTextDecorationColor)); |
| 1960 decorationColorIncludingFallback(insideLink() == InsideVisitedLink); | |
| 1961 | |
| 1962 int decorations = getTextDecoration(); | |
| 1963 | |
| 1964 if (decorations & TextDecorationUnderline) { | |
| 1965 // To save memory, we don't use AppliedTextDecoration objects in the | |
| 1966 // common case of a single simple underline. | |
| 1967 AppliedTextDecoration underline(TextDecorationUnderline, style, styleColor); | |
| 1968 | |
| 1969 if (!m_rareInheritedData->appliedTextDecorations && | |
| 1970 underline.isSimpleUnderline()) | |
| 1971 m_inheritedData.m_textUnderline = true; | |
| 1972 else | |
| 1973 addAppliedTextDecoration(underline); | |
| 1974 } | |
| 1975 if (decorations & TextDecorationOverline) | |
| 1976 addAppliedTextDecoration( | |
| 1977 AppliedTextDecoration(TextDecorationOverline, style, styleColor)); | |
| 1978 if (decorations & TextDecorationLineThrough) | |
| 1979 addAppliedTextDecoration( | |
| 1980 AppliedTextDecoration(TextDecorationLineThrough, style, styleColor)); | |
| 1981 } | 2009 } |
| 1982 | 2010 |
| 1983 void ComputedStyle::clearAppliedTextDecorations() { | 2011 void ComputedStyle::clearAppliedTextDecorations() { |
| 1984 m_inheritedData.m_textUnderline = false; | 2012 m_inheritedData.m_hasSimpleUnderline = false; |
| 1985 | 2013 |
| 1986 if (m_rareInheritedData->appliedTextDecorations) | 2014 if (m_rareInheritedData->appliedTextDecorations) |
| 1987 m_rareInheritedData.access()->appliedTextDecorations = nullptr; | 2015 m_rareInheritedData.access()->appliedTextDecorations = nullptr; |
| 1988 } | 2016 } |
| 1989 | 2017 |
| 1990 void ComputedStyle::restoreParentTextDecorations( | 2018 void ComputedStyle::restoreParentTextDecorations( |
| 1991 const ComputedStyle& parentStyle) { | 2019 const ComputedStyle& parentStyle) { |
| 1992 m_inheritedData.m_textUnderline = parentStyle.m_inheritedData.m_textUnderline; | 2020 m_inheritedData.m_hasSimpleUnderline = |
| 2021 parentStyle.m_inheritedData.m_hasSimpleUnderline; |
| 1993 if (m_rareInheritedData->appliedTextDecorations != | 2022 if (m_rareInheritedData->appliedTextDecorations != |
| 1994 parentStyle.m_rareInheritedData->appliedTextDecorations) | 2023 parentStyle.m_rareInheritedData->appliedTextDecorations) |
| 1995 m_rareInheritedData.access()->appliedTextDecorations = | 2024 m_rareInheritedData.access()->appliedTextDecorations = |
| 1996 parentStyle.m_rareInheritedData->appliedTextDecorations; | 2025 parentStyle.m_rareInheritedData->appliedTextDecorations; |
| 1997 } | 2026 } |
| 1998 | 2027 |
| 1999 void ComputedStyle::clearMultiCol() { | 2028 void ComputedStyle::clearMultiCol() { |
| 2000 m_rareNonInheritedData.access()->m_multiCol = nullptr; | 2029 m_rareNonInheritedData.access()->m_multiCol = nullptr; |
| 2001 m_rareNonInheritedData.access()->m_multiCol.init(); | 2030 m_rareNonInheritedData.access()->m_multiCol.init(); |
| 2002 } | 2031 } |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2417 if (value < 0) | 2446 if (value < 0) |
| 2418 fvalue -= 0.5f; | 2447 fvalue -= 0.5f; |
| 2419 else | 2448 else |
| 2420 fvalue += 0.5f; | 2449 fvalue += 0.5f; |
| 2421 } | 2450 } |
| 2422 | 2451 |
| 2423 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 2452 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
| 2424 } | 2453 } |
| 2425 | 2454 |
| 2426 } // namespace blink | 2455 } // namespace blink |
| OLD | NEW |