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 Adam Barth.
 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), which are described at the first column of each line in the input file. If the file name is a "/cygdrive/c/..."-style path, it is converted to a "C:\cygwin\..."-style path by the cygpath command.
 92 * WebCore.gypi: Added DOMWindowWebAudio.idl.
 93 * bindings/scripts/generate-bindings.pl: As a temporary solution, if the platform does not support the [Supplemental] IDL, the perl script ignores the [Supplemental] IDL and instead uses the [Supplemented] IDL. Otherwise, the perl script ignores the [Supplemented] IDL and instead uses the [Supplemental] IDL.
 94 * page/DOMWindow.idl: Added the [Supplemented] IDL to webaudio-related attributes. As I described above, the [Supplemented] IDL will be removed after all platforms support the [Supplemental] IDL.
 95 * webaudio/DOMWindowWebAudio.idl: Added. Describes the [Supplemental=DOMWindow] IDL. The attributes in this IDL file should be treated as if they are written in DOMWindow.idl.
 96
1972011-12-08 Sheriff Bot <webkit.review.bot@gmail.com>
298
399 Unreviewed, rolling out r102321.

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 ],
452491 'sources': [
453492 # bison rule
454493 '../css/CSSGrammar.y',

861900 },
862901 {
863902 '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  },
869903 'inputs': [
870904 'scripts/action_derivedsourcesallinone.py',
871  '<(idls_list_temp_file)',
872  '<!@(cat <(idls_list_temp_file))',
 905 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
873906 ],
874907 'outputs': [
875908 '<@(derived_sources_aggregate_files)',

877910 'action': [
878911 'python',
879912 'scripts/action_derivedsourcesallinone.py',
880  '<(idls_list_temp_file)',
 913 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
881914 '--',
882915 '<@(derived_sources_aggregate_files)',
883916 ],

930963 '../bindings/scripts/IDLParser.pm',
931964 '../bindings/scripts/IDLStructure.pm',
932965 '../bindings/scripts/preprocessor.pm',
 966 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
933967 ],
934968 'outputs': [
935969 # FIXME: The .cpp file should be in webkit/bindings once

9751009 '--generator',
9761010 'V8',
9771011 '<@(generator_include_dirs)',
 1012 '--supplementalDependencyFile',
 1013 '<(SHARED_INTERMEDIATE_DIR)/supplemental_dependency.tmp',
9781014 '<(RULE_INPUT_PATH)',
9791015 ],
9801016 '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

@@import re
4848import subprocess
4949import sys
5050
 51sys.path.append("../../../Tools/Scripts/")
 52from webkitpy.common.system import path
 53
5154# A regexp for finding Conditional attributes in interface definitions.
5255conditionalPattern = re.compile('interface[\s]*\[[^\]]*Conditional=([\_0-9a-zA-Z&|]*)')
5356

@@def main(args):
186189 outputFileNames = args[inOutBreakIndex+1:]
187190
188191 inputFile = open(inputFileName, 'r')
189  idlFileNames = inputFile.read().split('\n')
 192 idlFileNames = []
 193 for line in inputFile:
 194 idlFileName = line[:-1].split(' ')[0]
 195 if idlFileName.find("/cygdrive") == 0:
 196 idlFileName = path.cygpath(idlFileName)
 197 idlFileNames.append(idlFileName)
190198 inputFile.close()
191199
192200 filesMetaData = extractMetaData(idlFileNames)

Source/WebCore/WebCore.gypi

14921492 'webaudio/BiquadFilterNode.idl',
14931493 'webaudio/ConvolverNode.idl',
14941494 'webaudio/DelayNode.idl',
 1495 'webaudio/DOMWindowWebAudio.idl',
14951496 'webaudio/DynamicsCompressorNode.idl',
14961497 'webaudio/HighPass2FilterNode.idl',
14971498 'webaudio/JavaScriptAudioNode.idl',

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

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

Source/WebCore/page/DOMWindow.idl

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

@@module window {
552552 attribute [Conditional=TOUCH_EVENTS] TouchEventConstructor TouchEvent;
553553 attribute [Conditional=WEB_SOCKETS] CloseEventConstructor CloseEvent;
554554 attribute StorageEventConstructor StorageEvent;
555  attribute [Conditional=WEB_AUDIO] AudioProcessingEventConstructor AudioProcessingEvent;
556  attribute [Conditional=WEB_AUDIO] OfflineAudioCompletionEventConstructor OfflineAudioCompletionEvent;
 555 attribute [Supplemented, Conditional=WEB_AUDIO] AudioProcessingEventConstructor AudioProcessingEvent;
 556 attribute [Supplemented, Conditional=WEB_AUDIO] OfflineAudioCompletionEventConstructor OfflineAudioCompletionEvent;
557557 attribute [Conditional=INPUT_SPEECH] SpeechInputEventConstructor SpeechInputEvent;
558558 attribute [Conditional=MEDIA_STREAM] MediaStreamEventConstructor MediaStreamEvent;
559559 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}