Ignore:
Timestamp:
Sep 13, 2016, 12:08:30 PM (9 years ago)
Author:
[email protected]
Message:

[CSS Parser] Add CSS Variable Parsing support
https://bugs.webkit.org/show_bug.cgi?id=161916

Reviewed by Dean Jackson.

This patch not only adds the parser for CSS variables (from Blink), but it also brings in
all of the data structures used to store variables and custom property declarations. We
will be abandoning our old data structures eventually in favor of these new ones. They
are not significantly different other than operating on the CSSParserTokenRanges rather
than the soon-to-be-removed parser value lists.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSCustomIdentValue.cpp: Added.

(WebCore::CSSCustomIdentValue::CSSCustomIdentValue):
(WebCore::CSSCustomIdentValue::customCSSText):

  • css/CSSCustomIdentValue.h: Added.

(WebCore::CSSCustomIdentValue::create):
(WebCore::CSSCustomIdentValue::value):
(WebCore::CSSCustomIdentValue::isKnownPropertyID):
(WebCore::CSSCustomIdentValue::valueAsPropertyID):
(WebCore::CSSCustomIdentValue::equals):

  • css/CSSCustomPropertyDeclaration.cpp: Added.

(WebCore::CSSCustomPropertyDeclaration::customCSSText):

  • css/CSSCustomPropertyDeclaration.h: Added.

(WebCore::CSSCustomPropertyDeclaration::create):
(WebCore::CSSCustomPropertyDeclaration::name):
(WebCore::CSSCustomPropertyDeclaration::value):
(WebCore::CSSCustomPropertyDeclaration::id):
(WebCore::CSSCustomPropertyDeclaration::equals):
(WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration):

  • css/CSSCustomPropertyValue.h:
  • css/CSSValue.cpp:

(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isCustomPropertyDeclaration):
(WebCore::CSSValue::isCustomIdentValue):
(WebCore::CSSValue::isVariableReferenceValue):

  • css/CSSValueKeywords.in:
  • css/CSSVariableData.cpp: Added.

(WebCore::CSSVariableData::updateTokens):
(WebCore::CSSVariableData::operator==):
(WebCore::CSSVariableData::consumeAndUpdateTokens):
(WebCore::CSSVariableData::CSSVariableData):

  • css/CSSVariableData.h: Added.

(WebCore::CSSVariableData::create):
(WebCore::CSSVariableData::createResolved):
(WebCore::CSSVariableData::tokenRange):
(WebCore::CSSVariableData::tokens):
(WebCore::CSSVariableData::needsVariableResolution):
(WebCore::CSSVariableData::CSSVariableData):

  • css/CSSVariableDependentValue.h:
  • css/CSSVariableReferenceValue.cpp: Added.

(WebCore::CSSVariableReferenceValue::customCSSText):

  • css/CSSVariableReferenceValue.h: Added.

(WebCore::CSSVariableReferenceValue::create):
(WebCore::CSSVariableReferenceValue::variableDataValue):
(WebCore::CSSVariableReferenceValue::equals):
(WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue):

  • css/CSSVariableValue.h:
  • css/parser/CSSParserImpl.cpp:

(WebCore::filterProperties):
(WebCore::CSSParserImpl::consumeDeclaration):
(WebCore::CSSParserImpl::consumeVariableValue):

  • css/parser/CSSVariableParser.cpp: Added.

(WebCore::CSSVariableParser::isValidVariableName):
(WebCore::classifyBlock):
(WebCore::isValidVariableReference):
(WebCore::classifyVariableRange):
(WebCore::CSSVariableParser::containsValidVariableReferences):
(WebCore::CSSVariableParser::parseDeclarationValue):

  • css/parser/CSSVariableParser.h: Added.
File:
1 edited

Legend:

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

    r205093 r205869  
    3737#include "CSSCrossfadeValue.h"
    3838#include "CSSCursorImageValue.h"
     39#include "CSSCustomIdentValue.h"
     40#include "CSSCustomPropertyDeclaration.h"
    3941#include "CSSCustomPropertyValue.h"
    4042#include "CSSFilterImageValue.h"
     
    5961#include "CSSValueList.h"
    6062#include "CSSVariableDependentValue.h"
     63#include "CSSVariableReferenceValue.h"
    6164#include "CSSVariableValue.h"
    6265#include "SVGColor.h"
     
    363366    case VariableClass:
    364367        return downcast<CSSVariableValue>(*this).customCSSText();
     368    case CustomPropertyDeclarationClass:
     369        return downcast<CSSCustomPropertyDeclaration>(*this).customCSSText();
     370    case CustomIdentClass:
     371        return downcast<CSSCustomIdentValue>(*this).customCSSText();
     372    case VariableReferenceClass:
     373        return downcast<CSSVariableReferenceValue>(*this).customCSSText();
    365374    }
    366375
     
    505514    case VariableClass:
    506515        delete downcast<CSSVariableValue>(this);
     516        return;
     517    case CustomPropertyDeclarationClass:
     518        delete downcast<CSSCustomPropertyDeclaration>(this);
     519        return;
     520    case CustomIdentClass:
     521        delete downcast<CSSCustomIdentValue>(this);
     522        return;
     523    case VariableReferenceClass:
     524        delete downcast<CSSVariableReferenceValue>(this);
    507525        return;
    508526    }
Note: See TracChangeset for help on using the changeset viewer.