Skip to content

Commit fe3ef9a

Browse files
committed
Automatically generate WorkerContext constructor attributes
https://bugs.webkit.org/show_bug.cgi?id=117183 Reviewed by Kentaro Hara. .: Update GENERATE_BINDINGS macro to take an additional _workercontext_constructors_file optional argument. * Source/cmake/WebKitMacros.cmake: Source/WebCore: Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker] IDL extended attribute to indicate to the bindings generator on which global context the constructor attribute should be generated for interfaces without [NoInterfaceObject]: - WindowOnly: only on the global Window object (default if ommitted) - WorkerOnly: only on the worker context - WindowAndWorker: On both the global Window object and the worker context This covers all the current use cases. The JSC bindings generator now automatically generates the Constructor attributes on the WorkerContext for non-callback interfaces which do not have the [NoInterfaceObject] extended attribute but have [GlobalContext=WorkerOnly|WindowAndWorker] extended attribute. No new tests, already covered by: fast/js/global-constructors-attributes.html fast/js/global-constructors-attributes-worker.html * CMakeLists.txt: * DerivedSources.make: Pass new --workerContextConstructorsFile argument to preprocess-idls.pl. * DerivedSources.pri: Ditto. * GNUmakefile.am: Ditto. * PlatformBlackBerry.cmake: Ditto. * UseJSC.cmake: Ditto. * bindings/scripts/IDLAttributes.txt: Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker] IDL extended attribute. * bindings/scripts/preprocess-idls.pl: Add support for [GlobalContext] extended attribute and generate a partial interface for WorkerContext global constructors that are automatically generated. * dom/MessageEvent.idl: Add [GlobalContext=WindowAndWorker]. * fileapi/Blob.idl: Add [GlobalContext=WindowAndWorker]. * fileapi/FileReader.idl: Add [GlobalContext=WindowAndWorker]. * fileapi/FileReaderSync.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject] as the interface should only be visible in worker environment as per the spec. * html/DOMURL.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/ArrayBuffer.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/DataView.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Float32Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Float64Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Int16Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Int32Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Int8Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Uint16Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Uint32Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Uint8Array.idl: Add [GlobalContext=WindowAndWorker]. * html/canvas/Uint8ClampedArray.idl: Add [GlobalContext=WindowAndWorker]. * workers/WorkerContext.idl: Remove several Constructor attributes which are now automatically generated. * workers/WorkerLocation.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject] as the interface should only be visible in worker environment as per the spec. Tools: Pass new --workerContextConstructorsFile to preprocess-idl.pl for bindings tests. * Scripts/webkitpy/bindings/main.py: (BindingsTests.generate_supplemental_dependency): (BindingsTests.main): Canonical link: https://commits.webkit.org/135451@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@151169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent b3e6248 commit fe3ef9a

31 files changed

Lines changed: 162 additions & 52 deletions

ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2013-06-04 Christophe Dumez <[email protected]>
2+
3+
Automatically generate WorkerContext constructor attributes
4+
https://bugs.webkit.org/show_bug.cgi?id=117183
5+
6+
Reviewed by Kentaro Hara.
7+
8+
Update GENERATE_BINDINGS macro to take an additional _workercontext_constructors_file
9+
optional argument.
10+
11+
* Source/cmake/WebKitMacros.cmake:
12+
113
2013-06-03 Eduardo Lima Mitev <[email protected]>
214

315
[EFL] Add ATK version 2.8.0 to efl jhbuild moduleset

Source/WebCore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,7 @@ set(SCRIPTS_BINDINGS
29462946
set(IDL_FILES_TMP ${DERIVED_SOURCES_WEBCORE_DIR}/idl_files.tmp)
29472947
set(SUPPLEMENTAL_DEPENDENCY_FILE ${DERIVED_SOURCES_WEBCORE_DIR}/supplemental_dependency.tmp)
29482948
set(WINDOW_CONSTRUCTORS_FILE ${DERIVED_SOURCES_WEBCORE_DIR}/DOMWindowConstructors.idl)
2949+
set(WORKERCONTEXT_CONSTRUCTORS_FILE ${DERIVED_SOURCES_WEBCORE_DIR}/WorkerContextConstructors.idl)
29492950
set(IDL_ATTRIBUTES_FILE ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
29502951

29512952
include(${WEBCORE_DIR}/UseJSC.cmake)

Source/WebCore/ChangeLog

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,61 @@
1+
2013-06-04 Christophe Dumez <[email protected]>
2+
3+
Automatically generate WorkerContext constructor attributes
4+
https://bugs.webkit.org/show_bug.cgi?id=117183
5+
6+
Reviewed by Kentaro Hara.
7+
8+
Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker] IDL extended attribute
9+
to indicate to the bindings generator on which global context the constructor
10+
attribute should be generated for interfaces without [NoInterfaceObject]:
11+
- WindowOnly: only on the global Window object (default if ommitted)
12+
- WorkerOnly: only on the worker context
13+
- WindowAndWorker: On both the global Window object and the worker context
14+
15+
This covers all the current use cases.
16+
17+
The JSC bindings generator now automatically generates the Constructor attributes
18+
on the WorkerContext for non-callback interfaces which do not have the
19+
[NoInterfaceObject] extended attribute but have [GlobalContext=WorkerOnly|WindowAndWorker]
20+
extended attribute.
21+
22+
No new tests, already covered by:
23+
fast/js/global-constructors-attributes.html
24+
fast/js/global-constructors-attributes-worker.html
25+
26+
* CMakeLists.txt:
27+
* DerivedSources.make: Pass new --workerContextConstructorsFile argument to preprocess-idls.pl.
28+
* DerivedSources.pri: Ditto.
29+
* GNUmakefile.am: Ditto.
30+
* PlatformBlackBerry.cmake: Ditto.
31+
* UseJSC.cmake: Ditto.
32+
* bindings/scripts/IDLAttributes.txt: Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker]
33+
IDL extended attribute.
34+
* bindings/scripts/preprocess-idls.pl: Add support for [GlobalContext] extended attribute and
35+
generate a partial interface for WorkerContext global constructors that are automatically
36+
generated.
37+
* dom/MessageEvent.idl: Add [GlobalContext=WindowAndWorker].
38+
* fileapi/Blob.idl: Add [GlobalContext=WindowAndWorker].
39+
* fileapi/FileReader.idl: Add [GlobalContext=WindowAndWorker].
40+
* fileapi/FileReaderSync.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject]
41+
as the interface should only be visible in worker environment as per the spec.
42+
* html/DOMURL.idl: Add [GlobalContext=WindowAndWorker].
43+
* html/canvas/ArrayBuffer.idl: Add [GlobalContext=WindowAndWorker].
44+
* html/canvas/DataView.idl: Add [GlobalContext=WindowAndWorker].
45+
* html/canvas/Float32Array.idl: Add [GlobalContext=WindowAndWorker].
46+
* html/canvas/Float64Array.idl: Add [GlobalContext=WindowAndWorker].
47+
* html/canvas/Int16Array.idl: Add [GlobalContext=WindowAndWorker].
48+
* html/canvas/Int32Array.idl: Add [GlobalContext=WindowAndWorker].
49+
* html/canvas/Int8Array.idl: Add [GlobalContext=WindowAndWorker].
50+
* html/canvas/Uint16Array.idl: Add [GlobalContext=WindowAndWorker].
51+
* html/canvas/Uint32Array.idl: Add [GlobalContext=WindowAndWorker].
52+
* html/canvas/Uint8Array.idl: Add [GlobalContext=WindowAndWorker].
53+
* html/canvas/Uint8ClampedArray.idl: Add [GlobalContext=WindowAndWorker].
54+
* workers/WorkerContext.idl: Remove several Constructor attributes which are now automatically
55+
generated.
56+
* workers/WorkerLocation.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject]
57+
as the interface should only be visible in worker environment as per the spec.
58+
159
2013-06-04 Kangil Han <[email protected]>
260

361
Use ASSERT_DISABLED option for assertion purpose code in InlineBox

Source/WebCore/DerivedSources.make

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ WEB_DOM_HEADERS :=
660660
all : \
661661
$(SUPPLEMENTAL_DEPENDENCY_FILE) \
662662
$(WINDOW_CONSTRUCTORS_FILE) \
663+
$(WORKERCONTEXT_CONSTRUCTORS_FILE) \
663664
$(JS_DOM_HEADERS) \
664665
$(WEB_DOM_HEADERS) \
665666
\
@@ -1005,6 +1006,7 @@ JS_BINDINGS_SCRIPTS = $(GENERATE_SCRIPTS) bindings/scripts/CodeGeneratorJS.pm
10051006
SUPPLEMENTAL_DEPENDENCY_FILE = ./SupplementalDependencies.txt
10061007
SUPPLEMENTAL_MAKEFILE_DEPS = ./SupplementalDependencies.dep
10071008
WINDOW_CONSTRUCTORS_FILE = ./DOMWindowConstructors.idl
1009+
WORKERCONTEXT_CONSTRUCTORS_FILE = ./WorkerContextConstructors.idl
10081010
IDL_FILES_TMP = ./idl_files.tmp
10091011
ADDITIONAL_IDLS = $(WebCore)/inspector/JavaScriptCallFrame.idl
10101012
IDL_ATTRIBUTES_FILE = $(WebCore)/bindings/scripts/IDLAttributes.txt
@@ -1016,10 +1018,10 @@ space +=
10161018

10171019
$(SUPPLEMENTAL_MAKEFILE_DEPS) : $(PREPROCESS_IDLS_SCRIPTS) $(BINDING_IDLS) $(ADDITIONAL_IDLS) $(PLATFORM_FEATURE_DEFINES)
10181020
printf "$(subst $(space),,$(patsubst %,%\n,$(BINDING_IDLS) $(ADDITIONAL_IDLS)))" > $(IDL_FILES_TMP)
1019-
$(call preprocess_idls_script, $(PREPROCESS_IDLS_SCRIPTS)) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --idlFilesList $(IDL_FILES_TMP) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --windowConstructorsFile $(WINDOW_CONSTRUCTORS_FILE) --supplementalMakefileDeps $@
1021+
$(call preprocess_idls_script, $(PREPROCESS_IDLS_SCRIPTS)) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --idlFilesList $(IDL_FILES_TMP) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --windowConstructorsFile $(WINDOW_CONSTRUCTORS_FILE) --workerContextConstructorsFile $(WORKERCONTEXT_CONSTRUCTORS_FILE) --supplementalMakefileDeps $@
10201022
rm -f $(IDL_FILES_TMP)
10211023

1022-
JS%.h : %.idl $(JS_BINDINGS_SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(WINDOW_CONSTRUCTORS_FILE) $(PLATFORM_FEATURE_DEFINES)
1024+
JS%.h : %.idl $(JS_BINDINGS_SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(WINDOW_CONSTRUCTORS_FILE) $(WORKERCONTEXT_CONSTRUCTORS_FILE) $(PLATFORM_FEATURE_DEFINES)
10231025
$(call generator_script, $(JS_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --generator JS --idlAttributesFile $(IDL_ATTRIBUTES_FILE) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) $<
10241026

10251027
include $(SUPPLEMENTAL_MAKEFILE_DEPS)

Source/WebCore/DerivedSources.pri

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ IDL_BINDINGS += generated/$$INTERNAL_SETTINGS_GENERATED_IDL
731731
# GENERATOR 0: Resolve [Supplemental] dependency in IDLs
732732
SUPPLEMENTAL_DEPENDENCY_FILE = supplemental_dependency.tmp
733733
WINDOW_CONSTRUCTORS_FILE = DOMWindowConstructors.idl
734+
WORKERCONTEXT_CONSTRUCTORS_FILE = WorkerContextConstructors.idl
734735
IDL_FILES_TMP = ${QMAKE_FUNC_FILE_OUT_PATH}/idl_files.tmp
735736
PREPROCESS_IDLS_SCRIPT = $$PWD/bindings/scripts/preprocess-idls.pl
736737
IDL_ATTRIBUTES_FILE = $$PWD/bindings/scripts/IDLAttributes.txt
@@ -749,8 +750,9 @@ preprocessIdls.commands += perl -I$$PWD/bindings/scripts $$preprocessIdls.script
749750
--defines \"$$javascriptFeatureDefines()\" \
750751
--idlFilesList $$IDL_FILES_TMP \
751752
--supplementalDependencyFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$SUPPLEMENTAL_DEPENDENCY_FILE \
752-
--windowConstructorsFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$WINDOW_CONSTRUCTORS_FILE
753-
preprocessIdls.output = $$SUPPLEMENTAL_DEPENDENCY_FILE $$WINDOW_CONSTRUCTORS_FILE
753+
--windowConstructorsFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$WINDOW_CONSTRUCTORS_FILE \
754+
--workerContextConstructorsFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$WORKERCONTEXT_CONSTRUCTORS_FILE
755+
preprocessIdls.output = $$SUPPLEMENTAL_DEPENDENCY_FILE $$WINDOW_CONSTRUCTORS_FILE $$WORKERCONTEXT_CONSTRUCTORS_FILE
754756
preprocessIdls.add_output_to_sources = false
755757
preprocessIdls.depends = $$IDL_BINDINGS
756758
GENERATORS += preprocessIdls

Source/WebCore/GNUmakefile.am

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ vpath %.idl $(IDL_PATH)
402402

403403
supplemental_dependency_file = $(top_builddir)/DerivedSources/WebCore/idl_supplemental_dependencies
404404
window_constructors_file = $(top_builddir)/DerivedSources/WebCore/DOMWindowConstructors.idl
405+
workercontext_constructors_file = $(top_builddir)/DerivedSources/WebCore/WorkerContextConstructors.idl
405406
idl_files_list = $(top_builddir)/DerivedSources/WebCore/idl_files_list
406407
idl_attributes_file = $(WebCore)/bindings/scripts/IDLAttributes.txt
407408

@@ -410,9 +411,9 @@ $(supplemental_dependency_file): $(SCRIPTS_FOR_PREPROCESS_IDLS) $(dom_binding_id
410411
$(AM_V_GEN)
411412
$(AM_V_at)echo -n > $(idl_files_list)
412413
$(AM_V_at)($(foreach idl, $(dom_binding_idls), echo $(idl) &&) echo -n) >> $(idl_files_list)
413-
$(AM_V_at)$(PERL) -I$(WebCore)/bindings/scripts $(WebCore)/bindings/scripts/preprocess-idls.pl --defines "LANGUAGE_JAVASCRIPT=1 $(feature_defines)" --idlFilesList $(idl_files_list) --windowConstructorsFile $(window_constructors_file) --supplementalDependencyFile $@
414+
$(AM_V_at)$(PERL) -I$(WebCore)/bindings/scripts $(WebCore)/bindings/scripts/preprocess-idls.pl --defines "LANGUAGE_JAVASCRIPT=1 $(feature_defines)" --idlFilesList $(idl_files_list) --windowConstructorsFile $(window_constructors_file) --workerContextConstructorsFile $(workercontext_constructors_file) --supplementalDependencyFile $@
414415

415-
.PHONY: $(window_constructors_file)
416+
.PHONY: $(window_constructors_file) $(workercontext_constructors_file)
416417

417418
# This does not appear to work correctly with gnumake unless
418419
# it includes an empty command list (the semicolon).
@@ -432,7 +433,7 @@ DerivedSources/WebCore/JSInternalSettingsGenerated.h: DerivedSources/WebCore/Int
432433
# IDL generation takes a long time. The pipe represents an order-only dependency,
433434
# which means that GNUmake will only try to build the dependencies first, but
434435
# not rebuild all the targets if the dependencies change.
435-
$(webkitgtk_sources) $(webkit2_sources) $(webkit2_plugin_process_sources) $(webcore_sources) $(webcoregtk_sources) $(platformgtk_sources) : | $(supplemental_dependency_file) $(window_constructors_file) $(webcore_built_sources)
436+
$(webkitgtk_sources) $(webkit2_sources) $(webkit2_plugin_process_sources) $(webcore_sources) $(webcoregtk_sources) $(platformgtk_sources) : | $(supplemental_dependency_file) $(window_constructors_file) $(workercontext_constructors_file) $(webcore_built_sources)
436437

437438
noinst_LTLIBRARIES += \
438439
libWebCorePlatform.la \

Source/WebCore/PlatformBlackBerry.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ endforeach ()
295295
file(WRITE ${IDL_FILES_TMP} ${IDL_FILES_LIST})
296296

297297
add_custom_command(
298-
OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE}
298+
OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE} ${WORKERCONTEXT_CONSTRUCTORS_FILE}
299299
DEPENDS ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl ${SCRIPTS_RESOLVE_SUPPLEMENTAL} ${WebCore_CPP_IDL_FILES} ${IDL_ATTRIBUTES_FILE}
300-
COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --idlAttributesFile ${IDL_ATTRIBUTES_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE}
300+
COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --idlAttributesFile ${IDL_ATTRIBUTES_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE} --workerContextConstructorsFile ${WORKERCONTEXT_CONSTRUCTORS_FILE}
301301
VERBATIM)
302302

303303
GENERATE_BINDINGS(WebCore_SOURCES
@@ -307,7 +307,8 @@ GENERATE_BINDINGS(WebCore_SOURCES
307307
"${FEATURE_DEFINES_WEBCORE}"
308308
${DERIVED_SOURCES_WEBCORE_DIR} WebDOM CPP
309309
${SUPPLEMENTAL_DEPENDENCY_FILE}
310-
${WINDOW_CONSTRUCTORS_FILE})
310+
${WINDOW_CONSTRUCTORS_FILE}
311+
${WORKERCONTEXT_CONSTRUCTORS_FILE})
311312

312313
# Generate contents for PopupPicker.cpp
313314
set(WebCore_POPUP_CSS_AND_JS

Source/WebCore/UseJSC.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ list(APPEND WebCoreTestSupport_IDL_FILES ${DERIVED_SOURCES_WEBCORE_DIR}/Internal
304304
file(WRITE ${IDL_FILES_TMP} ${IDL_FILES_LIST})
305305

306306
add_custom_command(
307-
OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE}
307+
OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE} ${WORKERCONTEXT_CONSTRUCTORS_FILE}
308308
DEPENDS ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl ${SCRIPTS_PREPROCESS_IDLS} ${WebCore_IDL_FILES} ${WebCoreTestSupport_IDL_FILES}
309-
COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE}
309+
COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE} --workerContextConstructorsFile ${WORKERCONTEXT_CONSTRUCTORS_FILE}
310310
VERBATIM)
311311

312312
GENERATE_BINDINGS(WebCore_SOURCES
@@ -317,7 +317,8 @@ GENERATE_BINDINGS(WebCore_SOURCES
317317
${DERIVED_SOURCES_WEBCORE_DIR} JS JS
318318
${IDL_ATTRIBUTES_FILE}
319319
${SUPPLEMENTAL_DEPENDENCY_FILE}
320-
${WINDOW_CONSTRUCTORS_FILE})
320+
${WINDOW_CONSTRUCTORS_FILE}
321+
${WORKERCONTEXT_CONSTRUCTORS_FILE})
321322

322323
GENERATE_BINDINGS(WebCoreTestSupport_SOURCES
323324
"${WebCoreTestSupport_IDL_FILES}"
@@ -327,4 +328,5 @@ GENERATE_BINDINGS(WebCoreTestSupport_SOURCES
327328
${DERIVED_SOURCES_WEBCORE_DIR} JS JS
328329
${IDL_ATTRIBUTES_FILE}
329330
${SUPPLEMENTAL_DEPENDENCY_FILE}
330-
${WINDOW_CONSTRUCTORS_FILE})
331+
${WINDOW_CONSTRUCTORS_FILE}
332+
${WORKERCONTEXT_CONSTRUCTORS_FILE})

Source/WebCore/bindings/scripts/IDLAttributes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ EnforceRange
5656
EventTarget
5757
ExtendsDOMGlobalObject
5858
GenerateIsReachable=|Impl|ImplContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot
59+
GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker
5960
Immutable
6061
ImplementationLacksVTable
6162
ImplementationNamespace=*

Source/WebCore/bindings/scripts/preprocess-idls.pl

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@
2929
my $idlFilesList;
3030
my $supplementalDependencyFile;
3131
my $windowConstructorsFile;
32+
my $workerContextConstructorsFile;
3233
my $supplementalMakefileDeps;
3334

3435
GetOptions('defines=s' => \$defines,
3536
'preprocessor=s' => \$preprocessor,
3637
'idlFilesList=s' => \$idlFilesList,
3738
'supplementalDependencyFile=s' => \$supplementalDependencyFile,
3839
'windowConstructorsFile=s' => \$windowConstructorsFile,
40+
'workerContextConstructorsFile=s' => \$workerContextConstructorsFile,
3941
'supplementalMakefileDeps=s' => \$supplementalMakefileDeps);
4042

4143
die('Must specify #define macros using --defines.') unless defined($defines);
4244
die('Must specify an output file using --supplementalDependencyFile.') unless defined($supplementalDependencyFile);
4345
die('Must specify an output file using --windowConstructorsFile.') unless defined($windowConstructorsFile);
46+
die('Must specify an output file using --workerContextConstructorsFile.') unless defined($workerContextConstructorsFile);
4447
die('Must specify the file listing all IDLs using --idlFilesList.') unless defined($idlFilesList);
4548

4649
open FH, "< $idlFilesList" or die "Cannot open $idlFilesList\n";
@@ -53,7 +56,8 @@
5356
my %idlFileToInterfaceName;
5457
my %supplementalDependencies;
5558
my %supplementals;
56-
my $constructorAttributesCode = "";
59+
my $windowConstructorsCode = "";
60+
my $workerContextConstructorsCode = "";
5761
# Get rid of duplicates in idlFiles array.
5862
my %idlFileHash = map { $_, 1 } @idlFiles;
5963
foreach my $idlFile (keys %idlFileHash) {
@@ -68,7 +72,10 @@
6872
unless (isCallbackInterfaceFromIDL($idlFileContents)) {
6973
my $extendedAttributes = getInterfaceExtendedAttributesFromIDL($idlFileContents);
7074
unless ($extendedAttributes->{"NoInterfaceObject"}) {
71-
$constructorAttributesCode .= GenerateConstructorAttribute($interfaceName, $extendedAttributes);
75+
my $globalContext = $extendedAttributes->{"GlobalContext"} || "WindowOnly";
76+
my $attributeCode = GenerateConstructorAttribute($interfaceName, $extendedAttributes);
77+
$windowConstructorsCode .= $attributeCode unless $globalContext eq "WorkerOnly";
78+
$workerContextConstructorsCode .= $attributeCode unless $globalContext eq "WindowOnly"
7279
}
7380
}
7481
$interfaceNameToIdlFile{$interfaceName} = $fullPath;
@@ -77,13 +84,10 @@
7784
}
7885

7986
# Generate DOMWindow Constructors partial interface.
80-
open PARTIAL_WINDOW_FH, "> $windowConstructorsFile" or die "Cannot open $windowConstructorsFile\n";
81-
print PARTIAL_WINDOW_FH "partial interface DOMWindow {\n";
82-
print PARTIAL_WINDOW_FH $constructorAttributesCode;
83-
print PARTIAL_WINDOW_FH "};\n";
84-
close PARTIAL_WINDOW_FH;
85-
my $fullPath = Cwd::realpath($windowConstructorsFile);
86-
$supplementalDependencies{$fullPath} = "DOMWindow" if $interfaceNameToIdlFile{"DOMWindow"};
87+
GeneratePartialInterface("DOMWindow", $windowConstructorsCode, $windowConstructorsFile);
88+
89+
# Generate WorkerContext Constructors partial interface.
90+
GeneratePartialInterface("WorkerContext", $workerContextConstructorsCode, $workerContextConstructorsFile);
8791

8892
# Resolves partial interfaces dependencies.
8993
foreach my $idlFile (keys %supplementalDependencies) {
@@ -132,6 +136,22 @@
132136
close MAKE_FH;
133137
}
134138

139+
sub GeneratePartialInterface
140+
{
141+
my $interfaceName = shift;
142+
my $attributesCode = shift;
143+
my $destinationFile = shift;
144+
145+
# Generate partial interface for global constructors.
146+
open PARTIAL_INTERFACE_FH, "> $destinationFile" or die "Cannot open $destinationFile\n";
147+
print PARTIAL_INTERFACE_FH "partial interface ${interfaceName} {\n";
148+
print PARTIAL_INTERFACE_FH $attributesCode;
149+
print PARTIAL_INTERFACE_FH "};\n";
150+
close PARTIAL_INTERFACE_FH;
151+
my $fullPath = Cwd::realpath($destinationFile);
152+
$supplementalDependencies{$fullPath} = $interfaceName if $interfaceNameToIdlFile{$interfaceName};
153+
}
154+
135155
sub GenerateConstructorAttribute
136156
{
137157
my $interfaceName = shift;

0 commit comments

Comments
 (0)