Chromium Code Reviews

Side by Side Diff: Source/core/css/resolver/StyleBuilderCustom.cpp

Issue 350333003: Cascade declared property values instead of applying values on top of each other (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
(...skipping 596 matching lines...)
607 if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueW ebkitMatchParent) 607 if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueW ebkitMatchParent)
608 state.style()->setTextAlign(*primitiveValue); 608 state.style()->setTextAlign(*primitiveValue);
609 else if (state.parentStyle()->textAlign() == TASTART) 609 else if (state.parentStyle()->textAlign() == TASTART)
610 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? LEFT : RIGHT); 610 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? LEFT : RIGHT);
611 else if (state.parentStyle()->textAlign() == TAEND) 611 else if (state.parentStyle()->textAlign() == TAEND)
612 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? RIGHT : LEFT); 612 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? RIGHT : LEFT);
613 else 613 else
614 state.style()->setTextAlign(state.parentStyle()->textAlign()); 614 state.style()->setTextAlign(state.parentStyle()->textAlign());
615 } 615 }
616 616
617 void StyleBuilderFunctions::applyValueCSSPropertyTextDecoration(StyleResolverSta te& state, CSSValue* value) 617 void StyleBuilderFunctions::applyValueCSSPropertyTextDecorationLine(StyleResolve rState& state, CSSValue* value)
618 { 618 {
619 TextDecoration t = RenderStyle::initialTextDecoration(); 619 TextDecoration t = RenderStyle::initialTextDecoration();
620 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { 620 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) {
621 CSSValue* item = i.value(); 621 CSSValue* item = i.value();
622 t |= *toCSSPrimitiveValue(item); 622 t |= *toCSSPrimitiveValue(item);
623 } 623 }
624 state.style()->setTextDecoration(t); 624 state.style()->setTextDecoration(t);
625 } 625 }
626 626
627 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolverState & state) 627 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolverState & state)
(...skipping 354 matching lines...)
982 default: 982 default:
983 break; 983 break;
984 } 984 }
985 } else if (primitiveValue->isTime()) { 985 } else if (primitiveValue->isTime()) {
986 state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimi tiveValue::Milliseconds>()); 986 state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimi tiveValue::Milliseconds>());
987 } else if (primitiveValue->isNumber()) { // For scrollamount support. 987 } else if (primitiveValue->isNumber()) { // For scrollamount support.
988 state.style()->setMarqueeSpeed(primitiveValue->getIntValue()); 988 state.style()->setMarqueeSpeed(primitiveValue->getIntValue());
989 } 989 }
990 } 990 }
991 991
992 // FIXME: We should use the same system for this as the rest of the pseudo-short hands (e.g. background-position)
993 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(Style ResolverState& state)
994 {
995 applyInitialCSSPropertyWebkitPerspectiveOriginX(state);
996 applyInitialCSSPropertyWebkitPerspectiveOriginY(state);
997 }
998
999 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(Style ResolverState& state)
1000 {
1001 applyInheritCSSPropertyWebkitPerspectiveOriginX(state);
1002 applyInheritCSSPropertyWebkitPerspectiveOriginY(state);
1003 }
1004
1005 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleRe solverState&, CSSValue* value)
1006 {
1007 // This is expanded in the parser
1008 ASSERT_NOT_REACHED();
1009 }
1010
1011 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTapHighlightColor(StyleRe solverState& state, CSSValue* value) 992 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTapHighlightColor(StyleRe solverState& state, CSSValue* value)
1012 { 993 {
1013 if (!value->isPrimitiveValue()) 994 if (!value->isPrimitiveValue())
1014 return; 995 return;
1015 Color color = state.document().textLinkColors().colorFromPrimitiveValue(toCS SPrimitiveValue(value), state.style()->color()); 996 Color color = state.document().textLinkColors().colorFromPrimitiveValue(toCS SPrimitiveValue(value), state.style()->color());
1016 state.style()->setTapHighlightColor(color); 997 state.style()->setTapHighlightColor(color);
1017 } 998 }
1018 999
1019 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state) 1000 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state)
1020 { 1001 {
(...skipping 217 matching lines...)
1238 } 1219 }
1239 1220
1240 void StyleBuilderFunctions::applyValueCSSPropertyFont(StyleResolverState& state, CSSValue* value) 1221 void StyleBuilderFunctions::applyValueCSSPropertyFont(StyleResolverState& state, CSSValue* value)
1241 { 1222 {
1242 // Only System Font identifiers should come through this method 1223 // Only System Font identifiers should come through this method
1243 // all other values should have been handled when the shorthand 1224 // all other values should have been handled when the shorthand
1244 // was expanded by the parser. 1225 // was expanded by the parser.
1245 // FIXME: System Font identifiers should not hijack this 1226 // FIXME: System Font identifiers should not hijack this
1246 // short-hand CSSProperty like this (crbug.com/353932) 1227 // short-hand CSSProperty like this (crbug.com/353932)
1247 state.style()->setLineHeight(RenderStyle::initialLineHeight()); 1228 state.style()->setLineHeight(RenderStyle::initialLineHeight());
1248 state.setLineHeightValue(0);
1249 state.fontBuilder().fromSystemFont(toCSSPrimitiveValue(value)->getValueID(), state.style()->effectiveZoom()); 1229 state.fontBuilder().fromSystemFont(toCSSPrimitiveValue(value)->getValueID(), state.style()->effectiveZoom());
1250 } 1230 }
1251 1231
1252 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value) 1232 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value)
1253 { 1233 {
1254 if (!value->isPrimitiveValue()) 1234 if (!value->isPrimitiveValue())
1255 return; 1235 return;
1256 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 1236 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1257 if (primitiveValue->getValueID() == CSSValueAuto) 1237 if (primitiveValue->getValueID() == CSSValueAuto)
1258 state.style()->setLocale(nullAtom); 1238 state.style()->setLocale(nullAtom);
(...skipping 14 matching lines...)
1273 { 1253 {
1274 if (!value->isPrimitiveValue()) 1254 if (!value->isPrimitiveValue())
1275 return; 1255 return;
1276 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 1256 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1277 if (!primitiveValue->getValueID()) 1257 if (!primitiveValue->getValueID())
1278 return; 1258 return;
1279 state.style()->setDraggableRegionMode(primitiveValue->getValueID() == CSSVal ueDrag ? DraggableRegionDrag : DraggableRegionNoDrag); 1259 state.style()->setDraggableRegionMode(primitiveValue->getValueID() == CSSVal ueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
1280 state.document().setHasAnnotatedRegions(true); 1260 state.document().setHasAnnotatedRegions(true);
1281 } 1261 }
1282 1262
1283 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspective(StyleResolv erState& state)
1284 {
1285 applyInitialCSSPropertyPerspective(state);
1286 }
1287
1288 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspective(StyleResolv erState& state)
1289 {
1290 applyInheritCSSPropertyPerspective(state);
1291 }
1292
1293 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspective(StyleResolver State& state, CSSValue* value)
1294 {
1295 if (!value->isPrimitiveValue())
1296 return;
1297 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1298 if (primitiveValue->isNumber()) {
1299 float perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDo ubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.cssToLengthC onversionData());
1300 if (perspectiveValue >= 0.0f)
1301 state.style()->setPerspective(perspectiveValue);
1302 } else {
1303 applyValueCSSPropertyPerspective(state, value);
1304 }
1305 }
1306
1307 void StyleBuilderFunctions::applyValueCSSPropertyPerspective(StyleResolverState& state, CSSValue* value) 1263 void StyleBuilderFunctions::applyValueCSSPropertyPerspective(StyleResolverState& state, CSSValue* value)
1308 { 1264 {
1309 if (!value->isPrimitiveValue()) 1265 if (!value->isPrimitiveValue())
1310 return; 1266 return;
1311 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 1267 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1312 if (primitiveValue->getValueID() == CSSValueNone) { 1268 if (primitiveValue->getValueID() == CSSValueNone) {
1313 state.style()->setPerspective(0); 1269 state.style()->setPerspective(0);
1314 return; 1270 return;
1315 } 1271 }
1316 1272
1273 // This case is only hit when using -webkit-perspective
1274 if (primitiveValue->isNumber()) {
1275 float perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDo ubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.cssToLengthC onversionData());
1276 if (perspectiveValue >= 0.0f)
1277 state.style()->setPerspective(perspectiveValue);
1278 return;
1279 }
1280
1317 if (!primitiveValue->isLength()) 1281 if (!primitiveValue->isLength())
1318 return; 1282 return;
1319 float perspectiveValue = primitiveValue->computeLength<float>(state.cssToLen gthConversionData()); 1283 float perspectiveValue = primitiveValue->computeLength<float>(state.cssToLen gthConversionData());
1320 if (perspectiveValue >= 0.0f) 1284 if (perspectiveValue >= 0.0f)
1321 state.style()->setPerspective(perspectiveValue); 1285 state.style()->setPerspective(perspectiveValue);
1322 } 1286 }
1323 1287
1324 void StyleBuilderFunctions::applyInitialCSSPropertyInternalCallback(StyleResolve rState& state)
1325 {
1326 }
1327
1328 void StyleBuilderFunctions::applyInheritCSSPropertyInternalCallback(StyleResolve rState& state)
1329 {
1330 }
1331
1332 void StyleBuilderFunctions::applyValueCSSPropertyInternalCallback(StyleResolverS tate& state, CSSValue* value)
1333 {
1334 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueInternalPresence)
1335 state.style()->addCallbackSelector(state.currentRule()->selectorList().s electorsText());
1336 }
1337
1338 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value) 1288 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value)
1339 { 1289 {
1340 if (value->isPrimitiveValue()) 1290 if (value->isPrimitiveValue())
1341 state.setWritingMode(*toCSSPrimitiveValue(value)); 1291 state.setWritingMode(*toCSSPrimitiveValue(value));
1342 1292
1343 // FIXME: It is not ok to modify document state while applying style. 1293 // FIXME: It is not ok to modify document state while applying style.
1344 if (state.element() && state.element() == state.document().documentElement() ) 1294 if (state.element() && state.element() == state.document().documentElement() )
1345 state.document().setWritingModeSetOnDocumentElement(true); 1295 state.document().setWritingModeSetOnDocumentElement(true);
1346 } 1296 }
1347 1297
(...skipping 110 matching lines...)
1458 break; 1408 break;
1459 default: 1409 default:
1460 ASSERT_NOT_REACHED(); 1410 ASSERT_NOT_REACHED();
1461 break; 1411 break;
1462 } 1412 }
1463 1413
1464 state.style()->setGridAutoFlow(autoFlow); 1414 state.style()->setGridAutoFlow(autoFlow);
1465 } 1415 }
1466 1416
1467 } // namespace WebCore 1417 } // namespace WebCore
OLDNEW

Powered by Google App Engine