Chromium Code Reviews| 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 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 Loading... | |
| 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 Loading... | |
| 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 && !rareInheritedData->appliedText Decorations) | |
| 1249 return TextDecorationNone; | |
| 1250 if (inherited_flags.m_hasSimpleUnderline) | |
| 1251 return TextDecorationUnderline; | |
| 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 && !rareInheritedData->appliedText Decorations) { |
| 1261 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); | 1266 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); |
| 1262 return empty; | 1267 return empty; |
| 1263 } | 1268 } |
| 1264 if (inherited_flags.m_textUnderline) { | 1269 if (inherited_flags.m_hasSimpleUnderline) { |
| 1265 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline))); | 1270 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, visitedDepend entColor(CSSPropertyTextDecorationColor)))); |
| 1271 // Since we only have one of these in memory, just update the color befo re returning. | |
| 1272 underline.at(0).setColor(visitedDependentColor(CSSPropertyTextDecoration Color)); | |
| 1266 return underline; | 1273 return underline; |
| 1267 } | 1274 } |
| 1268 | 1275 |
| 1269 return rareInheritedData->appliedTextDecorations->vector(); | 1276 return rareInheritedData->appliedTextDecorations->vector(); |
| 1270 } | 1277 } |
| 1271 | 1278 |
| 1272 float ComputedStyle::wordSpacing() const { return fontDescription().wordSpacing( ); } | 1279 float ComputedStyle::wordSpacing() const { return fontDescription().wordSpacing( ); } |
| 1273 float ComputedStyle::letterSpacing() const { return fontDescription().letterSpac ing(); } | 1280 float ComputedStyle::letterSpacing() const { return fontDescription().letterSpac ing(); } |
| 1274 | 1281 |
| 1275 bool ComputedStyle::setFontDescription(const FontDescription& v) | 1282 bool ComputedStyle::setFontDescription(const FontDescription& v) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1363 | 1370 |
| 1364 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion) | 1371 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion) |
| 1365 { | 1372 { |
| 1366 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; | 1373 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; |
| 1367 | 1374 |
| 1368 if (!list) | 1375 if (!list) |
| 1369 list = AppliedTextDecorationList::create(); | 1376 list = AppliedTextDecorationList::create(); |
| 1370 else if (!list->hasOneRef()) | 1377 else if (!list->hasOneRef()) |
| 1371 list = list->copy(); | 1378 list = list->copy(); |
| 1372 | 1379 |
| 1373 if (inherited_flags.m_textUnderline) { | |
| 1374 inherited_flags.m_textUnderline = false; | |
| 1375 list->append(AppliedTextDecoration(TextDecorationUnderline)); | |
| 1376 } | |
| 1377 | |
| 1378 list->append(decoration); | 1380 list->append(decoration); |
| 1379 } | 1381 } |
| 1380 | 1382 |
| 1381 void ComputedStyle::applyTextDecorations() | 1383 void ComputedStyle::updateAppliedTextDecorations(Color propagatedColor) |
| 1382 { | 1384 { |
| 1383 if (textDecoration() == TextDecorationNone) | 1385 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; |
| 1386 | |
| 1387 ASSERT(list); | |
| 1388 if (!list->hasOneRef()) | |
| 1389 list = list->copy(); | |
| 1390 | |
| 1391 for (size_t i = 0; i < rareInheritedData->appliedTextDecorations->size(); ++ i) | |
| 1392 list->at(i).setColor(propagatedColor); | |
| 1393 } | |
| 1394 | |
| 1395 void ComputedStyle::applyTextDecorations(const ComputedStyle& parentStyle, bool overrideExistingColors) | |
|
Timothy Loh
2015/10/01 01:51:43
just pass in the parent style's decoration color
sashab
2015/10/02 02:45:42
Done.
| |
| 1396 { | |
| 1397 if (textDecoration() == TextDecorationNone && !inherited_flags.m_hasSimpleUn derline && !rareInheritedData->appliedTextDecorations) | |
| 1384 return; | 1398 return; |
| 1385 | 1399 |
| 1386 TextDecorationStyle style = textDecorationStyle(); | 1400 // If there are any color changes, stop using m_hasSimpleUnderline. |
| 1387 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins ideVisitedLink); | 1401 Color parentDecorationColor = parentStyle.visitedDependentColor(CSSPropertyT extDecorationColor); |
| 1402 if (inherited_flags.m_hasSimpleUnderline && visitedDependentColor(CSSPropert yTextDecorationColor) != parentDecorationColor) { | |
|
Timothy Loh
2015/10/01 01:51:43
can we not copy-paste visitedDependentColor(CSSPro
sashab
2015/10/02 02:45:42
Done.
| |
| 1403 inherited_flags.m_hasSimpleUnderline = false; | |
| 1404 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, parentDecorationColor)); | |
| 1405 } | |
| 1388 | 1406 |
| 1389 int decorations = textDecoration(); | 1407 // If we have a propagated color, update any other affected decorations. |
| 1408 if (overrideExistingColors && rareInheritedData->appliedTextDecorations) | |
| 1409 updateAppliedTextDecorations(visitedDependentColor(CSSPropertyTextDecora tionColor)); | |
| 1390 | 1410 |
| 1391 if (decorations & TextDecorationUnderline) { | 1411 TextDecoration decorationLines = textDecoration(); |
| 1392 // To save memory, we don't use AppliedTextDecoration objects in the | 1412 TextDecorationStyle decorationStyle = textDecorationStyle(); |
| 1393 // common case of a single simple underline. | 1413 StyleColor decorationColor = decorationColorIncludingFallback(insideLink() = = InsideVisitedLink); |
| 1394 AppliedTextDecoration underline(TextDecorationUnderline, style, styleCol or); | |
| 1395 | 1414 |
| 1396 if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnde rline()) | 1415 // To save memory, we don't use AppliedTextDecoration objects in the common case of a single simple underline. |
| 1397 inherited_flags.m_textUnderline = true; | 1416 if (!rareInheritedData->appliedTextDecorations && !inherited_flags.m_hasSimp leUnderline |
| 1398 else | 1417 && decorationLines == TextDecorationUnderline && decorationStyle == Text DecorationStyleSolid && decorationColor.isCurrentColor()) { |
| 1399 addAppliedTextDecoration(underline); | 1418 inherited_flags.m_hasSimpleUnderline = true; |
| 1419 return; | |
| 1400 } | 1420 } |
| 1401 if (decorations & TextDecorationOverline) | 1421 |
| 1402 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s tyle, styleColor)); | 1422 // Clear the existing optimization if we have it. |
|
Timothy Loh
2015/10/01 01:51:43
The logic here is a bit complicated, can we just o
sashab
2015/10/02 02:45:42
Simplified it a bit.
| |
| 1403 if (decorations & TextDecorationLineThrough) | 1423 if (inherited_flags.m_hasSimpleUnderline) { |
| 1404 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough , style, styleColor)); | 1424 inherited_flags.m_hasSimpleUnderline = false; |
| 1425 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, visitedDependentColor(CSSPropertyTextDecorationColor)) ); | |
| 1426 } | |
| 1427 | |
| 1428 Color resolvedDecorationColor = decorationColor.resolve(visitedDependentColo r(CSSPropertyTextDecorationColor)); | |
| 1429 addAppliedTextDecoration(AppliedTextDecoration(decorationLines, decorationSt yle, resolvedDecorationColor)); | |
| 1405 } | 1430 } |
| 1406 | 1431 |
| 1407 void ComputedStyle::clearAppliedTextDecorations() | 1432 void ComputedStyle::clearAppliedTextDecorations() |
| 1408 { | 1433 { |
| 1409 inherited_flags.m_textUnderline = false; | 1434 inherited_flags.m_hasSimpleUnderline = false; |
| 1410 | 1435 |
| 1411 if (rareInheritedData->appliedTextDecorations) | 1436 if (rareInheritedData->appliedTextDecorations) |
| 1412 rareInheritedData.access()->appliedTextDecorations = nullptr; | 1437 rareInheritedData.access()->appliedTextDecorations = nullptr; |
| 1413 } | 1438 } |
| 1414 | 1439 |
| 1415 void ComputedStyle::clearMultiCol() | 1440 void ComputedStyle::clearMultiCol() |
| 1416 { | 1441 { |
| 1417 rareNonInheritedData.access()->m_multiCol = nullptr; | 1442 rareNonInheritedData.access()->m_multiCol = nullptr; |
| 1418 rareNonInheritedData.access()->m_multiCol.init(); | 1443 rareNonInheritedData.access()->m_multiCol.init(); |
| 1419 } | 1444 } |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1798 } | 1823 } |
| 1799 | 1824 |
| 1800 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) | 1825 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) |
| 1801 { | 1826 { |
| 1802 setEmptyState(other.emptyState()); | 1827 setEmptyState(other.emptyState()); |
| 1803 if (other.hasExplicitlyInheritedProperties()) | 1828 if (other.hasExplicitlyInheritedProperties()) |
| 1804 setHasExplicitlyInheritedProperties(); | 1829 setHasExplicitlyInheritedProperties(); |
| 1805 } | 1830 } |
| 1806 | 1831 |
| 1807 } // namespace blink | 1832 } // namespace blink |
| OLD | NEW |