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 10 matching lines...) Expand all Loading... | |
21 */ | 21 */ |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "core/rendering/style/RenderStyle.h" | 24 #include "core/rendering/style/RenderStyle.h" |
25 | 25 |
26 #include <algorithm> | 26 #include <algorithm> |
27 #include "RuntimeEnabledFeatures.h" | 27 #include "RuntimeEnabledFeatures.h" |
28 #include "core/css/resolver/StyleResolver.h" | 28 #include "core/css/resolver/StyleResolver.h" |
29 #include "core/rendering/RenderTheme.h" | 29 #include "core/rendering/RenderTheme.h" |
30 #include "core/rendering/TextAutosizer.h" | 30 #include "core/rendering/TextAutosizer.h" |
31 #include "core/rendering/style/AppliedTextDecorationList.h" | |
31 #include "core/rendering/style/ContentData.h" | 32 #include "core/rendering/style/ContentData.h" |
32 #include "core/rendering/style/CursorList.h" | 33 #include "core/rendering/style/CursorList.h" |
33 #include "core/rendering/style/QuotesData.h" | 34 #include "core/rendering/style/QuotesData.h" |
34 #include "core/rendering/style/ShadowList.h" | 35 #include "core/rendering/style/ShadowList.h" |
35 #include "core/rendering/style/StyleImage.h" | 36 #include "core/rendering/style/StyleImage.h" |
36 #include "core/rendering/style/StyleInheritedData.h" | 37 #include "core/rendering/style/StyleInheritedData.h" |
37 #include "platform/LengthFunctions.h" | 38 #include "platform/LengthFunctions.h" |
38 #include "platform/fonts/Font.h" | 39 #include "platform/fonts/Font.h" |
39 #include "platform/fonts/FontSelector.h" | 40 #include "platform/fonts/FontSelector.h" |
40 #include "platform/geometry/FloatRoundedRect.h" | 41 #include "platform/geometry/FloatRoundedRect.h" |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 || rareNonInheritedData->m_backfaceVisibility != other->rareNonInher itedData->m_backfaceVisibility | 651 || rareNonInheritedData->m_backfaceVisibility != other->rareNonInher itedData->m_backfaceVisibility |
651 || rareNonInheritedData->m_perspective != other->rareNonInheritedDat a->m_perspective | 652 || rareNonInheritedData->m_perspective != other->rareNonInheritedDat a->m_perspective |
652 || rareNonInheritedData->m_perspectiveOriginX != other->rareNonInher itedData->m_perspectiveOriginX | 653 || rareNonInheritedData->m_perspectiveOriginX != other->rareNonInher itedData->m_perspectiveOriginX |
653 || rareNonInheritedData->m_perspectiveOriginY != other->rareNonInher itedData->m_perspectiveOriginY | 654 || rareNonInheritedData->m_perspectiveOriginY != other->rareNonInher itedData->m_perspectiveOriginY |
654 || hasWillChangeCompositingHint() != other->hasWillChangeCompositing Hint() | 655 || hasWillChangeCompositingHint() != other->hasWillChangeCompositing Hint() |
655 || hasWillChangeGpuRasterizationHint() != other->hasWillChangeGpuRas terizationHint()) | 656 || hasWillChangeGpuRasterizationHint() != other->hasWillChangeGpuRas terizationHint()) |
656 return StyleDifferenceRecompositeLayer; | 657 return StyleDifferenceRecompositeLayer; |
657 } | 658 } |
658 | 659 |
659 if (inherited->color != other->inherited->color | 660 if (inherited->color != other->inherited->color |
660 || inherited_flags._text_decorations != other->inherited_flags._text_dec orations | 661 || inherited_flags.m_textUnderline != other->inherited_flags.m_textUnder line |
661 || visual->textDecoration != other->visual->textDecoration | 662 || visual->textDecoration != other->visual->textDecoration |
662 || rareNonInheritedData->m_textDecorationStyle != other->rareNonInherite dData->m_textDecorationStyle | 663 || rareNonInheritedData->m_textDecorationStyle != other->rareNonInherite dData->m_textDecorationStyle |
663 || rareNonInheritedData->m_textDecorationColor != other->rareNonInherite dData->m_textDecorationColor | 664 || rareNonInheritedData->m_textDecorationColor != other->rareNonInherite dData->m_textDecorationColor |
664 || rareInheritedData->textFillColor() != other->rareInheritedData->textF illColor() | 665 || rareInheritedData->textFillColor() != other->rareInheritedData->textF illColor() |
665 || rareInheritedData->textStrokeColor() != other->rareInheritedData->tex tStrokeColor() | 666 || rareInheritedData->textStrokeColor() != other->rareInheritedData->tex tStrokeColor() |
666 || rareInheritedData->textEmphasisColor() != other->rareInheritedData->t extEmphasisColor() | 667 || rareInheritedData->textEmphasisColor() != other->rareInheritedData->t extEmphasisColor() |
667 || rareInheritedData->textEmphasisFill != other->rareInheritedData->text EmphasisFill) | 668 || rareInheritedData->textEmphasisFill != other->rareInheritedData->text EmphasisFill |
669 || rareInheritedData->appliedTextDecorations != other->rareInheritedData ->appliedTextDecorations) | |
668 return StyleDifferenceRepaintIfTextOrColorChange; | 670 return StyleDifferenceRepaintIfTextOrColorChange; |
669 | 671 |
670 // Cursors are not checked, since they will be set appropriately in response to mouse events, | 672 // Cursors are not checked, since they will be set appropriately in response to mouse events, |
671 // so they don't need to cause any repaint or layout. | 673 // so they don't need to cause any repaint or layout. |
672 | 674 |
673 // Animations don't need to be checked either. We always set the new style on the RenderObject, so we will get a chance to fire off | 675 // Animations don't need to be checked either. We always set the new style on the RenderObject, so we will get a chance to fire off |
674 // the resulting transition properly. | 676 // the resulting transition properly. |
675 return StyleDifferenceEqual; | 677 return StyleDifferenceEqual; |
676 } | 678 } |
677 | 679 |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1179 } | 1181 } |
1180 | 1182 |
1181 const Font& RenderStyle::font() const { return inherited->font; } | 1183 const Font& RenderStyle::font() const { return inherited->font; } |
1182 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fon tMetrics(); } | 1184 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fon tMetrics(); } |
1183 const FontDescription& RenderStyle::fontDescription() const { return inherited-> font.fontDescription(); } | 1185 const FontDescription& RenderStyle::fontDescription() const { return inherited-> font.fontDescription(); } |
1184 float RenderStyle::specifiedFontSize() const { return fontDescription().specifie dSize(); } | 1186 float RenderStyle::specifiedFontSize() const { return fontDescription().specifie dSize(); } |
1185 float RenderStyle::computedFontSize() const { return fontDescription().computedS ize(); } | 1187 float RenderStyle::computedFontSize() const { return fontDescription().computedS ize(); } |
1186 int RenderStyle::fontSize() const { return fontDescription().computedPixelSize() ; } | 1188 int RenderStyle::fontSize() const { return fontDescription().computedPixelSize() ; } |
1187 FontWeight RenderStyle::fontWeight() const { return fontDescription().weight(); } | 1189 FontWeight RenderStyle::fontWeight() const { return fontDescription().weight(); } |
1188 | 1190 |
1191 TextDecoration RenderStyle::textDecorationsInEffect() const | |
1192 { | |
1193 int decorations = 0; | |
1194 | |
1195 if (appliedTextUnderline()) | |
1196 decorations |= TextDecorationUnderline; | |
1197 | |
1198 const AppliedTextDecorationList* applied = appliedTextDecorations(); | |
1199 | |
1200 if (applied) | |
1201 for (size_t i = 0; i < applied->size(); ++i) | |
1202 decorations |= applied->at(i).line(); | |
esprehn
2014/03/31 17:41:24
This needs braces, we also prefer early return.
i
| |
1203 | |
1204 return static_cast<TextDecoration>(decorations); | |
1205 } | |
1206 | |
1189 float RenderStyle::wordSpacing() const { return fontDescription().wordSpacing(); } | 1207 float RenderStyle::wordSpacing() const { return fontDescription().wordSpacing(); } |
1190 float RenderStyle::letterSpacing() const { return fontDescription().letterSpacin g(); } | 1208 float RenderStyle::letterSpacing() const { return fontDescription().letterSpacin g(); } |
1191 | 1209 |
1192 bool RenderStyle::setFontDescription(const FontDescription& v) | 1210 bool RenderStyle::setFontDescription(const FontDescription& v) |
1193 { | 1211 { |
1194 if (inherited->font.fontDescription() != v) { | 1212 if (inherited->font.fontDescription() != v) { |
1195 inherited.access()->font = Font(v); | 1213 inherited.access()->font = Font(v); |
1196 return true; | 1214 return true; |
1197 } | 1215 } |
1198 return false; | 1216 return false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1274 | 1292 |
1275 void RenderStyle::setFontWeight(FontWeight weight) | 1293 void RenderStyle::setFontWeight(FontWeight weight) |
1276 { | 1294 { |
1277 FontSelector* currentFontSelector = font().fontSelector(); | 1295 FontSelector* currentFontSelector = font().fontSelector(); |
1278 FontDescription desc(fontDescription()); | 1296 FontDescription desc(fontDescription()); |
1279 desc.setWeight(weight); | 1297 desc.setWeight(weight); |
1280 setFontDescription(desc); | 1298 setFontDescription(desc); |
1281 font().update(currentFontSelector); | 1299 font().update(currentFontSelector); |
1282 } | 1300 } |
1283 | 1301 |
1302 void RenderStyle::setTextDecorationsInEffect(TextDecoration decorations) | |
1303 { | |
1304 clearAppliedTextDecorations(); | |
1305 | |
1306 if (decorations & TextDecorationUnderline) | |
1307 addAppliedTextDecoration(TextDecorationUnderline); | |
1308 if (decorations & TextDecorationOverline) | |
1309 addAppliedTextDecoration(TextDecorationOverline); | |
1310 if (decorations & TextDecorationLineThrough) | |
1311 addAppliedTextDecoration(TextDecorationLineThrough); | |
1312 } | |
1313 | |
1314 void RenderStyle::addAppliedTextDecoration(TextDecoration decoration) | |
1315 { | |
1316 if (!appliedTextDecorations() && decoration == TextDecorationUnderline) { | |
1317 // To save memory, we don't use AppliedTextDecoration objects in the | |
1318 // common case of a single solid underline with the current color. Inste ad, | |
1319 // we set a bit to indicate that an underline must be drawn during paint ing. | |
1320 inherited_flags.m_textUnderline = true; | |
1321 return; | |
1322 } | |
1323 | |
1324 addAppliedTextDecoration(AppliedTextDecoration(decoration, TextDecorationSty leSolid, color())); | |
1325 } | |
1326 | |
1327 void RenderStyle::addAppliedTextDecoration(const AppliedTextDecoration& decorati on) | |
1328 { | |
1329 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; | |
1330 | |
1331 if (!list) | |
1332 list = AppliedTextDecorationList::create(); | |
1333 else if (!list->hasOneRef()) | |
1334 list = list->copy(); | |
1335 | |
1336 list->append(decoration); | |
1337 } | |
1338 | |
1339 void RenderStyle::applyTextDecoration(TextDecoration decoration, TextDecorationS tyle style, const StyleColor& styleColor) | |
1340 { | |
1341 const bool isSimple = style == TextDecorationStyleSolid && styleColor.isCurr entColor(); | |
esprehn
2014/03/31 17:41:24
remove const
| |
1342 | |
1343 if (isSimple) | |
1344 addAppliedTextDecoration(decoration); | |
1345 else | |
1346 addAppliedTextDecoration(AppliedTextDecoration(decoration, style, styleC olor.resolve(color()))); | |
1347 } | |
1348 | |
1349 void RenderStyle::applyTextDecorations() | |
1350 { | |
1351 if (textDecoration() == TextDecorationNone) | |
1352 return; | |
1353 | |
1354 TextDecorationStyle style = textDecorationStyle(); | |
1355 StyleColor styleColor = visitedDependentDecorationStyleColor(); | |
1356 | |
1357 const int decorations = textDecoration(); | |
esprehn
2014/03/31 17:41:24
no const
| |
1358 | |
1359 if (decorations & TextDecorationUnderline) | |
1360 applyTextDecoration(TextDecorationUnderline, style, styleColor); | |
1361 if (decorations & TextDecorationOverline) | |
1362 applyTextDecoration(TextDecorationOverline, style, styleColor); | |
1363 if (decorations & TextDecorationLineThrough) | |
1364 applyTextDecoration(TextDecorationLineThrough, style, styleColor); | |
1365 } | |
1366 | |
1367 void RenderStyle::clearAppliedTextDecorations() | |
1368 { | |
1369 inherited_flags.m_textUnderline = false; | |
1370 | |
1371 if (rareInheritedData->appliedTextDecorations) | |
1372 rareInheritedData.access()->appliedTextDecorations = nullptr; | |
1373 } | |
1374 | |
1284 void RenderStyle::getShadowExtent(const ShadowList* shadowList, LayoutUnit &top, LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const | 1375 void RenderStyle::getShadowExtent(const ShadowList* shadowList, LayoutUnit &top, LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const |
1285 { | 1376 { |
1286 top = 0; | 1377 top = 0; |
1287 right = 0; | 1378 right = 0; |
1288 bottom = 0; | 1379 bottom = 0; |
1289 left = 0; | 1380 left = 0; |
1290 | 1381 |
1291 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1382 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
1292 for (size_t i = 0; i < shadowCount; ++i) { | 1383 for (size_t i = 0; i < shadowCount; ++i) { |
1293 const ShadowData& shadow = shadowList->shadows()[i]; | 1384 const ShadowData& shadow = shadowList->shadows()[i]; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 const ShadowData& shadow = shadowList->shadows()[i]; | 1442 const ShadowData& shadow = shadowList->shadows()[i]; |
1352 if (shadow.style() == Inset) | 1443 if (shadow.style() == Inset) |
1353 continue; | 1444 continue; |
1354 float blurAndSpread = shadow.blur() + shadow.spread(); | 1445 float blurAndSpread = shadow.blur() + shadow.spread(); |
1355 | 1446 |
1356 top = min<LayoutUnit>(top, shadow.y() - blurAndSpread); | 1447 top = min<LayoutUnit>(top, shadow.y() - blurAndSpread); |
1357 bottom = max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); | 1448 bottom = max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); |
1358 } | 1449 } |
1359 } | 1450 } |
1360 | 1451 |
1361 StyleColor RenderStyle::visitedDependentDecorationColor() const | 1452 StyleColor RenderStyle::visitedDependentDecorationStyleColor() const |
1362 { | 1453 { |
1363 // Text decoration color fallback is handled in RenderObject::decorationColo r. | 1454 const bool visitedLink = insideLink() == InsideVisitedLink; |
esprehn
2014/03/31 17:41:24
ditto
| |
1364 return insideLink() == InsideVisitedLink ? visitedLinkTextDecorationColor() : textDecorationColor(); | 1455 |
1456 StyleColor styleColor = visitedLink ? visitedLinkTextDecorationColor() : tex tDecorationColor(); | |
1457 | |
1458 if (!styleColor.isCurrentColor()) | |
1459 return styleColor; | |
1460 | |
1461 if (textStrokeWidth() > 0) { | |
esprehn
2014/03/31 17:41:24
Remove > 0, can this be negative?
| |
1462 // Prefer stroke color if possible but not if it's fully transparent. | |
1463 StyleColor textStrokeStyleColor = visitedLink ? visitedLinkTextStrokeCol or() : textStrokeColor(); | |
1464 if (!textStrokeStyleColor.isCurrentColor() && textStrokeStyleColor.color ().alpha()) | |
1465 return textStrokeStyleColor; | |
1466 } | |
1467 | |
1468 return visitedLink ? visitedLinkTextFillColor() : textFillColor(); | |
1469 } | |
1470 | |
1471 Color RenderStyle::visitedDependentDecorationColor() const | |
1472 { | |
1473 const bool visitedLink = insideLink() == InsideVisitedLink; | |
1474 return visitedDependentDecorationStyleColor().resolve(visitedLink ? visitedL inkColor() : color()); | |
1365 } | 1475 } |
1366 | 1476 |
1367 Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) c onst | 1477 Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) c onst |
1368 { | 1478 { |
1369 StyleColor result(StyleColor::currentColor()); | 1479 StyleColor result(StyleColor::currentColor()); |
1370 EBorderStyle borderStyle = BNONE; | 1480 EBorderStyle borderStyle = BNONE; |
1371 switch (colorProperty) { | 1481 switch (colorProperty) { |
1372 case CSSPropertyBackgroundColor: | 1482 case CSSPropertyBackgroundColor: |
1373 result = visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); | 1483 result = visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); |
1374 break; | 1484 break; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1654 // right | 1764 // right |
1655 radiiSum = radii.topRight().height() + radii.bottomRight().height(); | 1765 radiiSum = radii.topRight().height() + radii.bottomRight().height(); |
1656 if (radiiSum > rect.height()) | 1766 if (radiiSum > rect.height()) |
1657 factor = std::min(rect.height() / radiiSum, factor); | 1767 factor = std::min(rect.height() / radiiSum, factor); |
1658 | 1768 |
1659 ASSERT(factor <= 1); | 1769 ASSERT(factor <= 1); |
1660 return factor; | 1770 return factor; |
1661 } | 1771 } |
1662 | 1772 |
1663 } // namespace WebCore | 1773 } // namespace WebCore |
OLD | NEW |