content/media/TextTrackRegion.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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"
     8 #include "mozilla/dom/VTTRegionBinding.h"
    10 namespace mozilla {
    11 namespace dom {
    13 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TextTrackRegion, mParent)
    14 NS_IMPL_CYCLE_COLLECTING_ADDREF(TextTrackRegion)
    15 NS_IMPL_CYCLE_COLLECTING_RELEASE(TextTrackRegion)
    16 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextTrackRegion)
    17   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
    18   NS_INTERFACE_MAP_ENTRY(nsISupports)
    19 NS_INTERFACE_MAP_END
    21 JSObject*
    22 TextTrackRegion::WrapObject(JSContext* aCx)
    23 {
    24   return VTTRegionBinding::Wrap(aCx, this);
    25 }
    27 already_AddRefed<TextTrackRegion>
    28 TextTrackRegion::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
    29 {
    30   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
    31   if (!window) {
    32     aRv.Throw(NS_ERROR_FAILURE);
    33     return nullptr;
    34   }
    36   nsRefPtr<TextTrackRegion> region = new TextTrackRegion(aGlobal.GetAsSupports());
    37   return region.forget();
    38 }
    40 TextTrackRegion::TextTrackRegion(nsISupports* aGlobal)
    41   : mParent(aGlobal)
    42   , mWidth(100)
    43   , mLines(3)
    44   , mRegionAnchorX(0)
    45   , mRegionAnchorY(100)
    46   , mViewportAnchorX(0)
    47   , mViewportAnchorY(100)
    48 {
    49   SetIsDOMBinding();
    50 }
    52 void
    53 TextTrackRegion::CopyValues(TextTrackRegion& aRegion)
    54 {
    55   mWidth = aRegion.Width();
    56   mLines = aRegion.Lines();
    57   mRegionAnchorX = aRegion.RegionAnchorX();
    58   mRegionAnchorY = aRegion.RegionAnchorY();
    59   mViewportAnchorX = aRegion.ViewportAnchorX();
    60   mViewportAnchorY = aRegion.ViewportAnchorY();
    61   mScroll = aRegion.Scroll();
    62 }
    64 } //namespace dom
    65 } //namespace mozilla

mercurial