| 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt
er) | 738 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt
er) |
| 739 diff.setFilterChanged(); | 739 diff.setFilterChanged(); |
| 740 | 740 |
| 741 if (rareNonInheritedData->m_backdropFilter != other.rareNonInheritedData
->m_backdropFilter) | 741 if (rareNonInheritedData->m_backdropFilter != other.rareNonInheritedData
->m_backdropFilter) |
| 742 diff.setBackdropFilterChanged(); | 742 diff.setBackdropFilterChanged(); |
| 743 } | 743 } |
| 744 | 744 |
| 745 if (!diff.needsPaintInvalidation()) { | 745 if (!diff.needsPaintInvalidation()) { |
| 746 if (inherited->color != other.inherited->color | 746 if (inherited->color != other.inherited->color |
| 747 || inherited->visitedLinkColor != other.inherited->visitedLinkColor | 747 || inherited->visitedLinkColor != other.inherited->visitedLinkColor |
| 748 || inherited_flags.m_textUnderline != other.inherited_flags.m_textUn
derline | 748 || inherited_flags.m_hasSimpleUnderline != other.inherited_flags.m_h
asSimpleUnderline |
| 749 || visual->textDecoration != other.visual->textDecoration) { | 749 || visual->textDecoration != other.visual->textDecoration) { |
| 750 diff.setTextDecorationOrColorChanged(); | 750 diff.setTextDecorationOrColorChanged(); |
| 751 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get(
) | 751 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get(
) |
| 752 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe
ritedData->m_textDecorationStyle | 752 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe
ritedData->m_textDecorationStyle |
| 753 || rareNonInheritedData->m_textDecorationColor != other.rareNonI
nheritedData->m_textDecorationColor | 753 || rareNonInheritedData->m_textDecorationColor != other.rareNonI
nheritedData->m_textDecorationColor |
| 754 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth
er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) { | 754 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth
er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) { |
| 755 diff.setTextDecorationOrColorChanged(); | 755 diff.setTextDecorationOrColorChanged(); |
| 756 } else if (rareInheritedData.get() != other.rareInheritedData.get() | 756 } else if (rareInheritedData.get() != other.rareInheritedData.get() |
| 757 && (rareInheritedData->textFillColor() != other.rareInheritedData->t
extFillColor() | 757 && (rareInheritedData->textFillColor() != other.rareInheritedData->t
extFillColor() |
| 758 || rareInheritedData->textStrokeColor() != other.rareInheritedDa
ta->textStrokeColor() | 758 || rareInheritedData->textStrokeColor() != other.rareInheritedDa
ta->textStrokeColor() |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 float ComputedStyle::specifiedFontSize() const { return fontDescription().specif
iedSize(); } | 1241 float ComputedStyle::specifiedFontSize() const { return fontDescription().specif
iedSize(); } |
| 1242 float ComputedStyle::computedFontSize() const { return fontDescription().compute
dSize(); } | 1242 float ComputedStyle::computedFontSize() const { return fontDescription().compute
dSize(); } |
| 1243 int ComputedStyle::fontSize() const { return fontDescription().computedPixelSize
(); } | 1243 int ComputedStyle::fontSize() const { return fontDescription().computedPixelSize
(); } |
| 1244 float ComputedStyle::fontSizeAdjust() const { return fontDescription().sizeAdjus
t(); } | 1244 float ComputedStyle::fontSizeAdjust() const { return fontDescription().sizeAdjus
t(); } |
| 1245 bool ComputedStyle::hasFontSizeAdjust() const { return fontDescription().hasSize
Adjust(); } | 1245 bool ComputedStyle::hasFontSizeAdjust() const { return fontDescription().hasSize
Adjust(); } |
| 1246 FontWeight ComputedStyle::fontWeight() const { return fontDescription().weight()
; } | 1246 FontWeight ComputedStyle::fontWeight() const { return fontDescription().weight()
; } |
| 1247 FontStretch ComputedStyle::fontStretch() const { return fontDescription().stretc
h(); } | 1247 FontStretch ComputedStyle::fontStretch() const { return fontDescription().stretc
h(); } |
| 1248 | 1248 |
| 1249 TextDecoration ComputedStyle::textDecorationsInEffect() const | 1249 TextDecoration ComputedStyle::textDecorationsInEffect() const |
| 1250 { | 1250 { |
| 1251 if (inherited_flags.m_hasSimpleUnderline) |
| 1252 return TextDecorationUnderline; |
| 1253 if (!rareInheritedData->appliedTextDecorations) |
| 1254 return TextDecorationNone; |
| 1255 |
| 1251 int decorations = 0; | 1256 int decorations = 0; |
| 1252 | 1257 |
| 1253 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); | 1258 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); |
| 1254 | 1259 |
| 1255 for (size_t i = 0; i < applied.size(); ++i) | 1260 for (size_t i = 0; i < applied.size(); ++i) |
| 1256 decorations |= applied[i].line(); | 1261 decorations |= applied[i].lines(); |
| 1257 | 1262 |
| 1258 return static_cast<TextDecoration>(decorations); | 1263 return static_cast<TextDecoration>(decorations); |
| 1259 } | 1264 } |
| 1260 | 1265 |
| 1261 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con
st | 1266 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con
st |
| 1262 { | 1267 { |
| 1263 if (!inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecor
ations) { | 1268 if (inherited_flags.m_hasSimpleUnderline) { |
| 1269 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie
dTextDecoration(TextDecorationUnderline, TextDecorationStyleSolid, visitedDepend
entColor(CSSPropertyTextDecorationColor)))); |
| 1270 // Since we only have one of these in memory, just update the color befo
re returning. |
| 1271 underline.at(0).setColor(visitedDependentColor(CSSPropertyTextDecoration
Color)); |
| 1272 return underline; |
| 1273 } |
| 1274 if (!rareInheritedData->appliedTextDecorations) { |
| 1264 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); | 1275 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); |
| 1265 return empty; | 1276 return empty; |
| 1266 } | 1277 } |
| 1267 if (inherited_flags.m_textUnderline) { | |
| 1268 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie
dTextDecoration(TextDecorationUnderline))); | |
| 1269 return underline; | |
| 1270 } | |
| 1271 | 1278 |
| 1272 return rareInheritedData->appliedTextDecorations->vector(); | 1279 return rareInheritedData->appliedTextDecorations->vector(); |
| 1273 } | 1280 } |
| 1274 | 1281 |
| 1275 StyleVariableData* ComputedStyle::variables() const | 1282 StyleVariableData* ComputedStyle::variables() const |
| 1276 { | 1283 { |
| 1277 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); | 1284 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); |
| 1278 return rareInheritedData->variables.get(); | 1285 return rareInheritedData->variables.get(); |
| 1279 } | 1286 } |
| 1280 | 1287 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 | 1400 |
| 1394 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora
tion) | 1401 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora
tion) |
| 1395 { | 1402 { |
| 1396 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie
dTextDecorations; | 1403 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie
dTextDecorations; |
| 1397 | 1404 |
| 1398 if (!list) | 1405 if (!list) |
| 1399 list = AppliedTextDecorationList::create(); | 1406 list = AppliedTextDecorationList::create(); |
| 1400 else if (!list->hasOneRef()) | 1407 else if (!list->hasOneRef()) |
| 1401 list = list->copy(); | 1408 list = list->copy(); |
| 1402 | 1409 |
| 1403 if (inherited_flags.m_textUnderline) { | |
| 1404 inherited_flags.m_textUnderline = false; | |
| 1405 list->append(AppliedTextDecoration(TextDecorationUnderline)); | |
| 1406 } | |
| 1407 | |
| 1408 list->append(decoration); | 1410 list->append(decoration); |
| 1409 } | 1411 } |
| 1410 | 1412 |
| 1411 void ComputedStyle::applyTextDecorations() | 1413 void ComputedStyle::overrideTextDecorationColors(Color overrideColor) |
| 1412 { | 1414 { |
| 1415 |
| 1416 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie
dTextDecorations; |
| 1417 ASSERT(list); |
| 1418 if (!list->hasOneRef()) |
| 1419 list = list->copy(); |
| 1420 |
| 1421 for (size_t i = 0; i < list->size(); ++i) |
| 1422 list->at(i).setColor(overrideColor); |
| 1423 } |
| 1424 |
| 1425 void ComputedStyle::applyTextDecorations(const Color& parentTextDecorationColor,
bool overrideExistingColors) |
| 1426 { |
| 1427 if (textDecoration() == TextDecorationNone && !inherited_flags.m_hasSimpleUn
derline && !rareInheritedData->appliedTextDecorations) |
| 1428 return; |
| 1429 |
| 1430 // If there are any color changes or decorations set by this element, stop u
sing m_hasSimpleUnderline. |
| 1431 Color currentTextDecorationColor = visitedDependentColor(CSSPropertyTextDeco
rationColor); |
| 1432 if (inherited_flags.m_hasSimpleUnderline && (textDecoration() != TextDecorat
ionNone || currentTextDecorationColor != parentTextDecorationColor)) { |
| 1433 inherited_flags.m_hasSimpleUnderline = false; |
| 1434 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline,
TextDecorationStyleSolid, parentTextDecorationColor)); |
| 1435 } |
| 1436 |
| 1437 if (overrideExistingColors && rareInheritedData->appliedTextDecorations) |
| 1438 overrideTextDecorationColors(currentTextDecorationColor); |
| 1413 if (textDecoration() == TextDecorationNone) | 1439 if (textDecoration() == TextDecorationNone) |
| 1414 return; | 1440 return; |
| 1441 ASSERT(!inherited_flags.m_hasSimpleUnderline); |
| 1415 | 1442 |
| 1416 TextDecorationStyle style = textDecorationStyle(); | 1443 // To save memory, we don't use AppliedTextDecoration objects in the common
case of a single simple underline. |
| 1417 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins
ideVisitedLink); | 1444 TextDecoration decorationLines = textDecoration(); |
| 1445 TextDecorationStyle decorationStyle = textDecorationStyle(); |
| 1446 bool isSimpleUnderline = decorationLines == TextDecorationUnderline && decor
ationStyle == TextDecorationStyleSolid; |
| 1447 if (isSimpleUnderline && !rareInheritedData->appliedTextDecorations) { |
| 1448 inherited_flags.m_hasSimpleUnderline = true; |
| 1449 return; |
| 1450 } |
| 1418 | 1451 |
| 1419 int decorations = textDecoration(); | 1452 addAppliedTextDecoration(AppliedTextDecoration(decorationLines, decorationSt
yle, currentTextDecorationColor)); |
| 1420 | |
| 1421 if (decorations & TextDecorationUnderline) { | |
| 1422 // To save memory, we don't use AppliedTextDecoration objects in the | |
| 1423 // common case of a single simple underline. | |
| 1424 AppliedTextDecoration underline(TextDecorationUnderline, style, styleCol
or); | |
| 1425 | |
| 1426 if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnde
rline()) | |
| 1427 inherited_flags.m_textUnderline = true; | |
| 1428 else | |
| 1429 addAppliedTextDecoration(underline); | |
| 1430 } | |
| 1431 if (decorations & TextDecorationOverline) | |
| 1432 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s
tyle, styleColor)); | |
| 1433 if (decorations & TextDecorationLineThrough) | |
| 1434 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough
, style, styleColor)); | |
| 1435 } | 1453 } |
| 1436 | 1454 |
| 1437 void ComputedStyle::clearAppliedTextDecorations() | 1455 void ComputedStyle::clearAppliedTextDecorations() |
| 1438 { | 1456 { |
| 1439 inherited_flags.m_textUnderline = false; | 1457 inherited_flags.m_hasSimpleUnderline = false; |
| 1440 | 1458 |
| 1441 if (rareInheritedData->appliedTextDecorations) | 1459 if (rareInheritedData->appliedTextDecorations) |
| 1442 rareInheritedData.access()->appliedTextDecorations = nullptr; | 1460 rareInheritedData.access()->appliedTextDecorations = nullptr; |
| 1443 } | 1461 } |
| 1444 | 1462 |
| 1445 void ComputedStyle::clearMultiCol() | 1463 void ComputedStyle::clearMultiCol() |
| 1446 { | 1464 { |
| 1447 rareNonInheritedData.access()->m_multiCol = nullptr; | 1465 rareNonInheritedData.access()->m_multiCol = nullptr; |
| 1448 rareNonInheritedData.access()->m_multiCol.init(); | 1466 rareNonInheritedData.access()->m_multiCol.init(); |
| 1449 } | 1467 } |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 } | 1848 } |
| 1831 | 1849 |
| 1832 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) | 1850 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) |
| 1833 { | 1851 { |
| 1834 setEmptyState(other.emptyState()); | 1852 setEmptyState(other.emptyState()); |
| 1835 if (other.hasExplicitlyInheritedProperties()) | 1853 if (other.hasExplicitlyInheritedProperties()) |
| 1836 setHasExplicitlyInheritedProperties(); | 1854 setHasExplicitlyInheritedProperties(); |
| 1837 } | 1855 } |
| 1838 | 1856 |
| 1839 } // namespace blink | 1857 } // namespace blink |
| OLD | NEW |