Commit f571f791 authored by weinig@apple.com's avatar weinig@apple.com

[Re-land] Cleanup MediaQueryListListener

https://bugs.webkit.org/show_bug.cgi?id=119664

Reviewed by Andreas Kling.

Source/WebCore: 

Make MediaQueryListListener a proper WebIDL callback.

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Update project files.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackHeader):
(GenerateCallbackImplementation):
(JSValueToNative):
* bindings/scripts/IDLAttributes.txt:
Add support for CallbackNeedsOperatorEqual, which adds an operator==.

* css/MediaAllInOne.cpp:
Remove MediaQueryListListener.cpp.

* css/MediaQueryListListener.cpp:
Removed.

* css/MediaQueryListListener.h:
(WebCore::MediaQueryListListener::~MediaQueryListListener):
(WebCore::MediaQueryListListener::MediaQueryListListener):
* css/MediaQueryListListener.idl:
Convert to a proper WebIDL callback.

* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::Listener::evaluate):
(WebCore::MediaQueryMatcher::styleResolverChanged):
* css/MediaQueryMatcher.h:
Remove all traces of the ScriptState.

LayoutTests: 

* fast/media/media-query-list-07-expected.txt:
* fast/media/media-query-list-07.html:
* platform/mac/TestExpectations:
Update test to reflect that we are supposed to throw exceptions when when not passing a callback
object to addListener/removeListener. Also update the test to use the internals interface that is
supported by more ports.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 86696147
2013-08-13 Sam Weinig <sam@webkit.org>
[Re-land] Cleanup MediaQueryListListener
https://bugs.webkit.org/show_bug.cgi?id=119664
Reviewed by Andreas Kling.
* fast/media/media-query-list-07-expected.txt:
* fast/media/media-query-list-07.html:
* platform/mac/TestExpectations:
Update test to reflect that we are supposed to throw exceptions when when not passing a callback
object to addListener/removeListener. Also update the test to use the internals interface that is
supported by more ports.
2013-08-13 Alexey Proskuryakov <ap@apple.com>
Removed a bogus comment that didn't have any bugs after it.
......@@ -2,6 +2,9 @@ Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-media
Invalid listeners. Two callbacks are expected.
[1] - query (-webkit-view-mode: windowed) changed to false
[2] - query (-webkit-view-mode: windowed) changed to false
query.addListener(5) threw exception as expected
query.addListener('cinco') threw exception as expected
query.addListener([1,2]) threw exception as expected
[1] - query screen changed to false
[2] - query screen changed to false
......@@ -25,17 +25,30 @@
if (!window.testRunner)
return;
testRunner.setViewModeMediaFeature("windowed");
var query = window.matchMedia("(-webkit-view-mode: windowed)");
var query = window.matchMedia("screen");
query.addListener(callback1);
query.addListener(5);
query.addListener('cinco');
query.addListener([1,2]);
try {
query.addListener(5);
} catch (e) {
log("query.addListener(5) threw exception as expected");
}
try {
query.addListener('cinco');
} catch (e) {
log("query.addListener('cinco') threw exception as expected");
}
try {
query.addListener([1,2]);
} catch (e) {
log("query.addListener([1,2]) threw exception as expected");
}
query.addListener(callback2);
testRunner.setViewModeMediaFeature("minimized");
window.internals.settings.setMediaTypeOverride("handheld");
}
</script>
......
......@@ -85,7 +85,6 @@ fast/media/media-query-list-03.html [ Failure ]
fast/media/media-query-list-04.html [ Failure ]
fast/media/media-query-list-05.html [ Failure ]
fast/media/media-query-list-06.html [ Failure ]
fast/media/media-query-list-07.html [ Failure ]
# Needs layoutTestController.enableAutoResizeMode()
fast/autoresize
......
......@@ -316,6 +316,7 @@ set(WebCore_IDL_FILES
css/FontLoader.idl
css/MediaList.idl
css/MediaQueryList.idl
css/MediaQueryListListener.idl
css/RGBColor.idl
css/Rect.idl
css/StyleMedia.idl
......@@ -1074,7 +1075,6 @@ set(WebCore_SOURCES
css/MediaQueryEvaluator.cpp
css/MediaQueryExp.cpp
css/MediaQueryList.cpp
css/MediaQueryListListener.cpp
css/MediaQueryMatcher.cpp
css/PageRuleCollector.cpp
css/PropertySetCSSStyleDeclaration.cpp
......
2013-08-13 Sam Weinig <sam@webkit.org>
[Re-land] Cleanup MediaQueryListListener
https://bugs.webkit.org/show_bug.cgi?id=119664
Reviewed by Andreas Kling.
Make MediaQueryListListener a proper WebIDL callback.
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Update project files.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackHeader):
(GenerateCallbackImplementation):
(JSValueToNative):
* bindings/scripts/IDLAttributes.txt:
Add support for CallbackNeedsOperatorEqual, which adds an operator==.
* css/MediaAllInOne.cpp:
Remove MediaQueryListListener.cpp.
* css/MediaQueryListListener.cpp:
Removed.
* css/MediaQueryListListener.h:
(WebCore::MediaQueryListListener::~MediaQueryListListener):
(WebCore::MediaQueryListListener::MediaQueryListListener):
* css/MediaQueryListListener.idl:
Convert to a proper WebIDL callback.
* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::Listener::evaluate):
(WebCore::MediaQueryMatcher::styleResolverChanged):
* css/MediaQueryMatcher.h:
Remove all traces of the ScriptState.
2013-08-13 Dean Jackson <dino@apple.com>
<https://webkit.org/b/119776> Don't use ScriptProfiler to find canvases for instrumentation
......@@ -274,6 +274,7 @@
#include "JSMediaError.cpp"
#include "JSMediaList.cpp"
#include "JSMediaQueryList.cpp"
#include "JSMediaQueryListListener.cpp"
#if ENABLE(MEDIA_SOURCE)
#include "JSMediaSource.cpp"
#endif
......
......@@ -651,7 +651,7 @@ BINDING_IDLS = \
DOM_CLASSES=$(basename $(notdir $(BINDING_IDLS)))
JS_DOM_HEADERS=$(filter-out JSMediaQueryListListener.h JSEventListener.h, $(DOM_CLASSES:%=JS%.h))
JS_DOM_HEADERS=$(filter-out JSEventListener.h, $(DOM_CLASSES:%=JS%.h))
WEB_DOM_HEADERS :=
......
......@@ -209,6 +209,7 @@ IDL_BINDINGS += \
$$PWD/css/FontLoader.idl \
$$PWD/css/MediaList.idl \
$$PWD/css/MediaQueryList.idl \
$$PWD/css/MediaQueryListListener.idl \
$$PWD/css/Rect.idl \
$$PWD/css/RGBColor.idl \
$$PWD/css/StyleMedia.idl \
......
......@@ -527,6 +527,8 @@ webcore_built_sources += \
DerivedSources/WebCore/JSMediaStreamTrackEvent.h \
DerivedSources/WebCore/JSMediaQueryList.cpp \
DerivedSources/WebCore/JSMediaQueryList.h \
DerivedSources/WebCore/JSMediaQueryListListener.cpp \
DerivedSources/WebCore/JSMediaQueryListListener.h \
DerivedSources/WebCore/JSMessageChannel.cpp \
DerivedSources/WebCore/JSMessageChannel.h \
DerivedSources/WebCore/JSMessageEvent.cpp \
......@@ -1361,6 +1363,7 @@ dom_binding_idls += \
$(WebCore)/css/FontLoader.idl \
$(WebCore)/css/MediaList.idl \
$(WebCore)/css/MediaQueryList.idl \
$(WebCore)/css/MediaQueryListListener.idl \
$(WebCore)/css/RGBColor.idl \
$(WebCore)/css/Rect.idl \
$(WebCore)/css/StyleMedia.idl \
......@@ -2717,7 +2720,6 @@ webcore_sources += \
Source/WebCore/css/MediaQueryExp.h \
Source/WebCore/css/MediaQueryList.cpp \
Source/WebCore/css/MediaQueryList.h \
Source/WebCore/css/MediaQueryListListener.cpp \
Source/WebCore/css/MediaQueryListListener.h \
Source/WebCore/css/MediaQueryMatcher.cpp \
Source/WebCore/css/MediaQueryMatcher.h \
......
......@@ -317,7 +317,6 @@ SOURCES += \
css/MediaQueryEvaluator.cpp \
css/MediaQueryExp.cpp \
css/MediaQueryList.cpp \
css/MediaQueryListListener.cpp \
css/MediaQueryMatcher.cpp \
css/PageRuleCollector.cpp \
css/PropertySetCSSStyleDeclaration.cpp \
......
......@@ -3364,6 +3364,20 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaQueryListListener.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMessageChannel.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
......@@ -9275,14 +9289,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\css\MediaQueryListListener.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\css\MediaQueryMatcher.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
......@@ -18394,6 +18400,7 @@
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaError.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaList.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaQueryList.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaQueryListListener.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMessageChannel.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMessageEvent.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMessagePort.h" />
......@@ -2328,9 +2328,6 @@
<ClCompile Include="..\css\MediaQueryList.cpp">
<Filter>css</Filter>
</ClCompile>
<ClCompile Include="..\css\MediaQueryListListener.cpp">
<Filter>css</Filter>
</ClCompile>
<ClCompile Include="..\css\MediaQueryMatcher.cpp">
<Filter>css</Filter>
</ClCompile>
......@@ -6046,6 +6043,9 @@
<ClCompile Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaQueryList.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaQueryListListener.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMessageChannel.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
......@@ -13782,6 +13782,9 @@
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaQueryList.h">
<Filter>DerivedSources</Filter>
</ClInclude>
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMediaQueryListListener.h">
<Filter>DerivedSources</Filter>
</ClInclude>
<ClInclude Include="$(ConfigurationBuildDir)\obj32\$(ProjectName)\DerivedSources\JSMessageChannel.h">
<Filter>DerivedSources</Filter>
</ClInclude>
......
......@@ -1959,6 +1959,8 @@
7AFD4FF4113277B60035B883 /* ScriptDebugListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */; };
7C5343FC17B74B63004232F0 /* JSMediaQueryListListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */; };
7C5343FD17B74B63004232F0 /* JSMediaQueryListListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */; };
7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
7CE30DA9171B63D200EC33E1 /* FrameSnapshottingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CE30DA7171B63D200EC33E1 /* FrameSnapshottingMac.mm */; };
7CE30DAA171B63D200EC33E1 /* FrameSnapshottingMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE30DA8171B63D200EC33E1 /* FrameSnapshottingMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -5277,7 +5279,6 @@
D23CA56C0AB0EB8D005108A5 /* RangeException.h in Headers */ = {isa = PBXBuildFile; fileRef = D23CA56B0AB0EB8D005108A5 /* RangeException.h */; };
D302754912A5FE84004BD828 /* RenderDetailsMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D302754512A5FE84004BD828 /* RenderDetailsMarker.cpp */; };
D302754A12A5FE84004BD828 /* RenderDetailsMarker.h in Headers */ = {isa = PBXBuildFile; fileRef = D302754612A5FE84004BD828 /* RenderDetailsMarker.h */; };
D340629B1253BC8C009E4259 /* MediaQueryListListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D340629A1253BC8C009E4259 /* MediaQueryListListener.cpp */; };
D359D789129CA2710006E5D2 /* HTMLDetailsElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D359D786129CA2710006E5D2 /* HTMLDetailsElement.cpp */; };
D359D78A129CA2710006E5D2 /* HTMLDetailsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = D359D787129CA2710006E5D2 /* HTMLDetailsElement.h */; };
D359D791129CA3C00006E5D2 /* DOMHTMLDetailsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = D359D78E129CA3C00006E5D2 /* DOMHTMLDetailsElement.h */; };
......@@ -8391,6 +8392,8 @@
7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptDebugListener.h; sourceTree = "<group>"; };
7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorOverlay.cpp; sourceTree = "<group>"; };
7C522D4A15B478B2009B7C95 /* InspectorOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorOverlay.h; sourceTree = "<group>"; };
7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaQueryListListener.cpp; sourceTree = "<group>"; };
7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JSMediaQueryListListener.h; sourceTree = "<group>"; };
7C60128060078BB70E367A95 /* DNSResolveQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNSResolveQueue.cpp; sourceTree = "<group>"; };
7C6136F61710C35200FF4A57 /* Hasher.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = Hasher.pm; path = scripts/Hasher.pm; sourceTree = "<group>"; };
7C6136F71710C35200FF4A57 /* InFilesCompiler.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = InFilesCompiler.pm; path = scripts/InFilesCompiler.pm; sourceTree = "<group>"; };
......@@ -12048,7 +12051,6 @@
D23CA56B0AB0EB8D005108A5 /* RangeException.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RangeException.h; sourceTree = "<group>"; };
D302754512A5FE84004BD828 /* RenderDetailsMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderDetailsMarker.cpp; sourceTree = "<group>"; };
D302754612A5FE84004BD828 /* RenderDetailsMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderDetailsMarker.h; sourceTree = "<group>"; };
D340629A1253BC8C009E4259 /* MediaQueryListListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryListListener.cpp; sourceTree = "<group>"; };
D359D786129CA2710006E5D2 /* HTMLDetailsElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDetailsElement.cpp; sourceTree = "<group>"; };
D359D787129CA2710006E5D2 /* HTMLDetailsElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLDetailsElement.h; sourceTree = "<group>"; };
D359D788129CA2710006E5D2 /* HTMLDetailsElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLDetailsElement.idl; sourceTree = "<group>"; };
......@@ -17286,6 +17288,8 @@
BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */,
D3A94A42122DC40F00A37BBC /* JSMediaQueryList.cpp */,
D3A94A43122DC40F00A37BBC /* JSMediaQueryList.h */,
7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */,
7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */,
BCFE2F0F0C1B58370020235F /* JSRect.cpp */,
BCFE2F100C1B58370020235F /* JSRect.h */,
BC74DA461013F468007987AD /* JSRGBColor.cpp */,
......@@ -19828,7 +19832,6 @@
D3A94A31122DABAC00A37BBC /* MediaQueryList.cpp */,
D3A94A32122DABAC00A37BBC /* MediaQueryList.h */,
D3A94A33122DABAC00A37BBC /* MediaQueryList.idl */,
D340629A1253BC8C009E4259 /* MediaQueryListListener.cpp */,
D3A94A34122DABAC00A37BBC /* MediaQueryListListener.h */,
D3A94A35122DABAC00A37BBC /* MediaQueryListListener.idl */,
D3AA10F1123A98AA0092152B /* MediaQueryMatcher.cpp */,
......@@ -20989,6 +20992,7 @@
E1CDE9221501916900862CC5 /* AsyncFileStream.h in Headers */,
89D08DA012228451001241DF /* AsyncFileSystem.h in Headers */,
89D08DA112228451001241DF /* AsyncFileSystemCallbacks.h in Headers */,
7C5343FD17B74B63004232F0 /* JSMediaQueryListListener.h in Headers */,
976D6C77122B8A3D001FD1F7 /* AsyncFileWriter.h in Headers */,
976D6C93122B8A3D001FD1F7 /* AsyncFileWriterClient.h in Headers */,
37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */,
......@@ -24855,6 +24859,7 @@
85DF2C5D0AA341F600AD64C5 /* DOMHTMLFormElement.mm in Sources */,
85DF81960AA77E4B00486AD7 /* DOMHTMLFrameElement.mm in Sources */,
85DF81980AA77E4B00486AD7 /* DOMHTMLFrameSetElement.mm in Sources */,
7C5343FC17B74B63004232F0 /* JSMediaQueryListListener.cpp in Sources */,
85992EBB0AA5069500AC0785 /* DOMHTMLHeadElement.mm in Sources */,
85183B450AA6926100F19FA3 /* DOMHTMLHeadingElement.mm in Sources */,
85ECBEF20AA7626900544F0B /* DOMHTMLHRElement.mm in Sources */,
......@@ -26087,7 +26092,6 @@
4E19592B0A39DACC00220FE5 /* MediaQueryEvaluator.cpp in Sources */,
4E19592D0A39DACC00220FE5 /* MediaQueryExp.cpp in Sources */,
D3A94A38122DABAC00A37BBC /* MediaQueryList.cpp in Sources */,
D340629B1253BC8C009E4259 /* MediaQueryListListener.cpp in Sources */,
D3AA10F3123A98AA0092152B /* MediaQueryMatcher.cpp in Sources */,
FD671A77159BB07000197559 /* MediaStreamAudioSourceNode.cpp in Sources */,
BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */,
......@@ -3131,6 +3131,10 @@ sub GenerateCallbackHeader
# Destructor
push(@headerContent, " virtual ~$className();\n");
if ($interface->extendedAttributes->{"CallbackNeedsOperatorEqual"}) {
push(@headerContent, " virtual bool operator==(const $interfaceName&) const;\n\n")
}
# Functions
my $numFunctions = @{$interface->functions};
if ($numFunctions > 0) {
......@@ -3189,7 +3193,12 @@ sub GenerateCallbackImplementation
# Constructor
push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n");
push(@implContent, " : ActiveDOMCallback(globalObject->scriptExecutionContext())\n");
if ($interface->extendedAttributes->{"CallbackNeedsOperatorEqual"}) {
push(@implContent, " : ${interfaceName}(${className}Type)\n");
} else {
push(@implContent, " : ${interfaceName}()\n");
}
push(@implContent, " , ActiveDOMCallback(globalObject->scriptExecutionContext())\n");
push(@implContent, " , m_data(new JSCallbackData(callback, globalObject))\n");
push(@implContent, "{\n");
push(@implContent, "}\n\n");
......@@ -3207,8 +3216,16 @@ sub GenerateCallbackImplementation
push(@implContent, "#ifndef NDEBUG\n");
push(@implContent, " m_data = 0;\n");
push(@implContent, "#endif\n");
push(@implContent, "}\n");
push(@implContent, "}\n\n");
if ($interface->extendedAttributes->{"CallbackNeedsOperatorEqual"}) {
push(@implContent, "bool ${className}::operator==(const ${interfaceName}& other) const\n");
push(@implContent, "{\n");
push(@implContent, " if (other.type() != type())\n");
push(@implContent, " return false;\n");
push(@implContent, " return static_cast<const ${className}*>(&other)->m_data->callback() == m_data->callback();\n");
push(@implContent, "}\n\n");
}
# Functions
my $numFunctions = @{$interface->functions};
if ($numFunctions > 0) {
......@@ -3339,8 +3356,7 @@ my %nativeType = (
"unsigned long long" => "unsigned long long",
"byte" => "int8_t",
"octet" => "uint8_t",
"MediaQueryListListener" => "RefPtr<MediaQueryListListener>",
"DOMTimeStamp" => "DOMTimeStamp",
"DOMTimeStamp" => "DOMTimeStamp",
);
sub GetNativeType
......@@ -3475,11 +3491,6 @@ sub JSValueToNative
return "to$type(exec->vm(), $value)";
}
if ($type eq "MediaQueryListListener") {
AddToImplIncludes("MediaQueryListListener.h", $conditional);
return "MediaQueryListListener::create(ScriptValue(exec->vm(), " . $value ."))";
}
if ($type eq "SerializedScriptValue") {
AddToImplIncludes("SerializedScriptValue.h", $conditional);
return "SerializedScriptValue::create(exec, $value, 0, 0)";
......
......@@ -21,6 +21,7 @@
ActiveDOMObject
CPPPureInterface
CachedAttribute
CallbackNeedsOperatorEqual
CallWith=ScriptExecutionContext|ScriptState|ScriptArguments|CallStack
CheckSecurity
CheckSecurityForNode
......
......@@ -31,5 +31,4 @@
#include "MediaQueryEvaluator.cpp"
#include "MediaQueryExp.cpp"
#include "MediaQueryList.cpp"
#include "MediaQueryListListener.cpp"
#include "MediaQueryMatcher.cpp"
/*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "MediaQueryListListener.h"
#include "MediaQueryList.h"
#include "ScriptFunctionCall.h"
#include "JSMediaQueryList.h"
namespace WebCore {
void MediaQueryListListener::queryChanged(ScriptState* state, MediaQueryList* query)
{
ScriptCallback callback(state, m_value);
callback.appendArgument(toJS(state, deprecatedGlobalObjectForPrototype(state), query));
callback.call();
}
}
......@@ -20,35 +20,34 @@
#ifndef MediaQueryListListener_h
#define MediaQueryListListener_h
#include "ScriptState.h"
#include "ScriptValue.h"
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class MediaQueryList;
// See http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
class MediaQueryListListener : public RefCounted<MediaQueryListListener> {
public:
static PassRefPtr<MediaQueryListListener> create(const ScriptValue& value)
enum Type {
JSMediaQueryListListenerType
};
virtual bool queryChanged(MediaQueryList*) = 0;
virtual bool operator==(const MediaQueryListListener&) const = 0;
virtual ~MediaQueryListListener() { }
Type type() const { return m_type; }
protected:
explicit MediaQueryListListener(Type type)
: m_type(type)
{
if (!value.isFunction())
return 0;
return adoptRef(new MediaQueryListListener(value));
}
void queryChanged(ScriptState*, MediaQueryList*);
bool operator==(const MediaQueryListListener& other) const { return m_value == other.m_value; }
private:
MediaQueryListListener(const ScriptValue& value) : m_value(value) { }
ScriptValue m_value;
Type m_type;
};
}
} // namespace WebCore
#endif // MediaQueryListListener_h
......@@ -18,10 +18,7 @@
*/
[
NoInterfaceObject,
JSNoStaticTables,
ObjCProtocol,
CPPPureInterface,
] interface MediaQueryListListener {
void queryChanged([Default=Undefined] optional MediaQueryList list);
CallbackNeedsOperatorEqual
] callback interface MediaQueryListListener {
boolean queryChanged([Default=Undefined] optional MediaQueryList list);
};
......@@ -42,12 +42,12 @@ MediaQueryMatcher::Listener::~Listener()
{
}
void MediaQueryMatcher::Listener::evaluate(ScriptState* state, MediaQueryEvaluator* evaluator)
void MediaQueryMatcher::Listener::evaluate(MediaQueryEvaluator* evaluator)
{
bool notify;
m_query->evaluate(evaluator, notify);
if (notify)
m_listener->queryChanged(state, m_query.get());
m_listener->queryChanged(m_query.get());
}
MediaQueryMatcher::MediaQueryMatcher(Document* document)
......@@ -141,17 +141,13 @@ void MediaQueryMatcher::styleResolverChanged()
{
ASSERT(m_document);
ScriptState* scriptState = mainWorldScriptState(m_document->frame());
if (!scriptState)
return;
++m_evaluationRound;
OwnPtr<MediaQueryEvaluator> evaluator = prepareEvaluator();
if (!evaluator)
return;
for (size_t i = 0; i < m_listeners.size(); ++i)
m_listeners[i]->evaluate(scriptState, evaluator.get());
m_listeners[i]->evaluate(evaluator.get());
}
}
} // namespace WebCore
......@@ -20,7 +20,6 @@
#ifndef MediaQueryMatcher_h
#define MediaQueryMatcher_h
#include "ScriptState.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
......@@ -59,7 +58,7 @@ private:
Listener(PassRefPtr<MediaQueryListListener>, PassRefPtr<MediaQueryList>);
~Listener();
void evaluate(ScriptState*, MediaQueryEvaluator*);
void evaluate(MediaQueryEvaluator*);
MediaQueryListListener* listener() { return m_listener.get(); }
MediaQueryList* query() { return m_query.get(); }
......@@ -82,6 +81,6 @@ private:
unsigned m_evaluationRound;
};
}
} // namespace WebCore
#endif // MediaQueryMatcher_h
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment