Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: Source/core/rendering/style/RenderStyle.cpp

Issue 272443002: Store and propagate a list of applied text decorations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Undo NeedsRebaseline. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 682
682 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity ) 683 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity )
683 changedContextSensitiveProperties |= ContextSensitivePropertyOpacity ; 684 changedContextSensitiveProperties |= ContextSensitivePropertyOpacity ;
684 685
685 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er) 686 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er)
686 changedContextSensitiveProperties |= ContextSensitivePropertyFilter; 687 changedContextSensitiveProperties |= ContextSensitivePropertyFilter;
687 } 688 }
688 689
689 if (!diff.needsRepaint()) { 690 if (!diff.needsRepaint()) {
690 if (inherited->color != other.inherited->color 691 if (inherited->color != other.inherited->color
691 || inherited_flags._text_decorations != other.inherited_flags._text_ decorations 692 || inherited_flags.m_textUnderline != other.inherited_flags.m_textUn derline
692 || visual->textDecoration != other.visual->textDecoration) { 693 || visual->textDecoration != other.visual->textDecoration) {
693 changedContextSensitiveProperties |= ContextSensitivePropertyTextOrC olor; 694 changedContextSensitiveProperties |= ContextSensitivePropertyTextOrC olor;
694 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( )) { 695 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( )) {
695 if (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle 696 if (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle
696 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor) 697 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor)
697 changedContextSensitiveProperties |= ContextSensitivePropertyTex tOrColor; 698 changedContextSensitiveProperties |= ContextSensitivePropertyTex tOrColor;
698 } else if (rareInheritedData.get() != other.rareInheritedData.get()) { 699 } else if (rareInheritedData.get() != other.rareInheritedData.get()) {
699 if (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor() 700 if (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor()
700 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor() 701 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor()
701 || rareInheritedData->textEmphasisColor() != other.rareInherited Data->textEmphasisColor() 702 || rareInheritedData->textEmphasisColor() != other.rareInherited Data->textEmphasisColor()
702 || rareInheritedData->textEmphasisFill != other.rareInheritedDat a->textEmphasisFill) 703 || rareInheritedData->textEmphasisFill != other.rareInheritedDat a->textEmphasisFill
704 || rareInheritedData->appliedTextDecorations != other.rareInheri tedData->appliedTextDecorations)
703 changedContextSensitiveProperties |= ContextSensitivePropertyTex tOrColor; 705 changedContextSensitiveProperties |= ContextSensitivePropertyTex tOrColor;
704 } 706 }
705 } 707 }
706 708
707 return changedContextSensitiveProperties; 709 return changedContextSensitiveProperties;
708 } 710 }
709 711
710 void RenderStyle::setClip(Length top, Length right, Length bottom, Length left) 712 void RenderStyle::setClip(Length top, Length right, Length bottom, Length left)
711 { 713 {
712 StyleVisualData* data = visual.access(); 714 StyleVisualData* data = visual.access();
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1199 }
1198 1200
1199 const Font& RenderStyle::font() const { return inherited->font; } 1201 const Font& RenderStyle::font() const { return inherited->font; }
1200 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fon tMetrics(); } 1202 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fon tMetrics(); }
1201 const FontDescription& RenderStyle::fontDescription() const { return inherited-> font.fontDescription(); } 1203 const FontDescription& RenderStyle::fontDescription() const { return inherited-> font.fontDescription(); }
1202 float RenderStyle::specifiedFontSize() const { return fontDescription().specifie dSize(); } 1204 float RenderStyle::specifiedFontSize() const { return fontDescription().specifie dSize(); }
1203 float RenderStyle::computedFontSize() const { return fontDescription().computedS ize(); } 1205 float RenderStyle::computedFontSize() const { return fontDescription().computedS ize(); }
1204 int RenderStyle::fontSize() const { return fontDescription().computedPixelSize() ; } 1206 int RenderStyle::fontSize() const { return fontDescription().computedPixelSize() ; }
1205 FontWeight RenderStyle::fontWeight() const { return fontDescription().weight(); } 1207 FontWeight RenderStyle::fontWeight() const { return fontDescription().weight(); }
1206 1208
1209 TextDecoration RenderStyle::textDecorationsInEffect() const
1210 {
1211 int decorations = 0;
1212
1213 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations();
1214
1215 for (size_t i = 0; i < applied.size(); ++i)
1216 decorations |= applied[i].line();
1217
1218 return static_cast<TextDecoration>(decorations);
1219 }
1220
1221 const Vector<AppliedTextDecoration>& RenderStyle::appliedTextDecorations() const
1222 {
1223 if (!inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecor ations) {
1224 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ());
1225 return empty;
1226 }
1227 if (inherited_flags.m_textUnderline) {
1228 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline)));
1229 return underline;
1230 }
1231
1232 return rareInheritedData->appliedTextDecorations->vector();
1233 }
1234
1207 float RenderStyle::wordSpacing() const { return fontDescription().wordSpacing(); } 1235 float RenderStyle::wordSpacing() const { return fontDescription().wordSpacing(); }
1208 float RenderStyle::letterSpacing() const { return fontDescription().letterSpacin g(); } 1236 float RenderStyle::letterSpacing() const { return fontDescription().letterSpacin g(); }
1209 1237
1210 bool RenderStyle::setFontDescription(const FontDescription& v) 1238 bool RenderStyle::setFontDescription(const FontDescription& v)
1211 { 1239 {
1212 if (inherited->font.fontDescription() != v) { 1240 if (inherited->font.fontDescription() != v) {
1213 inherited.access()->font = Font(v); 1241 inherited.access()->font = Font(v);
1214 return true; 1242 return true;
1215 } 1243 }
1216 return false; 1244 return false;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1320
1293 void RenderStyle::setFontWeight(FontWeight weight) 1321 void RenderStyle::setFontWeight(FontWeight weight)
1294 { 1322 {
1295 FontSelector* currentFontSelector = font().fontSelector(); 1323 FontSelector* currentFontSelector = font().fontSelector();
1296 FontDescription desc(fontDescription()); 1324 FontDescription desc(fontDescription());
1297 desc.setWeight(weight); 1325 desc.setWeight(weight);
1298 setFontDescription(desc); 1326 setFontDescription(desc);
1299 font().update(currentFontSelector); 1327 font().update(currentFontSelector);
1300 } 1328 }
1301 1329
1330 void RenderStyle::addAppliedTextDecoration(const AppliedTextDecoration& decorati on)
1331 {
1332 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations;
1333
1334 if (!list)
1335 list = AppliedTextDecorationList::create();
1336 else if (!list->hasOneRef())
1337 list = list->copy();
1338
1339 if (inherited_flags.m_textUnderline) {
1340 inherited_flags.m_textUnderline = false;
1341 list->append(AppliedTextDecoration(TextDecorationUnderline));
1342 }
1343
1344 list->append(decoration);
1345 }
1346
1347 void RenderStyle::applyTextDecorations()
1348 {
1349 if (textDecoration() == TextDecorationNone)
1350 return;
1351
1352 int decorations = textDecoration();
1353
1354 if (decorations & TextDecorationUnderline) {
1355 // To save memory, we don't use AppliedTextDecoration objects in the
1356 // common case of a single underline.
1357 if (!rareInheritedData->appliedTextDecorations)
1358 inherited_flags.m_textUnderline = true;
1359 else
1360 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationUnderli ne));
1361 }
1362 if (decorations & TextDecorationOverline)
1363 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline));
1364 if (decorations & TextDecorationLineThrough)
1365 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough ));
1366 }
1367
1368 void RenderStyle::clearAppliedTextDecorations()
1369 {
1370 inherited_flags.m_textUnderline = false;
1371
1372 if (rareInheritedData->appliedTextDecorations)
1373 rareInheritedData.access()->appliedTextDecorations = nullptr;
1374 }
1375
1302 void RenderStyle::getShadowExtent(const ShadowList* shadowList, LayoutUnit &top, LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const 1376 void RenderStyle::getShadowExtent(const ShadowList* shadowList, LayoutUnit &top, LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const
1303 { 1377 {
1304 top = 0; 1378 top = 0;
1305 right = 0; 1379 right = 0;
1306 bottom = 0; 1380 bottom = 0;
1307 left = 0; 1381 left = 0;
1308 1382
1309 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; 1383 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0;
1310 for (size_t i = 0; i < shadowCount; ++i) { 1384 for (size_t i = 0; i < shadowCount; ++i) {
1311 const ShadowData& shadow = shadowList->shadows()[i]; 1385 const ShadowData& shadow = shadowList->shadows()[i];
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 // right 1746 // right
1673 radiiSum = radii.topRight().height() + radii.bottomRight().height(); 1747 radiiSum = radii.topRight().height() + radii.bottomRight().height();
1674 if (radiiSum > rect.height()) 1748 if (radiiSum > rect.height())
1675 factor = std::min(rect.height() / radiiSum, factor); 1749 factor = std::min(rect.height() / radiiSum, factor);
1676 1750
1677 ASSERT(factor <= 1); 1751 ASSERT(factor <= 1);
1678 return factor; 1752 return factor;
1679 } 1753 }
1680 1754
1681 } // namespace WebCore 1755 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/style/RenderStyle.h ('k') | Source/core/rendering/style/StyleRareInheritedData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698