Diff
Modified: trunk/Source/WebCore/ChangeLog (275906 => 275907)
--- trunk/Source/WebCore/ChangeLog 2021-04-13 20:37:34 UTC (rev 275906)
+++ trunk/Source/WebCore/ChangeLog 2021-04-13 20:38:03 UTC (rev 275907)
@@ -1,3 +1,26 @@
+2021-04-13 Devin Rousso <[email protected]>
+
+ [WebIDL] includes for `Conditional` dictionary members should also be guarded
+ https://bugs.webkit.org/show_bug.cgi?id=224501
+ <rdar://problem/76598492>
+
+ Reviewed by Tim Horton.
+
+ WebKitAdditions sometimes needs to conditionally include IDL files and in those cases the
+ generated `JS*.h` might not get created even though the wrapped C++ type does exist. In
+ these cases, we should also guard the `#include JS*.h` (in addition to the already guarded
+ usage of the wrapped C++ type in `convertDictionary`).
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateDictionaryImplementationContent):
+
+ * bindings/scripts/test/TestDictionary.idl: Added.
+ * bindings/scripts/test/JS/JSTestDictionary.h: Added.
+ * bindings/scripts/test/JS/JSTestDictionary.cpp: Added.
+ * bindings/scripts/test/TestDictionaryWithOnlyConditionalMembers.idl:
+ * bindings/scripts/test/JS/JSTestDictionaryWithOnlyConditionalMembers.cpp:
+ * bindings/scripts/test/SupplementalDependencies.dep:
+
2021-04-13 Said Abou-Hallawa <[email protected]>
[GPU Process] Make ImageBuffer calculate its memoryCost() from its size
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (275906 => 275907)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2021-04-13 20:37:34 UTC (rev 275906)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2021-04-13 20:38:03 UTC (rev 275907)
@@ -2627,11 +2627,11 @@
my @sortedMembers = sort { $a->name cmp $b->name } @{$dictionary->members};
foreach my $member (@sortedMembers) {
$member->default("undefined") if $member->type->name eq "any" and !defined($member->default); # Use undefined as default value for member of type 'any' unless specified otherwise.
+ my $conditional = $member->extendedAttributes->{Conditional};
my $type = $member->type;
- AddToImplIncludesForIDLType($type);
+ AddToImplIncludesForIDLType($type, $conditional);
- my $conditional = $member->extendedAttributes->{Conditional};
if ($conditional) {
my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional);
$result .= "#if ${conditionalString}\n";
Copied: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionary.cpp (from rev 275906, trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionaryWithOnlyConditionalMembers.cpp) (0 => 275907)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionary.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionary.cpp 2021-04-13 20:38:03 UTC (rev 275907)
@@ -0,0 +1,56 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ 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 "JSTestDictionary.h"
+
+#include "JSDOMConvertNumbers.h"
+#include <_javascript_Core/JSCInlines.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+template<> TestDictionary convertDictionary<TestDictionary>(JSGlobalObject& lexicalGlobalObject, JSValue value)
+{
+ VM& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ bool isNullOrUndefined = value.isUndefinedOrNull();
+ auto* object = isNullOrUndefined ? nullptr : value.getObject();
+ if (UNLIKELY(!isNullOrUndefined && !object)) {
+ throwTypeError(&lexicalGlobalObject, throwScope);
+ return { };
+ }
+ TestDictionary result;
+ JSValue memberValue;
+ if (isNullOrUndefined)
+ memberValue = jsUndefined();
+ else {
+ memberValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "member"));
+ RETURN_IF_EXCEPTION(throwScope, { });
+ }
+ if (!memberValue.isUndefined()) {
+ result.member = convert<IDLDouble>(lexicalGlobalObject, memberValue);
+ RETURN_IF_EXCEPTION(throwScope, { });
+ }
+ return result;
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionary.h (0 => 275907)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionary.h (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionary.h 2021-04-13 20:38:03 UTC (rev 275907)
@@ -0,0 +1,30 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ 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.
+*/
+
+#pragma once
+
+#include "JSDOMConvertDictionary.h"
+#include "TestDictionary.h"
+
+namespace WebCore {
+
+template<> TestDictionary convertDictionary<TestDictionary>(JSC::JSGlobalObject&, JSC::JSValue);
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionaryWithOnlyConditionalMembers.cpp (275906 => 275907)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionaryWithOnlyConditionalMembers.cpp 2021-04-13 20:37:34 UTC (rev 275906)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestDictionaryWithOnlyConditionalMembers.cpp 2021-04-13 20:38:03 UTC (rev 275907)
@@ -21,12 +21,15 @@
#include "config.h"
#include "JSTestDictionaryWithOnlyConditionalMembers.h"
-#include "JSDOMConvertNumbers.h"
#include "JSDOMGlobalObject.h"
#include <_javascript_Core/JSCInlines.h>
#include <_javascript_Core/ObjectConstructor.h>
+#if ENABLE(TEST_CONDITIONAL)
+#include "JSTestDictionary.h"
+#endif
+
namespace WebCore {
using namespace JSC;
@@ -42,15 +45,15 @@
}
TestDictionaryWithOnlyConditionalMembers result;
#if ENABLE(TEST_CONDITIONAL)
- JSValue conditionalAttrValue;
+ JSValue conditionalMemberValue;
if (isNullOrUndefined)
- conditionalAttrValue = jsUndefined();
+ conditionalMemberValue = jsUndefined();
else {
- conditionalAttrValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "conditionalAttr"));
+ conditionalMemberValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "conditionalMember"));
RETURN_IF_EXCEPTION(throwScope, { });
}
- if (!conditionalAttrValue.isUndefined()) {
- result.conditionalAttr = convert<IDLDouble>(lexicalGlobalObject, conditionalAttrValue);
+ if (!conditionalMemberValue.isUndefined()) {
+ result.conditionalMember = convert<IDLDictionary<TestDictionary>>(lexicalGlobalObject, conditionalMemberValue);
RETURN_IF_EXCEPTION(throwScope, { });
}
#endif
@@ -64,9 +67,9 @@
auto result = constructEmptyObject(&lexicalGlobalObject, globalObject.objectPrototype());
#if ENABLE(TEST_CONDITIONAL)
- if (!IDLDouble::isNullValue(dictionary.conditionalAttr)) {
- auto conditionalAttrValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.conditionalAttr));
- result->putDirect(vm, JSC::Identifier::fromString(vm, "conditionalAttr"), conditionalAttrValue);
+ if (!IDLDictionary<TestDictionary>::isNullValue(dictionary.conditionalMember)) {
+ auto conditionalMemberValue = toJS<IDLDictionary<TestDictionary>>(lexicalGlobalObject, globalObject, IDLDictionary<TestDictionary>::extractValueFromNullable(dictionary.conditionalMember));
+ result->putDirect(vm, JSC::Identifier::fromString(vm, "conditionalMember"), conditionalMemberValue);
}
#endif
UNUSED_PARAM(dictionary);
Modified: trunk/Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep (275906 => 275907)
--- trunk/Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep 2021-04-13 20:37:34 UTC (rev 275906)
+++ trunk/Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep 2021-04-13 20:38:03 UTC (rev 275907)
@@ -82,6 +82,9 @@
JSTestDerivedDictionary2.h:
DOMTestDerivedDictionary2.h:
WebDOMTestDerivedDictionary2.h:
+JSTestDictionary.h:
+DOMTestDictionary.h:
+WebDOMTestDictionary.h:
JSTestDictionaryWithOnlyConditionalMembers.h:
DOMTestDictionaryWithOnlyConditionalMembers.h:
WebDOMTestDictionaryWithOnlyConditionalMembers.h:
Copied: trunk/Source/WebCore/bindings/scripts/test/TestDictionary.idl (from rev 275906, trunk/Source/WebCore/bindings/scripts/test/TestDictionaryWithOnlyConditionalMembers.idl) (0 => 275907)
--- trunk/Source/WebCore/bindings/scripts/test/TestDictionary.idl (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/TestDictionary.idl 2021-04-13 20:38:03 UTC (rev 275907)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary form, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary TestDictionary {
+ double member;
+};
Modified: trunk/Source/WebCore/bindings/scripts/test/TestDictionaryWithOnlyConditionalMembers.idl (275906 => 275907)
--- trunk/Source/WebCore/bindings/scripts/test/TestDictionaryWithOnlyConditionalMembers.idl 2021-04-13 20:37:34 UTC (rev 275906)
+++ trunk/Source/WebCore/bindings/scripts/test/TestDictionaryWithOnlyConditionalMembers.idl 2021-04-13 20:38:03 UTC (rev 275907)
@@ -29,5 +29,5 @@
[
JSGenerateToJSObject,
] dictionary TestDictionaryWithOnlyConditionalMembers {
- [Conditional=TEST_CONDITIONAL] double conditionalAttr;
+ [Conditional=TEST_CONDITIONAL] TestDictionary conditionalMember;
};