Implement css-conditional's CSS.supports()
https://bugs.webkit.org/show_bug.cgi?id=100324
Patch by Pablo Flouret <pablof@motorola.com> on 2013-02-13
Reviewed by Antti Koivisto.
Source/WebCore:
http://dev.w3.org/csswg/css3-conditional/#the-css-interface
The supports() method provides the css @supports rule's corresponding
dom api.
The patch also adds the CSS interface on DOMWindow, which holds "useful
CSS-related functions that do not belong elsewhere". This is where
supports() lives.
Test: css3/supports-dom-api.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/gobject/GNUmakefile.am:
* bindings/scripts/CodeGeneratorGObject.pm:
(SkipFunction):
Add DOMWindowCSS.* to the build systems.
* bindings/scripts/CodeGenerator.pm:
(WK_lcfirst):
Handle CSS prefixes correctly (s/cSS/css/).
* css/CSSGrammar.y.in:
* css/CSSParser.cpp:
(WebCore::CSSParser::CSSParser):
(WebCore::CSSParser::parseSupportsCondition):
(WebCore::CSSParser::detectAtToken):
* css/CSSParser.h:
webkit_supports_condition parses just the condition part of an
@supports rule and evaluates it, outputting whether the condition
is supported or not.
* css/CSSAllInOne.cpp:
* css/DOMWindowCSS.cpp: Added.
* css/DOMWindowCSS.h: Added.
* css/DOMWindowCSS.idl: Added.
The CSS interface object.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::css):
* page/DOMWindow.h:
* page/DOMWindow.idl:
window.CSS
LayoutTests:
* css3/supports-dom-api-expected.txt: Added.
* css3/supports-dom-api.html: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:
* platform/wk2/TestExpectations:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index c58d15c..e61c89b 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -318,6 +318,7 @@
css/CSSSupportsRule.idl
css/CSSValue.idl
css/CSSValueList.idl
+ css/DOMWindowCSS.idl
css/MediaList.idl
css/MediaQueryList.idl
css/RGBColor.idl
@@ -1063,6 +1064,7 @@
css/CSSValue.cpp
css/CSSValueList.cpp
css/CSSValuePool.cpp
+ css/DOMWindowCSS.cpp
css/DocumentRuleSets.cpp
css/FontFeatureValue.cpp
css/FontValue.cpp
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 6fad4fc..93e458e 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,61 @@
+2013-02-13 Pablo Flouret <pablof@motorola.com>
+
+ Implement css-conditional's CSS.supports()
+ https://bugs.webkit.org/show_bug.cgi?id=100324
+
+ Reviewed by Antti Koivisto.
+
+ http://dev.w3.org/csswg/css3-conditional/#the-css-interface
+
+ The supports() method provides the css @supports rule's corresponding
+ dom api.
+ The patch also adds the CSS interface on DOMWindow, which holds "useful
+ CSS-related functions that do not belong elsewhere". This is where
+ supports() lives.
+
+ Test: css3/supports-dom-api.html
+
+ * CMakeLists.txt:
+ * DerivedSources.cpp:
+ * DerivedSources.make:
+ * DerivedSources.pri:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.exp.in:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/gobject/GNUmakefile.am:
+ * bindings/scripts/CodeGeneratorGObject.pm:
+ (SkipFunction):
+ Add DOMWindowCSS.* to the build systems.
+
+ * bindings/scripts/CodeGenerator.pm:
+ (WK_lcfirst):
+ Handle CSS prefixes correctly (s/cSS/css/).
+
+ * css/CSSGrammar.y.in:
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::CSSParser):
+ (WebCore::CSSParser::parseSupportsCondition):
+ (WebCore::CSSParser::detectAtToken):
+ * css/CSSParser.h:
+ webkit_supports_condition parses just the condition part of an
+ @supports rule and evaluates it, outputting whether the condition
+ is supported or not.
+
+ * css/CSSAllInOne.cpp:
+ * css/DOMWindowCSS.cpp: Added.
+ * css/DOMWindowCSS.h: Added.
+ * css/DOMWindowCSS.idl: Added.
+ The CSS interface object.
+
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::css):
+ * page/DOMWindow.h:
+ * page/DOMWindow.idl:
+ window.CSS
+
2013-02-13 Vladislav Kaznacheev <kaznacheev@chromium.org>
Web Inspector: Simplify SplitView to rely more on CSS
diff --git a/Source/WebCore/DerivedSources.cpp b/Source/WebCore/DerivedSources.cpp
index 7d96bfa..195beac 100644
--- a/Source/WebCore/DerivedSources.cpp
+++ b/Source/WebCore/DerivedSources.cpp
@@ -106,6 +106,7 @@
#include "JSDOMTokenList.cpp"
#include "JSDOMURL.cpp"
#include "JSDOMWindow.cpp"
+#include "JSDOMWindowCSS.cpp"
#include "JSElement.cpp"
#include "JSEntity.cpp"
#include "JSEntityReference.cpp"
diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make
index 0a59d59..3772252 100644
--- a/Source/WebCore/DerivedSources.make
+++ b/Source/WebCore/DerivedSources.make
@@ -193,6 +193,7 @@
$(WebCore)/css/CSSValue.idl \
$(WebCore)/css/CSSValueList.idl \
$(WebCore)/css/Counter.idl \
+ $(WebCore)/css/DOMWindowCSS.idl \
$(WebCore)/css/MediaList.idl \
$(WebCore)/css/MediaQueryList.idl \
$(WebCore)/css/MediaQueryListListener.idl \
diff --git a/Source/WebCore/DerivedSources.pri b/Source/WebCore/DerivedSources.pri
index 8ac7738..d11be4d 100644
--- a/Source/WebCore/DerivedSources.pri
+++ b/Source/WebCore/DerivedSources.pri
@@ -202,6 +202,7 @@
$$PWD/css/CSSSupportsRule.idl \
$$PWD/css/CSSValue.idl \
$$PWD/css/CSSValueList.idl \
+ $$PWD/css/DOMWindowCSS.idl \
$$PWD/css/MediaList.idl \
$$PWD/css/MediaQueryList.idl \
$$PWD/css/Rect.idl \
diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am
index c852ef7..0830f952 100644
--- a/Source/WebCore/GNUmakefile.list.am
+++ b/Source/WebCore/GNUmakefile.list.am
@@ -221,6 +221,8 @@
DerivedSources/WebCore/JSDOMURL.h \
DerivedSources/WebCore/JSDOMWindow.cpp \
DerivedSources/WebCore/JSDOMWindow.h \
+ DerivedSources/WebCore/JSDOMWindowCSS.cpp \
+ DerivedSources/WebCore/JSDOMWindowCSS.h \
DerivedSources/WebCore/JSDynamicsCompressorNode.h \
DerivedSources/WebCore/JSDynamicsCompressorNode.cpp \
DerivedSources/WebCore/JSElement.cpp \
@@ -1340,6 +1342,7 @@
$(WebCore)/css/CSSValue.idl \
$(WebCore)/css/CSSValueList.idl \
$(WebCore)/css/Counter.idl \
+ $(WebCore)/css/DOMWindowCSS.idl \
$(WebCore)/css/MediaList.idl \
$(WebCore)/css/MediaQueryList.idl \
$(WebCore)/css/RGBColor.idl \
@@ -2636,6 +2639,8 @@
Source/WebCore/css/CSSValuePool.cpp \
Source/WebCore/css/CSSValuePool.h \
Source/WebCore/css/CSSVariableValue.h \
+ Source/WebCore/css/DOMWindowCSS.cpp \
+ Source/WebCore/css/DOMWindowCSS.h \
Source/WebCore/css/DashboardRegion.h \
Source/WebCore/css/DocumentRuleSets.cpp \
Source/WebCore/css/DocumentRuleSets.h \
diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri
index fb1862e..7b33918 100644
--- a/Source/WebCore/Target.pri
+++ b/Source/WebCore/Target.pri
@@ -305,6 +305,7 @@
css/CSSValue.cpp \
css/CSSValueList.cpp \
css/CSSValuePool.cpp \
+ css/DOMWindowCSS.cpp \
css/DocumentRuleSets.cpp \
css/FontFeatureValue.cpp \
css/FontValue.cpp \
@@ -1538,6 +1539,7 @@
css/CSSValueList.h \
css/CSSValuePool.h \
css/CSSVariableValue.h \
+ css/DOMWindowCSS.h \
css/FontFeatureValue.h \
css/FontValue.h \
css/LengthFunctions.h \
diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in
index dfdae83..6709de1 100644
--- a/Source/WebCore/WebCore.exp.in
+++ b/Source/WebCore/WebCore.exp.in
@@ -169,6 +169,9 @@
__ZN7WebCore11startOfWordERKNS_15VisiblePositionENS_9EWordSideE
__ZN7WebCore11writeToFileEiPKci
__ZN7WebCore12ChromeClient23paintCustomOverhangAreaEPNS_15GraphicsContextERKNS_7IntRectES5_S5_
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+__ZN7WebCore12DOMWindowCSS6createEv
+#endif
__ZN7WebCore12EditingStyleD1Ev
__ZN7WebCore12EventHandler10mouseMovedERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler14scrollOverflowENS_15ScrollDirectionENS_17ScrollGranularityEPNS_4NodeE
@@ -808,6 +811,9 @@
__ZN7WebCore4coreEP20NSURLProtectionSpace
__ZN7WebCore4coreEP28NSURLAuthenticationChallenge
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_10ClientRectE
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_12DOMWindowCSSE
+#endif
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_13DOMStringListE
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_14ClientRectListE
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_19CSSStyleDeclarationE
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index 4c371bce..681389f 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -173,6 +173,7 @@
'css/CSSValue.idl',
'css/CSSValueList.idl',
'css/Counter.idl',
+ 'css/DOMWindowCSS.idl',
'css/MediaList.idl',
'css/MediaQueryList.idl',
'css/Rect.idl',
@@ -1538,6 +1539,8 @@
'css/CSSValuePool.h',
'css/CSSVariableValue.h',
'css/Counter.h',
+ 'css/DOMWindowCSS.cpp',
+ 'css/DOMWindowCSS.h',
'css/DashboardRegion.h',
'css/DocumentRuleSets.cpp',
'css/DocumentRuleSets.h',
@@ -6290,6 +6293,8 @@
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSDOMURL.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSDOMURL.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSDOMWindow.cpp',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDOMWindowCSS.cpp',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDOMWindowCSS.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSDataView.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSDataView.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSDatabase.cpp',
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index 5f244f5..80391fb 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -4463,6 +4463,62 @@
>
</File>
<File
+ RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSDOMWindowCSS.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSDOMWindowCSS.h"
+ >
+ </File>
+ <File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSElement.cpp"
>
<FileConfiguration
@@ -37939,6 +37995,62 @@
>
</File>
<File
+ RelativePath="..\css\DOMWindowCSS.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\css\DOMWindowCSS.h"
+ >
+ </File>
+ <File
RelativePath="..\css\CSSValuePool.cpp"
>
<FileConfiguration
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index 288f5a8..eecf59c 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -6523,6 +6523,10 @@
FCD8832B16A49F8200962227 /* DOMCSSSupportsRule.mm in Sources */ = {isa = PBXBuildFile; fileRef = FCD8832916A49F8200962227 /* DOMCSSSupportsRule.mm */; };
FCD8832C16A49FB000962227 /* DOMCSSSupportsRule.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = FCD8832816A49F8200962227 /* DOMCSSSupportsRule.h */; };
FCEBBAAB16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = FCEBBAAA16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h */; };
+ FC9A0F74164094CF003D6B8D /* DOMWindowCSS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC9A0F71164094CF003D6B8D /* DOMWindowCSS.cpp */; };
+ FC9A0F75164094CF003D6B8D /* DOMWindowCSS.h in Headers */ = {isa = PBXBuildFile; fileRef = FC9A0F72164094CF003D6B8D /* DOMWindowCSS.h */; };
+ FC9E0E4D16419C1E00392BE3 /* JSDOMWindowCSS.h in Headers */ = {isa = PBXBuildFile; fileRef = FC9E0E4B16419C1E00392BE3 /* JSDOMWindowCSS.h */; };
+ FC9E0E5116419C7F00392BE3 /* JSDOMWindowCSS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC9E0E4A16419C1E00392BE3 /* JSDOMWindowCSS.cpp */; };
FD00D7A414A3F61900734011 /* SincResampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD00D7A214A3F61900734011 /* SincResampler.cpp */; };
FD00D7A514A3F61900734011 /* SincResampler.h in Headers */ = {isa = PBXBuildFile; fileRef = FD00D7A314A3F61900734011 /* SincResampler.h */; };
FD06DFA5134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD06DFA3134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp */; };
@@ -14218,6 +14222,11 @@
FCD8832816A49F8200962227 /* DOMCSSSupportsRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCSSSupportsRule.h; sourceTree = "<group>"; };
FCD8832916A49F8200962227 /* DOMCSSSupportsRule.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMCSSSupportsRule.mm; sourceTree = "<group>"; };
FCEBBAAA16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCSSSupportsRuleInternal.h; sourceTree = "<group>"; };
+ FC9A0F71164094CF003D6B8D /* DOMWindowCSS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowCSS.cpp; sourceTree = "<group>"; };
+ FC9A0F72164094CF003D6B8D /* DOMWindowCSS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindowCSS.h; sourceTree = "<group>"; };
+ FC9A0F73164094CF003D6B8D /* DOMWindowCSS.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMWindowCSS.idl; sourceTree = "<group>"; };
+ FC9E0E4A16419C1E00392BE3 /* JSDOMWindowCSS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWindowCSS.cpp; sourceTree = "<group>"; };
+ FC9E0E4B16419C1E00392BE3 /* JSDOMWindowCSS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWindowCSS.h; sourceTree = "<group>"; };
FCEBCD711623A7910029965E /* CSSGrammar.y.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; path = CSSGrammar.y.in; sourceTree = "<group>"; };
FCEBCD721623A7910029965E /* CSSGrammar.y.includes */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; path = CSSGrammar.y.includes; sourceTree = "<group>"; };
FD00D7A214A3F61900734011 /* SincResampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SincResampler.cpp; sourceTree = "<group>"; };
@@ -19497,6 +19506,8 @@
14CF78A509F58CD800EB3665 /* JSCSSValue.h */,
A8D05FA90A23B30F005E7203 /* JSCSSValueList.cpp */,
A8D05FAA0A23B30F005E7203 /* JSCSSValueList.h */,
+ FC9E0E4A16419C1E00392BE3 /* JSDOMWindowCSS.cpp */,
+ FC9E0E4B16419C1E00392BE3 /* JSDOMWindowCSS.h */,
BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */,
BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */,
D3A94A42122DC40F00A37BBC /* JSMediaQueryList.cpp */,
@@ -21961,6 +21972,9 @@
4A4F48A716B0DFC000EDBB29 /* DocumentRuleSets.cpp */,
4A4F48A816B0DFC000EDBB29 /* DocumentRuleSets.h */,
4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */,
+ FC9A0F71164094CF003D6B8D /* DOMWindowCSS.cpp */,
+ FC9A0F72164094CF003D6B8D /* DOMWindowCSS.h */,
+ FC9A0F73164094CF003D6B8D /* DOMWindowCSS.idl */,
4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */,
A80E6CC70A1989CA007FB8C5 /* FontValue.cpp */,
A80E6CC30A1989CA007FB8C5 /* FontValue.h */,
@@ -24162,6 +24176,7 @@
85C7F5E70AAFBAFB004014DD /* DOMWheelEvent.h in Headers */,
85989DD10ACC8BBD00A0BC51 /* DOMWheelEventInternal.h in Headers */,
1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */,
+ FC9A0F75164094CF003D6B8D /* DOMWindowCSS.h in Headers */,
51FA2D78152132B300C1BA0B /* DOMWindowExtension.h in Headers */,
9712A5AE15004EDA0048AF10 /* DOMWindowIndexedDatabase.h in Headers */,
97B38E27151C4271004622E9 /* DOMWindowNotifications.h in Headers */,
@@ -24788,6 +24803,7 @@
7694563D1214D97C0007CBAE /* JSDOMTokenList.h in Headers */,
2E37E00612DBC5A400A6B233 /* JSDOMURL.h in Headers */,
BC6932740D7E293900AE44D1 /* JSDOMWindowBase.h in Headers */,
+ FC9E0E4D16419C1E00392BE3 /* JSDOMWindowCSS.h in Headers */,
652FBBBC0DE27CB60001D386 /* JSDOMWindowCustom.h in Headers */,
BCBFB53D0DCD29CF0019B3E5 /* JSDOMWindowShell.h in Headers */,
65E0E9441133C89F00B4CB10 /* JSDOMWrapper.h in Headers */,
@@ -27511,6 +27527,7 @@
31C0FF4D0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm in Sources */,
85C7F5E80AAFBAFB004014DD /* DOMWheelEvent.mm in Sources */,
1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
+ FC9A0F74164094CF003D6B8D /* DOMWindowCSS.cpp in Sources */,
517FBA1E151AB17C00B57959 /* DOMWindowExtension.cpp in Sources */,
9712A5AD15004EDA0048AF10 /* DOMWindowIndexedDatabase.cpp in Sources */,
97B38E28151C4273004622E9 /* DOMWindowNotifications.cpp in Sources */,
@@ -28103,6 +28120,7 @@
2E37E00512DBC5A400A6B233 /* JSDOMURL.cpp in Sources */,
1403BA0C09EB18C700797C7F /* JSDOMWindow.cpp in Sources */,
BC6932730D7E293900AE44D1 /* JSDOMWindowBase.cpp in Sources */,
+ FC9E0E5116419C7F00392BE3 /* JSDOMWindowCSS.cpp in Sources */,
BCD9C2620C17AA67005C90A2 /* JSDOMWindowCustom.cpp in Sources */,
BCBFB53C0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp in Sources */,
A80A9423149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp in Sources */,
diff --git a/Source/WebCore/bindings/gobject/GNUmakefile.am b/Source/WebCore/bindings/gobject/GNUmakefile.am
index c0d784f..2114fa8 100644
--- a/Source/WebCore/bindings/gobject/GNUmakefile.am
+++ b/Source/WebCore/bindings/gobject/GNUmakefile.am
@@ -57,6 +57,8 @@
DerivedSources/webkitdom/WebKitDOMDOMTokenList.cpp \
DerivedSources/webkitdom/WebKitDOMDOMTokenListPrivate.h \
DerivedSources/webkitdom/WebKitDOMDOMWindow.cpp \
+ DerivedSources/webkitdom/WebKitDOMDOMWindowCSS.cpp \
+ DerivedSources/webkitdom/WebKitDOMDOMWindowCSSPrivate.h \
DerivedSources/webkitdom/WebKitDOMDOMWindowPrivate.h \
DerivedSources/webkitdom/WebKitDOMElement.cpp \
DerivedSources/webkitdom/WebKitDOMElementPrivate.h \
@@ -393,6 +395,7 @@
DerivedSources/webkitdom/WebKitDOMBarInfo.h \
DerivedSources/webkitdom/WebKitDOMConsole.h \
DerivedSources/webkitdom/WebKitDOMCustom.h \
+ DerivedSources/webkitdom/WebKitDOMDOMWindowCSS.h \
DerivedSources/webkitdom/WebKitDOMDOMWindow.h \
DerivedSources/webkitdom/WebKitDOMDOMSelection.h \
DerivedSources/webkitdom/WebKitDOMEventTarget.h \
diff --git a/Source/WebCore/bindings/scripts/CodeGenerator.pm b/Source/WebCore/bindings/scripts/CodeGenerator.pm
index 90c3ce8..d4743a6 100644
--- a/Source/WebCore/bindings/scripts/CodeGenerator.pm
+++ b/Source/WebCore/bindings/scripts/CodeGenerator.pm
@@ -510,6 +510,7 @@
$ret =~ s/jS/js/ if $ret =~ /^jS/;
$ret =~ s/xML/xml/ if $ret =~ /^xML/;
$ret =~ s/xSLT/xslt/ if $ret =~ /^xSLT/;
+ $ret =~ s/cSS/css/ if $ret =~ /^cSS/;
# For HTML5 FileSystem API Flags attributes.
# (create is widely used to instantiate an object and must be avoided.)
diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
index 31485f0..4741852 100644
--- a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
+++ b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
@@ -262,6 +262,10 @@
return 1;
}
+ if ($function->signature->name eq "supports" && @{$function->parameters} == 1) {
+ return 1;
+ }
+
# Skip functions that have ["Callback"] parameters, because this
# code generator doesn't know how to auto-generate callbacks.
# Skip functions that have "MediaQueryListListener" or sequence<T> parameters, because this
diff --git a/Source/WebCore/css/CSSAllInOne.cpp b/Source/WebCore/css/CSSAllInOne.cpp
index e73e358..09a543b 100644
--- a/Source/WebCore/css/CSSAllInOne.cpp
+++ b/Source/WebCore/css/CSSAllInOne.cpp
@@ -69,6 +69,7 @@
#include "CSSValue.cpp"
#include "CSSValueList.cpp"
#include "CSSValuePool.cpp"
+#include "DOMWindowCSS.cpp"
#include "DocumentRuleSets.cpp"
#include "InspectorCSSOMWrappers.cpp"
#include "RuleFeature.cpp"
diff --git a/Source/WebCore/css/CSSGrammar.y.in b/Source/WebCore/css/CSSGrammar.y.in
index 10544c3b..cb84fe2 100644
--- a/Source/WebCore/css/CSSGrammar.y.in
+++ b/Source/WebCore/css/CSSGrammar.y.in
@@ -111,6 +111,9 @@
%token WEBKIT_SELECTOR_SYM
%token WEBKIT_REGION_RULE_SYM
%token WEBKIT_VIEWPORT_RULE_SYM
+#if ENABLE_CSS3_CONDITIONAL_RULES
+%token WEBKIT_SUPPORTS_CONDITION_SYM
+#endif
#if ENABLE_CSS_SHADERS
%token WEBKIT_FILTER_RULE_SYM
#endif
@@ -312,6 +315,9 @@
| webkit_mediaquery maybe_space
| webkit_selector maybe_space
| webkit_keyframe_rule maybe_space
+#if ENABLE_CSS3_CONDITIONAL_RULES
+ | webkit_supports_condition maybe_space
+#endif
;
webkit_rule:
@@ -359,6 +365,14 @@
}
;
+#if ENABLE_CSS3_CONDITIONAL_RULES
+webkit_supports_condition:
+ WEBKIT_SUPPORTS_CONDITION_SYM '{' maybe_space supports_condition '}' {
+ parser->m_supportsCondition = $4;
+ }
+;
+#endif
+
maybe_space:
/* empty */ %prec UNIMPORTANT_TOK
| maybe_space WHITESPACE
diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp
index 105f18c..509c0ac 100644
--- a/Source/WebCore/css/CSSParser.cpp
+++ b/Source/WebCore/css/CSSParser.cpp
@@ -260,6 +260,9 @@
, m_important(false)
, m_id(CSSPropertyInvalid)
, m_styleSheet(0)
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ , m_supportsCondition(false)
+#endif
, m_selectorListForParseSelector(0)
, m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES)
, m_inParseShorthand(0)
@@ -433,6 +436,16 @@
return m_keyframe.release();
}
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+bool CSSParser::parseSupportsCondition(const String& string)
+{
+ m_supportsCondition = false;
+ setupParser("@-webkit-supports-condition{ ", string, "} ");
+ cssyyparse(this);
+ return m_supportsCondition;
+}
+#endif
+
static inline bool isColorPropertyID(CSSPropertyID propertyId)
{
switch (propertyId) {
@@ -10251,6 +10264,15 @@
if (!hasEscape && isEqualToCSSIdentifier(name + 2, "webkit-keyframe-rule"))
m_token = WEBKIT_KEYFRAME_RULE_SYM;
return;
+
+ case 27:
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ if (isEqualToCSSIdentifier(name + 2, "webkit-supports-condition")) {
+ m_parsingMode = SupportsMode;
+ m_token = WEBKIT_SUPPORTS_CONDITION_SYM;
+ }
+#endif
+ return;
}
}
}
diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h
index dcb5134..a25ba4c 100644
--- a/Source/WebCore/css/CSSParser.h
+++ b/Source/WebCore/css/CSSParser.h
@@ -80,6 +80,9 @@
void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0, RuleSourceDataList* = 0);
PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&);
PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&);
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ bool parseSupportsCondition(const String&);
+#endif
static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
static bool parseColor(RGBA32& color, const String&, bool strict = false);
static bool parseSystemColor(RGBA32& color, const String&, Document*);
@@ -352,6 +355,10 @@
RefPtr<StyleKeyframe> m_keyframe;
OwnPtr<MediaQuery> m_mediaQuery;
OwnPtr<CSSParserValueList> m_valueList;
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ bool m_supportsCondition;
+#endif
+
typedef Vector<CSSProperty, 256> ParsedPropertyVector;
ParsedPropertyVector m_parsedProperties;
CSSSelectorList* m_selectorListForParseSelector;
diff --git a/Source/WebCore/css/DOMWindowCSS.cpp b/Source/WebCore/css/DOMWindowCSS.cpp
new file mode 100644
index 0000000..86611c2
--- /dev/null
+++ b/Source/WebCore/css/DOMWindowCSS.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2012 Motorola Mobility 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.
+ * 3. Neither the name of Motorola Mobility 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 "DOMWindowCSS.h"
+
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+
+#include "CSSParser.h"
+#include "StylePropertySet.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+PassRefPtr<DOMWindowCSS> DOMWindowCSS::create()
+{
+ return adoptRef(new DOMWindowCSS());
+}
+
+static String valueWithoutImportant(const String& value)
+{
+ if (!value.endsWith("important", false))
+ return value;
+
+ String newValue = value;
+ int bangIndex = newValue.length() - 9 - 1;
+ if (newValue[bangIndex] == ' ')
+ bangIndex--;
+ newValue = newValue.left(bangIndex);
+
+ return newValue;
+}
+
+bool DOMWindowCSS::supports(const String& property, const String& value) const
+{
+ CSSPropertyID propertyID = cssPropertyID(property.stripWhiteSpace());
+
+ if (propertyID == CSSPropertyInvalid)
+ return false;
+
+ // CSSParser::parseValue() won't work correctly if !important is present,
+ // so just get rid of it. It doesn't matter to supports() if it's actually
+ // there or not, provided how it's specified in the value is correct.
+ String normalizedValue = value.stripWhiteSpace().simplifyWhiteSpace();
+ normalizedValue = valueWithoutImportant(normalizedValue);
+
+ if (normalizedValue.isEmpty())
+ return false;
+
+ RefPtr<StylePropertySet> dummyStyle = StylePropertySet::create();
+ return CSSParser::parseValue(dummyStyle.get(), propertyID, normalizedValue, false, CSSStrictMode, 0);
+}
+
+bool DOMWindowCSS::supports(const String& conditionText) const
+{
+ CSSParserContext context(CSSStrictMode);
+ CSSParser parser(context);
+ return parser.parseSupportsCondition(conditionText);
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/css/DOMWindowCSS.h b/Source/WebCore/css/DOMWindowCSS.h
new file mode 100644
index 0000000..7070ae6
--- /dev/null
+++ b/Source/WebCore/css/DOMWindowCSS.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Motorola Mobility 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.
+ * 3. Neither the name of Motorola Mobility 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.
+ */
+
+#ifndef DOMWindowCSS_h
+#define DOMWindowCSS_h
+
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class DOMWindowCSS : public RefCounted<DOMWindowCSS> {
+public:
+ static PassRefPtr<DOMWindowCSS> create();
+
+ bool supports(const String& property, const String& value) const;
+ bool supports(const String& conditionText) const;
+
+private:
+ DOMWindowCSS()
+ {
+ }
+};
+
+}
+
+#endif // ENABLE(CSS3_CONDITIONAL_RULES)
+
+#endif
diff --git a/Source/WebCore/css/DOMWindowCSS.idl b/Source/WebCore/css/DOMWindowCSS.idl
new file mode 100644
index 0000000..aed4cf7
--- /dev/null
+++ b/Source/WebCore/css/DOMWindowCSS.idl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012 Motorola Mobility 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.
+ * 3. Neither the name of Motorola Mobility 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.
+ */
+
+[
+ InterfaceName=CSS,
+ Conditional=CSS3_CONDITIONAL_RULES
+] interface DOMWindowCSS {
+
+ boolean supports(DOMString property, DOMString value);
+ boolean supports(DOMString conditionText);
+
+};
+
diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp
index 22f448c..e02b48f 100644
--- a/Source/WebCore/page/DOMWindow.cpp
+++ b/Source/WebCore/page/DOMWindow.cpp
@@ -43,6 +43,7 @@
#include "DOMTimer.h"
#include "DOMTokenList.h"
#include "DOMURL.h"
+#include "DOMWindowCSS.h"
#include "DOMWindowExtension.h"
#include "DOMWindowNotifications.h"
#include "DeviceMotionController.h"
@@ -1566,6 +1567,15 @@
}
#endif
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+DOMWindowCSS* DOMWindow::css()
+{
+ if (!m_css)
+ m_css = DOMWindowCSS::create();
+ return m_css.get();
+}
+#endif
+
static void didAddStorageEventListener(DOMWindow* window)
{
// Creating these WebCore::Storage objects informs the system that we'd like to receive
diff --git a/Source/WebCore/page/DOMWindow.h b/Source/WebCore/page/DOMWindow.h
index bcfcb4e..4b76438 100644
--- a/Source/WebCore/page/DOMWindow.h
+++ b/Source/WebCore/page/DOMWindow.h
@@ -69,6 +69,7 @@
class Storage;
class StyleMedia;
class WebKitPoint;
+ class DOMWindowCSS;
#if ENABLE(REQUEST_ANIMATION_FRAME)
class RequestAnimationFrameCallback;
@@ -265,6 +266,10 @@
void cancelAnimationFrame(int id);
#endif
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ DOMWindowCSS* css();
+#endif
+
// Events
// EventTarget API
virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
@@ -457,6 +462,10 @@
#if ENABLE(WEB_TIMING)
mutable RefPtr<Performance> m_performance;
#endif
+
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ mutable RefPtr<DOMWindowCSS> m_css;
+#endif
};
inline String DOMWindow::status() const
diff --git a/Source/WebCore/page/DOMWindow.idl b/Source/WebCore/page/DOMWindow.idl
index d93cf73..d45c01f 100644
--- a/Source/WebCore/page/DOMWindow.idl
+++ b/Source/WebCore/page/DOMWindow.idl
@@ -219,6 +219,8 @@
DOMString btoa(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString string)
raises(DOMException);
+ attribute [Replaceable,Conditional=CSS3_CONDITIONAL_RULES] DOMWindowCSS CSS;
+
// Events
attribute EventListener onabort;
attribute EventListener onbeforeunload;