Closed Bug 1257328 Opened 4 years ago Closed 4 years ago

SpeechUtterance attributes need to be bounded

Categories

(Core :: Web Speech, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: eeejay, Assigned: eeejay)

Details

Attachments

(1 file)

Currently, they can accept any floating point value. We need to make sure the values are within the accepted range.

The three attributes are:
Volume (0 - 1)
Rate (0.1 - 10)
Pitch (0 - 2)
Comment on attachment 8731457 [details]
MozReview Request: Bug 1257328 - Limit SpeechSynthesisUtterance attribute values to spec ranges. r=smaug

https://reviewboard.mozilla.org/r/40609/#review37135

::: dom/media/webspeech/synth/SpeechSynthesisUtterance.cpp:125
(Diff revision 1)
>  }
>  
>  void
>  SpeechSynthesisUtterance::SetVolume(float aVolume)
>  {
> -  mVolume = aVolume;
> +  mVolume = std::max<float>(std::min<float>(aVolume, 1), 0);;;

You really like ';'s ;)

::: dom/media/webspeech/synth/SpeechSynthesisUtterance.cpp:149
(Diff revision 1)
>  }
>  
>  void
>  SpeechSynthesisUtterance::SetPitch(float aPitch)
>  {
> -  mPitch = aPitch;
> +  mPitch = std::max<float>(std::min<float>(aPitch, 2), 0);;

here too
Attachment #8731457 - Flags: review?(bugs) → review+
Comment on attachment 8731457 [details]
MozReview Request: Bug 1257328 - Limit SpeechSynthesisUtterance attribute values to spec ranges. r=smaug

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/40609/diff/1-2/
Attachment #8731457 - Attachment description: MozReview Request: Bug 1257328 - Limit SpeechSynthesisUtterance attribute values to spec ranges. r?smaug → MozReview Request: Bug 1257328 - Limit SpeechSynthesisUtterance attribute values to spec ranges. r=smaug
https://reviewboard.mozilla.org/r/40609/#review37135

> You really like ';'s ;)

lol, yes.
https://hg.mozilla.org/mozilla-central/rev/53758370cd5a
https://hg.mozilla.org/mozilla-central/rev/2d9167622832
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in before you can comment on or make changes to this bug.