Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / dom / media / webvtt / TextTrackRegion.cpp
blobd883659579a4b6ef2be2e01a2441c413f1543379
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 et tw=78: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/TextTrackRegion.h"
9 namespace mozilla::dom {
11 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TextTrackRegion, mParent)
12 NS_IMPL_CYCLE_COLLECTING_ADDREF(TextTrackRegion)
13 NS_IMPL_CYCLE_COLLECTING_RELEASE(TextTrackRegion)
14 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextTrackRegion)
15 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
16 NS_INTERFACE_MAP_ENTRY(nsISupports)
17 NS_INTERFACE_MAP_END
19 JSObject* TextTrackRegion::WrapObject(JSContext* aCx,
20 JS::Handle<JSObject*> aGivenProto) {
21 return VTTRegion_Binding::Wrap(aCx, this, aGivenProto);
24 already_AddRefed<TextTrackRegion> TextTrackRegion::Constructor(
25 const GlobalObject& aGlobal, ErrorResult& aRv) {
26 nsCOMPtr<nsPIDOMWindowInner> window =
27 do_QueryInterface(aGlobal.GetAsSupports());
28 if (!window) {
29 aRv.Throw(NS_ERROR_FAILURE);
30 return nullptr;
33 RefPtr<TextTrackRegion> region = new TextTrackRegion(aGlobal.GetAsSupports());
34 return region.forget();
37 TextTrackRegion::TextTrackRegion(nsISupports* aGlobal)
38 : mParent(aGlobal),
39 mWidth(100),
40 mLines(3),
41 mRegionAnchorX(0),
42 mRegionAnchorY(100),
43 mViewportAnchorX(0),
44 mViewportAnchorY(100),
45 mScroll(ScrollSetting::_empty) {}
47 void TextTrackRegion::CopyValues(TextTrackRegion& aRegion) {
48 mId = aRegion.Id();
49 mWidth = aRegion.Width();
50 mLines = aRegion.Lines();
51 mRegionAnchorX = aRegion.RegionAnchorX();
52 mRegionAnchorY = aRegion.RegionAnchorY();
53 mViewportAnchorX = aRegion.ViewportAnchorX();
54 mViewportAnchorY = aRegion.ViewportAnchorY();
55 mScroll = aRegion.Scroll();
58 } // namespace mozilla::dom