Ignore:
Timestamp:
Oct 15, 2015, 4:54:46 PM (10 years ago)
Author:
[email protected]
Message:

Add support for the CSS 'unset' keyword.
https://bugs.webkit.org/show_bug.cgi?id=148614

Reviewed by Dean Jackson.

Source/WebCore:

Added new test in fast/css, and existing variables tests also use unset in several tests.

  • WebCore.xcodeproj/project.pbxproj:

Add CSSUnsetValue.cpp to the project.

  • bindings/objc/DOMCSS.mm:

(kitClass):
Make sure UNSET is handled in the switch.

  • css/CSSParser.cpp:

(WebCore::parseKeywordValue):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseCustomPropertyDeclaration):
Add cases to create a CSSUnsetValue properly.

  • css/CSSToStyleMap.cpp:

(WebCore::CSSToStyleMap::styleImage):
(WebCore::CSSToStyleMap::mapFillAttachment):
(WebCore::CSSToStyleMap::mapFillClip):
(WebCore::CSSToStyleMap::mapFillComposite):
(WebCore::CSSToStyleMap::mapFillBlendMode):
(WebCore::CSSToStyleMap::mapFillOrigin):
(WebCore::CSSToStyleMap::mapFillImage):
(WebCore::CSSToStyleMap::mapFillRepeatX):
(WebCore::CSSToStyleMap::mapFillRepeatY):
(WebCore::convertToLengthSize):
(WebCore::CSSToStyleMap::mapFillSize):
(WebCore::CSSToStyleMap::mapFillXPosition):
(WebCore::CSSToStyleMap::mapFillYPosition):
(WebCore::CSSToStyleMap::mapFillMaskSourceType):
(WebCore::CSSToStyleMap::mapAnimationDelay):
(WebCore::CSSToStyleMap::mapAnimationDirection):
(WebCore::CSSToStyleMap::mapAnimationDuration):
(WebCore::CSSToStyleMap::mapAnimationFillMode):
(WebCore::CSSToStyleMap::mapAnimationIterationCount):
(WebCore::CSSToStyleMap::mapAnimationName):
(WebCore::CSSToStyleMap::mapAnimationPlayState):
(WebCore::CSSToStyleMap::mapAnimationProperty):
(WebCore::CSSToStyleMap::mapAnimationTimingFunction):
(WebCore::CSSToStyleMap::mapAnimationTrigger):
The background and animation functions need to check for unset and be able to map it properly to initial. This is done
with a new treatAsInitial method on CSSValue that can take the property ID and check for both initial
or unset on a non-inherited property.

  • css/CSSUnsetValue.cpp: Added.

(WebCore::CSSUnsetValue::customCSSText):

  • css/CSSUnsetValue.h: Added.

(WebCore::CSSUnsetValue::create):
(WebCore::CSSUnsetValue::equals):
(WebCore::CSSUnsetValue::CSSUnsetValue):
This new value looks exactly like CSSInheritedValue and CSSInitialValue.

  • css/CSSValue.cpp:

(WebCore::CSSValue::cssValueType):
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):
(WebCore::CSSValue::isInvalidCustomPropertyValue):
(WebCore::CSSValue::treatAsInheritedValue):
(WebCore::CSSValue::treatAsInitialValue):

  • css/CSSValue.h:

(WebCore::CSSValue::isUnsetValue):
Add isUnsetValue and the UnsetClass. Add support for treatAsInheritedValue and treatAsInitialValue to have
a way to query for initial/inherit or the matching unset type.

  • css/CSSValueKeywords.in:

Add the unset keyword.

  • css/CSSValuePool.cpp:

(WebCore::CSSValuePool::CSSValuePool):

  • css/CSSValuePool.h:

(WebCore::CSSValuePool::createUnsetValue):
Have a singleton model for unset just like we do for inherit/initial.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::applyProperty):
Handle unset correctly. It maps to inherit for inherited properties and initial for non-inherited ones.

LayoutTests:

Remove the 3 failing variables tests that used the unset keyword now that they pass.

  • fast/css/unset-keyword-expected.html: Added.
  • fast/css/unset-keyword.html: Added.

New test for both inherited and initial properties.

  • fast/css/variables/test-suite/129-expected.html: Added.
  • fast/css/variables/test-suite/129.html: Added.
  • fast/css/variables/test-suite/130-expected.html: Added.
  • fast/css/variables/test-suite/130.html: Added.
  • fast/css/variables/test-suite/134-expected.html: Added.
  • fast/css/variables/test-suite/134.html: Added.
  • fast/css/variables/test-suite/failures/129-expected.html: Removed.
  • fast/css/variables/test-suite/failures/129.html: Removed.
  • fast/css/variables/test-suite/failures/130-expected.html: Removed.
  • fast/css/variables/test-suite/failures/130.html: Removed.
  • fast/css/variables/test-suite/failures/134-expected.html: Removed.
  • fast/css/variables/test-suite/failures/134.html: Removed.

Move these tests into the passing directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSValue.cpp

    r191128 r191151  
    5151#include "CSSNamedImageValue.h"
    5252#include "CSSPrimitiveValue.h"
     53#include "CSSProperty.h"
    5354#include "CSSReflectValue.h"
    5455#include "CSSShadowValue.h"
    5556#include "CSSTimingFunctionValue.h"
    5657#include "CSSUnicodeRangeValue.h"
     58#include "CSSUnsetValue.h"
    5759#include "CSSValueList.h"
    5860#include "CSSVariableDependentValue.h"
     
    111113    if (isInitialValue())
    112114        return CSS_INITIAL;
     115    if (isUnsetValue())
     116        return CSS_UNSET;
    113117    return CSS_CUSTOM;
    114118}
     
    298302    case InitialClass:
    299303        return downcast<CSSInitialValue>(*this).customCSSText();
     304    case UnsetClass:
     305        return downcast<CSSUnsetValue>(*this).customCSSText();
    300306#if ENABLE(CSS_GRID_LAYOUT)
    301307    case GridLineNamesClass:
     
    407413        delete downcast<CSSInitialValue>(this);
    408414        return;
     415    case UnsetClass:
     416        delete downcast<CSSUnsetValue>(this);
     417        return;
    409418#if ENABLE(CSS_GRID_LAYOUT)
    410419    case GridLineNamesClass:
     
    516525}
    517526
    518 }
     527bool CSSValue::treatAsInheritedValue(CSSPropertyID propertyID) const
     528{
     529    return classType() == InheritedClass || (classType() == UnsetClass && CSSProperty::isInheritedProperty(propertyID));
     530}
     531
     532bool CSSValue::treatAsInitialValue(CSSPropertyID propertyID) const
     533{
     534    return classType() == InitialClass || (classType() == UnsetClass && !CSSProperty::isInheritedProperty(propertyID));
     535}
     536
     537}
Note: See TracChangeset for help on using the changeset viewer.