Implement css-conditional's CSS.supports()
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2013 13:45:05 +0000 (13:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2013 13:45:05 +0000 (13:45 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@142739 268f45cc-cd09-0410-ab3c-d52691b4dbfc

35 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/supports-dom-api-expected.txt [new file with mode: 0644]
LayoutTests/css3/supports-dom-api.html [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wincairo/TestExpectations
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/DerivedSources.pri
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/gobject/GNUmakefile.am
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
Source/WebCore/css/CSSAllInOne.cpp
Source/WebCore/css/CSSGrammar.y.in
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/DOMWindowCSS.cpp [new file with mode: 0644]
Source/WebCore/css/DOMWindowCSS.h [new file with mode: 0644]
Source/WebCore/css/DOMWindowCSS.idl [new file with mode: 0644]
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/DOMWindow.idl

index 46cbc42..69d94f1 100644 (file)
@@ -1,3 +1,21 @@
+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.
+
+        * 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:
+
 2013-02-13  Mike West  <mkwst@chromium.org>
 
         location.href does not throw SECURITY_ERR when accessed across origins with JSC bindings
diff --git a/LayoutTests/css3/supports-dom-api-expected.txt b/LayoutTests/css3/supports-dom-api-expected.txt
new file mode 100644 (file)
index 0000000..2370a9e
--- /dev/null
@@ -0,0 +1,66 @@
+Test window.CSS.supports()
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS CSS.supports("(display: none)") is true
+PASS CSS.supports("(display: deadbeef)") is false
+PASS CSS.supports("not (display: deadbeef)") is true
+PASS CSS.supports("not (display: none)") is false
+PASS CSS.supports("not (not (display: none))") is true
+PASS CSS.supports("not (not (not (display: none)))") is false
+PASS CSS.supports("(display: none) and (display: block)") is true
+PASS CSS.supports("(display: none) and (display: block) and (display: inline)") is true
+PASS CSS.supports("(display: none) and (display: block) and (display: deadbeef) and (display: inline)") is false
+PASS CSS.supports("(display: none) or (display: inline)") is true
+PASS CSS.supports("(display: none) or (display: block) or (display: inline)") is true
+PASS CSS.supports("(display: none) or (display: deadbeef) or (display: inline)") is true
+PASS CSS.supports("(display: ohhai) or (display: deadbeef) or (display: rainbows)") is false
+PASS CSS.supports("(display: none) and (display: block) or (display: inline)") is false
+PASS CSS.supports("not (display: deadbeef) and (display: block)") is false
+PASS CSS.supports("(not (border: 1px 1px 1px 1px 1px solid #000)) and (display: block)") is true
+PASS CSS.supports("(display: block !important) and ((display: inline) or (display: deadbeef))") is true
+PASS CSS.supports("not ((not (display: block)) or ((display: none) and (deadbeef: 1px)))") is true
+PASS CSS.supports("not( display: deadbeef)") is true
+PASS CSS.supports("(display: none)and (   -webkit-transition: all 1s )") is true
+PASS CSS.supports("(display: none)or(-webkit-transition: all 1s)") is true
+PASS CSS.supports("(display: none) or(-webkit-transition: all 1s    )") is true
+PASS CSS.supports("(((((((display: none)))))))") is true
+PASS CSS.supports("(!important)") is false
+PASS CSS.supports("not not not not (display: none)") is false
+PASS CSS.supports("(top: -webkit-calc(80% - 20px))") is true
+PASS CSS.supports("(background-color: rgb(0, 128, 0))") is true
+PASS CSS.supports("(background: url('/blah'))") is true
+PASS CSS.supports("((top: -webkit-calc(80% - 20px)) and (not (background-color: rgb(0, 128, 0)))) or (background: url('/blah'))") is true
+PASS CSS.supports("(background: invalid('/blah'))") is false
+PASS CSS.supports("top", "20%") is true
+PASS CSS.supports("top", " 20px   ") is true
+PASS CSS.supports("top", "20") is false
+PASS CSS.supports("dis\nplay", "none") is false
+PASS CSS.supports("display", "rainbow") is false
+PASS CSS.supports("display", "url(rainbow.png)") is false
+PASS CSS.supports(" background   ", "url(rainbow.png)") is true
+PASS CSS.supports("background", "invalid(rainbow.png)") is false
+PASS CSS.supports("background-color", "#000") is true
+PASS CSS.supports("background-color", "rgba(0,0,0,0)") is true
+PASS CSS.supports("background-color", "inherit") is true
+PASS CSS.supports("display", "none !important") is true
+PASS CSS.supports("display", "none!important") is true
+PASS CSS.supports("display", "!important none") is false
+PASS CSS.supports("display", "none !important ! important ") is false
+PASS CSS.supports("display", "none ! important") is true
+PASS CSS.supports("display", "none !   important") is true
+PASS CSS.supports("display", "none ! \nimportant") is true
+PASS CSS.supports("", "") is false
+PASS CSS.supports(true, "") is false
+PASS CSS.supports([], "none") is false
+PASS CSS.supports("display", "") is false
+PASS CSS.supports("display:", "none") is false
+PASS CSS.supports("z-index", 1) is true
+PASS CSS.supports("content", []) is false
+PASS CSS.supports("content", "!important") is false
+PASS CSS.supports("(display: none)", undefined) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/css3/supports-dom-api.html b/LayoutTests/css3/supports-dom-api.html
new file mode 100644 (file)
index 0000000..844e6a9
--- /dev/null
@@ -0,0 +1,88 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    description("Test window.CSS.supports()");
+
+    shouldBeTrue('CSS.supports("(display: none)")');
+    shouldBeFalse('CSS.supports("(display: deadbeef)")');
+
+    // Negation
+    shouldBeTrue('CSS.supports("not (display: deadbeef)")');
+    shouldBeFalse('CSS.supports("not (display: none)")');
+    shouldBeTrue('CSS.supports("not (not (display: none))")');
+    shouldBeFalse('CSS.supports("not (not (not (display: none)))")');
+
+    // Conjunction.
+    shouldBeTrue('CSS.supports("(display: none) and (display: block)")');
+    shouldBeTrue('CSS.supports("(display: none) and (display: block) and (display: inline)")');
+    shouldBeFalse('CSS.supports("(display: none) and (display: block) and (display: deadbeef) and (display: inline)")');
+
+    // Disjunction.
+    shouldBeTrue('CSS.supports("(display: none) or (display: inline)")');
+    shouldBeTrue('CSS.supports("(display: none) or (display: block) or (display: inline)")');
+    shouldBeTrue('CSS.supports("(display: none) or (display: deadbeef) or (display: inline)")');
+    shouldBeFalse('CSS.supports("(display: ohhai) or (display: deadbeef) or (display: rainbows)")');
+
+    // Bad syntax. Can't mix operators without a layer of parentheses..
+    shouldBeFalse('CSS.supports("(display: none) and (display: block) or (display: inline)")');
+    shouldBeFalse('CSS.supports("not (display: deadbeef) and (display: block)")');
+
+    // Mix 'n match.
+    shouldBeTrue('CSS.supports("(not (border: 1px 1px 1px 1px 1px solid #000)) and (display: block)")');
+    shouldBeTrue('CSS.supports("(display: block !important) and ((display: inline) or (display: deadbeef))")');
+    shouldBeTrue('CSS.supports("not ((not (display: block)) or ((display: none) and (deadbeef: 1px)))")');
+
+    // Whitespace/Syntax.
+    shouldBeTrue('CSS.supports("not( display: deadbeef)")');
+    shouldBeTrue('CSS.supports("(display: none)and (   -webkit-transition: all 1s )")');
+    shouldBeTrue('CSS.supports("(display: none)or(-webkit-transition: all 1s)")');
+    shouldBeTrue('CSS.supports("(display: none) or(-webkit-transition: all 1s    )")');
+    shouldBeTrue('CSS.supports("(((((((display: none)))))))")');
+    shouldBeFalse('CSS.supports("(!important)")');
+    shouldBeFalse('CSS.supports("not not not not (display: none)")');
+
+    // Functions.
+    shouldBeTrue('CSS.supports("(top: -webkit-calc(80% - 20px))")');
+    shouldBeTrue('CSS.supports("(background-color: rgb(0, 128, 0))")');
+    shouldBeTrue('CSS.supports("(background: url(\'/blah\'))")');
+    shouldBeTrue('CSS.supports("((top: -webkit-calc(80% - 20px)) and (not (background-color: rgb(0, 128, 0)))) or (background: url(\'/blah\'))")');
+    shouldBeFalse('CSS.supports("(background: invalid(\'/blah\'))")');
+
+    // Property/value variant.
+    shouldBeTrue('CSS.supports("top", "20%")');
+    shouldBeTrue('CSS.supports("top", " 20px   ")');
+    shouldBeFalse('CSS.supports("top", "20")');
+    shouldBeFalse('CSS.supports("dis\\nplay", "none")');
+    shouldBeFalse('CSS.supports("display", "rainbow")');
+    shouldBeFalse('CSS.supports("display", "url(rainbow.png)")');
+    shouldBeTrue('CSS.supports(" background   ", "url(rainbow.png)")');
+    shouldBeFalse('CSS.supports("background", "invalid(rainbow.png)")');
+    shouldBeTrue('CSS.supports("background-color", "#000")');
+    shouldBeTrue('CSS.supports("background-color", "rgba(0,0,0,0)")');
+    shouldBeTrue('CSS.supports("background-color", "inherit")');
+
+    shouldBeTrue('CSS.supports("display", "none !important")');
+    shouldBeTrue('CSS.supports("display", "none!important")');
+    shouldBeFalse('CSS.supports("display", "!important none")');
+    shouldBeFalse('CSS.supports("display", "none !important ! important ")');
+    shouldBeTrue('CSS.supports("display", "none ! important")');
+    shouldBeTrue('CSS.supports("display", "none ! \timportant")');
+    shouldBeTrue('CSS.supports("display", "none ! \\nimportant")');
+
+    shouldBeFalse('CSS.supports("", "")');
+    shouldBeFalse('CSS.supports(true, "")');
+    shouldBeFalse('CSS.supports([], "none")');
+    shouldBeFalse('CSS.supports("display", "")');
+    shouldBeFalse('CSS.supports("display:", "none")');
+    shouldBeTrue('CSS.supports("z-index", 1)');
+    shouldBeFalse('CSS.supports("content", [])');
+    shouldBeFalse('CSS.supports("content", "!important")');
+    shouldBeFalse('CSS.supports("(display: none)", undefined)');
+</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index b5b90af..ba33ac7 100644 (file)
@@ -3922,6 +3922,7 @@ webkit.org/b/95121 [ Android ] fast/borders/border-image-side-reduction.html [ I
 # css3-conditionals support is not yet enabled.
 webkit.org/b/86146 css3/supports.html
 webkit.org/b/104822 css3/supports-cssom.html
+webkit.org/b/100324 css3/supports-dom-api.html
 
 # CSS Device Adaptation is not enabled.
 webkit.org/b/95959 css3/device-adapt [ Skip ]
index a580d1e..1ab3f53 100644 (file)
@@ -1592,6 +1592,7 @@ webkit.org/b/99878 css3/flexbox/flexbox-baseline-margins.html [ Missing ImageOnl
 # css3-conditionals support is not yet enabled.
 webkit.org/b/86146 css3/supports.html
 webkit.org/b/104822 css3/supports-cssom.html
+webkit.org/b/100324 css3/supports-dom-api.html
 
 # Occasionally fails if run after right after
 # fast/selectors/unqualified-hover-quirks.html or itself.
index f4441c3..8e498b4 100644 (file)
@@ -411,6 +411,7 @@ webkit.org/b/99059 fast/dom/timer-throttling-hidden-page.html [ Failure ]
 # css3-conditionals support is not yet enabled.
 webkit.org/b/86146 css3/supports.html
 webkit.org/b/104822 css3/supports-cssom.html
+webkit.org/b/100324 css3/supports-dom-api.html
 
 # Requires Resolution Media Query support
 webkit.org/b/100137 fast/media/mq-resolution.html [ Failure ]
index 5bf08ff..550ee1a 100644 (file)
@@ -1178,6 +1178,7 @@ webkit.org/b/92464 [ Debug ] fast/events/tabindex-focus-blur-all.html [ Crash Pa
 # css3-conditionals support is not yet enabled.
 webkit.org/b/86146 css3/supports.html
 webkit.org/b/104822 css3/supports-cssom.html
+webkit.org/b/100324 css3/supports-dom-api.html
 
 # CSS Device Adaptation is not enabled.
 webkit.org/b/95959 css3/device-adapt [ Skip ]
index e897b8c..4ed2354 100644 (file)
@@ -2483,6 +2483,7 @@ webkit.org/b/23166 ietestcenter/css3/bordersbackgrounds/border-radius-clip-002.h
 # css3-conditionals support is not yet enabled.
 webkit.org/b/86146 css3/supports.html
 webkit.org/b/104822 css3/supports-cssom.html
+webkit.org/b/100324 css3/supports-dom-api.html
 
 # CSS Device Adaptation is not enabled.
 webkit.org/b/95969 css3/device-adapt [ Skip ]
index 23088c6..7fef7d3 100644 (file)
@@ -2409,9 +2409,10 @@ css3/flexbox/flexbox-baseline.html
 #https://bugs.webkit.org/show_bug.cgi?id=99878
 css3/flexbox/flexbox-baseline-margins.html
 
-# css3-conditionals support is not yet enabled. http://webkit.org/b/86146 http://webkit.org/b/104822
+# css3-conditionals support is not yet enabled. http://webkit.org/b/86146 http://webkit.org/b/104822 http://webkit.org/b/100324
 css3/supports.html
 css3/supports-cssom.html
+css3/supports-dom-api.html
 
 # https://bugs.webkit.org/show_bug.cgi?id=98169
 http/tests/inspector/stacktraces
index 8e1839f..bc3b030 100644 (file)
@@ -2908,9 +2908,10 @@ css3/flexbox/flexbox-baseline.html
 #https://bugs.webkit.org/show_bug.cgi?id=99878
 css3/flexbox/flexbox-baseline-margins.html
 
-# css3-conditionals support is not yet enabled. http://webkit.org/b/86146 http://webkit.org/b/104822
+# css3-conditionals support is not yet enabled. http://webkit.org/b/86146 http://webkit.org/b/104822 http://webkit.org/b/100324
 css3/supports.html
 css3/supports-cssom.html
+css3/supports-dom-api.html
 
 # https://bugs.webkit.org/show_bug.cgi?id=98169
 http/tests/inspector/stacktraces
index c114b4f..be6c757 100644 (file)
@@ -329,6 +329,7 @@ inspector/styles/override-screen-size.html
 # css3-conditionals support is not yet enabled.
 webkit.org/b/86146 css3/supports.html
 webkit.org/b/104822 css3/supports-cssom.html
+webkit.org/b/100324 css3/supports-dom-api.html
 
 # Text Autosizing is not yet enabled.
 # https://bugs.webkit.org/show_bug.cgi?id=84186
index c58d15c..e61c89b 100644 (file)
@@ -318,6 +318,7 @@ set(WebCore_IDL_FILES
     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 @@ set(WebCore_SOURCES
     css/CSSValue.cpp
     css/CSSValueList.cpp
     css/CSSValuePool.cpp
+    css/DOMWindowCSS.cpp
     css/DocumentRuleSets.cpp
     css/FontFeatureValue.cpp
     css/FontValue.cpp
index 6fad4fc..93e458e 100644 (file)
@@ -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
index 7d96bfa..195beac 100644 (file)
 #include "JSDOMTokenList.cpp"
 #include "JSDOMURL.cpp"
 #include "JSDOMWindow.cpp"
+#include "JSDOMWindowCSS.cpp"
 #include "JSElement.cpp"
 #include "JSEntity.cpp"
 #include "JSEntityReference.cpp"
index 0a59d59..3772252 100644 (file)
@@ -193,6 +193,7 @@ BINDING_IDLS = \
     $(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 \
index 8ac7738..d11be4d 100644 (file)
@@ -202,6 +202,7 @@ IDL_BINDINGS += \
     $$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 \
index c852ef7..0830f95 100644 (file)
@@ -221,6 +221,8 @@ webcore_built_sources += \
        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 @@ dom_binding_idls += \
        $(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 @@ webcore_sources += \
        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 \
index fb1862e..7b33918 100644 (file)
@@ -305,6 +305,7 @@ SOURCES += \
     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 @@ HEADERS += \
     css/CSSValueList.h \
     css/CSSValuePool.h \
     css/CSSVariableValue.h \
+    css/DOMWindowCSS.h \
     css/FontFeatureValue.h \
     css/FontValue.h \
     css/LengthFunctions.h \
index dfdae83..6709de1 100644 (file)
@@ -169,6 +169,9 @@ __ZN7WebCore11memoryCacheEv
 __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 @@ __ZN7WebCore4PathD1Ev
 __ZN7WebCore4coreEP20NSURLProtectionSpace
 __ZN7WebCore4coreEP28NSURLAuthenticationChallenge
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_10ClientRectE
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_12DOMWindowCSSE
+#endif
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_13DOMStringListE
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_14ClientRectListE
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_19CSSStyleDeclarationE
index 4c371bc..681389f 100644 (file)
             'css/CSSValue.idl',
             'css/CSSValueList.idl',
             'css/Counter.idl',
+            'css/DOMWindowCSS.idl',
             'css/MediaList.idl',
             'css/MediaQueryList.idl',
             'css/Rect.idl',
             'css/CSSValuePool.h',
             'css/CSSVariableValue.h',
             'css/Counter.h',
+            'css/DOMWindowCSS.cpp',
+            'css/DOMWindowCSS.h',
             'css/DashboardRegion.h',
             'css/DocumentRuleSets.cpp',
             'css/DocumentRuleSets.h',
             '<(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',
index 5f244f5..80391fb 100755 (executable)
                                >
                        </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
                                >
                        </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
index 288f5a8..eecf59c 100644 (file)
                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 */; };
                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>"; };
                                14CF78A509F58CD800EB3665 /* JSCSSValue.h */,
                                A8D05FA90A23B30F005E7203 /* JSCSSValueList.cpp */,
                                A8D05FAA0A23B30F005E7203 /* JSCSSValueList.h */,
+                               FC9E0E4A16419C1E00392BE3 /* JSDOMWindowCSS.cpp */,
+                               FC9E0E4B16419C1E00392BE3 /* JSDOMWindowCSS.h */,
                                BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */,
                                BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */,
                                D3A94A42122DC40F00A37BBC /* JSMediaQueryList.cpp */,
                                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 */,
                                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 */,
                                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 */,
                                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 */,
                                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 */,
index c0d784f..2114fa8 100644 (file)
@@ -57,6 +57,8 @@ webkitgtk_gdom_built_sources += \
        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 @@ webkitgtk_gdom_built_h_api += \
        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 \
index 90c3ce8..d4743a6 100644 (file)
@@ -510,6 +510,7 @@ sub WK_lcfirst
     $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.)
index 31485f0..4741852 100644 (file)
@@ -262,6 +262,10 @@ sub SkipFunction {
         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
index e73e358..09a543b 100644 (file)
@@ -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"
index 10544c3..cb84fe2 100644 (file)
@@ -111,6 +111,9 @@ static inline int cssyyerror(void*, const char*)
 %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 @@ stylesheet:
   | 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 @@ webkit_selector:
     }
 ;
 
+#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
index 105f18c..509c0ac 100644 (file)
@@ -260,6 +260,9 @@ CSSParser::CSSParser(const CSSParserContext& context)
     , 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 @@ PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet
     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 @@ inline void CSSParser::detectAtToken(int length, bool hasEscape)
             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;
         }
     }
 }
index dcb5134..a25ba4c 100644 (file)
@@ -80,6 +80,9 @@ public:
     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 @@ public:
     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 (file)
index 0000000..86611c2
--- /dev/null
@@ -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 (file)
index 0000000..7070ae6
--- /dev/null
@@ -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 (file)
index 0000000..aed4cf7
--- /dev/null
@@ -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);
+
+};
+
index 22f448c..e02b48f 100644 (file)
@@ -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 @@ void DOMWindow::cancelAnimationFrame(int id)
 }
 #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
index bcfcb4e..4b76438 100644 (file)
@@ -69,6 +69,7 @@ namespace WebCore {
     class Storage;
     class StyleMedia;
     class WebKitPoint;
+    class DOMWindowCSS;
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     class RequestAnimationFrameCallback;
@@ -265,6 +266,10 @@ namespace WebCore {
         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 @@ namespace WebCore {
 #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
index d93cf73..d45c01f 100644 (file)
     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;