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

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

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Missing file :( Created 5 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 | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "core/css/CSSValueList.h" 52 #include "core/css/CSSValueList.h"
53 #include "core/css/CSSValuePool.h" 53 #include "core/css/CSSValuePool.h"
54 #include "core/css/ElementRuleCollector.h" 54 #include "core/css/ElementRuleCollector.h"
55 #include "core/css/FontFace.h" 55 #include "core/css/FontFace.h"
56 #include "core/css/MediaQueryEvaluator.h" 56 #include "core/css/MediaQueryEvaluator.h"
57 #include "core/css/PageRuleCollector.h" 57 #include "core/css/PageRuleCollector.h"
58 #include "core/css/StylePropertySet.h" 58 #include "core/css/StylePropertySet.h"
59 #include "core/css/StyleRuleImport.h" 59 #include "core/css/StyleRuleImport.h"
60 #include "core/css/StyleSheetContents.h" 60 #include "core/css/StyleSheetContents.h"
61 #include "core/css/resolver/AnimatedStyleBuilder.h" 61 #include "core/css/resolver/AnimatedStyleBuilder.h"
62 #include "core/css/resolver/CSSVariableResolver.h"
62 #include "core/css/resolver/MatchResult.h" 63 #include "core/css/resolver/MatchResult.h"
63 #include "core/css/resolver/MediaQueryResult.h" 64 #include "core/css/resolver/MediaQueryResult.h"
64 #include "core/css/resolver/ScopedStyleResolver.h" 65 #include "core/css/resolver/ScopedStyleResolver.h"
65 #include "core/css/resolver/SharedStyleFinder.h" 66 #include "core/css/resolver/SharedStyleFinder.h"
66 #include "core/css/resolver/StyleAdjuster.h" 67 #include "core/css/resolver/StyleAdjuster.h"
67 #include "core/css/resolver/StyleResolverParentScope.h" 68 #include "core/css/resolver/StyleResolverParentScope.h"
68 #include "core/css/resolver/StyleResolverState.h" 69 #include "core/css/resolver/StyleResolverState.h"
69 #include "core/css/resolver/StyleResolverStats.h" 70 #include "core/css/resolver/StyleResolverStats.h"
70 #include "core/css/resolver/ViewportStyleResolver.h" 71 #include "core/css/resolver/ViewportStyleResolver.h"
71 #include "core/dom/CSSSelectorWatch.h" 72 #include "core/dom/CSSSelectorWatch.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 document().textLinkColors().setTextColor(state.style()->color()); 631 document().textLinkColors().setTextColor(state.style()->color());
631 632
632 setAnimationUpdateIfNeeded(state, *element); 633 setAnimationUpdateIfNeeded(state, *element);
633 634
634 if (state.style()->hasViewportUnits()) 635 if (state.style()->hasViewportUnits())
635 document().setHasViewportUnits(); 636 document().setHasViewportUnits();
636 637
637 if (state.style()->hasRemUnits()) 638 if (state.style()->hasRemUnits())
638 document().styleEngine().setUsesRemUnit(true); 639 document().styleEngine().setUsesRemUnit(true);
639 640
641 if (state.style()->variables())
642 document().styleEngine().setUsesVariables(true);
643
640 // Now return the style. 644 // Now return the style.
641 return state.takeStyle(); 645 return state.takeStyle();
642 } 646 }
643 647
644 // This function is used by the WebAnimations JavaScript API method animate(). 648 // This function is used by the WebAnimations JavaScript API method animate().
645 // FIXME: Remove this when animate() switches away from resolution-dependent par sing. 649 // FIXME: Remove this when animate() switches away from resolution-dependent par sing.
646 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, const ComputedStyle* baseStyle, CSSPropertyID property, C SSValue* value) 650 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, const ComputedStyle* baseStyle, CSSPropertyID property, C SSValue* value)
647 { 651 {
648 StyleResolverState state(element.document(), &element); 652 StyleResolverState state(element.document(), &element);
649 state.setStyle(baseStyle ? ComputedStyle::clone(*baseStyle) : ComputedStyle: :create()); 653 state.setStyle(baseStyle ? ComputedStyle::clone(*baseStyle) : ComputedStyle: :create());
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. 1301 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it.
1298 state.style()->setInsideLink(linkStatus); 1302 state.style()->setInsideLink(linkStatus);
1299 1303
1300 updateFont(state); 1304 updateFont(state);
1301 1305
1302 return; 1306 return;
1303 } 1307 }
1304 applyInheritedOnly = true; 1308 applyInheritedOnly = true;
1305 } 1309 }
1306 1310
1311 // TODO(leviw): We need the proper bit for tracking whether we need to do th is work.
1312 if (RuntimeEnabledFeatures::cssVariablesEnabled()) {
1313 applyMatchedProperties<ResolveVariables>(state, matchResult, false, matc hResult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1314 applyMatchedProperties<ResolveVariables>(state, matchResult, true, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1315 // TODO(leviw): stop recalculating every time
1316 CSSVariableResolver::resolveVariableDefinitions(state);
1317 }
1318
1307 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1319 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1308 // high-priority properties first, i.e., those properties that other propert ies depend on. 1320 // high-priority properties first, i.e., those properties that other propert ies depend on.
1309 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1321 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1310 // and (4) normal important. 1322 // and (4) normal important.
1311 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, matc hResult.begin(), matchResult.end(), applyInheritedOnly); 1323 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, matc hResult.begin(), matchResult.end(), applyInheritedOnly);
1312 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); 1324 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1313 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly); 1325 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly);
1314 1326
1315 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1327 if (UNLIKELY(isSVGForeignObjectElement(element))) {
1316 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. 1328 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 visitor->trace(m_watchedSelectorsRules); 1451 visitor->trace(m_watchedSelectorsRules);
1440 visitor->trace(m_treeBoundaryCrossingRules); 1452 visitor->trace(m_treeBoundaryCrossingRules);
1441 visitor->trace(m_styleResourceLoader); 1453 visitor->trace(m_styleResourceLoader);
1442 visitor->trace(m_styleSharingLists); 1454 visitor->trace(m_styleSharingLists);
1443 visitor->trace(m_pendingStyleSheets); 1455 visitor->trace(m_pendingStyleSheets);
1444 visitor->trace(m_document); 1456 visitor->trace(m_document);
1445 #endif 1457 #endif
1446 } 1458 }
1447 1459
1448 } // namespace blink 1460 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698