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

Unified Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 1328283005: Add support for multiple text decorations with same line positioning (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/style/ComputedStyle.cpp
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.cpp b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
index 2cfe368864871fa0ff9c64f8a2c15dfc50456082..a8267d69a8c1e1d30be18d51071fe5695700fcbc 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -742,7 +742,7 @@ void ComputedStyle::updatePropertySpecificDifferences(const ComputedStyle& other
if (!diff.needsPaintInvalidation()) {
if (inherited->color != other.inherited->color
|| inherited->visitedLinkColor != other.inherited->visitedLinkColor
- || inherited_flags.m_textUnderline != other.inherited_flags.m_textUnderline
+ || inherited_flags.m_hasSimpleUnderline != other.inherited_flags.m_hasSimpleUnderline
|| visual->textDecoration != other.visual->textDecoration) {
diff.setTextDecorationOrColorChanged();
} else if (rareNonInheritedData.get() != other.rareNonInheritedData.get()
@@ -1245,26 +1245,33 @@ FontStretch ComputedStyle::fontStretch() const { return fontDescription().stretc
TextDecoration ComputedStyle::textDecorationsInEffect() const
{
+ if (inherited_flags.m_hasSimpleUnderline)
+ return TextDecorationUnderline;
+ if (!rareInheritedData->appliedTextDecorations)
+ return TextDecorationNone;
+
int decorations = 0;
const Vector<AppliedTextDecoration>& applied = appliedTextDecorations();
for (size_t i = 0; i < applied.size(); ++i)
- decorations |= applied[i].line();
+ decorations |= applied[i].lines();
return static_cast<TextDecoration>(decorations);
}
const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() const
{
- if (!inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecorations) {
+ if (inherited_flags.m_hasSimpleUnderline) {
+ DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, AppliedTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, visitedDependentColor(CSSPropertyTextDecorationColor))));
+ // Since we only have one of these in memory, just update the color before returning.
+ underline.at(0).setColor(visitedDependentColor(CSSPropertyTextDecorationColor));
+ return underline;
+ }
+ if (!rareInheritedData->appliedTextDecorations) {
DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ());
return empty;
}
- if (inherited_flags.m_textUnderline) {
- DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, AppliedTextDecoration(TextDecorationUnderline)));
- return underline;
- }
return rareInheritedData->appliedTextDecorations->vector();
}
@@ -1397,43 +1404,55 @@ void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora
else if (!list->hasOneRef())
list = list->copy();
- if (inherited_flags.m_textUnderline) {
- inherited_flags.m_textUnderline = false;
- list->append(AppliedTextDecoration(TextDecorationUnderline));
- }
-
list->append(decoration);
}
-void ComputedStyle::applyTextDecorations()
+void ComputedStyle::overrideTextDecorationColors(Color overrideColor)
{
- if (textDecoration() == TextDecorationNone)
- return;
+ RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->appliedTextDecorations;
+
+ ASSERT(list);
+ if (!list->hasOneRef())
+ list = list->copy();
- TextDecorationStyle style = textDecorationStyle();
- StyleColor styleColor = decorationColorIncludingFallback(insideLink() == InsideVisitedLink);
+ for (size_t i = 0; i < rareInheritedData->appliedTextDecorations->size(); ++i)
Timothy Loh 2015/11/03 06:38:59 rareInheritedData->appliedTextDecorations should j
sashab 2015/11/03 22:51:26 Done.
+ list->at(i).setColor(overrideColor);
+}
- int decorations = textDecoration();
+void ComputedStyle::applyTextDecorations(const Color& parentTextDecorationColor, bool overrideExistingColors)
+{
+ if (textDecoration() == TextDecorationNone && !inherited_flags.m_hasSimpleUnderline && !rareInheritedData->appliedTextDecorations)
+ return;
- if (decorations & TextDecorationUnderline) {
- // To save memory, we don't use AppliedTextDecoration objects in the
- // common case of a single simple underline.
- AppliedTextDecoration underline(TextDecorationUnderline, style, styleColor);
+ // If there are any color changes or decorations set by this element, stop using m_hasSimpleUnderline.
+ Color currentTextDecorationColor = visitedDependentColor(CSSPropertyTextDecorationColor);
+ if (inherited_flags.m_hasSimpleUnderline && (textDecoration() != TextDecorationNone || currentTextDecorationColor != parentTextDecorationColor)) {
+ inherited_flags.m_hasSimpleUnderline = false;
+ addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, parentTextDecorationColor));
+ }
- if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnderline())
- inherited_flags.m_textUnderline = true;
- else
- addAppliedTextDecoration(underline);
+ if (overrideExistingColors && rareInheritedData->appliedTextDecorations)
+ overrideTextDecorationColors(currentTextDecorationColor);
+
+ if (textDecoration() == TextDecorationNone)
+ return;
+ ASSERT(!inherited_flags.m_hasSimpleUnderline);
+
+ // To save memory, we don't use AppliedTextDecoration objects in the common case of a single simple underline.
+ TextDecoration decorationLines = textDecoration();
+ TextDecorationStyle decorationStyle = textDecorationStyle();
+ bool isSimpleUnderline = decorationLines == TextDecorationUnderline && decorationStyle == TextDecorationStyleSolid;
+ if (!rareInheritedData->appliedTextDecorations && !inherited_flags.m_hasSimpleUnderline && isSimpleUnderline) {
Timothy Loh 2015/11/03 06:38:59 m_hasSimpleUnderline is always false here
sashab 2015/11/03 22:51:26 Done.
+ inherited_flags.m_hasSimpleUnderline = true;
+ return;
}
- if (decorations & TextDecorationOverline)
- addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, style, styleColor));
- if (decorations & TextDecorationLineThrough)
- addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough, style, styleColor));
+
+ addAppliedTextDecoration(AppliedTextDecoration(decorationLines, decorationStyle, currentTextDecorationColor));
}
void ComputedStyle::clearAppliedTextDecorations()
{
- inherited_flags.m_textUnderline = false;
+ inherited_flags.m_hasSimpleUnderline = false;
if (rareInheritedData->appliedTextDecorations)
rareInheritedData.access()->appliedTextDecorations = nullptr;
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698