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

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 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 aca10ca0e19bd1eda5376118770a76c337d1728d..fa5dcd0a267256f1555c6eeefe47df01e2b79df9 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -745,7 +745,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()
@@ -1248,26 +1248,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();
}
@@ -1400,43 +1407,54 @@ 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;
- TextDecorationStyle style = textDecorationStyle();
- StyleColor styleColor = decorationColorIncludingFallback(insideLink() == InsideVisitedLink);
+ RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->appliedTextDecorations;
+ ASSERT(list);
+ if (!list->hasOneRef())
+ list = list->copy();
- int decorations = textDecoration();
+ for (size_t i = 0; i < list->size(); ++i)
+ list->at(i).setColor(overrideColor);
+}
- 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);
+void ComputedStyle::applyTextDecorations(const Color& parentTextDecorationColor, bool overrideExistingColors)
+{
+ if (textDecoration() == TextDecorationNone && !inherited_flags.m_hasSimpleUnderline && !rareInheritedData->appliedTextDecorations)
+ return;
- if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnderline())
- inherited_flags.m_textUnderline = true;
- else
- addAppliedTextDecoration(underline);
+ // 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 (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 (isSimpleUnderline && !rareInheritedData->appliedTextDecorations) {
+ 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