| OLD | NEW |
| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 { | 386 { |
| 387 return static_cast<CSSPropertyID>(lastCSSProperty); | 387 return static_cast<CSSPropertyID>(lastCSSProperty); |
| 388 } | 388 } |
| 389 | 389 |
| 390 template <StyleResolver::StyleApplicationPass pass> | 390 template <StyleResolver::StyleApplicationPass pass> |
| 391 bool StyleResolver::isPropertyForPass(CSSPropertyID property) | 391 bool StyleResolver::isPropertyForPass(CSSPropertyID property) |
| 392 { | 392 { |
| 393 return firstCSSPropertyId<pass>() <= property && property <= lastCSSProperty
Id<pass>(); | 393 return firstCSSPropertyId<pass>() <= property && property <= lastCSSProperty
Id<pass>(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 // This method expands the 'all' shorthand property to longhand properties | |
| 397 // and applies the expanded longhand properties. | |
| 398 template <StyleResolver::StyleApplicationPass pass> | |
| 399 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal
ue) | |
| 400 { | |
| 401 bool isUnsetValue = !allValue->isInitialValue() && !allValue->isInheritedVal
ue(); | |
| 402 unsigned startCSSProperty = firstCSSPropertyId<pass>(); | |
| 403 unsigned endCSSProperty = lastCSSPropertyId<pass>(); | |
| 404 | |
| 405 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { | |
| 406 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); | |
| 407 | |
| 408 // StyleBuilder does not allow any expanded shorthands. | |
| 409 if (isExpandedShorthandForAll(propertyId)) | |
| 410 continue; | |
| 411 | |
| 412 // all shorthand spec says: | |
| 413 // The all property is a shorthand that resets all CSS properties | |
| 414 // except direction and unicode-bidi. | |
| 415 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand | |
| 416 // We skip applyProperty when a given property is unicode-bidi or | |
| 417 // direction. | |
| 418 if (!CSSProperty::isAffectedByAllProperty(propertyId)) | |
| 419 continue; | |
| 420 | |
| 421 CSSValue* value; | |
| 422 if (!isUnsetValue) { | |
| 423 value = allValue; | |
| 424 } else { | |
| 425 if (CSSPropertyMetadata::isInheritedProperty(propertyId)) | |
| 426 value = cssValuePool().createInheritedValue().get(); | |
| 427 else | |
| 428 value = cssValuePool().createExplicitInitialValue().get(); | |
| 429 } | |
| 430 StyleBuilder::applyProperty(propertyId, state, value); | |
| 431 } | |
| 432 } | |
| 433 | |
| 434 template <StyleResolver::StyleApplicationPass pass> | 396 template <StyleResolver::StyleApplicationPass pass> |
| 435 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, bool inheritedOnly) | 397 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, bool inheritedOnly) |
| 436 { | 398 { |
| 437 unsigned propertyCount = properties->propertyCount(); | 399 unsigned propertyCount = properties->propertyCount(); |
| 438 for (unsigned i = 0; i < propertyCount; ++i) { | 400 for (unsigned i = 0; i < propertyCount; ++i) { |
| 439 StylePropertySet::PropertyReference current = properties->propertyAt(i); | 401 StylePropertySet::PropertyReference current = properties->propertyAt(i); |
| 440 | 402 |
| 441 CSSPropertyID property = current.id(); | |
| 442 if (property == CSSPropertyAll) { | |
| 443 applyAllProperty<pass>(state, current.value()); | |
| 444 continue; | |
| 445 } | |
| 446 | |
| 447 if (inheritedOnly && !current.isInherited()) { | 403 if (inheritedOnly && !current.isInherited()) { |
| 448 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties | 404 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties |
| 449 // as they might override the value inherited here. For this reason
we don't allow declarations with | 405 // as they might override the value inherited here. For this reason
we don't allow declarations with |
| 450 // explicitly inherited properties to be cached. | 406 // explicitly inherited properties to be cached. |
| 451 ASSERT(!current.value()->isInheritedValue()); | 407 ASSERT(!current.value()->isInheritedValue()); |
| 452 continue; | 408 continue; |
| 453 } | 409 } |
| 454 | 410 |
| 411 CSSPropertyID property = current.id(); |
| 455 if (!isPropertyForPass<pass>(property)) | 412 if (!isPropertyForPass<pass>(property)) |
| 456 continue; | 413 continue; |
| 457 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) | 414 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) |
| 458 state.setLineHeightValue(current.value()); | 415 state.setLineHeightValue(current.value()); |
| 459 else | 416 else |
| 460 StyleBuilder::applyProperty(current.id(), state, current.value()); | 417 StyleBuilder::applyProperty(current.id(), state, current.value()); |
| 461 } | 418 } |
| 462 } | 419 } |
| 463 | 420 |
| 464 template <StyleResolver::StyleApplicationPass pass> | 421 template <StyleResolver::StyleApplicationPass pass> |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 break; | 549 break; |
| 593 default: | 550 default: |
| 594 break; | 551 break; |
| 595 } | 552 } |
| 596 StyleBuilder::applyProperty(properties[i].property, state, propertie
s[i].value); | 553 StyleBuilder::applyProperty(properties[i].property, state, propertie
s[i].value); |
| 597 } | 554 } |
| 598 } | 555 } |
| 599 } | 556 } |
| 600 | 557 |
| 601 } // namespace blink | 558 } // namespace blink |
| OLD | NEW |