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

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: Remove reftest.list :( Created 5 years, 1 month 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 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 1175
1175 ASSERT_NOT_REACHED(); 1176 ASSERT_NOT_REACHED();
1176 return true; 1177 return true;
1177 } 1178 }
1178 1179
1179 // This method expands the 'all' shorthand property to longhand properties 1180 // This method expands the 'all' shorthand property to longhand properties
1180 // and applies the expanded longhand properties. 1181 // and applies the expanded longhand properties.
1181 template <CSSPropertyPriority priority> 1182 template <CSSPropertyPriority priority>
1182 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) 1183 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
1183 { 1184 {
1185 // The 'all' property doesn't apply to variables:
1186 // https://drafts.csswg.org/css-variables/#defining-variables
1187 if (priority == ResolveVariables)
1188 return;
1189
1184 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first(); 1190 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first();
1185 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last(); 1191 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last();
1186 1192
1187 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { 1193 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) {
1188 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); 1194 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i);
1189 1195
1190 // StyleBuilder does not allow any expanded shorthands. 1196 // StyleBuilder does not allow any expanded shorthands.
1191 if (isShorthandProperty(propertyId)) 1197 if (isShorthandProperty(propertyId))
1192 continue; 1198 continue;
1193 1199
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. 1319 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it.
1314 state.style()->setInsideLink(linkStatus); 1320 state.style()->setInsideLink(linkStatus);
1315 1321
1316 updateFont(state); 1322 updateFont(state);
1317 1323
1318 return; 1324 return;
1319 } 1325 }
1320 applyInheritedOnly = true; 1326 applyInheritedOnly = true;
1321 } 1327 }
1322 1328
1329 // TODO(leviw): We need the proper bit for tracking whether we need to do th is work.
1330 if (RuntimeEnabledFeatures::cssVariablesEnabled()) {
1331 applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules( ), false, applyInheritedOnly);
1332 applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules( ), true, applyInheritedOnly);
1333 // TODO(leviw): stop recalculating every time
1334 CSSVariableResolver::resolveVariableDefinitions(state.style()->variables ());
1335 }
1336
1323 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1337 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1324 // high-priority properties first, i.e., those properties that other propert ies depend on. 1338 // high-priority properties first, i.e., those properties that other propert ies depend on.
1325 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1339 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1326 // and (4) normal important. 1340 // and (4) normal important.
1327 applyMatchedProperties<HighPropertyPriority>(state, matchResult.allRules(), false, applyInheritedOnly); 1341 applyMatchedProperties<HighPropertyPriority>(state, matchResult.allRules(), false, applyInheritedOnly);
1328 for (auto range : ImportantAuthorRanges(matchResult)) 1342 for (auto range : ImportantAuthorRanges(matchResult))
1329 applyMatchedProperties<HighPropertyPriority>(state, range, true, applyIn heritedOnly); 1343 applyMatchedProperties<HighPropertyPriority>(state, range, true, applyIn heritedOnly);
1330 applyMatchedProperties<HighPropertyPriority>(state, matchResult.uaRules(), t rue, applyInheritedOnly); 1344 applyMatchedProperties<HighPropertyPriority>(state, matchResult.uaRules(), t rue, applyInheritedOnly);
1331 1345
1332 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1346 if (UNLIKELY(isSVGForeignObjectElement(element))) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 visitor->trace(m_watchedSelectorsRules); 1504 visitor->trace(m_watchedSelectorsRules);
1491 visitor->trace(m_treeBoundaryCrossingRules); 1505 visitor->trace(m_treeBoundaryCrossingRules);
1492 visitor->trace(m_styleResourceLoader); 1506 visitor->trace(m_styleResourceLoader);
1493 visitor->trace(m_styleSharingLists); 1507 visitor->trace(m_styleSharingLists);
1494 visitor->trace(m_pendingStyleSheets); 1508 visitor->trace(m_pendingStyleSheets);
1495 visitor->trace(m_document); 1509 visitor->trace(m_document);
1496 #endif 1510 #endif
1497 } 1511 }
1498 1512
1499 } // namespace blink 1513 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698