Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (206006 => 206007)
--- trunk/Source/WebCore/CMakeLists.txt 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-09-16 00:33:45 UTC (rev 206007)
@@ -1332,6 +1332,7 @@
css/SVGCSSComputedStyleDeclaration.cpp
css/SelectorChecker.cpp
css/SelectorFilter.cpp
+ css/StyleColor.cpp
css/StyleInvalidationAnalysis.cpp
css/StyleMedia.cpp
css/StyleProperties.cpp
Modified: trunk/Source/WebCore/ChangeLog (206006 => 206007)
--- trunk/Source/WebCore/ChangeLog 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/ChangeLog 2016-09-16 00:33:45 UTC (rev 206007)
@@ -1,3 +1,73 @@
+2016-09-15 Dave Hyatt <[email protected]>
+
+ [CSS Parser] Get CSSParserFastPaths.cpp compiling
+ https://bugs.webkit.org/show_bug.cgi?id=162033
+
+ Reviewed by Dean Jackson.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new StyleColor.h/.cpp files to the projecty
+
+ * css/CSSFunctionValue.cpp:
+ (WebCore::CSSFunctionValue::CSSFunctionValue):
+ (WebCore::CSSFunctionValue::customCSSText):
+ (WebCore::CSSFunctionValue::append):
+ (WebCore::CSSFunctionValue::buildParserValueSubstitutingVariables):
+ * css/CSSFunctionValue.h:
+ Tweak CSSFunctionValue so that the name can be represented as a keyword ID instead of a String. Eventually we also
+ want to make CSSFunctionValue subclass CSSValueList rather than referencing a separate CSSValueList as a member. For now
+ I left that alone though in order to not change too much in the old parser.
+
+ * css/CSSProperty.cpp:
+ (WebCore::CSSProperty::isDescriptorOnly):
+ Whether or not a property is only a descriptor, e.g., used in viewport and font face stuff.
+
+ * css/CSSProperty.h:
+ * css/CSSValueKeywords.in:
+ Added new keywords for functions that can be used as values. The new parser uses keywords to represent function names.
+
+ * css/StyleColor.cpp: Added.
+ (WebCore::StyleColor::colorFromKeyword):
+ (WebCore::StyleColor::isColorKeyword):
+ (WebCore::StyleColor::isSystemColor):
+ * css/StyleColor.h: Added.
+ (WebCore::StyleColor::StyleColor):
+ (WebCore::StyleColor::currentColor):
+ (WebCore::StyleColor::isCurrentColor):
+ (WebCore::StyleColor::getColor):
+ (WebCore::StyleColor::resolve):
+ (WebCore::operator==):
+ (WebCore::operator!=):
+ New color helper that contains code for checking and looking up colors. This code is similar to some code we already
+ had in the old CSSParser.cpp file, but this way it can be used outside the parser and/or in different files.
+
+ * css/parser/CSSParserFastPaths.cpp:
+ (WebCore::parseSimpleLengthValue):
+ (WebCore::isColorPropertyID):
+ (WebCore::parseColorIntOrPercentage):
+ (WebCore::fastParseColorInternal):
+ (WebCore::CSSParserFastPaths::parseColor):
+ (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
+ (WebCore::isUniversalKeyword):
+ (WebCore::parseKeywordValue):
+ (WebCore::parseTransformTranslateArguments):
+ (WebCore::parseTransformNumberArguments):
+ (WebCore::parseSimpleTransformValue):
+ (WebCore::transformCanLikelyUseFastPath):
+ (WebCore::parseSimpleTransformList):
+ (WebCore::parseSimpleTransform):
+ (WebCore::CSSParserFastPaths::maybeParseValue):
+ * css/parser/CSSParserFastPaths.h:
+ Get everything compiling in this file. Key changes included reverting to our old unit names, making CSSFunctionValue compatible,
+ adding support for StyleColor, adding support for mode checking of keywords, and fixing up the memory management model so that
+ RefPtrs are used on returns from parsing functions.
+
+ * css/parser/CSSParserIdioms.cpp:
+ (WebCore::isValueAllowedInMode):
+ * css/parser/CSSParserIdioms.h:
+ New helper function for restricting keywords to certain modes only. The -webkit-text color quirk has been moved to this function.
+
2016-09-15 Brady Eidson <[email protected]>
WKWebView.hasOnlySecureContent always returns "YES" after going back to a CachedPage (even if it has http resources).
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206006 => 206007)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-16 00:33:45 UTC (rev 206007)
@@ -3339,6 +3339,8 @@
93F9B7A00BA6032600854064 /* JSCDATASection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F9B79E0BA6032600854064 /* JSCDATASection.cpp */; };
93F9B7A10BA6032600854064 /* JSCDATASection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F9B79F0BA6032600854064 /* JSCDATASection.h */; };
93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDAFC90B11307400E2746F /* EditorInsertAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 9418278A1D8B244000492764 /* StyleColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 941827881D8B242200492764 /* StyleColor.cpp */; };
+ 9418278B1D8B244000492764 /* StyleColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 941827891D8B242200492764 /* StyleColor.h */; };
9444CBD31D860C8B0073A074 /* SizesCalcParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBD01D860C740073A074 /* SizesCalcParser.cpp */; };
9444CBD41D860C8B0073A074 /* SizesCalcParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBCF1D860C740073A074 /* SizesCalcParser.h */; };
9444CBD51D860C8B0073A074 /* SizesAttributeParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBD21D860C740073A074 /* SizesAttributeParser.cpp */; };
@@ -9377,8 +9379,8 @@
5C5381AF1D8793E000E2EBE6 /* URLSearchParams.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = URLSearchParams.idl; sourceTree = "<group>"; };
5C5381B01D87D45700E2EBE6 /* URLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLSearchParams.cpp; sourceTree = "<group>"; };
5C5381B11D87D45700E2EBE6 /* URLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSearchParams.h; sourceTree = "<group>"; };
- 5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSURLSearchParams.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; };
- 5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSURLSearchParams.h; path = JSURLSearchParams.h; sourceTree = "<group>"; };
+ 5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; };
+ 5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSURLSearchParams.h; sourceTree = "<group>"; };
5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; };
5C688AA21D38126F000B54FA /* SocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketProvider.cpp; sourceTree = "<group>"; };
5C6E653F1D5CEDC900F7862E /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
@@ -10507,6 +10509,8 @@
93F9B79E0BA6032600854064 /* JSCDATASection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCDATASection.cpp; sourceTree = "<group>"; };
93F9B79F0BA6032600854064 /* JSCDATASection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCDATASection.h; sourceTree = "<group>"; };
93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; };
+ 941827881D8B242200492764 /* StyleColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleColor.cpp; sourceTree = "<group>"; };
+ 941827891D8B242200492764 /* StyleColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleColor.h; sourceTree = "<group>"; };
9444CBCF1D860C740073A074 /* SizesCalcParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SizesCalcParser.h; path = parser/SizesCalcParser.h; sourceTree = "<group>"; };
9444CBD01D860C740073A074 /* SizesCalcParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SizesCalcParser.cpp; path = parser/SizesCalcParser.cpp; sourceTree = "<group>"; };
9444CBD11D860C740073A074 /* SizesAttributeParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SizesAttributeParser.h; path = parser/SizesAttributeParser.h; sourceTree = "<group>"; };
@@ -22548,6 +22552,8 @@
8386A96C19F61B2E00E1EC4A /* StyleBuilder.h */,
83B9687919F8AB83004EF7AF /* StyleBuilderConverter.h */,
835D363619FF6193004C93AB /* StyleBuilderCustom.h */,
+ 941827881D8B242200492764 /* StyleColor.cpp */,
+ 941827891D8B242200492764 /* StyleColor.h */,
E47A97CE163059FC005DCD99 /* StyleInvalidationAnalysis.cpp */,
E47A97CF163059FC005DCD99 /* StyleInvalidationAnalysis.h */,
0FF5026E102BA9660066F39A /* StyleMedia.cpp */,
@@ -25657,6 +25663,7 @@
CEEFCD7A19DB31F7003876D7 /* MediaResourceLoader.h in Headers */,
1BF9DB3C1D3973AD0026AEB7 /* MediaSample.h in Headers */,
1B124D8D1D380B7000ECDFB0 /* MediaSampleAVFObjC.h in Headers */,
+ 9418278B1D8B244000492764 /* StyleColor.h in Headers */,
CDBEAEAD19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h in Headers */,
C9027F421B1D0AD200BFBFEF /* MediaSession.h in Headers */,
C9F87CFE1B28F40E00979B83 /* MediaSessionEvents.h in Headers */,
@@ -27973,6 +27980,7 @@
5C9A7A761AA0F6ED00958ACF /* DFABytecodeInterpreter.cpp in Sources */,
26A807841B18F97700E219BE /* DFACombiner.cpp in Sources */,
26A517FD1AB92238006335DF /* DFAMinimizer.cpp in Sources */,
+ 9418278A1D8B244000492764 /* StyleColor.cpp in Sources */,
26D4E8461B42539D00E033A2 /* DFANode.cpp in Sources */,
CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */,
CECADFC6153778FF00E37068 /* DictationAlternative.cpp in Sources */,
Modified: trunk/Source/WebCore/css/CSSFunctionValue.cpp (206006 => 206007)
--- trunk/Source/WebCore/css/CSSFunctionValue.cpp 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/CSSFunctionValue.cpp 2016-09-16 00:33:45 UTC (rev 206007)
@@ -34,7 +34,7 @@
CSSFunctionValue::CSSFunctionValue(CSSParserFunction* function)
: CSSValue(FunctionClass)
- , m_name(function->name)
+ , m_nameDeprecated(function->name)
, m_args(function->args ? RefPtr<CSSValueList>(CSSValueList::createFromParserValueList(*function->args)) : nullptr)
{
}
@@ -41,15 +41,25 @@
CSSFunctionValue::CSSFunctionValue(const String& name, Ref<CSSValueList>&& args)
: CSSValue(FunctionClass)
- , m_name(name)
+ , m_nameDeprecated(name)
, m_args(WTFMove(args))
{
}
+CSSFunctionValue::CSSFunctionValue(CSSValueID keyword)
+ : CSSValue(FunctionClass)
+ , m_name(keyword)
+{
+}
+
String CSSFunctionValue::customCSSText() const
{
StringBuilder result;
- result.append(m_name); // Includes the '('
+ if (m_name != CSSValueInvalid) {
+ result.append(getValueName(m_name));
+ result.append('(');
+ } else
+ result.append(m_nameDeprecated); // Includes the '('
if (m_args)
result.append(m_args->cssText());
result.append(')');
@@ -61,12 +71,19 @@
return m_name == other.m_name && compareCSSValuePtr(m_args, other.m_args);
}
+void CSSFunctionValue::append(Ref<CSSValue>&& value)
+{
+ if (!m_args)
+ m_args = CSSValueList::createCommaSeparated();
+ m_args->append(WTFMove(value));
+}
+
bool CSSFunctionValue::buildParserValueSubstitutingVariables(CSSParserValue* result, const CustomPropertyValueMap& customProperties) const
{
result->id = CSSValueInvalid;
result->unit = CSSParserValue::Function;
result->function = new CSSParserFunction;
- result->function->name.init(m_name);
+ result->function->name.init(m_nameDeprecated);
bool success = true;
if (m_args) {
CSSParserValueList* argList = new CSSParserValueList;
Modified: trunk/Source/WebCore/css/CSSFunctionValue.h (206006 => 206007)
--- trunk/Source/WebCore/css/CSSFunctionValue.h 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/CSSFunctionValue.h 2016-09-16 00:33:45 UTC (rev 206007)
@@ -26,6 +26,7 @@
#pragma once
#include "CSSValue.h"
+#include "CSSValueKeywords.h"
namespace WebCore {
@@ -33,6 +34,7 @@
struct CSSParserFunction;
struct CSSParserValue;
+// FIXME-NEWPARSER: This can just *be* a CSSValueList subclass.
class CSSFunctionValue final : public CSSValue {
public:
static Ref<CSSFunctionValue> create(CSSParserFunction* function)
@@ -45,6 +47,11 @@
return adoptRef(*new CSSFunctionValue(name, WTFMove(args)));
}
+ static Ref<CSSFunctionValue> create(CSSValueID keyword)
+ {
+ return adoptRef(*new CSSFunctionValue(keyword));
+ }
+
String customCSSText() const;
bool equals(const CSSFunctionValue&) const;
@@ -52,12 +59,18 @@
CSSValueList* arguments() const { return m_args.get(); }
bool buildParserValueSubstitutingVariables(CSSParserValue*, const CustomPropertyValueMap& customProperties) const;
-
+
+ void append(Ref<CSSValue>&&);
+
private:
explicit CSSFunctionValue(CSSParserFunction*);
CSSFunctionValue(const String&, Ref<CSSValueList>&&);
+ CSSFunctionValue(CSSValueID);
- String m_name;
+ CSSValueID m_name { CSSValueInvalid };
+
+ // FIXME-NEWPARSER: Remove these.
+ String m_nameDeprecated;
RefPtr<CSSValueList> m_args;
};
Modified: trunk/Source/WebCore/css/CSSProperty.cpp (206006 => 206007)
--- trunk/Source/WebCore/css/CSSProperty.cpp 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/CSSProperty.cpp 2016-09-16 00:33:45 UTC (rev 206007)
@@ -154,6 +154,23 @@
}
}
+bool CSSProperty::isDescriptorOnly(CSSPropertyID propertyID)
+{
+ switch (propertyID) {
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ case CSSPropertyMinZoom:
+ case CSSPropertyMaxZoom:
+ case CSSPropertyOrientation:
+ case CSSPropertyUserZoom:
+#endif
+ case CSSPropertySrc:
+ case CSSPropertyUnicodeRange:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool CSSProperty::isDirectionAwareProperty(CSSPropertyID propertyID)
{
switch (propertyID) {
Modified: trunk/Source/WebCore/css/CSSProperty.h (206006 => 206007)
--- trunk/Source/WebCore/css/CSSProperty.h 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/CSSProperty.h 2016-09-16 00:33:45 UTC (rev 206007)
@@ -79,6 +79,7 @@
static CSSPropertyID resolveDirectionAwareProperty(CSSPropertyID, TextDirection, WritingMode);
static bool isInheritedProperty(CSSPropertyID);
static bool isDirectionAwareProperty(CSSPropertyID);
+ static bool isDescriptorOnly(CSSPropertyID);
const StylePropertyMetadata& metadata() const { return m_metadata; }
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (206006 => 206007)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2016-09-16 00:33:45 UTC (rev 206007)
@@ -1149,6 +1149,88 @@
// none
scale-down
+// background-image, etc.
+linear-gradient
+radial-gradient
+repeating-linear-gradient
+repeating-radial-gradient
+paint
+-webkit-cross-fade
+-webkit-gradient
+-webkit-linear-gradient
+-webkit-radial-gradient
+-webkit-repeating-linear-gradient
+-webkit-repeating-radial-gradient
+-webkit-image-set
+
+// deprecated gradients
+from
+to
+color-stop
+radial
+
+// content
+attr
+counter
+counters
+
+// clip
+rect
+
+// shapes
+polygon
+
+// @font-face src
+format
+
+// (-webkit-)filter
+// invert
+grayscale
+sepia
+saturate
+hue-rotate
+opacity
+brightness
+contrast
+blur
+drop-shadow
+url
+
+// colors
+rgb
+rgba
+hsl
+hsla
+
+// transform
+matrix
+matrix3d
+perspective
+rotate
+rotateX
+rotateY
+rotateZ
+rotate3d
+scale
+scaleX
+scaleY
+scaleZ
+scale3d
+skew
+skewX
+skewY
+translate
+translateX
+translateY
+translateZ
+translate3d
+
+// motion path
+path
+
+calc
+-webkit-calc
+
#if defined(ENABLE_CSS_IMAGE_RESOLUTION) && ENABLE_CSS_IMAGE_RESOLUTION
from-image
snap
Added: trunk/Source/WebCore/css/StyleColor.cpp (0 => 206007)
--- trunk/Source/WebCore/css/StyleColor.cpp (rev 0)
+++ trunk/Source/WebCore/css/StyleColor.cpp 2016-09-16 00:33:45 UTC (rev 206007)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "StyleColor.h"
+
+#include "HashTools.h"
+#include "RenderTheme.h"
+
+namespace WebCore {
+
+Color StyleColor::colorFromKeyword(CSSValueID keyword)
+{
+ if (const char* valueName = getValueName(keyword)) {
+ if (const NamedColor* namedColor = findColor(valueName, strlen(valueName)))
+ return Color(namedColor->ARGBValue);
+ }
+ return RenderTheme::defaultTheme()->systemColor(keyword);
+}
+
+bool StyleColor::isColorKeyword(CSSValueID id)
+{
+ return (id >= CSSValueAlpha && id <= CSSValueWebkitText) || id == CSSValueMenu;
+}
+
+bool StyleColor::isSystemColor(CSSValueID id)
+{
+ return (id >= CSSValueActiveborder && id <= CSSValueAppleSystemYellow) || id == CSSValueMenu || id == CSSValueWebkitFocusRingColor;
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/css/StyleColor.h (0 => 206007)
--- trunk/Source/WebCore/css/StyleColor.h (rev 0)
+++ trunk/Source/WebCore/css/StyleColor.h 2016-09-16 00:33:45 UTC (rev 206007)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CSSValueKeywords.h"
+#include "Color.h"
+
+namespace WebCore {
+
+class StyleColor {
+public:
+ StyleColor()
+ : m_currentColor(true) { }
+ StyleColor(Color color)
+ : m_color(color)
+ , m_currentColor(false) { }
+ static StyleColor currentColor() { return StyleColor(); }
+
+ bool isCurrentColor() const { return m_currentColor; }
+ Color getColor() const { ASSERT(!isCurrentColor()); return m_color; }
+
+ Color resolve(Color currentColor) const { return m_currentColor ? currentColor : m_color; }
+
+ static Color colorFromKeyword(CSSValueID);
+ static bool isColorKeyword(CSSValueID);
+ static bool isSystemColor(CSSValueID);
+
+private:
+ Color m_color;
+ bool m_currentColor;
+};
+
+inline bool operator==(const StyleColor& a, const StyleColor& b)
+{
+ if (a.isCurrentColor() || b.isCurrentColor())
+ return a.isCurrentColor() && b.isCurrentColor();
+ return a.getColor() == b.getColor();
+}
+
+inline bool operator!=(const StyleColor& a, const StyleColor& b)
+{
+ return !(a == b);
+}
+
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (206006 => 206007)
--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2016-09-16 00:33:45 UTC (rev 206007)
@@ -30,7 +30,6 @@
#include "config.h"
#include "CSSParserFastPaths.h"
-// FIXME-NEWPARSER: #include "CSSColorValue.h"
#include "CSSFunctionValue.h"
#include "CSSInheritedValue.h"
#include "CSSInitialValue.h"
@@ -37,15 +36,15 @@
#include "CSSParserIdioms.h"
#include "CSSPrimitiveValue.h"
#include "CSSPropertyParser.h"
+#include "CSSValueList.h"
+#include "CSSValuePool.h"
#include "HTMLParserIdioms.h"
#include "RuntimeEnabledFeatures.h"
-// FIXME-NEWPARSER: #include "StyleColor.h"
+#include "StyleColor.h"
#include "StylePropertyShorthand.h"
namespace WebCore {
-/* FIXME-NEWPARSER: Turn off for now.
-
static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acceptsNegativeNumbers)
{
switch (propertyId) {
@@ -120,7 +119,7 @@
return true;
}
-static CSSValue* parseSimpleLengthValue(CSSPropertyID propertyId, const String& string, CSSParserMode cssParserMode)
+static RefPtr<CSSValue> parseSimpleLengthValue(CSSPropertyID propertyId, const String& string, CSSParserMode cssParserMode)
{
ASSERT(!string.isEmpty());
bool acceptsNegativeNumbers = false;
@@ -131,7 +130,7 @@
unsigned length = string.length();
double number;
- CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::UnitTypes::Number;
+ CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::UnitTypes::CSS_NUMBER;
if (string.is8Bit()) {
if (!parseSimpleLength(string.characters8(), length, unit, number))
@@ -141,12 +140,10 @@
return nullptr;
}
- if (unit == CSSPrimitiveValue::UnitTypes::Number) {
- if (cssParserMode == SVGAttributeMode)
- unit = CSSPrimitiveValue::UnitTypes::UserUnits;
- else if (!number)
- unit = CSSPrimitiveValue::UnitTypes::Pixels;
- else
+ if (unit == CSSPrimitiveValue::UnitTypes::CSS_NUMBER) {
+ if (!number)
+ unit = CSSPrimitiveValue::UnitTypes::CSS_PX;
+ else if (cssParserMode != SVGAttributeMode)
return nullptr;
}
@@ -179,7 +176,7 @@
case CSSPropertyWebkitTextEmphasisColor:
case CSSPropertyWebkitTextFillColor:
case CSSPropertyWebkitTextStrokeColor:
- case CSSPropertyTextDecorationColor:
+ case CSSPropertyWebkitTextDecorationColor:
return true;
default:
return false;
@@ -284,7 +281,7 @@
if (current == end)
return false;
- if (expect == CSSPrimitiveValue::UnitTypes::Number && (*current == '.' || *current == '%'))
+ if (expect == CSSPrimitiveValue::UnitTypes::CSS_NUMBER && (*current == '.' || *current == '%'))
return false;
if (*current == '.') {
@@ -300,11 +297,11 @@
localValue += percentage;
}
- if (expect == CSSPrimitiveValue::UnitTypes::Percentage && *current != '%')
+ if (expect == CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE && *current != '%')
return false;
if (*current == '%') {
- expect = CSSPrimitiveValue::UnitTypes::Percentage;
+ expect = CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE;
localValue = localValue / 100.0 * 256.0;
// Clamp values at 255 for percentages over 100%
if (localValue > 255)
@@ -311,7 +308,7 @@
localValue = 255;
current++;
} else {
- expect = CSSPrimitiveValue::UnitTypes::Number;
+ expect = CSSPrimitiveValue::UnitTypes::CSS_NUMBER;
}
while (current != end && isHTMLSpace<CharacterType>(*current))
@@ -416,7 +413,7 @@
template <typename CharacterType>
static bool fastParseColorInternal(RGBA32& rgb, const CharacterType* characters, unsigned length, bool quirksMode)
{
- CSSPrimitiveValue::UnitTypes expect = CSSPrimitiveValue::UnitTypes::Unknown;
+ CSSPrimitiveValue::UnitTypes expect = CSSPrimitiveValue::UnitTypes::CSS_UNKNOWN;
if (length >= 4 && characters[0] == '#')
return Color::parseHexColor(characters + 1, length - 1, rgb);
@@ -471,7 +468,7 @@
return false;
}
-CSSValue* CSSParserFastPaths::parseColor(const String& string, CSSParserMode parserMode)
+RefPtr<CSSValue> CSSParserFastPaths::parseColor(const String& string, CSSParserMode parserMode)
{
ASSERT(!string.isEmpty());
CSSValueID valueID = cssValueKeywordID(string);
@@ -492,7 +489,7 @@
parseResult = fastParseColorInternal(color, string.characters16(), string.length(), quirksMode);
if (!parseResult)
return nullptr;
- return CSSColorValue::create(color);
+ return CSSValuePool::singleton().createColorValue(color);
}
bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId, CSSValueID valueID, CSSParserMode parserMode)
@@ -537,9 +534,9 @@
return valueID == CSSValueNonzero || valueID == CSSValueEvenodd;
case CSSPropertyColorInterpolation:
case CSSPropertyColorInterpolationFilters:
- return valueID == CSSValueAuto || valueID == CSSValueSRGB || valueID == CSSValueLinearRGB;
+ return valueID == CSSValueAuto || valueID == CSSValueSrgb || valueID == CSSValueLinearrgb;
case CSSPropertyColorRendering:
- return valueID == CSSValueAuto || valueID == CSSValueOptimizeSpeed || valueID == CSSValueOptimizeQuality;
+ return valueID == CSSValueAuto || valueID == CSSValueOptimizespeed || valueID == CSSValueOptimizequality;
case CSSPropertyDirection: // ltr | rtl
return valueID == CSSValueLtr || valueID == CSSValueRtl;
case CSSPropertyDisplay:
@@ -548,7 +545,10 @@
// table-column-group | table-column | table-cell | table-caption | -webkit-box | -webkit-inline-box | none
// flex | inline-flex | -webkit-flex | -webkit-inline-flex | grid | inline-grid
return (valueID >= CSSValueInline && valueID <= CSSValueInlineFlex) || valueID == CSSValueWebkitFlex || valueID == CSSValueWebkitInlineFlex || valueID == CSSValueNone
- || (RuntimeEnabledFeatures::cssGridLayoutEnabled() && (valueID == CSSValueGrid || valueID == CSSValueInlineGrid));
+#if ENABLE(CSS_GRID_LAYOUT)
+ || (RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled() && (valueID == CSSValueGrid || valueID == CSSValueInlineGrid))
+#endif
+ ;
case CSSPropertyDominantBaseline:
// auto | use-script | no-change | reset-size | ideographic |
// alphabetic | hanging | mathematical | central | middle |
@@ -566,8 +566,10 @@
return valueID == CSSValueNormal || (valueID >= CSSValueUltraCondensed && valueID <= CSSValueUltraExpanded);
case CSSPropertyImageRendering: // auto | optimizeContrast | pixelated
return valueID == CSSValueAuto || valueID == CSSValueWebkitOptimizeContrast || valueID == CSSValuePixelated;
+#if ENABLE(CSS_COMPOSITING)
case CSSPropertyIsolation: // auto | isolate
return valueID == CSSValueAuto || valueID == CSSValueIsolate;
+#endif
case CSSPropertyListStylePosition: // inside | outside
return valueID == CSSValueInside || valueID == CSSValueOutside;
case CSSPropertyListStyleType:
@@ -580,8 +582,9 @@
return valueID == CSSValueFill || valueID == CSSValueContain || valueID == CSSValueCover || valueID == CSSValueNone || valueID == CSSValueScaleDown;
case CSSPropertyOutlineStyle: // (<border-style> except hidden) | auto
return valueID == CSSValueAuto || valueID == CSSValueNone || (valueID >= CSSValueInset && valueID <= CSSValueDouble);
- case CSSPropertyOverflowAnchor:
- return valueID == CSSValueVisible || valueID == CSSValueNone || valueID == CSSValueAuto;
+ // FIXME-NEWPARSER: Support?
+ // case CSSPropertyOverflowAnchor:
+ // return valueID == CSSValueVisible || valueID == CSSValueNone || valueID == CSSValueAuto;
case CSSPropertyOverflowWrap: // normal | break-word
case CSSPropertyWordWrap:
return valueID == CSSValueNormal || valueID == CSSValueBreakWord;
@@ -597,16 +600,17 @@
case CSSPropertyPointerEvents:
// none | visiblePainted | visibleFill | visibleStroke | visible |
// painted | fill | stroke | auto | all | bounding-box
- return valueID == CSSValueVisible || valueID == CSSValueNone || valueID == CSSValueAll || valueID == CSSValueAuto || (valueID >= CSSValueVisiblePainted && valueID <= CSSValueBoundingBox);
+ return valueID == CSSValueVisible || valueID == CSSValueNone || valueID == CSSValueAll || valueID == CSSValueAuto || (valueID >= CSSValueVisiblepainted && valueID <= CSSValueStroke);
case CSSPropertyPosition: // static | relative | absolute | fixed | sticky
- return valueID == CSSValueStatic || valueID == CSSValueRelative || valueID == CSSValueAbsolute || valueID == CSSValueFixed || (RuntimeEnabledFeatures::cssStickyPositionEnabled() && valueID == CSSValueSticky);
+ return valueID == CSSValueStatic || valueID == CSSValueRelative || valueID == CSSValueAbsolute || valueID == CSSValueFixed || valueID == CSSValueWebkitSticky;
case CSSPropertyResize: // none | both | horizontal | vertical | auto
return valueID == CSSValueNone || valueID == CSSValueBoth || valueID == CSSValueHorizontal || valueID == CSSValueVertical || valueID == CSSValueAuto;
- case CSSPropertyScrollBehavior: // auto | smooth
- ASSERT(RuntimeEnabledFeatures::cssomSmoothScrollEnabled());
- return valueID == CSSValueAuto || valueID == CSSValueSmooth;
+ // FIXME-NEWPARSER: Investigate this property.
+ // case CSSPropertyScrollBehavior: // auto | smooth
+ // ASSERT(RuntimeEnabledFeatures::cssomSmoothScrollEnabled());
+ // return valueID == CSSValueAuto || valueID == CSSValueSmooth;
case CSSPropertyShapeRendering:
- return valueID == CSSValueAuto || valueID == CSSValueOptimizeSpeed || valueID == CSSValueCrispEdges || valueID == CSSValueGeometricPrecision;
+ return valueID == CSSValueAuto || valueID == CSSValueOptimizespeed || valueID == CSSValueCrispEdges || valueID == CSSValueGeometricprecision;
case CSSPropertySpeak: // none | normal | spell-out | digits | literal-punctuation | no-punctuation
return valueID == CSSValueNone || valueID == CSSValueNormal || valueID == CSSValueSpellOut || valueID == CSSValueDigits || valueID == CSSValueLiteralPunctuation || valueID == CSSValueNoPunctuation;
case CSSPropertyStrokeLinejoin:
@@ -616,30 +620,32 @@
case CSSPropertyTableLayout: // auto | fixed
return valueID == CSSValueAuto || valueID == CSSValueFixed;
case CSSPropertyTextAlign:
- return (valueID >= CSSValueWebkitAuto && valueID <= CSSValueInternalCenter) || valueID == CSSValueStart || valueID == CSSValueEnd;
- case CSSPropertyTextAlignLast:
+ return (valueID >= CSSValueWebkitAuto && valueID <= CSSValueWebkitMatchParent) || valueID == CSSValueStart || valueID == CSSValueEnd;
+#if ENABLE(CSS3_TEXT)
+ case CSSPropertyWebkitTextAlignLast:
// auto | start | end | left | right | center | justify
return (valueID >= CSSValueLeft && valueID <= CSSValueJustify) || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueAuto;
+#endif
case CSSPropertyTextAnchor:
return valueID == CSSValueStart || valueID == CSSValueMiddle || valueID == CSSValueEnd;
- case CSSPropertyTextCombineUpright:
- return valueID == CSSValueNone || valueID == CSSValueAll;
- case CSSPropertyTextDecorationStyle:
+// FIXME-NEWPARSER: Support
+// case CSSPropertyTextCombineUpright:
+// return valueID == CSSValueNone || valueID == CSSValueAll;
+ case CSSPropertyWebkitTextDecorationStyle:
// solid | double | dotted | dashed | wavy
- ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
return valueID == CSSValueSolid || valueID == CSSValueDouble || valueID == CSSValueDotted || valueID == CSSValueDashed || valueID == CSSValueWavy;
- case CSSPropertyTextJustify:
+#if ENABLE(CSS3_TEXT)
+ case CSSPropertyWebkitTextJustify:
// auto | none | inter-word | distribute
ASSERT(RuntimeEnabledFeatures::css3TextEnabled());
return valueID == CSSValueInterWord || valueID == CSSValueDistribute || valueID == CSSValueAuto || valueID == CSSValueNone;
- case CSSPropertyTextOrientation: // mixed | upright | sideways | sideways-right
+#endif
+ case CSSPropertyWebkitTextOrientation: // mixed | upright | sideways | sideways-right
return valueID == CSSValueMixed || valueID == CSSValueUpright || valueID == CSSValueSideways || valueID == CSSValueSidewaysRight;
- case CSSPropertyWebkitTextOrientation:
- return valueID == CSSValueSideways || valueID == CSSValueSidewaysRight || valueID == CSSValueVerticalRight || valueID == CSSValueUpright;
case CSSPropertyTextOverflow: // clip | ellipsis
return valueID == CSSValueClip || valueID == CSSValueEllipsis;
case CSSPropertyTextRendering: // auto | optimizeSpeed | optimizeLegibility | geometricPrecision
- return valueID == CSSValueAuto || valueID == CSSValueOptimizeSpeed || valueID == CSSValueOptimizeLegibility || valueID == CSSValueGeometricPrecision;
+ return valueID == CSSValueAuto || valueID == CSSValueOptimizespeed || valueID == CSSValueOptimizelegibility || valueID == CSSValueGeometricprecision;
case CSSPropertyTextTransform: // capitalize | uppercase | lowercase | none
return (valueID >= CSSValueCapitalize && valueID <= CSSValueLowercase) || valueID == CSSValueNone;
case CSSPropertyUnicodeBidi:
@@ -646,7 +652,7 @@
return valueID == CSSValueNormal || valueID == CSSValueEmbed
|| valueID == CSSValueBidiOverride || valueID == CSSValueWebkitIsolate
|| valueID == CSSValueWebkitIsolateOverride || valueID == CSSValueWebkitPlaintext
- || valueID == CSSValueIsolate || valueID == CSSValueIsolateOverride || valueID == CSSValuePlaintext;
+ || valueID == CSSValueIsolate || valueID == CSSValueWebkitIsolateOverride || valueID == CSSValueWebkitPlaintext;
case CSSPropertyVectorEffect:
return valueID == CSSValueNone || valueID == CSSValueNonScalingStroke;
case CSSPropertyVisibility: // visible | hidden | collapse
@@ -653,13 +659,15 @@
return valueID == CSSValueVisible || valueID == CSSValueHidden || valueID == CSSValueCollapse;
case CSSPropertyWebkitAppearance:
return (valueID >= CSSValueCheckbox && valueID <= CSSValueTextarea) || valueID == CSSValueNone;
- case CSSPropertyBackfaceVisibility:
+ case CSSPropertyWebkitBackfaceVisibility:
return valueID == CSSValueVisible || valueID == CSSValueHidden;
+#if ENABLE(CSS_COMPOSITING)
case CSSPropertyMixBlendMode:
return valueID == CSSValueNormal || valueID == CSSValueMultiply || valueID == CSSValueScreen || valueID == CSSValueOverlay
|| valueID == CSSValueDarken || valueID == CSSValueLighten || valueID == CSSValueColorDodge || valueID == CSSValueColorBurn
|| valueID == CSSValueHardLight || valueID == CSSValueSoftLight || valueID == CSSValueDifference || valueID == CSSValueExclusion
|| valueID == CSSValueHue || valueID == CSSValueSaturation || valueID == CSSValueColor || valueID == CSSValueLuminosity;
+#endif
case CSSPropertyWebkitBoxAlign:
return valueID == CSSValueStretch || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline;
case CSSPropertyWebkitBoxDecorationBreak:
@@ -687,12 +695,12 @@
return valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID == CSSValueColumn || valueID == CSSValueColumnReverse;
case CSSPropertyFlexWrap:
return valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == CSSValueWrapReverse;
- case CSSPropertyHyphens:
+ case CSSPropertyWebkitHyphens:
return valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueManual;
case CSSPropertyJustifyContent:
// FIXME: Per CSS alignment, this property should accept an optional <overflow-position>. We should share this parsing code with 'justify-self'.
return valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround;
- case CSSPropertyFontKerning:
+ case CSSPropertyWebkitFontKerning:
return valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == CSSValueNone;
case CSSPropertyWebkitFontSmoothing:
return valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueAntialiased || valueID == CSSValueSubpixelAntialiased;
@@ -721,7 +729,7 @@
return valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueElement;
case CSSPropertyWebkitUserModify: // read-only | read-write
return valueID == CSSValueReadOnly || valueID == CSSValueReadWrite || valueID == CSSValueReadWritePlaintextOnly;
- case CSSPropertyUserSelect: // auto | none | text | all
+ case CSSPropertyWebkitUserSelect: // auto | none | text | all
return valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText || valueID == CSSValueAll;
case CSSPropertyWebkitWritingMode:
return valueID >= CSSValueHorizontalTb && valueID <= CSSValueVerticalLr;
@@ -734,15 +742,29 @@
return valueID == CSSValueNormal || valueID == CSSValuePre || valueID == CSSValuePreWrap || valueID == CSSValuePreLine || valueID == CSSValueNowrap;
case CSSPropertyWordBreak: // normal | break-all | keep-all | break-word (this is a custom extension)
return valueID == CSSValueNormal || valueID == CSSValueBreakAll || valueID == CSSValueKeepAll || valueID == CSSValueBreakWord;
- case CSSPropertyScrollSnapType: // none | mandatory | proximity
- ASSERT(RuntimeEnabledFeatures::cssScrollSnapPointsEnabled());
+#if ENABLE(CSS_SCROLL_SNAP)
+ case CSSPropertyWebkitScrollSnapType: // none | mandatory | proximity
return valueID == CSSValueNone || valueID == CSSValueMandatory || valueID == CSSValueProximity;
+#endif
+#if ENABLE(TOUCH_EVENTS)
+ case CSSPropertyTouchAction: // auto | manipulation
+ return valueID == CSSValueAuto || valueID == CSSValueManipulation;
+#endif
+#if ENABLE(CSS_TRAILING_WORD)
+ case CSSPropertyAppleTrailingWord: // auto | -apple-partially-balanced
+ return valueID == CSSValueAuto || valueID == CSSValueWebkitPartiallyBalanced;
+#endif
+#if ENABLE(APPLE_PAY)
+ case CSSPropertyApplePayButtonStyle: // white | white-outline | black
+ return valueID == CSSValueWhite || valueID == CSSValueWhiteOutline || valueID == CSSValueBlack;
+ case CSSPropertyApplePayButtonType: // plain | buy | set-up | in-store
+ return valueID == CSSValuePlain || valueID == CSSValueBuy || valueID == CSSValueSetUp || valueID == CSSValueInStore;
+#endif
default:
ASSERT_NOT_REACHED();
return false;
}
}
-*/
bool CSSParserFastPaths::isKeywordPropertyID(CSSPropertyID propertyId)
{
@@ -941,15 +963,22 @@
}
}
-/* FIXME-NEWPARSER: Turn off for now.
+static bool isUniversalKeyword(const String& string)
+{
+ // These keywords can be used for all properties.
+ return equalLettersIgnoringASCIICase(string, "initial")
+ || equalLettersIgnoringASCIICase(string, "inherit")
+ || equalLettersIgnoringASCIICase(string, "unset")
+ || equalLettersIgnoringASCIICase(string, "revert");
+}
-static CSSValue* parseKeywordValue(CSSPropertyID propertyId, const String& string, CSSParserMode parserMode)
+static RefPtr<CSSValue> parseKeywordValue(CSSPropertyID propertyId, const String& string, CSSParserMode parserMode)
{
ASSERT(!string.isEmpty());
if (!CSSParserFastPaths::isKeywordPropertyID(propertyId)) {
// All properties accept the values of "initial" and "inherit".
- if (!equalIgnoringASCIICase(string, "initial") && !equalIgnoringASCIICase(string, "inherit"))
+ if (!isUniversalKeyword(string))
return nullptr;
// Parse initial/inherit shorthands using the CSSPropertyParser.
@@ -957,7 +986,7 @@
return nullptr;
// Descriptors do not support css wide keywords.
- if (CSSPropertyMetadata::isDescriptorOnly(propertyId))
+ if (CSSProperty::isDescriptorOnly(propertyId))
return nullptr;
}
@@ -967,9 +996,14 @@
return nullptr;
if (valueID == CSSValueInherit)
- return CSSInheritedValue::create();
+ return CSSValuePool::singleton().createInheritedValue();
if (valueID == CSSValueInitial)
- return CSSInitialValue::create();
+ return CSSValuePool::singleton().createExplicitInitialValue();
+ if (valueID == CSSValueUnset)
+ return CSSValuePool::singleton().createUnsetValue();
+ if (valueID == CSSValueRevert)
+ return CSSValuePool::singleton().createRevertValue();
+
if (CSSParserFastPaths::isValidKeywordPropertyAndValue(propertyId, valueID, parserMode))
return CSSPrimitiveValue::createIdentifier(valueID);
return nullptr;
@@ -980,16 +1014,16 @@
{
while (expectedCount) {
size_t delimiter = WTF::find(pos, end - pos, expectedCount == 1 ? ')' : ',');
- if (delimiter == kNotFound)
+ if (delimiter == notFound)
return false;
unsigned argumentLength = static_cast<unsigned>(delimiter);
- CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::UnitTypes::Number;
+ CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::UnitTypes::CSS_NUMBER;
double number;
if (!parseSimpleLength(pos, argumentLength, unit, number))
return false;
- if (unit != CSSPrimitiveValue::UnitTypes::Pixels && (number || unit != CSSPrimitiveValue::UnitTypes::Number))
+ if (unit != CSSPrimitiveValue::UnitTypes::CSS_PX && (number || unit != CSSPrimitiveValue::UnitTypes::CSS_NUMBER))
return false;
- transformValue->append(*CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitTypes::Pixels));
+ transformValue->append(CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitTypes::CSS_PX));
pos += argumentLength + 1;
--expectedCount;
}
@@ -1001,7 +1035,7 @@
{
while (expectedCount) {
size_t delimiter = WTF::find(pos, end - pos, expectedCount == 1 ? ')' : ',');
- if (delimiter == kNotFound)
+ if (delimiter == notFound)
return false;
unsigned argumentLength = static_cast<unsigned>(delimiter);
bool ok;
@@ -1008,7 +1042,7 @@
double number = charactersToDouble(pos, argumentLength, &ok);
if (!ok)
return false;
- transformValue->append(*CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitTypes::Number));
+ transformValue->append(CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitTypes::CSS_NUMBER));
pos += argumentLength + 1;
--expectedCount;
}
@@ -1018,7 +1052,7 @@
static const int kShortestValidTransformStringLength = 12;
template <typename CharType>
-static CSSFunctionValue* parseSimpleTransformValue(CharType*& pos, CharType* end)
+static RefPtr<CSSFunctionValue> parseSimpleTransformValue(CharType*& pos, CharType* end)
{
if (end - pos < kShortestValidTransformStringLength)
return nullptr;
@@ -1039,11 +1073,11 @@
unsigned argumentStart = 11;
CharType c9 = toASCIILower(pos[9]);
if (c9 == 'x' && pos[10] == '(') {
- transformType = CSSValueTranslateX;
+ transformType = CSSValueTranslatex;
} else if (c9 == 'y' && pos[10] == '(') {
- transformType = CSSValueTranslateY;
+ transformType = CSSValueTranslatey;
} else if (c9 == 'z' && pos[10] == '(') {
- transformType = CSSValueTranslateZ;
+ transformType = CSSValueTranslatez;
} else if (c9 == '(') {
transformType = CSSValueTranslate;
expectedArgumentCount = 2;
@@ -1056,8 +1090,8 @@
return nullptr;
}
pos += argumentStart;
- CSSFunctionValue* transformValue = CSSFunctionValue::create(transformType);
- if (!parseTransformTranslateArguments(pos, end, expectedArgumentCount, transformValue))
+ RefPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(transformType);
+ if (!parseTransformTranslateArguments(pos, end, expectedArgumentCount, transformValue.get()))
return nullptr;
return transformValue;
}
@@ -1074,8 +1108,8 @@
if (isMatrix3d) {
pos += 9;
- CSSFunctionValue* transformValue = CSSFunctionValue::create(CSSValueMatrix3d);
- if (!parseTransformNumberArguments(pos, end, 16, transformValue))
+ RefPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(CSSValueMatrix3d);
+ if (!parseTransformNumberArguments(pos, end, 16, transformValue.get()))
return nullptr;
return transformValue;
}
@@ -1091,8 +1125,8 @@
if (isScale3d) {
pos += 8;
- CSSFunctionValue* transformValue = CSSFunctionValue::create(CSSValueScale3d);
- if (!parseTransformNumberArguments(pos, end, 3, transformValue))
+ RefPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(CSSValueScale3d);
+ if (!parseTransformNumberArguments(pos, end, 3, transformValue.get()))
return nullptr;
return transformValue;
}
@@ -1139,7 +1173,7 @@
return false;
}
size_t argumentsEnd = WTF::find(chars, length, ')', i);
- if (argumentsEnd == kNotFound)
+ if (argumentsEnd == notFound)
return false;
// Advance to the end of the arguments.
i = argumentsEnd + 1;
@@ -1148,19 +1182,19 @@
}
template <typename CharType>
-static CSSValueList* parseSimpleTransformList(const CharType* chars, unsigned length)
+static RefPtr<CSSValueList> parseSimpleTransformList(const CharType* chars, unsigned length)
{
if (!transformCanLikelyUseFastPath(chars, length))
return nullptr;
const CharType*& pos = chars;
const CharType* end = chars + length;
- CSSValueList* transformList = nullptr;
+ RefPtr<CSSValueList> transformList;
while (pos < end) {
while (pos < end && isCSSSpace(*pos))
++pos;
if (pos >= end)
break;
- CSSFunctionValue* transformValue = parseSimpleTransformValue(pos, end);
+ RefPtr<CSSFunctionValue> transformValue = parseSimpleTransformValue(pos, end);
if (!transformValue)
return nullptr;
if (!transformList)
@@ -1170,7 +1204,7 @@
return transformList;
}
-static CSSValue* parseSimpleTransform(CSSPropertyID propertyID, const String& string)
+static RefPtr<CSSValue> parseSimpleTransform(CSSPropertyID propertyID, const String& string)
{
ASSERT(!string.isEmpty());
@@ -1181,18 +1215,20 @@
return parseSimpleTransformList(string.characters16(), string.length());
}
-CSSValue* CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
+RefPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
{
- if (CSSValue* length = parseSimpleLengthValue(propertyID, string, parserMode))
- return length;
+ RefPtr<CSSValue> result = parseSimpleLengthValue(propertyID, string, parserMode);
+ if (result)
+ return result;
if (isColorPropertyID(propertyID))
return parseColor(string, parserMode);
- if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode))
- return keyword;
- if (CSSValue* transform = parseSimpleTransform(propertyID, string))
- return transform;
+ result = parseKeywordValue(propertyID, string, parserMode);
+ if (result)
+ return result;
+ result = parseSimpleTransform(propertyID, string);
+ if (result)
+ return result;
return nullptr;
}
- */
} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.h (206006 => 206007)
--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.h 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.h 2016-09-16 00:33:45 UTC (rev 206007)
@@ -43,13 +43,13 @@
public:
// Parses simple values like '10px' or 'green', but makes no guarantees
// about handling any property completely.
- static CSSValue* maybeParseValue(CSSPropertyID, const String&, CSSParserMode);
+ static RefPtr<CSSValue> maybeParseValue(CSSPropertyID, const String&, CSSParserMode);
// Properties handled here shouldn't be explicitly handled in CSSPropertyParser
static bool isKeywordPropertyID(CSSPropertyID);
static bool isValidKeywordPropertyAndValue(CSSPropertyID, CSSValueID, CSSParserMode);
- static CSSValue* parseColor(const String&, CSSParserMode);
+ static RefPtr<CSSValue> parseColor(const String&, CSSParserMode);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp (206006 => 206007)
--- trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2016-09-16 00:33:45 UTC (rev 206007)
@@ -29,6 +29,7 @@
#include "config.h"
#include "CSSParserIdioms.h"
+#include "CSSValueKeywords.h"
namespace WebCore {
@@ -48,4 +49,16 @@
WebCore::convertToASCIILowercaseInPlace(const_cast<UChar*>(stringView.characters16()), stringView.length());
}
+bool isValueAllowedInMode(unsigned short id, CSSParserMode mode)
+{
+ switch (id) {
+ case CSSValueInternalVariableValue:
+ return isUASheetBehavior(mode);
+ case CSSValueWebkitFocusRingColor:
+ return isUASheetBehavior(mode) || isQuirksModeBehavior(mode);
+ default:
+ return true;
+ }
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.h (206006 => 206007)
--- trunk/Source/WebCore/css/parser/CSSParserIdioms.h 2016-09-16 00:27:11 UTC (rev 206006)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.h 2016-09-16 00:33:45 UTC (rev 206007)
@@ -32,6 +32,7 @@
#ifndef CSSParserIdioms_h
#define CSSParserIdioms_h
+#include "CSSParserMode.h"
#include <wtf/ASCIICType.h>
#include <wtf/text/StringView.h>
@@ -60,6 +61,8 @@
void convertToASCIILowercaseInPlace(StringView&);
+bool isValueAllowedInMode(unsigned short, CSSParserMode);
+
}
#endif