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

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: Use m_unit 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "core/css/CSSValueList.h" 54 #include "core/css/CSSValueList.h"
55 #include "core/css/CSSValuePool.h" 55 #include "core/css/CSSValuePool.h"
56 #include "core/css/ElementRuleCollector.h" 56 #include "core/css/ElementRuleCollector.h"
57 #include "core/css/FontFace.h" 57 #include "core/css/FontFace.h"
58 #include "core/css/MediaQueryEvaluator.h" 58 #include "core/css/MediaQueryEvaluator.h"
59 #include "core/css/PageRuleCollector.h" 59 #include "core/css/PageRuleCollector.h"
60 #include "core/css/StylePropertySet.h" 60 #include "core/css/StylePropertySet.h"
61 #include "core/css/StyleRuleImport.h" 61 #include "core/css/StyleRuleImport.h"
62 #include "core/css/StyleSheetContents.h" 62 #include "core/css/StyleSheetContents.h"
63 #include "core/css/resolver/AnimatedStyleBuilder.h" 63 #include "core/css/resolver/AnimatedStyleBuilder.h"
64 #include "core/css/resolver/CSSVariableResolver.h"
64 #include "core/css/resolver/MatchResult.h" 65 #include "core/css/resolver/MatchResult.h"
65 #include "core/css/resolver/MediaQueryResult.h" 66 #include "core/css/resolver/MediaQueryResult.h"
66 #include "core/css/resolver/ScopedStyleResolver.h" 67 #include "core/css/resolver/ScopedStyleResolver.h"
67 #include "core/css/resolver/SharedStyleFinder.h" 68 #include "core/css/resolver/SharedStyleFinder.h"
68 #include "core/css/resolver/StyleAdjuster.h" 69 #include "core/css/resolver/StyleAdjuster.h"
69 #include "core/css/resolver/StyleResolverParentScope.h" 70 #include "core/css/resolver/StyleResolverParentScope.h"
70 #include "core/css/resolver/StyleResolverState.h" 71 #include "core/css/resolver/StyleResolverState.h"
71 #include "core/css/resolver/StyleResolverStats.h" 72 #include "core/css/resolver/StyleResolverStats.h"
72 #include "core/css/resolver/ViewportStyleResolver.h" 73 #include "core/css/resolver/ViewportStyleResolver.h"
73 #include "core/dom/CSSSelectorWatch.h" 74 #include "core/dom/CSSSelectorWatch.h"
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1224
1224 ASSERT_NOT_REACHED(); 1225 ASSERT_NOT_REACHED();
1225 return true; 1226 return true;
1226 } 1227 }
1227 1228
1228 // This method expands the 'all' shorthand property to longhand properties 1229 // This method expands the 'all' shorthand property to longhand properties
1229 // and applies the expanded longhand properties. 1230 // and applies the expanded longhand properties.
1230 template <CSSPropertyPriority priority> 1231 template <CSSPropertyPriority priority>
1231 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) 1232 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
1232 { 1233 {
1234 // The 'all' property doesn't apply to variables:
1235 // https://drafts.csswg.org/css-variables/#defining-variables
1236 if (priority == ResolveVariables)
1237 return;
1238
1233 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first(); 1239 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first();
1234 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last(); 1240 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last();
1235 1241
1236 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { 1242 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) {
1237 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); 1243 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i);
1238 1244
1239 // StyleBuilder does not allow any expanded shorthands. 1245 // StyleBuilder does not allow any expanded shorthands.
1240 if (isShorthandProperty(propertyId)) 1246 if (isShorthandProperty(propertyId))
1241 continue; 1247 continue;
1242 1248
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. 1368 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it.
1363 state.style()->setInsideLink(linkStatus); 1369 state.style()->setInsideLink(linkStatus);
1364 1370
1365 updateFont(state); 1371 updateFont(state);
1366 1372
1367 return; 1373 return;
1368 } 1374 }
1369 applyInheritedOnly = true; 1375 applyInheritedOnly = true;
1370 } 1376 }
1371 1377
1378 // TODO(leviw): We need the proper bit for tracking whether we need to do th is work.
1379 if (RuntimeEnabledFeatures::cssVariablesEnabled()) {
1380 applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules( ), false, applyInheritedOnly);
1381 applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules( ), true, applyInheritedOnly);
1382 // TODO(leviw): stop recalculating every time
1383 CSSVariableResolver::resolveVariableDefinitions(state.style()->variables ());
1384 }
1385
1372 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1386 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1373 // high-priority properties first, i.e., those properties that other propert ies depend on. 1387 // high-priority properties first, i.e., those properties that other propert ies depend on.
1374 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1388 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1375 // and (4) normal important. 1389 // and (4) normal important.
1376 applyMatchedProperties<HighPropertyPriority>(state, matchResult.allRules(), false, applyInheritedOnly); 1390 applyMatchedProperties<HighPropertyPriority>(state, matchResult.allRules(), false, applyInheritedOnly);
1377 for (auto range : ImportantAuthorRanges(matchResult)) 1391 for (auto range : ImportantAuthorRanges(matchResult))
1378 applyMatchedProperties<HighPropertyPriority>(state, range, true, applyIn heritedOnly); 1392 applyMatchedProperties<HighPropertyPriority>(state, range, true, applyIn heritedOnly);
1379 applyMatchedProperties<HighPropertyPriority>(state, matchResult.uaRules(), t rue, applyInheritedOnly); 1393 applyMatchedProperties<HighPropertyPriority>(state, matchResult.uaRules(), t rue, applyInheritedOnly);
1380 1394
1381 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1395 if (UNLIKELY(isSVGForeignObjectElement(element))) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 visitor->trace(m_watchedSelectorsRules); 1553 visitor->trace(m_watchedSelectorsRules);
1540 visitor->trace(m_treeBoundaryCrossingScopes); 1554 visitor->trace(m_treeBoundaryCrossingScopes);
1541 visitor->trace(m_styleResourceLoader); 1555 visitor->trace(m_styleResourceLoader);
1542 visitor->trace(m_styleSharingLists); 1556 visitor->trace(m_styleSharingLists);
1543 visitor->trace(m_pendingStyleSheets); 1557 visitor->trace(m_pendingStyleSheets);
1544 visitor->trace(m_document); 1558 visitor->trace(m_document);
1545 #endif 1559 #endif
1546 } 1560 }
1547 1561
1548 } // namespace blink 1562 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698