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

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: rebase Created 6 years, 4 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
« no previous file with comments | « Source/core/css/resolver/CascadedValues.cpp ('k') | Source/core/css/resolver/StyleResolver.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) 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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 default: 963 default:
964 break; 964 break;
965 } 965 }
966 } else if (primitiveValue->isTime()) { 966 } else if (primitiveValue->isTime()) {
967 state.style()->setMarqueeSpeed(static_cast<int>(primitiveValue->computeS econds()) * 1000); 967 state.style()->setMarqueeSpeed(static_cast<int>(primitiveValue->computeS econds()) * 1000);
968 } else if (primitiveValue->isNumber()) { // For scrollamount support. 968 } else if (primitiveValue->isNumber()) { // For scrollamount support.
969 state.style()->setMarqueeSpeed(primitiveValue->getIntValue()); 969 state.style()->setMarqueeSpeed(primitiveValue->getIntValue());
970 } 970 }
971 } 971 }
972 972
973 // FIXME: We should use the same system for this as the rest of the pseudo-short hands (e.g. background-position)
974 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(Style ResolverState& state)
975 {
976 applyInitialCSSPropertyWebkitPerspectiveOriginX(state);
977 applyInitialCSSPropertyWebkitPerspectiveOriginY(state);
978 }
979
980 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(Style ResolverState& state)
981 {
982 applyInheritCSSPropertyWebkitPerspectiveOriginX(state);
983 applyInheritCSSPropertyWebkitPerspectiveOriginY(state);
984 }
985
986 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleRe solverState&, CSSValue* value)
987 {
988 // This is expanded in the parser
989 ASSERT_NOT_REACHED();
990 }
991
992 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state) 973 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state)
993 { 974 {
994 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); 975 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
995 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); 976 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
996 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCus tomMark()); 977 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCus tomMark());
997 } 978 }
998 979
999 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state) 980 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state)
1000 { 981 {
1001 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill()); 982 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill());
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 } 1174 }
1194 1175
1195 void StyleBuilderFunctions::applyValueCSSPropertyFont(StyleResolverState& state, CSSValue* value) 1176 void StyleBuilderFunctions::applyValueCSSPropertyFont(StyleResolverState& state, CSSValue* value)
1196 { 1177 {
1197 // Only System Font identifiers should come through this method 1178 // Only System Font identifiers should come through this method
1198 // all other values should have been handled when the shorthand 1179 // all other values should have been handled when the shorthand
1199 // was expanded by the parser. 1180 // was expanded by the parser.
1200 // FIXME: System Font identifiers should not hijack this 1181 // FIXME: System Font identifiers should not hijack this
1201 // short-hand CSSProperty like this (crbug.com/353932) 1182 // short-hand CSSProperty like this (crbug.com/353932)
1202 state.style()->setLineHeight(RenderStyle::initialLineHeight()); 1183 state.style()->setLineHeight(RenderStyle::initialLineHeight());
1203 state.setLineHeightValue(0);
1204 state.fontBuilder().fromSystemFont(toCSSPrimitiveValue(value)->getValueID(), state.style()->effectiveZoom()); 1184 state.fontBuilder().fromSystemFont(toCSSPrimitiveValue(value)->getValueID(), state.style()->effectiveZoom());
1205 } 1185 }
1206 1186
1207 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value) 1187 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value)
1208 { 1188 {
1209 if (!value->isPrimitiveValue()) 1189 if (!value->isPrimitiveValue())
1210 return; 1190 return;
1211 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 1191 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1212 if (primitiveValue->getValueID() == CSSValueAuto) 1192 if (primitiveValue->getValueID() == CSSValueAuto)
1213 state.style()->setLocale(nullAtom); 1193 state.style()->setLocale(nullAtom);
(...skipping 14 matching lines...) Expand all
1228 { 1208 {
1229 if (!value->isPrimitiveValue()) 1209 if (!value->isPrimitiveValue())
1230 return; 1210 return;
1231 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 1211 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1232 if (!primitiveValue->getValueID()) 1212 if (!primitiveValue->getValueID())
1233 return; 1213 return;
1234 state.style()->setDraggableRegionMode(primitiveValue->getValueID() == CSSVal ueDrag ? DraggableRegionDrag : DraggableRegionNoDrag); 1214 state.style()->setDraggableRegionMode(primitiveValue->getValueID() == CSSVal ueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
1235 state.document().setHasAnnotatedRegions(true); 1215 state.document().setHasAnnotatedRegions(true);
1236 } 1216 }
1237 1217
1238 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspective(StyleResolv erState& state)
1239 {
1240 applyInitialCSSPropertyPerspective(state);
1241 }
1242
1243 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspective(StyleResolv erState& state)
1244 {
1245 applyInheritCSSPropertyPerspective(state);
1246 }
1247
1248 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspective(StyleResolver State& state, CSSValue* value)
1249 {
1250 if (!value->isPrimitiveValue())
1251 return;
1252 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1253 if (primitiveValue->isNumber()) {
1254 float perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDo ubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.cssToLengthC onversionData());
1255 if (perspectiveValue >= 0.0f)
1256 state.style()->setPerspective(perspectiveValue);
1257 } else {
1258 applyValueCSSPropertyPerspective(state, value);
1259 }
1260 }
1261
1262 void StyleBuilderFunctions::applyValueCSSPropertyPerspective(StyleResolverState& state, CSSValue* value) 1218 void StyleBuilderFunctions::applyValueCSSPropertyPerspective(StyleResolverState& state, CSSValue* value)
1263 { 1219 {
1264 if (!value->isPrimitiveValue()) 1220 if (!value->isPrimitiveValue())
1265 return; 1221 return;
1266 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 1222 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1267 if (primitiveValue->getValueID() == CSSValueNone) { 1223 if (primitiveValue->getValueID() == CSSValueNone) {
1268 state.style()->setPerspective(0); 1224 state.style()->setPerspective(0);
1269 return; 1225 return;
1270 } 1226 }
1271 1227
1228 // This case is only hit when using -webkit-perspective
1229 if (primitiveValue->isNumber()) {
1230 float perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDo ubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.cssToLengthC onversionData());
1231 if (perspectiveValue >= 0.0f)
1232 state.style()->setPerspective(perspectiveValue);
1233 return;
1234 }
1235
1272 if (!primitiveValue->isLength()) 1236 if (!primitiveValue->isLength())
1273 return; 1237 return;
1274 float perspectiveValue = primitiveValue->computeLength<float>(state.cssToLen gthConversionData()); 1238 float perspectiveValue = primitiveValue->computeLength<float>(state.cssToLen gthConversionData());
1275 if (perspectiveValue >= 0.0f) 1239 if (perspectiveValue >= 0.0f)
1276 state.style()->setPerspective(perspectiveValue); 1240 state.style()->setPerspective(perspectiveValue);
1277 } 1241 }
1278 1242
1279 void StyleBuilderFunctions::applyInitialCSSPropertyInternalCallback(StyleResolve rState& state)
1280 {
1281 }
1282
1283 void StyleBuilderFunctions::applyInheritCSSPropertyInternalCallback(StyleResolve rState& state)
1284 {
1285 }
1286
1287 void StyleBuilderFunctions::applyValueCSSPropertyInternalCallback(StyleResolverS tate& state, CSSValue* value)
1288 {
1289 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueInternalPresence)
1290 state.style()->addCallbackSelector(state.currentRule()->selectorList().s electorsText());
1291 }
1292
1293 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value) 1243 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value)
1294 { 1244 {
1295 if (value->isPrimitiveValue()) 1245 if (value->isPrimitiveValue())
1296 state.setWritingMode(*toCSSPrimitiveValue(value)); 1246 state.setWritingMode(*toCSSPrimitiveValue(value));
1297 1247
1298 // FIXME: It is not ok to modify document state while applying style. 1248 // FIXME: It is not ok to modify document state while applying style.
1299 if (state.element() && state.element() == state.document().documentElement() ) 1249 if (state.element() && state.element() == state.document().documentElement() )
1300 state.document().setWritingModeSetOnDocumentElement(true); 1250 state.document().setWritingModeSetOnDocumentElement(true);
1301 } 1251 }
1302 1252
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 break; 1363 break;
1414 default: 1364 default:
1415 ASSERT_NOT_REACHED(); 1365 ASSERT_NOT_REACHED();
1416 break; 1366 break;
1417 } 1367 }
1418 1368
1419 state.style()->setGridAutoFlow(autoFlow); 1369 state.style()->setGridAutoFlow(autoFlow);
1420 } 1370 }
1421 1371
1422 } // namespace blink 1372 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/CascadedValues.cpp ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698