Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1415805 - region.scroll setter should not throw. r=smaug
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: FU9YBBeLT5B
  • Loading branch information
bechen committed Nov 22, 2017
1 parent f24af18 commit d429a4b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dom/media/TextTrackRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/dom/TextTrackRegion.h"
#include "mozilla/dom/VTTRegionBinding.h"

namespace mozilla {
namespace dom {
Expand Down Expand Up @@ -45,6 +44,7 @@ TextTrackRegion::TextTrackRegion(nsISupports* aGlobal)
, mRegionAnchorY(100)
, mViewportAnchorX(0)
, mViewportAnchorY(100)
, mScroll(ScrollSetting::_empty)
{
}

Expand Down
20 changes: 7 additions & 13 deletions dom/media/TextTrackRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "nsWrapperCache.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/TextTrack.h"
#include "mozilla/dom/VTTRegionBinding.h"
#include "mozilla/Preferences.h"

namespace mozilla {
Expand Down Expand Up @@ -116,19 +117,16 @@ class TextTrackRegion final : public nsISupports,
}
}

void GetScroll(nsAString& aScroll) const
ScrollSetting Scroll() const
{
aScroll = mScroll;
return mScroll;
}

void SetScroll(const nsAString& aScroll, ErrorResult& aRv)
void SetScroll(const ScrollSetting& aScroll)
{
if (!aScroll.EqualsLiteral("") && !aScroll.EqualsLiteral("up")) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
if (aScroll == ScrollSetting::_empty || aScroll == ScrollSetting::Up) {
mScroll = aScroll;
}

mScroll = aScroll;
}

void GetId(nsAString& aId) const
Expand All @@ -149,10 +147,6 @@ class TextTrackRegion final : public nsISupports,
void CopyValues(TextTrackRegion& aRegion);

// -----helpers-------
const nsAString& Scroll() const
{
return mScroll;
}
const nsAString& Id() const
{
return mId;
Expand All @@ -169,7 +163,7 @@ class TextTrackRegion final : public nsISupports,
double mRegionAnchorY;
double mViewportAnchorX;
double mViewportAnchorY;
nsString mScroll;
ScrollSetting mScroll;

// Helper to ensure new value is in the range: 0.0% - 100.0%; throws
// an IndexSizeError otherwise.
Expand Down
11 changes: 8 additions & 3 deletions dom/webidl/VTTRegion.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://dev.w3.org/html5/webvtt/#extension-of-the-texttrack-interface-for-region-support
* https://w3c.github.io/webvtt/#the-vttregion-interface
*/

enum ScrollSetting {
"",
"up"
};

[Constructor, Pref="media.webvtt.regions.enabled"]
interface VTTRegion {
attribute DOMString id;
Expand All @@ -22,6 +27,6 @@ interface VTTRegion {
attribute double viewportAnchorX;
[SetterThrows]
attribute double viewportAnchorY;
[SetterThrows]
attribute DOMString scroll;

attribute ScrollSetting scroll;
};

0 comments on commit d429a4b

Please sign in to comment.