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

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

Issue 18311002: Partial implementation of CSSVariablesMap for CSS Variables CSSOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased onto ToT, cleaned up includes Created 7 years, 5 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
« no previous file with comments | « Source/core/css/StylePropertySet.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 1344
1345 knownExpressions.append(expression); 1345 knownExpressions.append(expression);
1346 1346
1347 // FIXME: It would be faster not to re-parse from strings, but for now CSS p roperty validation lives inside the parser so we do it there. 1347 // FIXME: It would be faster not to re-parse from strings, but for now CSS p roperty validation lives inside the parser so we do it there.
1348 RefPtr<MutableStylePropertySet> resultSet = MutableStylePropertySet::create( ); 1348 RefPtr<MutableStylePropertySet> resultSet = MutableStylePropertySet::create( );
1349 if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, do cument())) 1349 if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, do cument()))
1350 return; // expression failed to parse. 1350 return; // expression failed to parse.
1351 1351
1352 for (unsigned i = 0; i < resultSet->propertyCount(); i++) { 1352 for (unsigned i = 0; i < resultSet->propertyCount(); i++) {
1353 StylePropertySet::PropertyReference property = resultSet->propertyAt(i); 1353 StylePropertySet::PropertyReference property = resultSet->propertyAt(i);
1354 if (property.id() != CSSPropertyVariable && hasVariableReference(propert y.value())) 1354 if (property.id() != CSSPropertyVariable && hasVariableReference(propert y.value())) {
1355 resolveVariables(property.id(), property.value(), knownExpressions); 1355 resolveVariables(property.id(), property.value(), knownExpressions);
1356 else 1356 } else {
1357 applyProperty(property.id(), property.value()); 1357 applyProperty(property.id(), property.value());
1358 // All properties become dependent on their parent style when they u se variables.
1359 m_state.style()->setHasExplicitlyInheritedProperties();
1360 }
1358 } 1361 }
1359 } 1362 }
1360 1363
1361 void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) 1364 void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
1362 { 1365 {
1363 if (id != CSSPropertyVariable && hasVariableReference(value)) { 1366 if (id != CSSPropertyVariable && hasVariableReference(value)) {
1364 Vector<std::pair<CSSPropertyID, String> > knownExpressions; 1367 Vector<std::pair<CSSPropertyID, String> > knownExpressions;
1365 resolveVariables(id, value, knownExpressions); 1368 resolveVariables(id, value, knownExpressions);
1366 return; 1369 return;
1367 } 1370 }
(...skipping 15 matching lines...) Expand all
1383 1386
1384 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0; 1387 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0;
1385 if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor) 1388 if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor)
1386 state.style()->setHasCurrentColor(); 1389 state.style()->setHasCurrentColor();
1387 1390
1388 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) 1391 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
1389 state.parentStyle()->setHasExplicitlyInheritedProperties(); 1392 state.parentStyle()->setHasExplicitlyInheritedProperties();
1390 1393
1391 if (id == CSSPropertyVariable) { 1394 if (id == CSSPropertyVariable) {
1392 ASSERT_WITH_SECURITY_IMPLICATION(value->isVariableValue()); 1395 ASSERT_WITH_SECURITY_IMPLICATION(value->isVariableValue());
1393 CSSVariableValue* variable = static_cast<CSSVariableValue*>(value); 1396 CSSVariableValue* variable = toCSSVariableValue(value);
1394 ASSERT(!variable->name().isEmpty()); 1397 ASSERT(!variable->name().isEmpty());
1395 ASSERT(!variable->value().isEmpty()); 1398 ASSERT(!variable->value().isEmpty());
1396 state.style()->setVariable(variable->name(), variable->value()); 1399 state.style()->setVariable(variable->name(), variable->value());
1397 return; 1400 return;
1398 } 1401 }
1399 1402
1400 if (StyleBuilder::applyProperty(id, this, state, value, isInitial, isInherit )) 1403 if (StyleBuilder::applyProperty(id, this, state, value, isInitial, isInherit ))
1401 return; 1404 return;
1402 1405
1403 // Fall back to the old switch statement, which is now in StyleBuilderCustom .cpp 1406 // Fall back to the old switch statement, which is now in StyleBuilderCustom .cpp
1404 StyleBuilder::oldApplyProperty(id, this, state, value, isInitial, isInherit) ; 1407 StyleBuilder::oldApplyProperty(id, this, state, value, isInitial, isInherit) ;
1405 } 1408 }
1406 1409
1407 void StyleResolver::addViewportDependentMediaQueryResult(const MediaQueryExp* ex pr, bool result) 1410 void StyleResolver::addViewportDependentMediaQueryResult(const MediaQueryExp* ex pr, bool result)
1408 { 1411 {
1409 m_viewportDependentMediaQueryResults.append(adoptPtr(new MediaQueryResult(*e xpr, result))); 1412 m_viewportDependentMediaQueryResults.append(adoptPtr(new MediaQueryResult(*e xpr, result)));
1410 } 1413 }
1411 1414
1412 bool StyleResolver::affectedByViewportChange() const 1415 bool StyleResolver::affectedByViewportChange() const
1413 { 1416 {
1414 unsigned s = m_viewportDependentMediaQueryResults.size(); 1417 unsigned s = m_viewportDependentMediaQueryResults.size();
1415 for (unsigned i = 0; i < s; i++) { 1418 for (unsigned i = 0; i < s; i++) {
1416 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) 1419 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result)
1417 return true; 1420 return true;
1418 } 1421 }
1419 return false; 1422 return false;
1420 } 1423 }
1421 1424
1422 } // namespace WebCore 1425 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySet.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698