diff --git a/dom/media/TextTrackRegion.cpp b/dom/media/TextTrackRegion.cpp index 9a82011cd125..0ddfb20d1542 100644 --- a/dom/media/TextTrackRegion.cpp +++ b/dom/media/TextTrackRegion.cpp @@ -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 { @@ -45,6 +44,7 @@ TextTrackRegion::TextTrackRegion(nsISupports* aGlobal) , mRegionAnchorY(100) , mViewportAnchorX(0) , mViewportAnchorY(100) + , mScroll(ScrollSetting::_empty) { } diff --git a/dom/media/TextTrackRegion.h b/dom/media/TextTrackRegion.h index 892d7c7ad19d..cef0f7942506 100644 --- a/dom/media/TextTrackRegion.h +++ b/dom/media/TextTrackRegion.h @@ -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 { @@ -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 @@ -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; @@ -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. diff --git a/dom/webidl/VTTRegion.webidl b/dom/webidl/VTTRegion.webidl index df35eb2815db..d665cfea4c83 100644 --- a/dom/webidl/VTTRegion.webidl +++ b/dom/webidl/VTTRegion.webidl @@ -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; @@ -22,6 +27,6 @@ interface VTTRegion { attribute double viewportAnchorX; [SetterThrows] attribute double viewportAnchorY; - [SetterThrows] - attribute DOMString scroll; + + attribute ScrollSetting scroll; };