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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Whoops, the forward declaration just needed to be moved. Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "core/css/CSSValueList.h" 53 #include "core/css/CSSValueList.h"
54 #include "core/css/CSSValuePool.h" 54 #include "core/css/CSSValuePool.h"
55 #include "core/css/ElementRuleCollector.h" 55 #include "core/css/ElementRuleCollector.h"
56 #include "core/css/FontFace.h" 56 #include "core/css/FontFace.h"
57 #include "core/css/MediaQueryEvaluator.h" 57 #include "core/css/MediaQueryEvaluator.h"
58 #include "core/css/PageRuleCollector.h" 58 #include "core/css/PageRuleCollector.h"
59 #include "core/css/StylePropertySet.h" 59 #include "core/css/StylePropertySet.h"
60 #include "core/css/StyleRuleImport.h" 60 #include "core/css/StyleRuleImport.h"
61 #include "core/css/StyleSheetContents.h" 61 #include "core/css/StyleSheetContents.h"
62 #include "core/css/resolver/AnimatedStyleBuilder.h" 62 #include "core/css/resolver/AnimatedStyleBuilder.h"
63 #include "core/css/resolver/CSSVariableResolver.h"
63 #include "core/css/resolver/MatchResult.h" 64 #include "core/css/resolver/MatchResult.h"
64 #include "core/css/resolver/MediaQueryResult.h" 65 #include "core/css/resolver/MediaQueryResult.h"
65 #include "core/css/resolver/ScopedStyleResolver.h" 66 #include "core/css/resolver/ScopedStyleResolver.h"
66 #include "core/css/resolver/SharedStyleFinder.h" 67 #include "core/css/resolver/SharedStyleFinder.h"
67 #include "core/css/resolver/StyleAdjuster.h" 68 #include "core/css/resolver/StyleAdjuster.h"
68 #include "core/css/resolver/StyleResolverParentScope.h" 69 #include "core/css/resolver/StyleResolverParentScope.h"
69 #include "core/css/resolver/StyleResolverState.h" 70 #include "core/css/resolver/StyleResolverState.h"
70 #include "core/css/resolver/StyleResolverStats.h" 71 #include "core/css/resolver/StyleResolverStats.h"
71 #include "core/css/resolver/ViewportStyleResolver.h" 72 #include "core/css/resolver/ViewportStyleResolver.h"
72 #include "core/dom/CSSSelectorWatch.h" 73 #include "core/dom/CSSSelectorWatch.h"
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1172
1172 ASSERT_NOT_REACHED(); 1173 ASSERT_NOT_REACHED();
1173 return true; 1174 return true;
1174 } 1175 }
1175 1176
1176 // This method expands the 'all' shorthand property to longhand properties 1177 // This method expands the 'all' shorthand property to longhand properties
1177 // and applies the expanded longhand properties. 1178 // and applies the expanded longhand properties.
1178 template <CSSPropertyPriority priority> 1179 template <CSSPropertyPriority priority>
1179 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) 1180 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
1180 { 1181 {
1182 // The 'all' property doesn't apply to variables:
1183 // https://drafts.csswg.org/css-variables/#defining-variables
1184 if (priority == ResolveVariables)
1185 return;
1186
1181 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first(); 1187 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first();
1182 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last(); 1188 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last();
1183 1189
1184 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { 1190 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) {
1185 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); 1191 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i);
1186 1192
1187 // StyleBuilder does not allow any expanded shorthands. 1193 // StyleBuilder does not allow any expanded shorthands.
1188 if (isShorthandProperty(propertyId)) 1194 if (isShorthandProperty(propertyId))
1189 continue; 1195 continue;
1190 1196
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. 1316 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it.
1311 state.style()->setInsideLink(linkStatus); 1317 state.style()->setInsideLink(linkStatus);
1312 1318
1313 updateFont(state); 1319 updateFont(state);
1314 1320
1315 return; 1321 return;
1316 } 1322 }
1317 applyInheritedOnly = true; 1323 applyInheritedOnly = true;
1318 } 1324 }
1319 1325
1326 // TODO(leviw): We need the proper bit for tracking whether we need to do th is work.
1327 if (RuntimeEnabledFeatures::cssVariablesEnabled()) {
1328 applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules( ), false, applyInheritedOnly);
1329 applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules( ), true, applyInheritedOnly);
1330 // TODO(leviw): stop recalculating every time
1331 CSSVariableResolver::resolveVariableDefinitions(state);
1332 }
1333
1320 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1334 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1321 // high-priority properties first, i.e., those properties that other propert ies depend on. 1335 // high-priority properties first, i.e., those properties that other propert ies depend on.
1322 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1336 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1323 // and (4) normal important. 1337 // and (4) normal important.
1324 applyMatchedProperties<HighPropertyPriority>(state, matchResult.allRules(), false, applyInheritedOnly); 1338 applyMatchedProperties<HighPropertyPriority>(state, matchResult.allRules(), false, applyInheritedOnly);
1325 for (auto range : ImportantAuthorRanges(matchResult)) 1339 for (auto range : ImportantAuthorRanges(matchResult))
1326 applyMatchedProperties<HighPropertyPriority>(state, range, true, applyIn heritedOnly); 1340 applyMatchedProperties<HighPropertyPriority>(state, range, true, applyIn heritedOnly);
1327 applyMatchedProperties<HighPropertyPriority>(state, matchResult.uaRules(), t rue, applyInheritedOnly); 1341 applyMatchedProperties<HighPropertyPriority>(state, matchResult.uaRules(), t rue, applyInheritedOnly);
1328 1342
1329 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1343 if (UNLIKELY(isSVGForeignObjectElement(element))) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 visitor->trace(m_watchedSelectorsRules); 1501 visitor->trace(m_watchedSelectorsRules);
1488 visitor->trace(m_treeBoundaryCrossingRules); 1502 visitor->trace(m_treeBoundaryCrossingRules);
1489 visitor->trace(m_styleResourceLoader); 1503 visitor->trace(m_styleResourceLoader);
1490 visitor->trace(m_styleSharingLists); 1504 visitor->trace(m_styleSharingLists);
1491 visitor->trace(m_pendingStyleSheets); 1505 visitor->trace(m_pendingStyleSheets);
1492 visitor->trace(m_document); 1506 visitor->trace(m_document);
1493 #endif 1507 #endif
1494 } 1508 }
1495 1509
1496 } // namespace blink 1510 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698