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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity ) | 730 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity ) |
| 731 diff.setOpacityChanged(); | 731 diff.setOpacityChanged(); |
| 732 | 732 |
| 733 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er) | 733 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er) |
| 734 diff.setFilterChanged(); | 734 diff.setFilterChanged(); |
| 735 } | 735 } |
| 736 | 736 |
| 737 if (!diff.needsPaintInvalidation()) { | 737 if (!diff.needsPaintInvalidation()) { |
| 738 if (inherited->color != other.inherited->color | 738 if (inherited->color != other.inherited->color |
| 739 || inherited->visitedLinkColor != other.inherited->visitedLinkColor | 739 || inherited->visitedLinkColor != other.inherited->visitedLinkColor |
| 740 || inherited_flags.m_textUnderline != other.inherited_flags.m_textUn derline | |
| 741 || visual->textDecoration != other.visual->textDecoration) { | 740 || visual->textDecoration != other.visual->textDecoration) { |
| 742 diff.setTextOrColorChanged(); | 741 diff.setTextOrColorChanged(); |
| 743 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( ) | 742 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( ) |
| 744 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle | 743 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle |
| 745 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor | 744 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor |
| 746 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) { | 745 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) { |
| 747 diff.setTextOrColorChanged(); | 746 diff.setTextOrColorChanged(); |
| 748 } else if (rareInheritedData.get() != other.rareInheritedData.get() | 747 } else if (rareInheritedData.get() != other.rareInheritedData.get() |
| 749 && (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor() | 748 && (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor() |
| 750 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor() | 749 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor() |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1207 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); | 1206 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); |
| 1208 | 1207 |
| 1209 for (size_t i = 0; i < applied.size(); ++i) | 1208 for (size_t i = 0; i < applied.size(); ++i) |
| 1210 decorations |= applied[i].line(); | 1209 decorations |= applied[i].line(); |
| 1211 | 1210 |
| 1212 return static_cast<TextDecoration>(decorations); | 1211 return static_cast<TextDecoration>(decorations); |
| 1213 } | 1212 } |
| 1214 | 1213 |
| 1215 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con st | 1214 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con st |
| 1216 { | 1215 { |
| 1217 if (!inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecor ations) { | 1216 if (!isSimpleUnderlineDecoration() && !rareInheritedData->appliedTextDecorat ions) { |
| 1218 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); | 1217 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); |
| 1219 return empty; | 1218 return empty; |
| 1220 } | 1219 } |
| 1221 if (inherited_flags.m_textUnderline) { | 1220 if (isSimpleUnderlineDecoration()) { |
| 1222 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline))); | 1221 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline))); |
| 1223 return underline; | 1222 return underline; |
| 1224 } | 1223 } |
| 1225 | 1224 |
| 1226 return rareInheritedData->appliedTextDecorations->vector(); | 1225 return rareInheritedData->appliedTextDecorations->vector(); |
| 1227 } | 1226 } |
| 1228 | 1227 |
| 1229 float ComputedStyle::wordSpacing() const { return fontDescription().wordSpacing( ); } | 1228 float ComputedStyle::wordSpacing() const { return fontDescription().wordSpacing( ); } |
| 1230 float ComputedStyle::letterSpacing() const { return fontDescription().letterSpac ing(); } | 1229 float ComputedStyle::letterSpacing() const { return fontDescription().letterSpac ing(); } |
| 1231 | 1230 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1315 | 1314 |
| 1316 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion) | 1315 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion) |
| 1317 { | 1316 { |
| 1318 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; | 1317 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; |
| 1319 | 1318 |
| 1320 if (!list) | 1319 if (!list) |
| 1321 list = AppliedTextDecorationList::create(); | 1320 list = AppliedTextDecorationList::create(); |
| 1322 else if (!list->hasOneRef()) | 1321 else if (!list->hasOneRef()) |
| 1323 list = list->copy(); | 1322 list = list->copy(); |
| 1324 | 1323 |
| 1325 if (inherited_flags.m_textUnderline) { | 1324 if (isSimpleUnderlineDecoration()) { |
| 1326 inherited_flags.m_textUnderline = false; | |
| 1327 list->append(AppliedTextDecoration(TextDecorationUnderline)); | 1325 list->append(AppliedTextDecoration(TextDecorationUnderline)); |
| 1328 } | 1326 } |
| 1329 | 1327 |
| 1330 list->append(decoration); | 1328 list->append(decoration); |
| 1331 } | 1329 } |
| 1332 | 1330 |
| 1333 void ComputedStyle::applyTextDecorations() | 1331 void ComputedStyle::applyTextDecorations(const ComputedStyle& parentStyle) |
| 1334 { | 1332 { |
| 1335 if (textDecoration() == TextDecorationNone) | 1333 if (textDecoration() == TextDecorationNone) { |
| 1334 if (hasOutOfFlowPosition() || isFloating()) { | |
|
samahto
2015/05/17 17:12:40
[spec says]: "text decorations are not propagated
wkorman
2015/07/01 15:16:14
Add layout tests to validate this works as expecte
| |
| 1335 clearAppliedTextDecorations(); | |
| 1336 return; | |
| 1337 } | |
| 1338 if ((parentStyle.isSimpleUnderlineDecoration())) { | |
| 1339 TextDecorationStyle style = parentStyle.textDecorationStyle(); | |
| 1340 Color color = parentStyle.visitedDependentColor(CSSPropertyTextDecor ationColor); | |
| 1341 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderli ne, style, color)); | |
| 1342 } | |
| 1336 return; | 1343 return; |
| 1344 } | |
| 1337 | 1345 |
| 1338 TextDecorationStyle style = textDecorationStyle(); | 1346 TextDecorationStyle style = textDecorationStyle(); |
| 1339 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins ideVisitedLink); | 1347 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins ideVisitedLink); |
| 1348 Color resolvedColor = styleColor.resolve(color()); | |
| 1340 | 1349 |
| 1341 int decorations = textDecoration(); | 1350 int decorations = textDecoration(); |
| 1342 | 1351 |
| 1343 if (decorations & TextDecorationUnderline) { | 1352 if (decorations & TextDecorationUnderline) { |
| 1344 // To save memory, we don't use AppliedTextDecoration objects in the | 1353 // To save memory, we don't use AppliedTextDecoration objects in the |
| 1345 // common case of a single simple underline. | 1354 // common case of a single simple underline. |
| 1346 AppliedTextDecoration underline(TextDecorationUnderline, style, styleCol or); | 1355 AppliedTextDecoration underline(TextDecorationUnderline, style, resolved Color); |
| 1347 | 1356 if (rareInheritedData->appliedTextDecorations || !styleColor.isCurrentCo lor()) |
| 1348 if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnde rline()) | |
| 1349 inherited_flags.m_textUnderline = true; | |
| 1350 else | |
| 1351 addAppliedTextDecoration(underline); | 1357 addAppliedTextDecoration(underline); |
| 1352 } | 1358 } |
| 1353 if (decorations & TextDecorationOverline) | 1359 if (decorations & TextDecorationOverline) |
| 1354 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s tyle, styleColor)); | 1360 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s tyle, resolvedColor)); |
| 1355 if (decorations & TextDecorationLineThrough) | 1361 if (decorations & TextDecorationLineThrough) |
| 1356 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough , style, styleColor)); | 1362 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough , style, resolvedColor)); |
| 1357 } | 1363 } |
| 1358 | 1364 |
| 1359 void ComputedStyle::clearAppliedTextDecorations() | 1365 void ComputedStyle::clearAppliedTextDecorations() |
| 1360 { | 1366 { |
| 1361 inherited_flags.m_textUnderline = false; | |
| 1362 | |
| 1363 if (rareInheritedData->appliedTextDecorations) | 1367 if (rareInheritedData->appliedTextDecorations) |
| 1364 rareInheritedData.access()->appliedTextDecorations = nullptr; | 1368 rareInheritedData.access()->appliedTextDecorations = nullptr; |
| 1365 } | 1369 } |
| 1366 | 1370 |
| 1367 void ComputedStyle::clearMultiCol() | 1371 void ComputedStyle::clearMultiCol() |
| 1368 { | 1372 { |
| 1369 rareNonInheritedData.access()->m_multiCol = nullptr; | 1373 rareNonInheritedData.access()->m_multiCol = nullptr; |
| 1370 rareNonInheritedData.access()->m_multiCol.init(); | 1374 rareNonInheritedData.access()->m_multiCol.init(); |
| 1371 } | 1375 } |
| 1372 | 1376 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1692 { | 1696 { |
| 1693 if (!hasBorder()) | 1697 if (!hasBorder()) |
| 1694 return false; | 1698 return false; |
| 1695 | 1699 |
| 1696 // Bail if we have any border-image for now. We could look at the image alph a to improve this. | 1700 // Bail if we have any border-image for now. We could look at the image alph a to improve this. |
| 1697 if (borderImage().image()) | 1701 if (borderImage().image()) |
| 1698 return false; | 1702 return false; |
| 1699 | 1703 |
| 1700 BorderEdge edges[4]; | 1704 BorderEdge edges[4]; |
| 1701 getBorderEdgeInfo(edges); | 1705 getBorderEdgeInfo(edges); |
| 1702 | |
| 1703 for (int i = BSTop; i <= BSLeft; ++i) { | 1706 for (int i = BSTop; i <= BSLeft; ++i) { |
| 1704 const BorderEdge& currEdge = edges[i]; | 1707 const BorderEdge& currEdge = edges[i]; |
| 1705 if (!currEdge.obscuresBackground()) | 1708 if (!currEdge.obscuresBackground()) |
| 1706 return false; | 1709 return false; |
| 1707 } | 1710 } |
| 1708 | 1711 |
| 1709 return true; | 1712 return true; |
| 1710 } | 1713 } |
| 1711 | 1714 |
| 1712 void ComputedStyle::getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLef tEdge, bool includeLogicalRightEdge) const | 1715 void ComputedStyle::getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLef tEdge, bool includeLogicalRightEdge) const |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1732 horizontal || includeLogicalRightEdge); | 1735 horizontal || includeLogicalRightEdge); |
| 1733 | 1736 |
| 1734 edges[BSLeft] = BorderEdge(borderLeftWidth(), | 1737 edges[BSLeft] = BorderEdge(borderLeftWidth(), |
| 1735 visitedDependentColor(CSSPropertyBorderLeftColor), | 1738 visitedDependentColor(CSSPropertyBorderLeftColor), |
| 1736 borderLeftStyle(), | 1739 borderLeftStyle(), |
| 1737 borderLeftIsTransparent(), | 1740 borderLeftIsTransparent(), |
| 1738 !horizontal || includeLogicalLeftEdge); | 1741 !horizontal || includeLogicalLeftEdge); |
| 1739 } | 1742 } |
| 1740 | 1743 |
| 1741 } // namespace blink | 1744 } // namespace blink |
| OLD | NEW |