Source/WebCore/ChangeLog

 12011-12-07 Kentaro Hara <haraken@chromium.org>
 2
 3 Use the [Supplemental] IDL for webaudio attributes in Chromium
 4 https://bugs.webkit.org/show_bug.cgi?id=73394
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 - Overview: Using the [Supplemental] IDL, this patch moves the attribute
 9 declarations of webaudio from DOMWindow.idl into a new IDL file
 10 webaudio/DOMWindowWebAudio.idl, which helps make webaudio a self-contained
 11 feature (aka a module).
 12
 13 - This patch changes the build flow of WebCore.gyp as follows:
 14
 15 Previous build flow:
 16 foreach $idl (all IDL files) {
 17 generate-bindings.pl depends on $idl;
 18 generate-bindings.pl reads $idl;
 19 generate-bindings.pl generates .h and .cpp files for $idl;
 20 }
 21
 22 New build flow (See the discussions in bug 72138 for more details):
 23 resolve-supplemental.pl depends on all IDL files;
 24 resolve-supplemental.pl reads all IDL files;
 25 resolve-supplemental.pl resolves the dependency of [Supplemental=XXXX];
 26 resolve-supplemental.pl outputs supplemental_dependency.tmp;
 27 foreach $idl (all IDL files) {
 28 generate-bindings.pl depends on $idl and supplemental_dependency.tmp;
 29 generate-bindings.pl reads $idl;
 30 generate-bindings.pl reads supplemental_dependency.tmp;
 31 generate-bindings.pl generates .h and .cpp files for $idl, including all attributes in IDL files whilementing $idl;
 32 }
 33
 34 - This patch introduces a temporary IDL, [Supplemented]. The [Supplemented] IDL
 35 will be removed after build scripts for all platforms support the [Supplemental] IDL.
 36 The motivation for the [Supplemented] IDL is as follows:
 37
 38 In order to support the [Supplemental] IDL, we need to
 39 (1) run resolve-supplemental.pl and generate supplemental_dependency.tmp
 40 (2) and run generate-bindings.pl with the supplemental_dependency.tmp.
 41
 42 This build flow requires a change on the following build scripts,
 43 but changing all the build scripts all at once without any regression is too difficult:
 44
 45 - DerivedSources.make
 46 - DerivedSources.pri
 47 - GNUmakefile.am
 48 - PlatformBlackBerry.cmake
 49 - UseJSC.cmake
 50 - UseV8.cmake
 51 - WebCore.vcproj/MigrateScripts
 52 - WebCore.vcproj/WebCore.vcproj
 53 - bindings/gobject/GNUmakefile.am
 54 - WebCore.gyp/WebCore.gyp
 55
 56 Thus, we are planning to change the build scripts one by one, which implies that
 57 we need to allow the temporary state in which some build scripts support [Supplemental] IDL
 58 but others do not. To accomplish this, we introduce a temporary IDL, [Supplemented].
 59 The [Supplemented] IDL on an attribute means that the attribute is marked with [Supplemental]
 60 in another IDL file somewhere, like this:
 61
 62 DOMWindowWebAudio.idl:
 63 interface [
 64 Supplemental=DOMWindow
 65 ] DOMWindowWebAudio {
 66 attribute attr1;
 67 attribute attr2;
 68 };
 69
 70 DOMWindow.idl:
 71 interface [
 72 ] DOMWindow {
 73 attribute [Supplemented] attr1; // This line will be removed after all build scripts support the [Su IDL
 74 attribute [Supplemented] attr2; // This line will be removed after all build scripts support the [Su IDL.
 75 attribute attr3;
 76 attribute attr4;
 77 };
 78
 79 Assuming these IDL files, this patch implements the following logic in generate-bindings.pl:
 80
 81 - If a given build script supports the [Supplemental] IDL,
 82 generate-bindings.pl ignores all attributes with the [Supplemented] IDL.
 83 - Otherwise, generate-bindings.pl treats all attributes with the [Supplemented] IDL
 84 as normal attributes and instead ignores all attributes with the [Supplemental] IDL
 85 (i.e. generate-bindings.pl generates nothing from the IDL file with the [Supplemental] IDL).
 86
 87 Tests: webaudio/*
 88
 89 * WebCore.gyp/WebCore.gyp: Describes the build flow that I described above.
 90 * WebCore.gyp/scripts/action_derivedsourcesallinone.py:
 91 (main): Reads the IDL file names from the input file (i.e. supplemental_dependency.tmp),
 92 which are described at the first column of each line in the input file.
 93 If the file name is a "/cygdrive/c/..."-style path, it is converted to a "C:\cygwin\..."-style
 94 path by the cygpath command.
 95 * WebCore.gypi: Added DOMWindowWebAudio.idl.
 96 * bindings/scripts/generate-bindings.pl: As a temporary solution, if the platform does not
 97 support the [Supplemental] IDL, the perl script ignores the [Supplemental] IDL and instead
 98 uses the [Supplemented] IDL. Otherwise, the perl script ignores the [Supplemented] IDL and
 99 instead uses the [Supplemental] IDL.
 100 Added the --additionalIdlFilesList option to specify the IDL files that are not listed in
 101 supplemental-dependency.tmp but should generate .h and .cpp files.
 102 * page/DOMWindow.idl: Added the [Supplemented] IDL to webaudio-related attributes.
 103 As I described above, the [Supplemented] IDL will be removed after all platforms support
 104 the [Supplemental] IDL.
 105 * webaudio/DOMWindowWebAudio.idl: Added. Describes the [Supplemental=DOMWindow] IDL.
 106 The attributes in this IDL file should be treated as if they are written in DOMWindow.idl.
 107
11082011-12-12 Kenneth Russell <kbr@google.com>
2109
3110 Unreviewed Windows build fix after http://trac.webkit.org/changeset/102619 .

Source/WebCore/WebCore.gyp/WebCore.gyp

446446 ]
447447 },
448448 {
 449 'target_name': 'generate_supplemental_dependency',
 450 'type': 'none',
 451 'actions': [
 452 {
 453 'action_name': 'generateSupplementalDependency',
 454 'variables': {
 455 # Write sources into a file, so that the action command line won't
 456 # exceed OS limits.
 457 'idl_files_list': '<|(idl_files_list.tmp <@(bindings_idl_files))',
 458 },
 459 'inputs': [
 460 '../bindings/scripts/resolve-supplemental.pl',
 461 '../bindings/scripts/IDLParser.pm',
 462 '<(idl_files_list)',
 463 '<!@(cat <(idl_files_list))',
 464 ],
 465 'outputs': [
 466 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
 467 ],
 468 'action': [
 469 'perl',
 470 '-w',
 471 '-I../bindings/scripts',
 472 '../bindings/scripts/resolve-supplemental.pl',
 473 '--defines',
 474 '<(feature_defines) LANGUAGE_JAVASCRIPT V8_BINDING',
 475 '--idlFilesList',
 476 '<(idl_files_list)',
 477 '--supplementalDependencyFile',
 478 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
 479 ],
 480 'message': 'Resolving [Supplemental=XXX] dependencies in all IDL files',
 481 }
 482 ]
 483 },
 484 {
449485 'target_name': 'webcore_bindings_sources',
450486 'type': 'none',
451487 'hard_dependency': 1,
 488 'dependencies': [
 489 'generate_supplemental_dependency',
 490 ],
 491 'variables': {
 492 # Write sources into a file, so that the action command line won't
 493 # exceed OS limits.
 494 'additional_idl_files_list': '<|(additional_idl_files_list.tmp <@(webcore_test_support_idl_files))',
 495 },
452496 'sources': [
453497 # bison rule
454498 '../css/CSSGrammar.y',

861905 },
862906 {
863907 'action_name': 'derived_sources_all_in_one',
864  'variables': {
865  # Write sources into a file, so that the action command line won't
866  # exceed OS limites.
867  'idls_list_temp_file': '<|(idls_list_temp_file.tmp <@(bindings_idl_files))',
868  },
869908 'inputs': [
870909 'scripts/action_derivedsourcesallinone.py',
871  '<(idls_list_temp_file)',
872  '<!@(cat <(idls_list_temp_file))',
 910 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
873911 ],
874912 'outputs': [
875913 '<@(derived_sources_aggregate_files)',

877915 'action': [
878916 'python',
879917 'scripts/action_derivedsourcesallinone.py',
880  '<(idls_list_temp_file)',
 918 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
881919 '--',
882920 '<@(derived_sources_aggregate_files)',
883921 ],

930968 '../bindings/scripts/IDLParser.pm',
931969 '../bindings/scripts/IDLStructure.pm',
932970 '../bindings/scripts/preprocessor.pm',
 971 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
 972 '<(additional_idl_files_list)',
 973 '<!@(cat <(additional_idl_files_list))',
933974 ],
934975 'outputs': [
935976 # FIXME: The .cpp file should be in webkit/bindings once

9751016 '--generator',
9761017 'V8',
9771018 '<@(generator_include_dirs)',
 1019 '--supplementalDependencyFile',
 1020 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
 1021 '--additionalIdlFilesList',
 1022 '<(additional_idl_files_list)',
9781023 '<(RULE_INPUT_PATH)',
9791024 ],
9801025 'message': 'Generating binding from <(RULE_INPUT_PATH)',

Source/WebCore/WebCore.gyp/scripts/action_derivedsourcesallinone.py

3232# Use of this source code is governed by a BSD-style license that can be
3333# found in the LICENSE file.
3434
35 # action_derivedsourceslist.py generates a single cpp file that includes
 35# action_derivedsourcesallinone.py generates a single cpp file that includes
3636# all v8 bindings cpp files generated from idls. Files can be assigned into
3737# multiple output files, to reduce maximum compilation unit size and allow
3838# parallel compilation.
3939#
40 # usage: action_derivedsourceslist.py IDL_FILES_LIST -- OUTPUT_FILE1 OUTPUT_FILE2 ...
 40# usage: action_derivedsourcesallinone.py IDL_FILES_LIST -- OUTPUT_FILE1 OUTPUT_FILE2 ...
4141#
4242# Note that IDL_FILES_LIST is a text file containing the IDL file paths.
4343

@@def writeContent(content, outputFileName):
179179 f.close()
180180
181181
 182def resolveCygpath(cygdriveNames):
 183 cmd = ['cygpath', '-f', '-', '-wa']
 184 process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 185 idlFileNames = []
 186 for fileName in cygdriveNames:
 187 process.stdin.write("%s\n" % fileName)
 188 process.stdin.flush()
 189 idlFileNames.append(process.stdout.readline().rstrip())
 190 process.stdin.close()
 191 process.wait()
 192 return idlFileNames
 193
 194
182195def main(args):
183196 assert(len(args) > 3)
184197 inOutBreakIndex = args.index('--')

@@def main(args):
186199 outputFileNames = args[inOutBreakIndex+1:]
187200
188201 inputFile = open(inputFileName, 'r')
189  idlFileNames = inputFile.read().split('\n')
 202 idlFileNames = []
 203 cygdriveNames = []
 204 for line in inputFile:
 205 idlFileName = line.rstrip().split(' ')[0]
 206 if idlFileName.startswith("/cygdrive"):
 207 cygdriveNames.append(idlFileName)
 208 else:
 209 idlFileNames.append(idlFileName)
 210
 211 if cygdriveNames:
 212 idlFileNames.extend(resolveCygpath(cygdriveNames))
190213 inputFile.close()
191214
192215 filesMetaData = extractMetaData(idlFileNames)

Source/WebCore/WebCore.gypi

14961496 'webaudio/BiquadFilterNode.idl',
14971497 'webaudio/ConvolverNode.idl',
14981498 'webaudio/DelayNode.idl',
 1499 'webaudio/DOMWindowWebAudio.idl',
14991500 'webaudio/DynamicsCompressorNode.idl',
15001501 'webaudio/HighPass2FilterNode.idl',
15011502 'webaudio/JavaScriptAudioNode.idl',

Source/WebCore/bindings/scripts/generate-bindings.pl

@@my $preprocessor;
4949my $writeDependencies;
5050my $verbose;
5151my $supplementalDependencyFile;
 52my $additionalIdlFilesList;
5253
5354GetOptions('include=s@' => \@idlDirectories,
5455 'outputDir=s' => \$outputDirectory,

@@GetOptions('include=s@' => \@idlDirectories,
6061 'preprocessor=s' => \$preprocessor,
6162 'verbose' => \$verbose,
6263 'write-dependencies' => \$writeDependencies,
63  'supplementalDependencyFile=s' => \$supplementalDependencyFile);
 64 'supplementalDependencyFile=s' => \$supplementalDependencyFile,
 65 'additionalIdlFilesList=s' => \$additionalIdlFilesList);
6466
6567my $targetIdlFile = $ARGV[0];
6668

@@if ($supplementalDependencyFile) {
9395 open FH, "< $supplementalDependencyFile" or die "Cannot open $supplementalDependencyFile\n";
9496 while (my $line = <FH>) {
9597 my ($idlFile, @followingIdlFiles) = split(/\s+/, $line);
96  if ($idlFile and $idlFile eq $targetIdlFile) {
 98 if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) {
9799 $idlFound = 1;
98100 @supplementedIdlFiles = @followingIdlFiles;
99101 }
100102 }
101103 close FH;
102104
 105 # The file $additionalIdlFilesList contains one IDL file per line:
 106 # P.idl
 107 # Q.idl
 108 # ...
 109 # These IDL files are ones which should not be included in DerivedSources*.cpp
 110 # (i.e. they are not described in the supplemental dependency file)
 111 # but should generate .h and .cpp files.
 112 if (!$idlFound and $additionalIdlFilesList) {
 113 open FH, "< $additionalIdlFilesList" or die "Cannot open $additionalIdlFilesList\n";
 114 my @idlFiles = <FH>;
 115 chomp(@idlFiles);
 116 $idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @idlFiles;
 117 close FH;
 118 }
 119
103120 if (!$idlFound) {
104121 if ($verbose) {
105122 print "$targetIdlFile is supplementing another IDL file, and thus .h and .cpp for $targetIdlFile are not generated.\n";

@@if ($supplementalDependencyFile) {
112129my $targetParser = IDLParser->new(!$verbose);
113130my $targetDocument = $targetParser->Parse($targetIdlFile, $defines, $preprocessor);
114131
 132# FIXME(haraken): Remove this if-else statement.
 133# This if-else statement is temporary and will be removed
 134# after build scripts for all platforms support [Supplemental] IDL.
 135# The motivation for the [Supplemented] IDL is as follows:
 136#
 137# In order to support the [Supplemental] IDL, we need to
 138# (1) run resolve-supplemental.pl and generate supplemental_dependency.tmp
 139# (2) and run generate-bindings.pl with the supplemental_dependency.tmp.
 140#
 141# This build flow requires a change on the following build scripts,
 142# but changing all the build scripts all at once without any regression is too difficult:
 143#
 144# - DerivedSources.make
 145# - DerivedSources.pri
 146# - GNUmakefile.am
 147# - PlatformBlackBerry.cmake
 148# - UseJSC.cmake
 149# - UseV8.cmake
 150# - WebCore.vcproj/MigrateScripts
 151# - WebCore.vcproj/WebCore.vcproj
 152# - bindings/gobject/GNUmakefile.am
 153# - WebCore.gyp/WebCore.gyp
 154#
 155# Thus, we are planning to change the build scripts one by one, which implies that
 156# we need to allow the temporary state in which some build scripts support [Supplemental] IDL
 157# but others do not. To accomplish this, we introduce a temporal IDL, [Supplemented].
 158# The [Supplemented] IDL on an attribute means that the attribute is marked with [Supplemental]
 159# in another IDL file somewhere, like this:
 160#
 161# DOMWindowWebAudio.idl:
 162# interface [
 163# Supplemental=DOMWindow
 164# ] DOMWindowWebAudio {
 165# attribute attr1;
 166# attribute attr2;
 167# };
 168#
 169# DOMWindow.idl:
 170# interface [
 171# ] DOMWindow {
 172# attribute [Supplemented] attr1; // This line will be removed after all build scripts support the [SupplementalL.
 173# attribute [Supplemented] attr2; // This line will be removed after all build scripts support the [SupplementalL.
 174# attribute attr3;
 175# attribute attr4;
 176# };
 177#
 178# Assuming these IDL files, the below code is doing the following logic:
 179#
 180# - If a given build script supports the [Supplemental] IDL (i.e. --supplementalDependencyFile is specified),
 181# we ignore all attributes with the [Supplemented] IDL.
 182# - Otherwise (i.e. --supplementalDependencyFile is not specified),
 183# we treat all attributes with the [Supplemented] IDL as normal attributes
 184# and instead ignore all attributes with the [Supplemental] IDL
 185# (i.e. we generate nothing from the idl file with the [Supplemental] IDL).
 186if ($supplementalDependencyFile) {
 187 foreach my $dataNode (@{$targetDocument->classes}) {
 188 my @nonSupplementedAttributes;
 189 foreach my $attribute (@{$dataNode->attributes}) {
 190 if (!$attribute->signature->extendedAttributes->{"Supplemented"}) {
 191 push(@nonSupplementedAttributes, $attribute);
 192 }
 193 }
 194 $dataNode->attributes(\@nonSupplementedAttributes);
 195 }
 196} else {
 197 foreach my $dataNode (@{$targetDocument->classes}) {
 198 if ($dataNode->extendedAttributes->{"Supplemental"}) {
 199 exit 0;
 200 }
 201 }
 202}
 203# Temporary if-else statement until here.
 204
115205foreach my $idlFile (@supplementedIdlFiles) {
116206 next if $idlFile eq $targetIdlFile;
117207

Source/WebCore/page/DOMWindow.idl

@@module window {
523523 attribute [JSCCustomGetter] Float64ArrayConstructor Float64Array; // Usable with new operator
524524 attribute [JSCCustomGetter] DataViewConstructor DataView; // Usable with new operator
525525
526  attribute [JSCCustomGetter,Conditional=WEB_AUDIO,EnabledAtRuntime] AudioContextConstructor webkitAudioContext; // Usable with new operator
527  attribute [Conditional=WEB_AUDIO] AudioPannerNodeConstructor webkitAudioPannerNode; // Needed for panning model constants
 526 attribute [Supplemented, JSCCustomGetter, Conditional=WEB_AUDIO, EnabledAtRuntime] AudioContextConstructor webkitAudioContext; // Usable with new operator
 527 attribute [Supplemented, Conditional=WEB_AUDIO] AudioPannerNodeConstructor webkitAudioPannerNode; // Needed for panning model constants
528528
529529 // Event Constructors
530530 attribute EventConstructor Event;

@@module window {
553553 attribute [Conditional=TOUCH_EVENTS] TouchEventConstructor TouchEvent;
554554 attribute [Conditional=WEB_SOCKETS] CloseEventConstructor CloseEvent;
555555 attribute StorageEventConstructor StorageEvent;
556  attribute [Conditional=WEB_AUDIO] AudioProcessingEventConstructor AudioProcessingEvent;
557  attribute [Conditional=WEB_AUDIO] OfflineAudioCompletionEventConstructor OfflineAudioCompletionEvent;
 556 attribute [Supplemented, Conditional=WEB_AUDIO] AudioProcessingEventConstructor AudioProcessingEvent;
 557 attribute [Supplemented, Conditional=WEB_AUDIO] OfflineAudioCompletionEventConstructor OfflineAudioCompletionEvent;
558558 attribute [Conditional=INPUT_SPEECH] SpeechInputEventConstructor SpeechInputEvent;
559559 attribute [Conditional=MEDIA_STREAM] MediaStreamEventConstructor MediaStreamEvent;
560560 attribute [Conditional=WEBGL] WebGLContextEventConstructor WebGLContextEvent;

Source/WebCore/webaudio/DOMWindowWebAudio.idl

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20module window {
 21
 22 interface [
 23 Conditional=WEB_AUDIO,
 24 Supplemental=DOMWindow
 25 ] DOMWindowWebAudio {
 26 attribute [JSCCustomGetter, EnabledAtRuntime] AudioContextConstructor webkitAudioContext;
 27 attribute AudioPannerNodeConstructor webkitAudioPannerNode;
 28 attribute AudioProcessingEventConstructor AudioProcessingEvent;
 29 attribute OfflineAudioCompletionEventConstructor OfflineAudioCompletionEvent;
 30 };
 31
 32}