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

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

Issue 1645433002: Basic implementation of @apply (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix expted.txt for failing test Created 4 years, 10 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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #include "core/dom/Text.h" 77 #include "core/dom/Text.h"
78 #include "core/dom/shadow/ElementShadow.h" 78 #include "core/dom/shadow/ElementShadow.h"
79 #include "core/dom/shadow/ShadowRoot.h" 79 #include "core/dom/shadow/ShadowRoot.h"
80 #include "core/frame/FrameView.h" 80 #include "core/frame/FrameView.h"
81 #include "core/frame/LocalFrame.h" 81 #include "core/frame/LocalFrame.h"
82 #include "core/frame/Settings.h" 82 #include "core/frame/Settings.h"
83 #include "core/html/HTMLIFrameElement.h" 83 #include "core/html/HTMLIFrameElement.h"
84 #include "core/inspector/InspectorInstrumentation.h" 84 #include "core/inspector/InspectorInstrumentation.h"
85 #include "core/layout/GeneratedChildren.h" 85 #include "core/layout/GeneratedChildren.h"
86 #include "core/layout/LayoutView.h" 86 #include "core/layout/LayoutView.h"
87 #include "core/style/StyleVariableData.h"
87 #include "core/svg/SVGDocumentExtensions.h" 88 #include "core/svg/SVGDocumentExtensions.h"
88 #include "core/svg/SVGElement.h" 89 #include "core/svg/SVGElement.h"
89 #include "platform/RuntimeEnabledFeatures.h" 90 #include "platform/RuntimeEnabledFeatures.h"
90 #include "wtf/StdLibExtras.h" 91 #include "wtf/StdLibExtras.h"
91 92
92 namespace { 93 namespace {
93 94
94 using namespace blink; 95 using namespace blink;
95 96
96 void setAnimationUpdateIfNeeded(StyleResolverState& state, Element& element) 97 void setAnimationUpdateIfNeeded(StyleResolverState& state, Element& element)
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 // When hitting matched properties' cache, only inherited properties wil l be 1263 // When hitting matched properties' cache, only inherited properties wil l be
1263 // applied. 1264 // applied.
1264 if (inheritedOnly && !CSSPropertyMetadata::isInheritedProperty(propertyI d)) 1265 if (inheritedOnly && !CSSPropertyMetadata::isInheritedProperty(propertyI d))
1265 continue; 1266 continue;
1266 1267
1267 StyleBuilder::applyProperty(propertyId, state, allValue); 1268 StyleBuilder::applyProperty(propertyId, state, allValue);
1268 } 1269 }
1269 } 1270 }
1270 1271
1271 template <CSSPropertyPriority priority> 1272 template <CSSPropertyPriority priority>
1273 void StyleResolver::applyPropertiesForApplyAtRule(StyleResolverState& state, con st CSSValue* value, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
1274 {
1275 if (priority == ResolveVariables)
1276 return;
1277 if (!state.style()->variables())
1278 return;
1279 AtomicString name(toCSSCustomIdentValue(value)->value());
1280 CSSVariableData* variableData = state.style()->variables()->getVariable(name );
1281 if (!variableData)
1282 return;
1283 const StylePropertySet* propertySet = variableData->propertySet();
1284 if (propertySet)
1285 applyProperties<priority>(state, propertySet, isImportant, inheritedOnly , propertyWhitelistType);
1286 }
1287
1288 template <CSSPropertyPriority priority>
1272 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, bool isImportant, bool inheritedOnly, PropertyWhitelistType p ropertyWhitelistType) 1289 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, bool isImportant, bool inheritedOnly, PropertyWhitelistType p ropertyWhitelistType)
1273 { 1290 {
1274 unsigned propertyCount = properties->propertyCount(); 1291 unsigned propertyCount = properties->propertyCount();
1275 for (unsigned i = 0; i < propertyCount; ++i) { 1292 for (unsigned i = 0; i < propertyCount; ++i) {
1276 StylePropertySet::PropertyReference current = properties->propertyAt(i); 1293 StylePropertySet::PropertyReference current = properties->propertyAt(i);
1294 CSSPropertyID property = current.id();
1295
1296 if (property == CSSPropertyApplyAtRule) {
1297 applyPropertiesForApplyAtRule<priority>(state, current.value(), isIm portant, inheritedOnly, propertyWhitelistType);
1298 continue;
1299 }
1300
1277 if (isImportant != current.isImportant()) 1301 if (isImportant != current.isImportant())
1278 continue; 1302 continue;
1279 1303
1280 CSSPropertyID property = current.id();
1281 if (property == CSSPropertyAll) { 1304 if (property == CSSPropertyAll) {
1282 applyAllProperty<priority>(state, current.value(), inheritedOnly, pr opertyWhitelistType); 1305 applyAllProperty<priority>(state, current.value(), inheritedOnly, pr opertyWhitelistType);
1283 continue; 1306 continue;
1284 } 1307 }
1285 1308
1286 if (!isPropertyInWhitelist(propertyWhitelistType, property, document())) 1309 if (!isPropertyInWhitelist(propertyWhitelistType, property, document()))
1287 continue; 1310 continue;
1288 1311
1289 if (inheritedOnly && !current.isInherited()) { 1312 if (inheritedOnly && !current.isInherited()) {
1290 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties 1313 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 visitor->trace(m_uncommonAttributeRuleSet); 1581 visitor->trace(m_uncommonAttributeRuleSet);
1559 visitor->trace(m_watchedSelectorsRules); 1582 visitor->trace(m_watchedSelectorsRules);
1560 visitor->trace(m_treeBoundaryCrossingScopes); 1583 visitor->trace(m_treeBoundaryCrossingScopes);
1561 visitor->trace(m_styleSharingLists); 1584 visitor->trace(m_styleSharingLists);
1562 visitor->trace(m_pendingStyleSheets); 1585 visitor->trace(m_pendingStyleSheets);
1563 visitor->trace(m_document); 1586 visitor->trace(m_document);
1564 #endif 1587 #endif
1565 } 1588 }
1566 1589
1567 } // namespace blink 1590 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698