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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er) 735 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er)
736 diff.setFilterChanged(); 736 diff.setFilterChanged();
737 737
738 if (rareNonInheritedData->m_backdropFilter != other.rareNonInheritedData ->m_backdropFilter) 738 if (rareNonInheritedData->m_backdropFilter != other.rareNonInheritedData ->m_backdropFilter)
739 diff.setBackdropFilterChanged(); 739 diff.setBackdropFilterChanged();
740 } 740 }
741 741
742 if (!diff.needsPaintInvalidation()) { 742 if (!diff.needsPaintInvalidation()) {
743 if (inherited->color != other.inherited->color 743 if (inherited->color != other.inherited->color
744 || inherited->visitedLinkColor != other.inherited->visitedLinkColor 744 || inherited->visitedLinkColor != other.inherited->visitedLinkColor
745 || inherited_flags.m_textUnderline != other.inherited_flags.m_textUn derline 745 || inherited_flags.m_hasSimpleUnderline != other.inherited_flags.m_h asSimpleUnderline
746 || visual->textDecoration != other.visual->textDecoration) { 746 || visual->textDecoration != other.visual->textDecoration) {
747 diff.setTextDecorationOrColorChanged(); 747 diff.setTextDecorationOrColorChanged();
748 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( ) 748 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( )
749 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle 749 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle
750 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor 750 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor
751 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) { 751 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) {
752 diff.setTextDecorationOrColorChanged(); 752 diff.setTextDecorationOrColorChanged();
753 } else if (rareInheritedData.get() != other.rareInheritedData.get() 753 } else if (rareInheritedData.get() != other.rareInheritedData.get()
754 && (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor() 754 && (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor()
755 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor() 755 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor()
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 float ComputedStyle::specifiedFontSize() const { return fontDescription().specif iedSize(); } 1238 float ComputedStyle::specifiedFontSize() const { return fontDescription().specif iedSize(); }
1239 float ComputedStyle::computedFontSize() const { return fontDescription().compute dSize(); } 1239 float ComputedStyle::computedFontSize() const { return fontDescription().compute dSize(); }
1240 int ComputedStyle::fontSize() const { return fontDescription().computedPixelSize (); } 1240 int ComputedStyle::fontSize() const { return fontDescription().computedPixelSize (); }
1241 float ComputedStyle::fontSizeAdjust() const { return fontDescription().sizeAdjus t(); } 1241 float ComputedStyle::fontSizeAdjust() const { return fontDescription().sizeAdjus t(); }
1242 bool ComputedStyle::hasFontSizeAdjust() const { return fontDescription().hasSize Adjust(); } 1242 bool ComputedStyle::hasFontSizeAdjust() const { return fontDescription().hasSize Adjust(); }
1243 FontWeight ComputedStyle::fontWeight() const { return fontDescription().weight() ; } 1243 FontWeight ComputedStyle::fontWeight() const { return fontDescription().weight() ; }
1244 FontStretch ComputedStyle::fontStretch() const { return fontDescription().stretc h(); } 1244 FontStretch ComputedStyle::fontStretch() const { return fontDescription().stretc h(); }
1245 1245
1246 TextDecoration ComputedStyle::textDecorationsInEffect() const 1246 TextDecoration ComputedStyle::textDecorationsInEffect() const
1247 { 1247 {
1248 if (inherited_flags.m_hasSimpleUnderline)
1249 return TextDecorationUnderline;
1250 if (!rareInheritedData->appliedTextDecorations)
1251 return TextDecorationNone;
1252
1248 int decorations = 0; 1253 int decorations = 0;
1249 1254
1250 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); 1255 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations();
1251 1256
1252 for (size_t i = 0; i < applied.size(); ++i) 1257 for (size_t i = 0; i < applied.size(); ++i)
1253 decorations |= applied[i].line(); 1258 decorations |= applied[i].lines();
1254 1259
1255 return static_cast<TextDecoration>(decorations); 1260 return static_cast<TextDecoration>(decorations);
1256 } 1261 }
1257 1262
1258 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con st 1263 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con st
1259 { 1264 {
1260 if (!inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecor ations) { 1265 if (inherited_flags.m_hasSimpleUnderline) {
1266 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, visitedDepend entColor(CSSPropertyTextDecorationColor))));
1267 // Since we only have one of these in memory, just update the color befo re returning.
1268 underline.at(0).setColor(visitedDependentColor(CSSPropertyTextDecoration Color));
1269 return underline;
1270 }
1271 if (!rareInheritedData->appliedTextDecorations) {
1261 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); 1272 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ());
1262 return empty; 1273 return empty;
1263 } 1274 }
1264 if (inherited_flags.m_textUnderline) {
1265 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline)));
1266 return underline;
1267 }
1268 1275
1269 return rareInheritedData->appliedTextDecorations->vector(); 1276 return rareInheritedData->appliedTextDecorations->vector();
1270 } 1277 }
1271 1278
1272 StyleVariableData* ComputedStyle::variables() const 1279 StyleVariableData* ComputedStyle::variables() const
1273 { 1280 {
1274 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); 1281 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
1275 return rareInheritedData->variables.get(); 1282 return rareInheritedData->variables.get();
1276 } 1283 }
1277 1284
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 1397
1391 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion) 1398 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion)
1392 { 1399 {
1393 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; 1400 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations;
1394 1401
1395 if (!list) 1402 if (!list)
1396 list = AppliedTextDecorationList::create(); 1403 list = AppliedTextDecorationList::create();
1397 else if (!list->hasOneRef()) 1404 else if (!list->hasOneRef())
1398 list = list->copy(); 1405 list = list->copy();
1399 1406
1400 if (inherited_flags.m_textUnderline) {
1401 inherited_flags.m_textUnderline = false;
1402 list->append(AppliedTextDecoration(TextDecorationUnderline));
1403 }
1404
1405 list->append(decoration); 1407 list->append(decoration);
1406 } 1408 }
1407 1409
1408 void ComputedStyle::applyTextDecorations() 1410 void ComputedStyle::overrideTextDecorationColors(Color overrideColor)
1409 { 1411 {
1412 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations;
1413
1414 ASSERT(list);
1415 if (!list->hasOneRef())
1416 list = list->copy();
1417
1418 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.
1419 list->at(i).setColor(overrideColor);
1420 }
1421
1422 void ComputedStyle::applyTextDecorations(const Color& parentTextDecorationColor, bool overrideExistingColors)
1423 {
1424 if (textDecoration() == TextDecorationNone && !inherited_flags.m_hasSimpleUn derline && !rareInheritedData->appliedTextDecorations)
1425 return;
1426
1427 // If there are any color changes or decorations set by this element, stop u sing m_hasSimpleUnderline.
1428 Color currentTextDecorationColor = visitedDependentColor(CSSPropertyTextDeco rationColor);
1429 if (inherited_flags.m_hasSimpleUnderline && (textDecoration() != TextDecorat ionNone || currentTextDecorationColor != parentTextDecorationColor)) {
1430 inherited_flags.m_hasSimpleUnderline = false;
1431 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, parentTextDecorationColor));
1432 }
1433
1434 if (overrideExistingColors && rareInheritedData->appliedTextDecorations)
1435 overrideTextDecorationColors(currentTextDecorationColor);
1436
1410 if (textDecoration() == TextDecorationNone) 1437 if (textDecoration() == TextDecorationNone)
1411 return; 1438 return;
1439 ASSERT(!inherited_flags.m_hasSimpleUnderline);
1412 1440
1413 TextDecorationStyle style = textDecorationStyle(); 1441 // To save memory, we don't use AppliedTextDecoration objects in the common case of a single simple underline.
1414 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins ideVisitedLink); 1442 TextDecoration decorationLines = textDecoration();
1443 TextDecorationStyle decorationStyle = textDecorationStyle();
1444 bool isSimpleUnderline = decorationLines == TextDecorationUnderline && decor ationStyle == TextDecorationStyleSolid;
1445 if (!rareInheritedData->appliedTextDecorations && !inherited_flags.m_hasSimp leUnderline && isSimpleUnderline) {
Timothy Loh 2015/11/03 06:38:59 m_hasSimpleUnderline is always false here
sashab 2015/11/03 22:51:26 Done.
1446 inherited_flags.m_hasSimpleUnderline = true;
1447 return;
1448 }
1415 1449
1416 int decorations = textDecoration(); 1450 addAppliedTextDecoration(AppliedTextDecoration(decorationLines, decorationSt yle, currentTextDecorationColor));
1417
1418 if (decorations & TextDecorationUnderline) {
1419 // To save memory, we don't use AppliedTextDecoration objects in the
1420 // common case of a single simple underline.
1421 AppliedTextDecoration underline(TextDecorationUnderline, style, styleCol or);
1422
1423 if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnde rline())
1424 inherited_flags.m_textUnderline = true;
1425 else
1426 addAppliedTextDecoration(underline);
1427 }
1428 if (decorations & TextDecorationOverline)
1429 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s tyle, styleColor));
1430 if (decorations & TextDecorationLineThrough)
1431 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough , style, styleColor));
1432 } 1451 }
1433 1452
1434 void ComputedStyle::clearAppliedTextDecorations() 1453 void ComputedStyle::clearAppliedTextDecorations()
1435 { 1454 {
1436 inherited_flags.m_textUnderline = false; 1455 inherited_flags.m_hasSimpleUnderline = false;
1437 1456
1438 if (rareInheritedData->appliedTextDecorations) 1457 if (rareInheritedData->appliedTextDecorations)
1439 rareInheritedData.access()->appliedTextDecorations = nullptr; 1458 rareInheritedData.access()->appliedTextDecorations = nullptr;
1440 } 1459 }
1441 1460
1442 void ComputedStyle::clearMultiCol() 1461 void ComputedStyle::clearMultiCol()
1443 { 1462 {
1444 rareNonInheritedData.access()->m_multiCol = nullptr; 1463 rareNonInheritedData.access()->m_multiCol = nullptr;
1445 rareNonInheritedData.access()->m_multiCol.init(); 1464 rareNonInheritedData.access()->m_multiCol.init();
1446 } 1465 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 } 1836 }
1818 1837
1819 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) 1838 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other)
1820 { 1839 {
1821 setEmptyState(other.emptyState()); 1840 setEmptyState(other.emptyState());
1822 if (other.hasExplicitlyInheritedProperties()) 1841 if (other.hasExplicitlyInheritedProperties())
1823 setHasExplicitlyInheritedProperties(); 1842 setHasExplicitlyInheritedProperties();
1824 } 1843 }
1825 1844
1826 } // namespace blink 1845 } // namespace blink
OLDNEW
« 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