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/AppliedTextDecoration.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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity
) | 695 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity
) |
695 changedContextSensitiveProperties |= ContextSensitivePropertyOpacity
; | 696 changedContextSensitiveProperties |= ContextSensitivePropertyOpacity
; |
696 | 697 |
697 if (rareNonInheritedData->m_filter.get() != other.rareNonInheritedData->
m_filter.get() | 698 if (rareNonInheritedData->m_filter.get() != other.rareNonInheritedData->
m_filter.get() |
698 && *rareNonInheritedData->m_filter.get() != *other.rareNonInheritedD
ata->m_filter.get()) | 699 && *rareNonInheritedData->m_filter.get() != *other.rareNonInheritedD
ata->m_filter.get()) |
699 changedContextSensitiveProperties |= ContextSensitivePropertyFilter; | 700 changedContextSensitiveProperties |= ContextSensitivePropertyFilter; |
700 } | 701 } |
701 | 702 |
702 if (!diff.needsRepaint()) { | 703 if (!diff.needsRepaint()) { |
703 if (inherited->color != other.inherited->color | 704 if (inherited->color != other.inherited->color |
704 || inherited_flags._text_decorations != other.inherited_flags._text_
decorations | 705 || inherited_flags.m_textUnderline != other.inherited_flags.m_textUn
derline |
705 || visual->textDecoration != other.visual->textDecoration | 706 || visual->textDecoration != other.visual->textDecoration |
706 || rareNonInheritedData->m_textDecorationStyle != other.rareNonInher
itedData->m_textDecorationStyle | 707 || rareNonInheritedData->m_textDecorationStyle != other.rareNonInher
itedData->m_textDecorationStyle |
707 || rareNonInheritedData->m_textDecorationColor != other.rareNonInher
itedData->m_textDecorationColor | 708 || rareNonInheritedData->m_textDecorationColor != other.rareNonInher
itedData->m_textDecorationColor |
708 || rareInheritedData->textFillColor() != other.rareInheritedData->te
xtFillColor() | 709 || rareInheritedData->textFillColor() != other.rareInheritedData->te
xtFillColor() |
709 || rareInheritedData->textStrokeColor() != other.rareInheritedData->
textStrokeColor() | 710 || rareInheritedData->textStrokeColor() != other.rareInheritedData->
textStrokeColor() |
710 || rareInheritedData->textEmphasisColor() != other.rareInheritedData
->textEmphasisColor() | 711 || rareInheritedData->textEmphasisColor() != other.rareInheritedData
->textEmphasisColor() |
711 || rareInheritedData->textEmphasisFill != other.rareInheritedData->t
extEmphasisFill) | 712 || rareInheritedData->textEmphasisFill != other.rareInheritedData->t
extEmphasisFill |
| 713 || rareInheritedData->appliedTextDecorations != other.rareInheritedD
ata->appliedTextDecorations) |
712 changedContextSensitiveProperties |= ContextSensitivePropertyTextOrC
olor; | 714 changedContextSensitiveProperties |= ContextSensitivePropertyTextOrC
olor; |
713 } | 715 } |
714 | 716 |
715 return changedContextSensitiveProperties; | 717 return changedContextSensitiveProperties; |
716 } | 718 } |
717 | 719 |
718 void RenderStyle::setClip(Length top, Length right, Length bottom, Length left) | 720 void RenderStyle::setClip(Length top, Length right, Length bottom, Length left) |
719 { | 721 { |
720 StyleVisualData* data = visual.access(); | 722 StyleVisualData* data = visual.access(); |
721 data->clip.m_top = top; | 723 data->clip.m_top = top; |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1209 } |
1208 | 1210 |
1209 const Font& RenderStyle::font() const { return inherited->font; } | 1211 const Font& RenderStyle::font() const { return inherited->font; } |
1210 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fon
tMetrics(); } | 1212 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fon
tMetrics(); } |
1211 const FontDescription& RenderStyle::fontDescription() const { return inherited->
font.fontDescription(); } | 1213 const FontDescription& RenderStyle::fontDescription() const { return inherited->
font.fontDescription(); } |
1212 float RenderStyle::specifiedFontSize() const { return fontDescription().specifie
dSize(); } | 1214 float RenderStyle::specifiedFontSize() const { return fontDescription().specifie
dSize(); } |
1213 float RenderStyle::computedFontSize() const { return fontDescription().computedS
ize(); } | 1215 float RenderStyle::computedFontSize() const { return fontDescription().computedS
ize(); } |
1214 int RenderStyle::fontSize() const { return fontDescription().computedPixelSize()
; } | 1216 int RenderStyle::fontSize() const { return fontDescription().computedPixelSize()
; } |
1215 FontWeight RenderStyle::fontWeight() const { return fontDescription().weight();
} | 1217 FontWeight RenderStyle::fontWeight() const { return fontDescription().weight();
} |
1216 | 1218 |
| 1219 TextDecoration RenderStyle::textDecorationsInEffect() const |
| 1220 { |
| 1221 int decorations = 0; |
| 1222 |
| 1223 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); |
| 1224 |
| 1225 for (size_t i = 0; i < applied.size(); ++i) |
| 1226 decorations |= applied[i].line(); |
| 1227 |
| 1228 return static_cast<TextDecoration>(decorations); |
| 1229 } |
| 1230 |
| 1231 const Vector<AppliedTextDecoration>& RenderStyle::appliedTextDecorations() const |
| 1232 { |
| 1233 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); |
| 1234 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, AppliedTex
tDecoration(TextDecorationUnderline))); |
| 1235 |
| 1236 if (!inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecor
ations) |
| 1237 return empty; |
| 1238 if (inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecora
tions) |
| 1239 return underline; |
| 1240 |
| 1241 return rareInheritedData->appliedTextDecorations->vector(); |
| 1242 } |
| 1243 |
1217 float RenderStyle::wordSpacing() const { return fontDescription().wordSpacing();
} | 1244 float RenderStyle::wordSpacing() const { return fontDescription().wordSpacing();
} |
1218 float RenderStyle::letterSpacing() const { return fontDescription().letterSpacin
g(); } | 1245 float RenderStyle::letterSpacing() const { return fontDescription().letterSpacin
g(); } |
1219 | 1246 |
1220 bool RenderStyle::setFontDescription(const FontDescription& v) | 1247 bool RenderStyle::setFontDescription(const FontDescription& v) |
1221 { | 1248 { |
1222 if (inherited->font.fontDescription() != v) { | 1249 if (inherited->font.fontDescription() != v) { |
1223 inherited.access()->font = Font(v); | 1250 inherited.access()->font = Font(v); |
1224 return true; | 1251 return true; |
1225 } | 1252 } |
1226 return false; | 1253 return false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 | 1329 |
1303 void RenderStyle::setFontWeight(FontWeight weight) | 1330 void RenderStyle::setFontWeight(FontWeight weight) |
1304 { | 1331 { |
1305 FontSelector* currentFontSelector = font().fontSelector(); | 1332 FontSelector* currentFontSelector = font().fontSelector(); |
1306 FontDescription desc(fontDescription()); | 1333 FontDescription desc(fontDescription()); |
1307 desc.setWeight(weight); | 1334 desc.setWeight(weight); |
1308 setFontDescription(desc); | 1335 setFontDescription(desc); |
1309 font().update(currentFontSelector); | 1336 font().update(currentFontSelector); |
1310 } | 1337 } |
1311 | 1338 |
| 1339 void RenderStyle::setTextDecorationsInEffect(TextDecoration decorations) |
| 1340 { |
| 1341 clearAppliedTextDecorations(); |
| 1342 |
| 1343 if (decorations & TextDecorationUnderline) |
| 1344 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline))
; |
| 1345 if (decorations & TextDecorationOverline) |
| 1346 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline)); |
| 1347 if (decorations & TextDecorationLineThrough) |
| 1348 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough
)); |
| 1349 } |
| 1350 |
| 1351 void RenderStyle::addAppliedTextDecoration(const AppliedTextDecoration& decorati
on) |
| 1352 { |
| 1353 bool isSimpleUnderline = decoration.isSimple() && decoration.line() == TextD
ecorationUnderline; |
| 1354 |
| 1355 if (!rareInheritedData->appliedTextDecorations && isSimpleUnderline) { |
| 1356 // To save memory, we don't use AppliedTextDecoration objects in the |
| 1357 // common case of a single solid underline with the current color. Inste
ad, |
| 1358 // we set a bit to indicate that a solid underline must be drawn with th
e |
| 1359 // current color. |
| 1360 inherited_flags.m_textUnderline = true; |
| 1361 return; |
| 1362 } |
| 1363 |
| 1364 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie
dTextDecorations; |
| 1365 |
| 1366 if (!list) |
| 1367 list = AppliedTextDecorationList::create(); |
| 1368 else if (!list->hasOneRef()) |
| 1369 list = list->copy(); |
| 1370 |
| 1371 if (inherited_flags.m_textUnderline) { |
| 1372 inherited_flags.m_textUnderline = false; |
| 1373 list->append(AppliedTextDecoration(TextDecorationUnderline, TextDecorati
onStyleSolid, StyleColor::currentColor())); |
| 1374 } |
| 1375 |
| 1376 list->append(decoration); |
| 1377 } |
| 1378 |
| 1379 void RenderStyle::applyTextDecorations() |
| 1380 { |
| 1381 if (textDecoration() == TextDecorationNone) |
| 1382 return; |
| 1383 |
| 1384 TextDecorationStyle style = textDecorationStyle(); |
| 1385 StyleColor styleColor = visitedDependentDecorationStyleColor(); |
| 1386 |
| 1387 int decorations = textDecoration(); |
| 1388 |
| 1389 if (decorations & TextDecorationUnderline) |
| 1390 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderline,
style, styleColor)); |
| 1391 if (decorations & TextDecorationOverline) |
| 1392 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s
tyle, styleColor)); |
| 1393 if (decorations & TextDecorationLineThrough) |
| 1394 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough
, style, styleColor)); |
| 1395 } |
| 1396 |
| 1397 void RenderStyle::clearAppliedTextDecorations() |
| 1398 { |
| 1399 inherited_flags.m_textUnderline = false; |
| 1400 |
| 1401 if (rareInheritedData->appliedTextDecorations) |
| 1402 rareInheritedData.access()->appliedTextDecorations = nullptr; |
| 1403 } |
| 1404 |
1312 void RenderStyle::getShadowExtent(const ShadowList* shadowList, LayoutUnit &top,
LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const | 1405 void RenderStyle::getShadowExtent(const ShadowList* shadowList, LayoutUnit &top,
LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const |
1313 { | 1406 { |
1314 top = 0; | 1407 top = 0; |
1315 right = 0; | 1408 right = 0; |
1316 bottom = 0; | 1409 bottom = 0; |
1317 left = 0; | 1410 left = 0; |
1318 | 1411 |
1319 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1412 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
1320 for (size_t i = 0; i < shadowCount; ++i) { | 1413 for (size_t i = 0; i < shadowCount; ++i) { |
1321 const ShadowData& shadow = shadowList->shadows()[i]; | 1414 const ShadowData& shadow = shadowList->shadows()[i]; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 const ShadowData& shadow = shadowList->shadows()[i]; | 1472 const ShadowData& shadow = shadowList->shadows()[i]; |
1380 if (shadow.style() == Inset) | 1473 if (shadow.style() == Inset) |
1381 continue; | 1474 continue; |
1382 float blurAndSpread = shadow.blur() + shadow.spread(); | 1475 float blurAndSpread = shadow.blur() + shadow.spread(); |
1383 | 1476 |
1384 top = min<LayoutUnit>(top, shadow.y() - blurAndSpread); | 1477 top = min<LayoutUnit>(top, shadow.y() - blurAndSpread); |
1385 bottom = max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); | 1478 bottom = max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); |
1386 } | 1479 } |
1387 } | 1480 } |
1388 | 1481 |
1389 StyleColor RenderStyle::visitedDependentDecorationColor() const | 1482 StyleColor RenderStyle::visitedDependentDecorationStyleColor() const |
1390 { | 1483 { |
1391 // Text decoration color fallback is handled in RenderObject::decorationColo
r. | 1484 bool visitedLink = insideLink() == InsideVisitedLink; |
1392 return insideLink() == InsideVisitedLink ? visitedLinkTextDecorationColor()
: textDecorationColor(); | 1485 |
| 1486 StyleColor styleColor = visitedLink ? visitedLinkTextDecorationColor() : tex
tDecorationColor(); |
| 1487 |
| 1488 if (!styleColor.isCurrentColor()) |
| 1489 return styleColor; |
| 1490 |
| 1491 if (textStrokeWidth()) { |
| 1492 // Prefer stroke color if possible but not if it's fully transparent. |
| 1493 StyleColor textStrokeStyleColor = visitedLink ? visitedLinkTextStrokeCol
or() : textStrokeColor(); |
| 1494 if (!textStrokeStyleColor.isCurrentColor() && textStrokeStyleColor.color
().alpha()) |
| 1495 return textStrokeStyleColor; |
| 1496 } |
| 1497 |
| 1498 return visitedLink ? visitedLinkTextFillColor() : textFillColor(); |
| 1499 } |
| 1500 |
| 1501 Color RenderStyle::visitedDependentDecorationColor() const |
| 1502 { |
| 1503 bool visitedLink = insideLink() == InsideVisitedLink; |
| 1504 return visitedDependentDecorationStyleColor().resolve(visitedLink ? visitedL
inkColor() : color()); |
1393 } | 1505 } |
1394 | 1506 |
1395 Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) c
onst | 1507 Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) c
onst |
1396 { | 1508 { |
1397 StyleColor result(StyleColor::currentColor()); | 1509 StyleColor result(StyleColor::currentColor()); |
1398 EBorderStyle borderStyle = BNONE; | 1510 EBorderStyle borderStyle = BNONE; |
1399 switch (colorProperty) { | 1511 switch (colorProperty) { |
1400 case CSSPropertyBackgroundColor: | 1512 case CSSPropertyBackgroundColor: |
1401 result = visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); | 1513 result = visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); |
1402 break; | 1514 break; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 // right | 1794 // right |
1683 radiiSum = radii.topRight().height() + radii.bottomRight().height(); | 1795 radiiSum = radii.topRight().height() + radii.bottomRight().height(); |
1684 if (radiiSum > rect.height()) | 1796 if (radiiSum > rect.height()) |
1685 factor = std::min(rect.height() / radiiSum, factor); | 1797 factor = std::min(rect.height() / radiiSum, factor); |
1686 | 1798 |
1687 ASSERT(factor <= 1); | 1799 ASSERT(factor <= 1); |
1688 return factor; | 1800 return factor; |
1689 } | 1801 } |
1690 | 1802 |
1691 } // namespace WebCore | 1803 } // namespace WebCore |
OLD | NEW |