Skip to content
Permalink
Browse files
[Web IDL] Specify default values for optional parameters of type 'uns…
…igned long'

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

Reviewed by Alex Christensen.

Specify default values for optional parameters of type 'unsigned long' and let
the bindings generator use WTF::Optional<> for the parameters that do not have
such default value.

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::createScriptProcessor): Deleted.
(WebCore::AudioContext::createChannelSplitter): Deleted.
(WebCore::AudioContext::createChannelMerger): Deleted.
* Modules/webaudio/AudioContext.h:
* Modules/webaudio/AudioContext.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(CanUseWTFOptionalForParameter): Deleted.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::addRule):
* css/CSSStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule):

Canonical link: https://commits.webkit.org/175165@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Apr 26, 2016
1 parent 5f31904 commit 7be0011c2f1762ed3d0eb689ca2272fddf7392bc
@@ -1,3 +1,28 @@
2016-04-26 Chris Dumez <cdumez@apple.com>

[Web IDL] Specify default values for optional parameters of type 'unsigned long'
https://bugs.webkit.org/show_bug.cgi?id=157043

Reviewed by Alex Christensen.

Specify default values for optional parameters of type 'unsigned long' and let
the bindings generator use WTF::Optional<> for the parameters that do not have
such default value.

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::createScriptProcessor): Deleted.
(WebCore::AudioContext::createChannelSplitter): Deleted.
(WebCore::AudioContext::createChannelMerger): Deleted.
* Modules/webaudio/AudioContext.h:
* Modules/webaudio/AudioContext.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(CanUseWTFOptionalForParameter): Deleted.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::addRule):
* css/CSSStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule):

2016-04-26 Ryosuke Niwa <rniwa@webkit.org>

ASSERTION FAILED: m_templateInsertionModes.isEmpty() in WebCore::HTMLTreeBuilder::finished
@@ -481,18 +481,6 @@ Ref<MediaStreamAudioDestinationNode> AudioContext::createMediaStreamDestination(

#endif

RefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t bufferSize, ExceptionCode& ec)
{
// Set number of input/output channels to stereo by default.
return createScriptProcessor(bufferSize, 2, 2, ec);
}

RefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, ExceptionCode& ec)
{
// Set number of output channels to stereo by default.
return createScriptProcessor(bufferSize, numberOfInputChannels, 2, ec);
}

RefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionCode& ec)
{
ASSERT(isMainThread());
@@ -567,12 +555,6 @@ RefPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionCode&
return WTFMove(node);
}

RefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(ExceptionCode& ec)
{
const unsigned ChannelSplitterDefaultNumberOfOutputs = 6;
return createChannelSplitter(ChannelSplitterDefaultNumberOfOutputs, ec);
}

RefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numberOfOutputs, ExceptionCode& ec)
{
ASSERT(isMainThread());
@@ -588,12 +570,6 @@ RefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numberOfO
return node;
}

RefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionCode& ec)
{
const unsigned ChannelMergerDefaultNumberOfInputs = 6;
return createChannelMerger(ChannelMergerDefaultNumberOfInputs, ec);
}

RefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfInputs, ExceptionCode& ec)
{
ASSERT(isMainThread());
@@ -137,12 +137,8 @@ class AudioContext : public ActiveDOMObject, public ThreadSafeRefCounted<AudioCo
Ref<ConvolverNode> createConvolver();
Ref<DynamicsCompressorNode> createDynamicsCompressor();
Ref<AnalyserNode> createAnalyser();
RefPtr<ScriptProcessorNode> createScriptProcessor(size_t bufferSize, ExceptionCode&);
RefPtr<ScriptProcessorNode> createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, ExceptionCode&);
RefPtr<ScriptProcessorNode> createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionCode&);
RefPtr<ChannelSplitterNode> createChannelSplitter(ExceptionCode&);
RefPtr<ChannelSplitterNode> createChannelSplitter(size_t numberOfOutputs, ExceptionCode&);
RefPtr<ChannelMergerNode> createChannelMerger(ExceptionCode&);
RefPtr<ChannelMergerNode> createChannelMerger(size_t numberOfInputs, ExceptionCode&);
Ref<OscillatorNode> createOscillator();
RefPtr<PeriodicWave> createPeriodicWave(Float32Array* real, Float32Array* imag, ExceptionCode&);
@@ -84,13 +84,13 @@ enum AudioContextState {
ConvolverNode createConvolver();
DynamicsCompressorNode createDynamicsCompressor();
AnalyserNode createAnalyser();
[RaisesException] ScriptProcessorNode createScriptProcessor(unsigned long bufferSize, optional unsigned long numberOfInputChannels, optional unsigned long numberOfOutputChannels);
[RaisesException] ScriptProcessorNode createScriptProcessor(unsigned long bufferSize, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2);
OscillatorNode createOscillator();
[RaisesException] PeriodicWave createPeriodicWave(Float32Array real, Float32Array imag);

// Channel splitting and merging
[RaisesException] ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs);
[RaisesException] ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs);
[RaisesException] ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
[RaisesException] ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);

// Offline rendering
// void prepareOfflineBufferRendering(unsigned long numberOfChannels, unsigned long numberOfFrames, unrestricted float sampleRate);
@@ -100,6 +100,6 @@ enum AudioContextState {
[Conditional=LEGACY_WEB_AUDIO, ImplementedAs=createGain] GainNode createGainNode();
[Conditional=LEGACY_WEB_AUDIO, ImplementedAs=createDelay, RaisesException] DelayNode createDelayNode(optional unrestricted double maxDelayTime = 1);

[Conditional=LEGACY_WEB_AUDIO, ImplementedAs=createScriptProcessor, RaisesException] ScriptProcessorNode createJavaScriptNode(unsigned long bufferSize, optional unsigned long numberOfInputChannels, optional unsigned long numberOfOutputChannels);
[Conditional=LEGACY_WEB_AUDIO, ImplementedAs=createScriptProcessor, RaisesException] ScriptProcessorNode createJavaScriptNode(unsigned long bufferSize, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2);

};
@@ -3384,7 +3384,6 @@ sub CanUseWTFOptionalForParameter
return 0 if $codeGenerator->IsWrapperType($type);
return 0 if $type eq "DOMString";
return 0 if $type eq "any";
return 0 if $type eq "unsigned long";

return 1;
}
@@ -340,7 +340,7 @@ void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
}
}

int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
int CSSStyleSheet::addRule(const String& selector, const String& style, Optional<unsigned> index, ExceptionCode& ec)
{
StringBuilder text;
text.append(selector);
@@ -349,18 +349,12 @@ int CSSStyleSheet::addRule(const String& selector, const String& style, int inde
if (!style.isEmpty())
text.append(' ');
text.append('}');
insertRule(text.toString(), index, ec);
insertRule(text.toString(), index.valueOr(length()), ec);

// As per Microsoft documentation, always return -1.
return -1;
}

int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionCode& ec)
{
return addRule(selector, style, length(), ec);
}


RefPtr<CSSRuleList> CSSStyleSheet::cssRules()
{
if (!canAccessRules())
@@ -70,8 +70,7 @@ class CSSStyleSheet final : public StyleSheet {

// IE Extensions
RefPtr<CSSRuleList> rules();
int addRule(const String& selector, const String& style, int index, ExceptionCode&);
int addRule(const String& selector, const String& style, ExceptionCode&);
int addRule(const String& selector, const String& style, Optional<unsigned> index, ExceptionCode&);
void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }

// For CSSRuleList.
@@ -708,7 +708,7 @@ CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode
StringBuilder styleSheetText;
styleSheetText.append(text);

m_pageStyleSheet->addRule(selector, "", ec);
m_pageStyleSheet->addRule(selector, emptyString(), Nullopt, ec);
if (ec)
return nullptr;
ASSERT(m_pageStyleSheet->length());

0 comments on commit 7be0011

Please sign in to comment.