Add support for Web IDL partial interfaces to the bindings generator

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

Reviewed by Kentaro Hara.

Add support for Web IDL partial interfaces to the bindings generator:
http://dev.w3.org/2006/webapi/WebIDL/#dfn-partial-interface

Also drop support for the the WebKit-specific [Supplemental] extended
attribute and use partial interfaces instead in existing IDL files.

No new tests, no behavior change.

* Modules/battery/NavigatorBattery.idl:
* Modules/filesystem/DOMWindowFileSystem.idl:
* Modules/filesystem/DataTransferItemFileSystem.idl:
* Modules/filesystem/HTMLInputElementFileSystem.idl:
* Modules/filesystem/WorkerContextFileSystem.idl:
* Modules/gamepad/NavigatorGamepad.idl:
* Modules/geolocation/NavigatorGeolocation.idl:
* Modules/indexeddb/DOMWindowIndexedDatabase.idl:
* Modules/indexeddb/WorkerContextIndexedDatabase.idl:
* Modules/mediastream/DOMWindowMediaStream.idl:
* Modules/mediastream/NavigatorMediaStream.idl:
* Modules/navigatorcontentutils/NavigatorContentUtils.idl:
* Modules/networkinfo/NavigatorNetworkInfoConnection.idl:
* Modules/notifications/DOMWindowNotifications.idl:
* Modules/notifications/WorkerContextNotifications.idl:
* Modules/quota/DOMWindowQuota.idl:
* Modules/quota/NavigatorStorageQuota.idl:
* Modules/quota/WorkerNavigatorStorageQuota.idl:
* Modules/speech/DOMWindowSpeech.idl:
* Modules/speech/DOMWindowSpeechSynthesis.idl:
* Modules/vibration/NavigatorVibration.idl:
* Modules/webaudio/DOMWindowWebAudio.idl:
* Modules/webdatabase/DOMWindowWebDatabase.idl:
* Modules/webdatabase/WorkerContextWebDatabase.idl:
* Modules/websockets/DOMWindowWebSocket.idl:
* Modules/websockets/WorkerContextWebSocket.idl:
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/IDLParser.pm:
(parsePartialDefinition):
* bindings/scripts/generate-bindings.pl:
* bindings/scripts/preprocess-idls.pl:
(getPartialInterfaceNameFromIDLFile):
* bindings/scripts/test/TestSupplemental.idl:
* page/DOMWindowPagePopup.idl:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149170 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c78c8564
2013-04-26 Christophe Dumez <ch.dumez@sisa.samsung.com>
Add support for Web IDL partial interfaces to the bindings generator
https://bugs.webkit.org/show_bug.cgi?id=115228
Reviewed by Kentaro Hara.
Add support for Web IDL partial interfaces to the bindings generator:
http://dev.w3.org/2006/webapi/WebIDL/#dfn-partial-interface
Also drop support for the the WebKit-specific [Supplemental] extended
attribute and use partial interfaces instead in existing IDL files.
No new tests, no behavior change.
* Modules/battery/NavigatorBattery.idl:
* Modules/filesystem/DOMWindowFileSystem.idl:
* Modules/filesystem/DataTransferItemFileSystem.idl:
* Modules/filesystem/HTMLInputElementFileSystem.idl:
* Modules/filesystem/WorkerContextFileSystem.idl:
* Modules/gamepad/NavigatorGamepad.idl:
* Modules/geolocation/NavigatorGeolocation.idl:
* Modules/indexeddb/DOMWindowIndexedDatabase.idl:
* Modules/indexeddb/WorkerContextIndexedDatabase.idl:
* Modules/mediastream/DOMWindowMediaStream.idl:
* Modules/mediastream/NavigatorMediaStream.idl:
* Modules/navigatorcontentutils/NavigatorContentUtils.idl:
* Modules/networkinfo/NavigatorNetworkInfoConnection.idl:
* Modules/notifications/DOMWindowNotifications.idl:
* Modules/notifications/WorkerContextNotifications.idl:
* Modules/quota/DOMWindowQuota.idl:
* Modules/quota/NavigatorStorageQuota.idl:
* Modules/quota/WorkerNavigatorStorageQuota.idl:
* Modules/speech/DOMWindowSpeech.idl:
* Modules/speech/DOMWindowSpeechSynthesis.idl:
* Modules/vibration/NavigatorVibration.idl:
* Modules/webaudio/DOMWindowWebAudio.idl:
* Modules/webdatabase/DOMWindowWebDatabase.idl:
* Modules/webdatabase/WorkerContextWebDatabase.idl:
* Modules/websockets/DOMWindowWebSocket.idl:
* Modules/websockets/WorkerContextWebSocket.idl:
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/IDLParser.pm:
(parsePartialDefinition):
* bindings/scripts/generate-bindings.pl:
* bindings/scripts/preprocess-idls.pl:
(getPartialInterfaceNameFromIDLFile):
* bindings/scripts/test/TestSupplemental.idl:
* page/DOMWindowPagePopup.idl:
2013-04-25 Mihnea Ovidenie <mihnea@adobe.com>
[CSS Regions] Hit testing is broken for absolutely positioned regions that have overflow: hidden
......
......@@ -19,8 +19,7 @@
[
Conditional=BATTERY_STATUS,
Supplemental=Navigator
] interface NavigatorBattery {
] partial interface Navigator {
readonly attribute BatteryManager webkitBattery;
};
......@@ -26,8 +26,7 @@
[
Conditional=FILE_SYSTEM,
Supplemental=DOMWindow
] interface DOMWindowFileSystem {
] partial interface DOMWindow {
const unsigned short TEMPORARY = 0;
const unsigned short PERSISTENT = 1;
......
......@@ -30,8 +30,7 @@
[
Conditional=DATA_TRANSFER_ITEMS&FILE_SYSTEM,
Supplemental=DataTransferItem
] interface DataTransferItemFileSystem {
] partial interface DataTransferItem {
[CallWith=ScriptExecutionContext] Entry webkitGetAsEntry();
};
......@@ -30,8 +30,7 @@
[
Conditional=FILE_SYSTEM,
Supplemental=HTMLInputElement
] interface HTMLInputElementFileSystem {
] partial interface HTMLInputElement {
[CallWith=ScriptExecutionContext] readonly attribute EntryArray webkitEntries;
};
......@@ -26,8 +26,7 @@
[
Conditional=FILE_SYSTEM,
Supplemental=WorkerContext
] interface WorkerContextFileSystem {
] partial interface WorkerContext {
const unsigned short TEMPORARY = 0;
const unsigned short PERSISTENT = 1;
......
......@@ -19,8 +19,7 @@
[
Conditional=GAMEPAD,
Supplemental=Navigator
] interface NavigatorGamepad {
] partial interface Navigator {
GamepadList webkitGetGamepads();
};
......@@ -19,8 +19,7 @@
[
Conditional=GEOLOCATION,
Supplemental=Navigator
] interface NavigatorGeolocation {
] partial interface Navigator {
readonly attribute Geolocation geolocation;
};
......@@ -26,8 +26,7 @@
[
Conditional=INDEXED_DATABASE,
Supplemental=DOMWindow
] interface DOMWindowIndexedDatabase {
] partial interface DOMWindow {
[ImplementedAs=indexedDB] readonly attribute IDBFactory webkitIndexedDB;
attribute IDBCursorConstructor webkitIDBCursor;
......
......@@ -26,8 +26,7 @@
[
Conditional=INDEXED_DATABASE,
Supplemental=WorkerContext
] interface WorkerContextIndexedDatabase {
] partial interface WorkerContext {
[ImplementedAs=indexedDB] readonly attribute IDBFactory webkitIndexedDB;
attribute IDBCursorConstructor webkitIDBCursor;
......
......@@ -26,8 +26,7 @@
[
Conditional=MEDIA_STREAM,
Supplemental=DOMWindow
] interface DOMWindowMediaStream {
] partial interface DOMWindow {
attribute MediaStreamConstructor webkitMediaStream;
attribute RTCPeerConnectionConstructor webkitRTCPeerConnection;
attribute RTCSessionDescriptionConstructor RTCSessionDescription;
......
......@@ -19,8 +19,7 @@
[
Conditional=MEDIA_STREAM,
Supplemental=Navigator
] interface NavigatorMediaStream {
] partial interface Navigator {
void webkitGetUserMedia(in Dictionary options,
in [Callback] NavigatorUserMediaSuccessCallback successCallback,
in [Callback, Optional] NavigatorUserMediaErrorCallback errorCallback)
......
......@@ -19,9 +19,7 @@
*/
// http://www.w3.org/TR/html5/system-state-and-capabilities.html#custom-handlers
[
Supplemental=Navigator
] interface NavigatorContentUtils {
partial interface Navigator {
[Conditional=NAVIGATOR_CONTENT_UTILS] void registerProtocolHandler(in DOMString scheme, in DOMString url, in DOMString title)
raises(DOMException);
[Conditional=NAVIGATOR_CONTENT_UTILS&CUSTOM_SCHEME_HANDLER] DOMString isProtocolHandlerRegistered(in DOMString scheme, in DOMString url)
......
......@@ -19,8 +19,7 @@
[
Conditional=NETWORK_INFO,
Supplemental=Navigator
] interface NavigatorNetworkInfoConnection {
] partial interface Navigator {
readonly attribute NetworkInfoConnection webkitConnection;
};
......@@ -26,8 +26,7 @@
[
Conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS,
Supplemental=DOMWindow
] interface DOMWindowNotifications {
] partial interface DOMWindow {
#if defined(ENABLE_LEGACY_NOTIFICATIONS) && ENABLE_LEGACY_NOTIFICATIONS
readonly attribute NotificationCenter webkitNotifications;
#endif
......
......@@ -26,8 +26,7 @@
[
Conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS,
Supplemental=WorkerContext
] interface WorkerContextNotifications {
] partial interface WorkerContext {
#if defined(ENABLE_LEGACY_NOTIFICATIONS) && ENABLE_LEGACY_NOTIFICATIONS
readonly attribute NotificationCenter webkitNotifications;
#endif
......
......@@ -25,8 +25,7 @@
[
Conditional=QUOTA,
Supplemental=DOMWindow
] interface DOMWindowQuota {
] partial interface DOMWindow {
readonly attribute StorageInfo webkitStorageInfo;
};
......@@ -19,8 +19,7 @@
[
Conditional=QUOTA,
Supplemental=Navigator
] interface NavigatorStorageQuota {
] partial interface Navigator {
readonly attribute StorageQuota webkitTemporaryStorage;
readonly attribute StorageQuota webkitPersistentStorage;
};
......@@ -19,8 +19,7 @@
[
Conditional=QUOTA,
Supplemental=WorkerNavigator
] interface WorkerNavigatorStorageQuota {
] partial interface WorkerNavigator {
readonly attribute StorageQuota webkitTemporaryStorage;
readonly attribute StorageQuota webkitPersistentStorage;
};
......@@ -25,8 +25,7 @@
[
Conditional=SCRIPTED_SPEECH,
Supplemental=DOMWindow
] interface DOMWindowSpeech {
] partial interface DOMWindow {
attribute SpeechRecognitionConstructor webkitSpeechRecognition;
attribute SpeechRecognitionErrorConstructor webkitSpeechRecognitionError;
attribute SpeechRecognitionEventConstructor webkitSpeechRecognitionEvent;
......
......@@ -25,8 +25,7 @@
[
Conditional=SPEECH_SYNTHESIS,
Supplemental=DOMWindow
] interface DOMWindowSpeechSynthesis {
] partial interface DOMWindow {
readonly attribute SpeechSynthesis speechSynthesis;
attribute SpeechSynthesisEventConstructor SpeechSynthesisEvent;
......
......@@ -19,8 +19,7 @@
[
Conditional=VIBRATION,
Supplemental=Navigator
] interface NavigatorVibration {
] partial interface Navigator {
void vibrate(in sequence<unsigned long> pattern) raises(DOMException);
void vibrate(in unsigned long time) raises(DOMException);
};
......
......@@ -26,8 +26,7 @@
[
Conditional=WEB_AUDIO,
Supplemental=DOMWindow
] interface DOMWindowWebAudio {
] partial interface DOMWindow {
#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
[CustomGetter] attribute AudioContextConstructor webkitAudioContext;
attribute OfflineAudioContextConstructor webkitOfflineAudioContext;
......
......@@ -26,8 +26,7 @@
[
Conditional=SQL_DATABASE,
Supplemental=DOMWindow
] interface DOMWindowWebDatabase {
] partial interface DOMWindow {
Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in [Callback, Optional] DatabaseCallback creationCallback)
raises(DOMException);
#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
......
......@@ -26,8 +26,7 @@
[
Conditional=SQL_DATABASE,
Supplemental=WorkerContext
] interface WorkerContextWebDatabase {
] partial interface WorkerContext {
Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in [Callback, Optional] DatabaseCallback creationCallback)
raises(DOMException);
......
......@@ -26,8 +26,7 @@
[
Conditional=WEB_SOCKETS,
Supplemental=DOMWindow
] interface DOMWindowWebSocket {
] partial interface DOMWindow {
#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
attribute CloseEventConstructor CloseEvent;
[CustomGetter] attribute WebSocketConstructor WebSocket; // Usable with the new operator
......
......@@ -26,8 +26,7 @@
[
Conditional=WEB_SOCKETS,
Supplemental=WorkerContext
] interface WorkerContextWebSocket {
] partial interface WorkerContext {
[CustomGetter] attribute WebSocketConstructor WebSocket; // Usable with the new operator
};
......@@ -99,7 +99,6 @@ ReplaceableConstructor
ReturnNewObject
SkipVTableValidation
StrictTypeChecking
Supplemental=*
SuppressToJSObject
TransferList=*
TreatNullAs=NullString
......
......@@ -51,6 +51,7 @@ struct( domInterface => {
constructors => '@', # Constructors, list of 'domFunction'
isException => '$', # Used for exception interfaces
isCallback => '$', # Used for callback interfaces
isPartial => '$', # Used for partial interfaces
});
# Used to represent domInterface contents (name of method, signature)
......@@ -529,7 +530,9 @@ sub parsePartialDefinition
my $next = $self->nextToken();
if ($next->value() eq "interface") {
return $self->parsePartialInterface($extendedAttributeList);
my $interface = $self->parseInterface($extendedAttributeList);
$interface->isPartial(1);
return $interface;
}
if ($next->value() eq "dictionary") {
return $self->parsePartialDictionary($extendedAttributeList);
......
......@@ -139,7 +139,7 @@ foreach my $idlFile (@supplementedIdlFiles) {
my $document = $parser->Parse($idlFile, $defines, $preprocessor);
foreach my $interface (@{$document->interfaces}) {
if ($interface->extendedAttributes->{"Supplemental"} and $interface->extendedAttributes->{"Supplemental"} eq $targetInterfaceName) {
if ($interface->isPartial and $interface->name eq $targetInterfaceName) {
my $targetDataNode;
foreach my $interface (@{$targetDocument->interfaces}) {
if ($interface->name eq $targetInterfaceName) {
......@@ -149,40 +149,37 @@ foreach my $idlFile (@supplementedIdlFiles) {
}
die "Not found an interface ${targetInterfaceName} in ${targetInterfaceName}.idl." unless defined $targetDataNode;
# Support [Supplemental] for attributes.
# Support for attributes of partial interfaces.
foreach my $attribute (@{$interface->attributes}) {
# Record that this attribute is implemented by $interfaceName.
$attribute->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName;
# Add interface-wide extended attributes to each attribute.
foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) {
next if ($extendedAttributeName eq "Supplemental");
$attribute->signature->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName};
}
push(@{$targetDataNode->attributes}, $attribute);
}
# Support [Supplemental] for methods.
# Support for methods of partial interfaces.
foreach my $function (@{$interface->functions}) {
# Record that this method is implemented by $interfaceName.
$function->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName;
# Add interface-wide extended attributes to each method.
foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) {
next if ($extendedAttributeName eq "Supplemental");
$function->signature->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName};
}
push(@{$targetDataNode->functions}, $function);
}
# Support [Supplemental] for constants.
# Support for constants of partial interfaces.
foreach my $constant (@{$interface->constants}) {
# Record that this constant is implemented by $interfaceName.
$constant->extendedAttributes->{"ImplementedBy"} = $interfaceName;
# Add interface-wide extended attributes to each constant.
foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) {
next if ($extendedAttributeName eq "Supplemental");
$constant->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName};
}
push(@{$targetDataNode->constants}, $constant);
......
......@@ -52,9 +52,9 @@ my %supplementalDependencies;
my %supplementals;
foreach my $idlFile (@idlFiles) {
my $fullPath = Cwd::realpath($idlFile);
my $supplemental = getSupplementalFromIDLFile($fullPath);
if ($supplemental) {
$supplementalDependencies{$fullPath} = $supplemental;
my $partialInterfaceName = getPartialInterfaceNameFromIDLFile($fullPath);
if ($partialInterfaceName) {
$supplementalDependencies{$fullPath} = $partialInterfaceName;
}
my $interfaceName = fileparse(basename($idlFile), ".idl");
$interfaceNameToIdlFile{$interfaceName} = $fullPath;
......@@ -62,7 +62,7 @@ foreach my $idlFile (@idlFiles) {
$supplementals{$fullPath} = [];
}
# Resolves [Supplemental=XXX] dependencies.
# Resolves partial interfaces dependencies.
foreach my $idlFile (keys %supplementalDependencies) {
my $baseFile = $supplementalDependencies{$idlFile};
my $targetIdlFile = $interfaceNameToIdlFile{$baseFile};
......@@ -110,7 +110,7 @@ if ($supplementalMakefileDeps) {
}
sub getSupplementalFromIDLFile
sub getPartialInterfaceNameFromIDLFile
{
my $idlFile = shift;
......@@ -119,12 +119,7 @@ sub getSupplementalFromIDLFile
close FILE;
my $fileContents = join('', @lines);
while ($fileContents =~ /\[(.*?)\] interface (\w+)/gs) {
my @attributes = split(',', $1);
foreach (@attributes) {
if (/Supplemental=(\w+)/) {
return $1;
}
}
if ($fileContents =~ /partial\s+interface\s+(\w+)/gs) {
return $1;
}
}
......@@ -30,8 +30,7 @@
// changes in its ouput.
[
Conditional=Condition11|Condition12,
Supplemental=TestInterface
] interface TestSupplemental {
] partial interface TestInterface {
static readonly attribute long supplementalStaticReadOnlyAttr;
static attribute DOMString supplementalStaticAttr;
readonly attribute DOMString supplementalStr1;
......
......@@ -30,7 +30,6 @@
[
Conditional=PAGE_POPUP,
Supplemental=DOMWindow
] interface DOMWindowPagePopup {
] partial interface DOMWindow {
readonly attribute PagePopupController pagePopupController;
};
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