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

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

Issue 23581008: Revert r154797: "Move isValid/isCurrentColor from Color to StyleColor" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/style/RenderStyle.h ('k') | Source/core/rendering/style/ShadowData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 noninherited_flags._vertical_align = other->noninherited_flags._vertical_ali gn; 179 noninherited_flags._vertical_align = other->noninherited_flags._vertical_ali gn;
180 noninherited_flags._clear = other->noninherited_flags._clear; 180 noninherited_flags._clear = other->noninherited_flags._clear;
181 noninherited_flags._position = other->noninherited_flags._position; 181 noninherited_flags._position = other->noninherited_flags._position;
182 noninherited_flags._floating = other->noninherited_flags._floating; 182 noninherited_flags._floating = other->noninherited_flags._floating;
183 noninherited_flags._table_layout = other->noninherited_flags._table_layout; 183 noninherited_flags._table_layout = other->noninherited_flags._table_layout;
184 noninherited_flags._unicodeBidi = other->noninherited_flags._unicodeBidi; 184 noninherited_flags._unicodeBidi = other->noninherited_flags._unicodeBidi;
185 noninherited_flags._page_break_before = other->noninherited_flags._page_brea k_before; 185 noninherited_flags._page_break_before = other->noninherited_flags._page_brea k_before;
186 noninherited_flags._page_break_after = other->noninherited_flags._page_break _after; 186 noninherited_flags._page_break_after = other->noninherited_flags._page_break _after;
187 noninherited_flags._page_break_inside = other->noninherited_flags._page_brea k_inside; 187 noninherited_flags._page_break_inside = other->noninherited_flags._page_brea k_inside;
188 noninherited_flags.explicitInheritance = other->noninherited_flags.explicitI nheritance; 188 noninherited_flags.explicitInheritance = other->noninherited_flags.explicitI nheritance;
189 noninherited_flags.currentColor = other->noninherited_flags.currentColor;
189 if (m_svgStyle != other->m_svgStyle) 190 if (m_svgStyle != other->m_svgStyle)
190 m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get()); 191 m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get());
191 ASSERT(zoom() == initialZoom()); 192 ASSERT(zoom() == initialZoom());
192 } 193 }
193 194
194 bool RenderStyle::operator==(const RenderStyle& o) const 195 bool RenderStyle::operator==(const RenderStyle& o) const
195 { 196 {
196 // compare everything except the pseudoStyle pointer 197 // compare everything except the pseudoStyle pointer
197 return inherited_flags == o.inherited_flags 198 return inherited_flags == o.inherited_flags
198 && noninherited_flags == o.noninherited_flags 199 && noninherited_flags == o.noninherited_flags
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 return factor; 910 return factor;
910 } 911 }
911 912
912 StyleImage* RenderStyle::listStyleImage() const { return rareInheritedData->list StyleImage.get(); } 913 StyleImage* RenderStyle::listStyleImage() const { return rareInheritedData->list StyleImage.get(); }
913 void RenderStyle::setListStyleImage(PassRefPtr<StyleImage> v) 914 void RenderStyle::setListStyleImage(PassRefPtr<StyleImage> v)
914 { 915 {
915 if (rareInheritedData->listStyleImage != v) 916 if (rareInheritedData->listStyleImage != v)
916 rareInheritedData.access()->listStyleImage = v; 917 rareInheritedData.access()->listStyleImage = v;
917 } 918 }
918 919
919 StyleColor RenderStyle::color() const { return inherited->color; } 920 Color RenderStyle::color() const { return inherited->color; }
920 StyleColor RenderStyle::visitedLinkColor() const { return inherited->visitedLink Color; } 921 Color RenderStyle::visitedLinkColor() const { return inherited->visitedLinkColor ; }
921 void RenderStyle::setColor(const StyleColor& v) { SET_VAR(inherited, color, v); } 922 void RenderStyle::setColor(const Color& v) { SET_VAR(inherited, color, v); }
922 void RenderStyle::setVisitedLinkColor(const StyleColor& v) { SET_VAR(inherited, visitedLinkColor, v); } 923 void RenderStyle::setVisitedLinkColor(const Color& v) { SET_VAR(inherited, visit edLinkColor, v); }
923 924
924 short RenderStyle::horizontalBorderSpacing() const { return inherited->horizonta l_border_spacing; } 925 short RenderStyle::horizontalBorderSpacing() const { return inherited->horizonta l_border_spacing; }
925 short RenderStyle::verticalBorderSpacing() const { return inherited->vertical_bo rder_spacing; } 926 short RenderStyle::verticalBorderSpacing() const { return inherited->vertical_bo rder_spacing; }
926 void RenderStyle::setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horiz ontal_border_spacing, v); } 927 void RenderStyle::setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horiz ontal_border_spacing, v); }
927 void RenderStyle::setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertica l_border_spacing, v); } 928 void RenderStyle::setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertica l_border_spacing, v); }
928 929
929 RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, Rende rView* renderView, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) co nst 930 RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, Rende rView* renderView, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) co nst
930 { 931 {
931 IntRect snappedBorderRect(pixelSnappedIntRect(borderRect)); 932 IntRect snappedBorderRect(pixelSnappedIntRect(borderRect));
932 RoundedRect roundedRect(snappedBorderRect); 933 RoundedRect roundedRect(snappedBorderRect);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 for ( ; shadow; shadow = shadow->next()) { 1285 for ( ; shadow; shadow = shadow->next()) {
1285 if (shadow->style() == Inset) 1286 if (shadow->style() == Inset)
1286 continue; 1287 continue;
1287 int blurAndSpread = shadow->blur() + shadow->spread(); 1288 int blurAndSpread = shadow->blur() + shadow->spread();
1288 1289
1289 top = min<LayoutUnit>(top, shadow->y() - blurAndSpread); 1290 top = min<LayoutUnit>(top, shadow->y() - blurAndSpread);
1290 bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread); 1291 bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread);
1291 } 1292 }
1292 } 1293 }
1293 1294
1294 StyleColor RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLi nk) const 1295 Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) c onst
1295 { 1296 {
1296 StyleColor result; 1297 Color result;
1297 EBorderStyle borderStyle = BNONE; 1298 EBorderStyle borderStyle = BNONE;
1298 switch (colorProperty) { 1299 switch (colorProperty) {
1299 case CSSPropertyBackgroundColor: 1300 case CSSPropertyBackgroundColor:
1300 return visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); / / Background color doesn't fall back. 1301 return visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); / / Background color doesn't fall back.
1301 case CSSPropertyBorderLeftColor: 1302 case CSSPropertyBorderLeftColor:
1302 result = visitedLink ? visitedLinkBorderLeftColor() : borderLeftColor(); 1303 result = visitedLink ? visitedLinkBorderLeftColor() : borderLeftColor();
1303 borderStyle = borderLeftStyle(); 1304 borderStyle = borderLeftStyle();
1304 break; 1305 break;
1305 case CSSPropertyBorderRightColor: 1306 case CSSPropertyBorderRightColor:
1306 result = visitedLink ? visitedLinkBorderRightColor() : borderRightColor( ); 1307 result = visitedLink ? visitedLinkBorderRightColor() : borderRightColor( );
(...skipping 21 matching lines...) Expand all
1328 return visitedLink ? visitedLinkTextDecorationColor() : textDecorationCo lor(); 1329 return visitedLink ? visitedLinkTextDecorationColor() : textDecorationCo lor();
1329 case CSSPropertyWebkitTextEmphasisColor: 1330 case CSSPropertyWebkitTextEmphasisColor:
1330 result = visitedLink ? visitedLinkTextEmphasisColor() : textEmphasisColo r(); 1331 result = visitedLink ? visitedLinkTextEmphasisColor() : textEmphasisColo r();
1331 break; 1332 break;
1332 case CSSPropertyWebkitTextFillColor: 1333 case CSSPropertyWebkitTextFillColor:
1333 result = visitedLink ? visitedLinkTextFillColor() : textFillColor(); 1334 result = visitedLink ? visitedLinkTextFillColor() : textFillColor();
1334 break; 1335 break;
1335 case CSSPropertyWebkitTextStrokeColor: 1336 case CSSPropertyWebkitTextStrokeColor:
1336 result = visitedLink ? visitedLinkTextStrokeColor() : textStrokeColor(); 1337 result = visitedLink ? visitedLinkTextStrokeColor() : textStrokeColor();
1337 break; 1338 break;
1338 case CSSPropertyFloodColor: 1339 case CSSPropertyFloodColor:
leviw_travelin_and_unemployed 2013/09/04 00:51:44 I'm really sad to hear we don't have test coverage
1339 result = floodColor(); 1340 result = floodColor();
1340 break; 1341 break;
1341 case CSSPropertyLightingColor: 1342 case CSSPropertyLightingColor:
1342 result = lightingColor(); 1343 result = lightingColor();
1343 break; 1344 break;
1344 case CSSPropertyStopColor: 1345 case CSSPropertyStopColor:
1345 result = stopColor(); 1346 result = stopColor();
1346 break; 1347 break;
1347 case CSSPropertyWebkitTapHighlightColor: 1348 case CSSPropertyWebkitTapHighlightColor:
1348 result = tapHighlightColor(); 1349 result = tapHighlightColor();
1349 break; 1350 break;
1350 default: 1351 default:
1351 ASSERT_NOT_REACHED(); 1352 ASSERT_NOT_REACHED();
1352 break; 1353 break;
1353 } 1354 }
1354 1355
1355 if (!result.isValid() && !result.isCurrentColor()) { 1356 if (!result.isValid()) {
1356 if (!visitedLink && (borderStyle == INSET || borderStyle == OUTSET || bo rderStyle == RIDGE || borderStyle == GROOVE)) 1357 if (!visitedLink && (borderStyle == INSET || borderStyle == OUTSET || bo rderStyle == RIDGE || borderStyle == GROOVE))
1357 result.setRGB(238, 238, 238); 1358 result.setRGB(238, 238, 238);
1358 else 1359 else
1359 result = visitedLink ? visitedLinkColor() : color(); 1360 result = visitedLink ? visitedLinkColor() : color();
1360 } 1361 }
1361 return result; 1362 return result;
1362 } 1363 }
1363 1364
1364 StyleColor RenderStyle::visitedDependentColor(int colorProperty) const 1365 Color RenderStyle::visitedDependentColor(int colorProperty) const
1365 { 1366 {
1366 StyleColor unvisitedColor = colorIncludingFallback(colorProperty, false); 1367 Color unvisitedColor = colorIncludingFallback(colorProperty, false);
1367 if (insideLink() != InsideVisitedLink) 1368 if (insideLink() != InsideVisitedLink)
1368 return unvisitedColor; 1369 return unvisitedColor;
1369 1370
1370 StyleColor visitedColor = colorIncludingFallback(colorProperty, true); 1371 Color visitedColor = colorIncludingFallback(colorProperty, true);
1371 1372
1372 // Text decoration color validity is preserved (checked in RenderObject::dec orationColor). 1373 // Text decoration color validity is preserved (checked in RenderObject::dec orationColor).
1373 if (colorProperty == CSSPropertyTextDecorationColor) 1374 if (colorProperty == CSSPropertyTextDecorationColor)
1374 return visitedColor; 1375 return visitedColor;
1375 1376
1376 // FIXME: Technically someone could explicitly specify the color transparent , but for now we'll just 1377 // FIXME: Technically someone could explicitly specify the color transparent , but for now we'll just
1377 // assume that if the background color is transparent that it wasn't set. No te that it's weird that 1378 // assume that if the background color is transparent that it wasn't set. No te that it's weird that
1378 // we're returning unvisited info for a visited link, but given our restrict ion that the alpha values 1379 // we're returning unvisited info for a visited link, but given our restrict ion that the alpha values
1379 // have to match, it makes more sense to return the unvisited background col or if specified than it 1380 // have to match, it makes more sense to return the unvisited background col or if specified than it
1380 // does to return black. This behavior matches what Firefox 4 does as well. 1381 // does to return black. This behavior matches what Firefox 4 does as well.
1381 if (colorProperty == CSSPropertyBackgroundColor && visitedColor == Color::tr ansparent) 1382 if (colorProperty == CSSPropertyBackgroundColor && visitedColor == Color::tr ansparent)
1382 return unvisitedColor; 1383 return unvisitedColor;
1383 1384
1384 // Unless the visitied color is 'currentColor'; take the alpha from the unvi sited color, 1385 // Take the alpha from the unvisited color, but get the RGB values from the visited color.
1385 // but get the RGB values from the visited color. 1386 return Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), unvisitedColor.alpha());
1386 if (visitedColor.isCurrentColor())
1387 return visitedColor;
1388
1389 return StyleColor(visitedColor.red(), visitedColor.green(), visitedColor.blu e(), unvisitedColor.alpha());
1390 } 1387 }
1391 1388
1392 const BorderValue& RenderStyle::borderBefore() const 1389 const BorderValue& RenderStyle::borderBefore() const
1393 { 1390 {
1394 switch (writingMode()) { 1391 switch (writingMode()) {
1395 case TopToBottomWritingMode: 1392 case TopToBottomWritingMode:
1396 return borderTop(); 1393 return borderTop();
1397 case BottomToTopWritingMode: 1394 case BottomToTopWritingMode:
1398 return borderBottom(); 1395 return borderBottom();
1399 case LeftToRightWritingMode: 1396 case LeftToRightWritingMode:
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 surround.access()->border.m_image.setOutset(outset); 1561 surround.access()->border.m_image.setOutset(outset);
1565 } 1562 }
1566 1563
1567 ShapeValue* RenderStyle::initialShapeInside() 1564 ShapeValue* RenderStyle::initialShapeInside()
1568 { 1565 {
1569 DEFINE_STATIC_LOCAL(RefPtr<ShapeValue>, sOutsideValue, (ShapeValue::createOu tsideValue())); 1566 DEFINE_STATIC_LOCAL(RefPtr<ShapeValue>, sOutsideValue, (ShapeValue::createOu tsideValue()));
1570 return sOutsideValue.get(); 1567 return sOutsideValue.get();
1571 } 1568 }
1572 1569
1573 } // namespace WebCore 1570 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/style/RenderStyle.h ('k') | Source/core/rendering/style/ShadowData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698