Move CSSParserContext to a file of its own
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2018 15:46:25 +0000 (15:46 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2018 15:46:25 +0000 (15:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187342

Reviewed by Zalan Bujtas.

Move it out from CSSParserMode.h and CSSParser.cpp.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* contentextensions/ContentExtensionParser.cpp:
* css/PropertySetCSSStyleDeclaration.h:
* css/StyleProperties.h:
* css/StyleSheetContents.h:
* css/parser/CSSDeferredParser.h:
* css/parser/CSSParser.cpp:
(WebCore::strictCSSParserContext): Deleted.
(WebCore::CSSParserContext::CSSParserContext): Deleted.
(WebCore::operator==): Deleted.
* css/parser/CSSParser.h:
* css/parser/CSSParserContext.cpp: Added.
(WebCore::strictCSSParserContext):
(WebCore::CSSParserContext::CSSParserContext):
(WebCore::operator==):

Also add the missing textAutosizingEnabled bit.

* css/parser/CSSParserContext.h: Copied from Source/WebCore/css/parser/CSSParserMode.h.
(WebCore::CSSParserContextHash::hash):

Also add the missing bits to the hash function.

(WebCore::isQuirksModeBehavior): Deleted.
(WebCore::isUASheetBehavior): Deleted.
(WebCore::isUnitLessValueParsingEnabledForMode): Deleted.
(WebCore::isCSSViewportParsingEnabledForMode): Deleted.
(WebCore::strictToCSSParserMode): Deleted.
(WebCore::isStrictParserMode): Deleted.
* css/parser/CSSParserIdioms.h:
* css/parser/CSSParserImpl.h:
* css/parser/CSSParserMode.h:
(WebCore::CSSParserContext::completeURL const): Deleted.
(WebCore::operator!=): Deleted.
(WebCore::CSSParserContextHash::hash): Deleted.
(WebCore::CSSParserContextHash::equal): Deleted.
(WTF::HashTraits<WebCore::CSSParserContext>::constructDeletedValue): Deleted.
(WTF::HashTraits<WebCore::CSSParserContext>::isDeletedValue): Deleted.
(WTF::HashTraits<WebCore::CSSParserContext>::emptyValue): Deleted.
* css/parser/CSSPropertyParserHelpers.h:
* css/parser/CSSSelectorParser.cpp:
* css/parser/CSSVariableParser.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233520 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/contentextensions/ContentExtensionParser.cpp
Source/WebCore/css/PropertySetCSSStyleDeclaration.h
Source/WebCore/css/StyleProperties.h
Source/WebCore/css/StyleSheetContents.h
Source/WebCore/css/parser/CSSDeferredParser.h
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParser.h
Source/WebCore/css/parser/CSSParserContext.cpp [new file with mode: 0644]
Source/WebCore/css/parser/CSSParserContext.h [new file with mode: 0644]
Source/WebCore/css/parser/CSSParserIdioms.h
Source/WebCore/css/parser/CSSParserImpl.h
Source/WebCore/css/parser/CSSParserMode.h
Source/WebCore/css/parser/CSSPropertyParserHelpers.h
Source/WebCore/css/parser/CSSSelectorParser.cpp
Source/WebCore/css/parser/CSSVariableParser.cpp

index 4065047..2d5ac91 100644 (file)
@@ -1,3 +1,56 @@
+2018-07-05  Antti Koivisto  <antti@apple.com>
+
+        Move CSSParserContext to a file of its own
+        https://bugs.webkit.org/show_bug.cgi?id=187342
+
+        Reviewed by Zalan Bujtas.
+
+        Move it out from CSSParserMode.h and CSSParser.cpp.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * contentextensions/ContentExtensionParser.cpp:
+        * css/PropertySetCSSStyleDeclaration.h:
+        * css/StyleProperties.h:
+        * css/StyleSheetContents.h:
+        * css/parser/CSSDeferredParser.h:
+        * css/parser/CSSParser.cpp:
+        (WebCore::strictCSSParserContext): Deleted.
+        (WebCore::CSSParserContext::CSSParserContext): Deleted.
+        (WebCore::operator==): Deleted.
+        * css/parser/CSSParser.h:
+        * css/parser/CSSParserContext.cpp: Added.
+        (WebCore::strictCSSParserContext):
+        (WebCore::CSSParserContext::CSSParserContext):
+        (WebCore::operator==):
+
+        Also add the missing textAutosizingEnabled bit.
+
+        * css/parser/CSSParserContext.h: Copied from Source/WebCore/css/parser/CSSParserMode.h.
+        (WebCore::CSSParserContextHash::hash):
+
+        Also add the missing bits to the hash function.
+        
+        (WebCore::isQuirksModeBehavior): Deleted.
+        (WebCore::isUASheetBehavior): Deleted.
+        (WebCore::isUnitLessValueParsingEnabledForMode): Deleted.
+        (WebCore::isCSSViewportParsingEnabledForMode): Deleted.
+        (WebCore::strictToCSSParserMode): Deleted.
+        (WebCore::isStrictParserMode): Deleted.
+        * css/parser/CSSParserIdioms.h:
+        * css/parser/CSSParserImpl.h:
+        * css/parser/CSSParserMode.h:
+        (WebCore::CSSParserContext::completeURL const): Deleted.
+        (WebCore::operator!=): Deleted.
+        (WebCore::CSSParserContextHash::hash): Deleted.
+        (WebCore::CSSParserContextHash::equal): Deleted.
+        (WTF::HashTraits<WebCore::CSSParserContext>::constructDeletedValue): Deleted.
+        (WTF::HashTraits<WebCore::CSSParserContext>::isDeletedValue): Deleted.
+        (WTF::HashTraits<WebCore::CSSParserContext>::emptyValue): Deleted.
+        * css/parser/CSSPropertyParserHelpers.h:
+        * css/parser/CSSSelectorParser.cpp:
+        * css/parser/CSSVariableParser.cpp:
+
 2018-07-05  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] The ready promise should initially be resolved
index b423c7b..3391e4b 100644 (file)
@@ -663,6 +663,7 @@ css/WebKitCSSViewportRule.cpp
 css/parser/CSSAtRuleID.cpp
 css/parser/CSSDeferredParser.cpp
 css/parser/CSSParser.cpp
+css/parser/CSSParserContext.cpp
 css/parser/CSSParserFastPaths.cpp
 css/parser/CSSParserIdioms.cpp
 css/parser/CSSParserImpl.cpp
index e675cb6..f7035bb 100644 (file)
                E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; };
                E4A007831B820EC8002C5A6E /* DataURLDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A007821B820EC8002C5A6E /* DataURLDecoder.h */; };
+               E4A7995220EE4B1400C19568 /* CSSParserContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A7994E20EE4AE100C19568 /* CSSParserContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4A814D41C6DEC4000BF85AC /* ClassChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A814D31C6DEC4000BF85AC /* ClassChangeInvalidation.h */; };
                E4A814DA1C70E10D00BF85AC /* AttributeChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A814D91C70E10D00BF85AC /* AttributeChangeInvalidation.h */; };
                E4A814E01C7338EB00BF85AC /* IdChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A814DF1C7338EB00BF85AC /* IdChangeInvalidation.h */; };
                9B6C41521344949000085B62 /* StringWithDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringWithDirection.h; sourceTree = "<group>"; };
                9B714E1E1C91166900AC0E92 /* EventPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventPath.cpp; sourceTree = "<group>"; };
                9B714E1F1C91166900AC0E92 /* EventPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventPath.h; sourceTree = "<group>"; };
-               9B85530520E733B5009EEF4F /* EventTargetFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EventTargetFactory.cpp; path = EventTargetFactory.cpp; sourceTree = "<group>"; };
+               9B85530520E733B5009EEF4F /* EventTargetFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventTargetFactory.cpp; sourceTree = "<group>"; };
                9B9299B01F6796A4006723C2 /* WebContentReaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContentReaderCocoa.mm; sourceTree = "<group>"; };
                9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogicalSelectionOffsetCaches.h; sourceTree = "<group>"; };
                9BA827781F06156500F71E75 /* NavigationDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationDisabler.h; sourceTree = "<group>"; };
                E4A007821B820EC8002C5A6E /* DataURLDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataURLDecoder.h; sourceTree = "<group>"; };
                E4A007841B820ED3002C5A6E /* DataURLDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataURLDecoder.cpp; sourceTree = "<group>"; };
                E4A1822F1F13BE5800FEF698 /* StyleInvalidationFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StyleInvalidationFunctions.h; sourceTree = "<group>"; };
+               E4A7994E20EE4AE100C19568 /* CSSParserContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSParserContext.h; path = parser/CSSParserContext.h; sourceTree = "<group>"; };
+               E4A7995020EE4AE200C19568 /* CSSParserContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSSParserContext.cpp; path = parser/CSSParserContext.cpp; sourceTree = "<group>"; };
                E4A814D31C6DEC4000BF85AC /* ClassChangeInvalidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassChangeInvalidation.h; sourceTree = "<group>"; };
                E4A814D51C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassChangeInvalidation.cpp; sourceTree = "<group>"; };
                E4A814D71C70E10500BF85AC /* AttributeChangeInvalidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AttributeChangeInvalidation.cpp; sourceTree = "<group>"; };
                                94476BD91DFCA4A700690E23 /* CSSDeferredParser.h */,
                                946D37281D6CB28B0077084F /* CSSParser.cpp */,
                                946D37291D6CB28B0077084F /* CSSParser.h */,
+                               E4A7995020EE4AE200C19568 /* CSSParserContext.cpp */,
+                               E4A7994E20EE4AE100C19568 /* CSSParserContext.h */,
                                949C76FE1D6E1D8C00C0DE4F /* CSSParserFastPaths.cpp */,
                                949C76FF1D6E1D8C00C0DE4F /* CSSParserFastPaths.h */,
                                94DE5C7D1D78CB2500164F2A /* CSSParserIdioms.cpp */,
                                75793EC90D0CE72D007FC0AC /* JSMessageEvent.h in Headers */,
                                E1ADEDDA0E76BD93004A1A5E /* JSMessagePort.h in Headers */,
                                A86629D109DA2B48009633A5 /* JSMouseEvent.h in Headers */,
+                               E4A7995220EE4B1400C19568 /* CSSParserContext.h in Headers */,
                                830A36BD1DAC5FAD006D7D09 /* JSMouseEventInit.h in Headers */,
                                65DF31FC09D1CC60000BE325 /* JSMutationEvent.h in Headers */,
                                C6F0902D14327D4F00685849 /* JSMutationObserver.h in Headers */,
index e7c361f..77e3b4f 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(CONTENT_EXTENSIONS)
 
 #include "CSSParser.h"
-#include "CSSParserMode.h"
 #include "CSSSelectorList.h"
 #include "ContentExtensionError.h"
 #include "ContentExtensionRule.h"
index 7bc1f6e..5983f21 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include "CSSStyleDeclaration.h"
 #include "DeprecatedCSSOMValue.h"
 #include <memory>
index 2661ec1..a183a9c 100644 (file)
@@ -21,7 +21,7 @@
 
 #pragma once
 
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include "CSSParserTokenRange.h"
 #include "CSSProperty.h"
 #include "CSSValueKeywords.h"
index 490803d..2c2bd11 100644 (file)
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include "CachePolicy.h"
 #include "URL.h"
 #include <wtf/Function.h>
index 7a381d0..07e9c92 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include <wtf/RefCounted.h>
 #include <wtf/WeakPtr.h>
 
index 8413801..591d3bd 100644 (file)
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/StringBuilder.h>
 
-
 namespace WebCore {
 using namespace WTF;
 
-const CSSParserContext& strictCSSParserContext()
-{
-    static NeverDestroyed<CSSParserContext> strictContext(HTMLStandardMode);
-    return strictContext;
-}
-
-CSSParserContext::CSSParserContext(CSSParserMode mode, const URL& baseURL)
-    : baseURL(baseURL)
-    , mode(mode)
-{
-#if PLATFORM(IOS)
-    // FIXME: Force the site specific quirk below to work on iOS. Investigating other site specific quirks
-    // to see if we can enable the preference all together is to be handled by:
-    // <rdar://problem/8493309> Investigate Enabling Site Specific Quirks in MobileSafari and UIWebView
-    needsSiteSpecificQuirks = true;
-#endif
-}
-
-CSSParserContext::CSSParserContext(Document& document, const URL& sheetBaseURL, const String& charset)
-    : baseURL(sheetBaseURL.isNull() ? document.baseURL() : sheetBaseURL)
-    , charset(charset)
-    , mode(document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode)
-    , isHTMLDocument(document.isHTMLDocument())
-    , hasDocumentSecurityOrigin(sheetBaseURL.isNull() || document.securityOrigin().canRequest(baseURL))
-{
-    
-    needsSiteSpecificQuirks = document.settings().needsSiteSpecificQuirks();
-    enforcesCSSMIMETypeInNoQuirksMode = document.settings().enforceCSSMIMETypeInNoQuirksMode();
-    useLegacyBackgroundSizeShorthandBehavior = document.settings().useLegacyBackgroundSizeShorthandBehavior();
-#if ENABLE(TEXT_AUTOSIZING)
-    textAutosizingEnabled = document.settings().textAutosizingEnabled();
-#endif
-    springTimingFunctionEnabled = document.settings().springTimingFunctionEnabled();
-    constantPropertiesEnabled = document.settings().constantPropertiesEnabled();
-    conicGradientsEnabled = document.settings().conicGradientsEnabled();
-    colorFilterEnabled = document.settings().colorFilterEnabled();
-    deferredCSSParserEnabled = document.settings().deferredCSSParserEnabled();
-    allowNewLinesClamp = document.settings().appleMailLinesClampEnabled();
-    useSystemAppearance = document.page() ? document.page()->useSystemAppearance() : false;
-    
-#if PLATFORM(IOS)
-    // FIXME: Force the site specific quirk below to work on iOS. Investigating other site specific quirks
-    // to see if we can enable the preference all together is to be handled by:
-    // <rdar://problem/8493309> Investigate Enabling Site Specific Quirks in MobileSafari and UIWebView
-    needsSiteSpecificQuirks = true;
-#endif
-}
-
-bool operator==(const CSSParserContext& a, const CSSParserContext& b)
-{
-    return a.baseURL == b.baseURL
-        && a.charset == b.charset
-        && a.mode == b.mode
-        && a.isHTMLDocument == b.isHTMLDocument
-        && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
-        && a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode
-        && a.useLegacyBackgroundSizeShorthandBehavior == b.useLegacyBackgroundSizeShorthandBehavior
-        && a.springTimingFunctionEnabled == b.springTimingFunctionEnabled
-        && a.constantPropertiesEnabled == b.constantPropertiesEnabled
-        && a.conicGradientsEnabled == b.conicGradientsEnabled
-        && a.colorFilterEnabled == b.colorFilterEnabled
-        && a.deferredCSSParserEnabled == b.deferredCSSParserEnabled
-        && a.hasDocumentSecurityOrigin == b.hasDocumentSecurityOrigin
-        && a.useSystemAppearance == b.useSystemAppearance;
-}
-
 CSSParser::CSSParser(const CSSParserContext& context)
     : m_context(context)
 {
index 2930d45..ca5faa4 100644 (file)
@@ -22,7 +22,7 @@
 
 #pragma once
 
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include "CSSValue.h"
 #include "WritingMode.h"
 #include <wtf/text/WTFString.h>
diff --git a/Source/WebCore/css/parser/CSSParserContext.cpp b/Source/WebCore/css/parser/CSSParserContext.cpp
new file mode 100644 (file)
index 0000000..4e41c90
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2018 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "CSSParserContext.h"
+
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+const CSSParserContext& strictCSSParserContext()
+{
+    static NeverDestroyed<CSSParserContext> strictContext(HTMLStandardMode);
+    return strictContext;
+}
+
+CSSParserContext::CSSParserContext(CSSParserMode mode, const URL& baseURL)
+    : baseURL(baseURL)
+    , mode(mode)
+{
+#if PLATFORM(IOS)
+    // FIXME: Force the site specific quirk below to work on iOS. Investigating other site specific quirks
+    // to see if we can enable the preference all together is to be handled by:
+    // <rdar://problem/8493309> Investigate Enabling Site Specific Quirks in MobileSafari and UIWebView
+    needsSiteSpecificQuirks = true;
+#endif
+}
+
+CSSParserContext::CSSParserContext(Document& document, const URL& sheetBaseURL, const String& charset)
+    : baseURL(sheetBaseURL.isNull() ? document.baseURL() : sheetBaseURL)
+    , charset(charset)
+    , mode(document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode)
+    , isHTMLDocument(document.isHTMLDocument())
+    , hasDocumentSecurityOrigin(sheetBaseURL.isNull() || document.securityOrigin().canRequest(baseURL))
+{
+
+    needsSiteSpecificQuirks = document.settings().needsSiteSpecificQuirks();
+    enforcesCSSMIMETypeInNoQuirksMode = document.settings().enforceCSSMIMETypeInNoQuirksMode();
+    useLegacyBackgroundSizeShorthandBehavior = document.settings().useLegacyBackgroundSizeShorthandBehavior();
+#if ENABLE(TEXT_AUTOSIZING)
+    textAutosizingEnabled = document.settings().textAutosizingEnabled();
+#endif
+    springTimingFunctionEnabled = document.settings().springTimingFunctionEnabled();
+    constantPropertiesEnabled = document.settings().constantPropertiesEnabled();
+    conicGradientsEnabled = document.settings().conicGradientsEnabled();
+    colorFilterEnabled = document.settings().colorFilterEnabled();
+    deferredCSSParserEnabled = document.settings().deferredCSSParserEnabled();
+    allowNewLinesClamp = document.settings().appleMailLinesClampEnabled();
+    useSystemAppearance = document.page() ? document.page()->useSystemAppearance() : false;
+
+#if PLATFORM(IOS)
+    // FIXME: Force the site specific quirk below to work on iOS. Investigating other site specific quirks
+    // to see if we can enable the preference all together is to be handled by:
+    // <rdar://problem/8493309> Investigate Enabling Site Specific Quirks in MobileSafari and UIWebView
+    needsSiteSpecificQuirks = true;
+#endif
+}
+
+bool operator==(const CSSParserContext& a, const CSSParserContext& b)
+{
+    return a.baseURL == b.baseURL
+        && a.charset == b.charset
+        && a.mode == b.mode
+        && a.isHTMLDocument == b.isHTMLDocument
+#if ENABLE(TEXT_AUTOSIZING)
+        && a.textAutosizingEnabled == b.textAutosizingEnabled
+#endif
+        && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
+        && a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode
+        && a.useLegacyBackgroundSizeShorthandBehavior == b.useLegacyBackgroundSizeShorthandBehavior
+        && a.springTimingFunctionEnabled == b.springTimingFunctionEnabled
+        && a.constantPropertiesEnabled == b.constantPropertiesEnabled
+        && a.conicGradientsEnabled == b.conicGradientsEnabled
+        && a.colorFilterEnabled == b.colorFilterEnabled
+        && a.deferredCSSParserEnabled == b.deferredCSSParserEnabled
+        && a.hasDocumentSecurityOrigin == b.hasDocumentSecurityOrigin
+        && a.useSystemAppearance == b.useSystemAppearance;
+}
+
+}
diff --git a/Source/WebCore/css/parser/CSSParserContext.h b/Source/WebCore/css/parser/CSSParserContext.h
new file mode 100644 (file)
index 0000000..ac168ea
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2018 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "CSSParserMode.h"
+#include "TextEncoding.h"
+#include "URL.h"
+#include "URLHash.h"
+#include <wtf/HashFunctions.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+class Document;
+
+struct CSSParserContext {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    CSSParserContext(CSSParserMode, const URL& baseURL = URL());
+    WEBCORE_EXPORT CSSParserContext(Document&, const URL& baseURL = URL(), const String& charset = emptyString());
+
+    URL baseURL;
+    String charset;
+    CSSParserMode mode { HTMLStandardMode };
+    bool isHTMLDocument { false };
+#if ENABLE(TEXT_AUTOSIZING)
+    bool textAutosizingEnabled { false };
+#endif
+    bool needsSiteSpecificQuirks { false };
+    bool enforcesCSSMIMETypeInNoQuirksMode { true };
+    bool useLegacyBackgroundSizeShorthandBehavior { false };
+    bool springTimingFunctionEnabled { false };
+    bool constantPropertiesEnabled { false };
+    bool conicGradientsEnabled { false };
+    bool colorFilterEnabled { false };
+    bool deferredCSSParserEnabled { false };
+    bool allowNewLinesClamp { false };
+    
+    // This is only needed to support getMatchedCSSRules.
+    bool hasDocumentSecurityOrigin { false };
+    
+    bool useSystemAppearance { false };
+
+    URL completeURL(const String& url) const
+    {
+        if (url.isNull())
+            return URL();
+        if (charset.isEmpty())
+            return URL(baseURL, url);
+        return URL(baseURL, url, TextEncoding(charset));
+    }
+};
+
+bool operator==(const CSSParserContext&, const CSSParserContext&);
+inline bool operator!=(const CSSParserContext& a, const CSSParserContext& b) { return !(a == b); }
+
+WEBCORE_EXPORT const CSSParserContext& strictCSSParserContext();
+
+struct CSSParserContextHash {
+    static unsigned hash(const CSSParserContext& key)
+    {
+        auto hash = URLHash::hash(key.baseURL);
+        if (!key.charset.isEmpty())
+            hash ^= StringHash::hash(key.charset);
+        unsigned bits = key.isHTMLDocument                  << 0
+#if ENABLE(TEXT_AUTOSIZING)
+            & key.textAutosizingEnabled                     << 1
+#endif
+            & key.needsSiteSpecificQuirks                   << 2
+            & key.enforcesCSSMIMETypeInNoQuirksMode         << 3
+            & key.useLegacyBackgroundSizeShorthandBehavior  << 4
+            & key.springTimingFunctionEnabled               << 5
+            & key.constantPropertiesEnabled                 << 6
+            & key.conicGradientsEnabled                     << 7
+            & key.colorFilterEnabled                        << 8
+            & key.deferredCSSParserEnabled                  << 9
+            & key.allowNewLinesClamp                        << 10
+            & key.hasDocumentSecurityOrigin                 << 11
+            & key.useSystemAppearance                       << 12
+            & key.mode                                      << 13; // Keep this last.
+        hash ^= WTF::intHash(bits);
+        return hash;
+    }
+    static bool equal(const CSSParserContext& a, const CSSParserContext& b)
+    {
+        return a == b;
+    }
+    static const bool safeToCompareToEmptyOrDeleted = false;
+};
+
+} // namespace WebCore
+
+namespace WTF {
+template<> struct HashTraits<WebCore::CSSParserContext> : GenericHashTraits<WebCore::CSSParserContext> {
+    static void constructDeletedValue(WebCore::CSSParserContext& slot) { new (NotNull, &slot.baseURL) WebCore::URL(WTF::HashTableDeletedValue); }
+    static bool isDeletedValue(const WebCore::CSSParserContext& value) { return value.baseURL.isHashTableDeletedValue(); }
+    static WebCore::CSSParserContext emptyValue() { return WebCore::CSSParserContext(WebCore::HTMLStandardMode); }
+};
+
+template<> struct DefaultHash<WebCore::CSSParserContext> {
+    typedef WebCore::CSSParserContextHash Hash;
+};
+} // namespace WTF
index c96706f..871d599 100644 (file)
@@ -31,7 +31,7 @@
 
 #pragma once
 
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include <wtf/ASCIICType.h>
 
 namespace WebCore {
index 29ebd4f..36e3790 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "CSSDeferredParser.h"
 #include "CSSParser.h"
-#include "CSSParserMode.h"
 #include "CSSParserTokenRange.h"
 #include "CSSPropertyNames.h"
 #include "StyleRule.h"
index 99c1e3a..d42a429 100644 (file)
 
 #pragma once
 
-#include "TextEncoding.h"
-#include "URL.h"
-#include "URLHash.h"
-#include <wtf/HashFunctions.h>
-#include <wtf/text/StringHash.h>
-
 namespace WebCore {
 
-class Document;
-
 // Must not grow beyond 3 bits, due to packing in StyleProperties.
 enum CSSParserMode {
     HTMLStandardMode,
@@ -86,89 +78,4 @@ inline bool isStrictParserMode(CSSParserMode cssParserMode)
     return cssParserMode == UASheetMode || cssParserMode == HTMLStandardMode || cssParserMode == SVGAttributeMode;
 }
 
-struct CSSParserContext {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    CSSParserContext(CSSParserMode, const URL& baseURL = URL());
-    WEBCORE_EXPORT CSSParserContext(Document&, const URL& baseURL = URL(), const String& charset = emptyString());
-
-    URL baseURL;
-    String charset;
-    CSSParserMode mode { HTMLStandardMode };
-    bool isHTMLDocument { false };
-#if ENABLE(TEXT_AUTOSIZING)
-    bool textAutosizingEnabled { false };
-#endif
-    bool needsSiteSpecificQuirks { false };
-    bool enforcesCSSMIMETypeInNoQuirksMode { true };
-    bool useLegacyBackgroundSizeShorthandBehavior { false };
-    bool springTimingFunctionEnabled { false };
-    bool constantPropertiesEnabled { false };
-    bool conicGradientsEnabled { false };
-    bool colorFilterEnabled { false };
-    bool deferredCSSParserEnabled { false };
-    bool allowNewLinesClamp { false };
-    
-    // This is only needed to support getMatchedCSSRules.
-    bool hasDocumentSecurityOrigin { false };
-    
-    bool useSystemAppearance { false };
-
-    URL completeURL(const String& url) const
-    {
-        if (url.isNull())
-            return URL();
-        if (charset.isEmpty())
-            return URL(baseURL, url);
-        return URL(baseURL, url, TextEncoding(charset));
-    }
-};
-
-bool operator==(const CSSParserContext&, const CSSParserContext&);
-inline bool operator!=(const CSSParserContext& a, const CSSParserContext& b) { return !(a == b); }
-
-WEBCORE_EXPORT const CSSParserContext& strictCSSParserContext();
-
-struct CSSParserContextHash {
-    static unsigned hash(const CSSParserContext& key)
-    {
-        auto hash = URLHash::hash(key.baseURL);
-        if (!key.charset.isEmpty())
-            hash ^= StringHash::hash(key.charset);
-        unsigned bits = key.isHTMLDocument                  << 0
-            & key.isHTMLDocument                            << 1
-#if ENABLE(TEXT_AUTOSIZING)
-            & key.textAutosizingEnabled                     << 2
-#endif
-            & key.needsSiteSpecificQuirks                   << 3
-            & key.enforcesCSSMIMETypeInNoQuirksMode         << 4
-            & key.useLegacyBackgroundSizeShorthandBehavior  << 5
-            & key.springTimingFunctionEnabled               << 6
-            & key.conicGradientsEnabled                     << 7
-            & key.deferredCSSParserEnabled                  << 8
-            & key.hasDocumentSecurityOrigin                 << 9
-            & key.mode                                      << 10
-            & key.allowNewLinesClamp                        << 11;
-        hash ^= WTF::intHash(bits);
-        return hash;
-    }
-    static bool equal(const CSSParserContext& a, const CSSParserContext& b)
-    {
-        return a == b;
-    }
-    static const bool safeToCompareToEmptyOrDeleted = false;
-};
-
 } // namespace WebCore
-
-namespace WTF {
-template<> struct HashTraits<WebCore::CSSParserContext> : GenericHashTraits<WebCore::CSSParserContext> {
-    static void constructDeletedValue(WebCore::CSSParserContext& slot) { new (NotNull, &slot.baseURL) WebCore::URL(WTF::HashTableDeletedValue); }
-    static bool isDeletedValue(const WebCore::CSSParserContext& value) { return value.baseURL.isHashTableDeletedValue(); }
-    static WebCore::CSSParserContext emptyValue() { return WebCore::CSSParserContext(WebCore::HTMLStandardMode); }
-};
-
-template<> struct DefaultHash<WebCore::CSSParserContext> {
-    typedef WebCore::CSSParserContextHash Hash;
-};
-} // namespace WTF
index ce35266..a078107 100644 (file)
@@ -30,7 +30,7 @@
 #pragma once
 
 #include "CSSFunctionValue.h"
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include "CSSParserTokenRange.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSShadowValue.h"
index 8df2965..9788e94 100644 (file)
@@ -30,7 +30,7 @@
 #include "config.h"
 #include "CSSSelectorParser.h"
 
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include "CSSSelectorList.h"
 #include "StyleSheetContents.h"
 #include <memory>
index 1715ff1..87086e3 100644 (file)
@@ -31,7 +31,7 @@
 #include "CSSVariableParser.h"
 
 #include "CSSCustomPropertyValue.h"
-#include "CSSParserMode.h"
+#include "CSSParserContext.h"
 #include "CSSParserTokenRange.h"
 
 namespace WebCore {