1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/TextTrackRegion.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 et tw=78: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "mozilla/dom/TextTrackRegion.h" 1.11 +#include "mozilla/dom/VTTRegionBinding.h" 1.12 + 1.13 +namespace mozilla { 1.14 +namespace dom { 1.15 + 1.16 +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TextTrackRegion, mParent) 1.17 +NS_IMPL_CYCLE_COLLECTING_ADDREF(TextTrackRegion) 1.18 +NS_IMPL_CYCLE_COLLECTING_RELEASE(TextTrackRegion) 1.19 +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextTrackRegion) 1.20 + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY 1.21 + NS_INTERFACE_MAP_ENTRY(nsISupports) 1.22 +NS_INTERFACE_MAP_END 1.23 + 1.24 +JSObject* 1.25 +TextTrackRegion::WrapObject(JSContext* aCx) 1.26 +{ 1.27 + return VTTRegionBinding::Wrap(aCx, this); 1.28 +} 1.29 + 1.30 +already_AddRefed<TextTrackRegion> 1.31 +TextTrackRegion::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) 1.32 +{ 1.33 + nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports()); 1.34 + if (!window) { 1.35 + aRv.Throw(NS_ERROR_FAILURE); 1.36 + return nullptr; 1.37 + } 1.38 + 1.39 + nsRefPtr<TextTrackRegion> region = new TextTrackRegion(aGlobal.GetAsSupports()); 1.40 + return region.forget(); 1.41 +} 1.42 + 1.43 +TextTrackRegion::TextTrackRegion(nsISupports* aGlobal) 1.44 + : mParent(aGlobal) 1.45 + , mWidth(100) 1.46 + , mLines(3) 1.47 + , mRegionAnchorX(0) 1.48 + , mRegionAnchorY(100) 1.49 + , mViewportAnchorX(0) 1.50 + , mViewportAnchorY(100) 1.51 +{ 1.52 + SetIsDOMBinding(); 1.53 +} 1.54 + 1.55 +void 1.56 +TextTrackRegion::CopyValues(TextTrackRegion& aRegion) 1.57 +{ 1.58 + mWidth = aRegion.Width(); 1.59 + mLines = aRegion.Lines(); 1.60 + mRegionAnchorX = aRegion.RegionAnchorX(); 1.61 + mRegionAnchorY = aRegion.RegionAnchorY(); 1.62 + mViewportAnchorX = aRegion.ViewportAnchorX(); 1.63 + mViewportAnchorY = aRegion.ViewportAnchorY(); 1.64 + mScroll = aRegion.Scroll(); 1.65 +} 1.66 + 1.67 +} //namespace dom 1.68 +} //namespace mozilla 1.69 +