| 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.setTextOrColorChanged(); | 747 diff.setTextOrColorChanged(); |
| 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.setTextOrColorChanged(); | 752 diff.setTextOrColorChanged(); |
| 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, Color::transp
arent, true))); |
| 1271 // Since we only have one of these in memory, just update the color befo
re returning. |
| 1272 underline.at(0).applyPropagatedColor(visitedDependentSimpleUnderlineColo
r()); |
| 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::updateAppliedTextDecoration(size_t index, Color newColor) |
| 1382 { | 1384 { |
| 1383 if (textDecoration() == TextDecorationNone) | 1385 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie
dTextDecorations; |
| 1386 |
| 1387 if (!list) |
| 1388 list = AppliedTextDecorationList::create(); |
| 1389 else if (!list->hasOneRef()) |
| 1390 list = list->copy(); |
| 1391 |
| 1392 list->at(index).applyPropagatedColor(newColor); |
| 1393 } |
| 1394 |
| 1395 void ComputedStyle::applyTextDecorations(bool overrideExistingColors) |
| 1396 { |
| 1397 if (textDecoration() == TextDecorationNone && !inherited_flags.m_hasSimpleUn
derline && !rareInheritedData->appliedTextDecorations) |
| 1384 return; | 1398 return; |
| 1385 | 1399 |
| 1386 TextDecorationStyle style = textDecorationStyle(); | 1400 // If we have a propagated color, update any other affected decorations. |
| 1387 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins
ideVisitedLink); | 1401 if (overrideExistingColors && inherited_flags.m_hasSimpleUnderline) { |
| 1402 setSimpleUnderlineColor(colorIncludingFallback(CSSPropertyTextDecoration
Color, false)); |
| 1403 setSimpleUnderlineVisitedColor(colorIncludingFallback(CSSPropertyTextDec
orationColor, true)); |
| 1404 } else if (overrideExistingColors && rareInheritedData->appliedTextDecoratio
ns) { |
| 1405 for (size_t i = 0; i < rareInheritedData->appliedTextDecorations->size()
; ++i) { |
| 1406 AppliedTextDecoration& decoration = rareInheritedData->appliedTextDe
corations->at(i); |
| 1407 if (decoration.isAffectedByPropagatedColors()) |
| 1408 updateAppliedTextDecoration(i, visitedDependentColor(CSSProperty
TextDecorationColor)); |
| 1409 } |
| 1410 } |
| 1388 | 1411 |
| 1389 int decorations = textDecoration(); | 1412 TextDecoration decorationLines = textDecoration(); |
| 1413 TextDecorationStyle decorationStyle = textDecorationStyle(); |
| 1414 StyleColor decorationColor = decorationColorIncludingFallback(insideLink() =
= InsideVisitedLink); |
| 1390 | 1415 |
| 1391 if (decorations & TextDecorationUnderline) { | 1416 // To save memory, we don't use AppliedTextDecoration objects in the common
case of a single simple underline. |
| 1392 // To save memory, we don't use AppliedTextDecoration objects in the | 1417 if (!rareInheritedData->appliedTextDecorations && !inherited_flags.m_hasSimp
leUnderline |
| 1393 // common case of a single simple underline. | 1418 && decorationLines == TextDecorationUnderline && decorationStyle == Text
DecorationStyleSolid && decorationColor.isCurrentColor()) { |
| 1394 AppliedTextDecoration underline(TextDecorationUnderline, style, styleCol
or); | 1419 inherited_flags.m_hasSimpleUnderline = true; |
| 1420 setSimpleUnderlineColor(colorIncludingFallback(CSSPropertyTextDecoration
Color, false)); |
| 1421 setSimpleUnderlineVisitedColor(colorIncludingFallback(CSSPropertyTextDec
orationColor, true)); |
| 1422 return; |
| 1423 } |
| 1395 | 1424 |
| 1396 if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnde
rline()) | 1425 // Clear the existing optimization if we have it. |
| 1397 inherited_flags.m_textUnderline = true; | 1426 if (inherited_flags.m_hasSimpleUnderline) { |
| 1398 else | 1427 inherited_flags.m_hasSimpleUnderline = false; |
| 1399 addAppliedTextDecoration(underline); | 1428 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline,
TextDecorationStyleSolid, visitedDependentSimpleUnderlineColor(), true)); |
| 1400 } | 1429 } |
| 1401 if (decorations & TextDecorationOverline) | 1430 |
| 1402 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s
tyle, styleColor)); | 1431 Color currentTextDecorationColor = visitedDependentColor(CSSPropertyTextDeco
rationColor); |
| 1403 if (decorations & TextDecorationLineThrough) | 1432 addAppliedTextDecoration(AppliedTextDecoration(decorationLines, decorationSt
yle, decorationColor.resolve(currentTextDecorationColor), decorationColor.isCurr
entColor())); |
| 1404 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough
, style, styleColor)); | |
| 1405 } | 1433 } |
| 1406 | 1434 |
| 1407 void ComputedStyle::clearAppliedTextDecorations() | 1435 void ComputedStyle::clearAppliedTextDecorations() |
| 1408 { | 1436 { |
| 1409 inherited_flags.m_textUnderline = false; | 1437 inherited_flags.m_hasSimpleUnderline = false; |
| 1410 | 1438 |
| 1411 if (rareInheritedData->appliedTextDecorations) | 1439 if (rareInheritedData->appliedTextDecorations) |
| 1412 rareInheritedData.access()->appliedTextDecorations = nullptr; | 1440 rareInheritedData.access()->appliedTextDecorations = nullptr; |
| 1413 } | 1441 } |
| 1414 | 1442 |
| 1415 void ComputedStyle::clearMultiCol() | 1443 void ComputedStyle::clearMultiCol() |
| 1416 { | 1444 { |
| 1417 rareNonInheritedData.access()->m_multiCol = nullptr; | 1445 rareNonInheritedData.access()->m_multiCol = nullptr; |
| 1418 rareNonInheritedData.access()->m_multiCol.init(); | 1446 rareNonInheritedData.access()->m_multiCol.init(); |
| 1419 } | 1447 } |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 } | 1826 } |
| 1799 | 1827 |
| 1800 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) | 1828 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) |
| 1801 { | 1829 { |
| 1802 setEmptyState(other.emptyState()); | 1830 setEmptyState(other.emptyState()); |
| 1803 if (other.hasExplicitlyInheritedProperties()) | 1831 if (other.hasExplicitlyInheritedProperties()) |
| 1804 setHasExplicitlyInheritedProperties(); | 1832 setHasExplicitlyInheritedProperties(); |
| 1805 } | 1833 } |
| 1806 | 1834 |
| 1807 } // namespace blink | 1835 } // namespace blink |
| OLD | NEW |