LCOV - code coverage report
Current view: top level - dom/media - TextTrackRegion.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 54 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 25 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       6             : 
       7             : #ifndef mozilla_dom_TextTrackRegion_h
       8             : #define mozilla_dom_TextTrackRegion_h
       9             : 
      10             : #include "nsCycleCollectionParticipant.h"
      11             : #include "nsString.h"
      12             : #include "nsWrapperCache.h"
      13             : #include "mozilla/ErrorResult.h"
      14             : #include "mozilla/dom/TextTrack.h"
      15             : #include "mozilla/Preferences.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : class GlobalObject;
      21             : class TextTrack;
      22             : 
      23             : class TextTrackRegion final : public nsISupports,
      24             :                               public nsWrapperCache
      25             : {
      26             : public:
      27             : 
      28             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      29           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrackRegion)
      30             : 
      31             :   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
      32             : 
      33           0 :   nsISupports* GetParentObject() const
      34             :   {
      35           0 :     return mParent;
      36             :   }
      37             : 
      38             :   explicit TextTrackRegion(nsISupports* aGlobal);
      39             : 
      40             :   /** WebIDL Methods. */
      41             : 
      42             :   static already_AddRefed<TextTrackRegion>
      43             :   Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
      44             : 
      45           0 :   double Lines() const
      46             :   {
      47           0 :     return mLines;
      48             :   }
      49             : 
      50           0 :   void SetLines(double aLines)
      51             :   {
      52           0 :     mLines = aLines;
      53           0 :   }
      54             : 
      55           0 :   double Width() const
      56             :   {
      57           0 :     return mWidth;
      58             :   }
      59             : 
      60           0 :   void SetWidth(double aWidth, ErrorResult& aRv)
      61             :   {
      62           0 :     if (!InvalidValue(aWidth, aRv)) {
      63           0 :       mWidth = aWidth;
      64             :     }
      65           0 :   }
      66             : 
      67           0 :   double RegionAnchorX() const
      68             :   {
      69           0 :     return mRegionAnchorX;
      70             :   }
      71             : 
      72           0 :   void SetRegionAnchorX(double aVal, ErrorResult& aRv)
      73             :   {
      74           0 :     if (!InvalidValue(aVal, aRv)) {
      75           0 :       mRegionAnchorX = aVal;
      76             :     }
      77           0 :   }
      78             : 
      79           0 :   double RegionAnchorY() const
      80             :   {
      81           0 :     return mRegionAnchorY;
      82             :   }
      83             : 
      84           0 :   void SetRegionAnchorY(double aVal, ErrorResult& aRv)
      85             :   {
      86           0 :     if (!InvalidValue(aVal, aRv)) {
      87           0 :       mRegionAnchorY = aVal;
      88             :     }
      89           0 :   }
      90             : 
      91           0 :   double ViewportAnchorX() const
      92             :   {
      93           0 :     return mViewportAnchorX;
      94             :   }
      95             : 
      96           0 :   void SetViewportAnchorX(double aVal, ErrorResult& aRv)
      97             :   {
      98           0 :     if (!InvalidValue(aVal, aRv)) {
      99           0 :       mViewportAnchorX = aVal;
     100             :     }
     101           0 :   }
     102             : 
     103           0 :   double ViewportAnchorY() const
     104             :   {
     105           0 :     return mViewportAnchorY;
     106             :   }
     107             : 
     108           0 :   void SetViewportAnchorY(double aVal, ErrorResult& aRv)
     109             :   {
     110           0 :     if (!InvalidValue(aVal, aRv)) {
     111           0 :       mViewportAnchorY = aVal;
     112             :     }
     113           0 :   }
     114             : 
     115           0 :   void GetScroll(nsAString& aScroll) const
     116             :   {
     117           0 :     aScroll = mScroll;
     118           0 :   }
     119             : 
     120           0 :   void SetScroll(const nsAString& aScroll, ErrorResult& aRv)
     121             :   {
     122           0 :     if (!aScroll.EqualsLiteral("") && !aScroll.EqualsLiteral("up")) {
     123           0 :       aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
     124           0 :       return;
     125             :     }
     126             : 
     127           0 :     mScroll = aScroll;
     128             :   }
     129             : 
     130             :   /** end WebIDL Methods. */
     131             : 
     132             : 
     133             :   // Helper to aid copying of a given TextTrackRegion's width, lines,
     134             :   // anchor, viewport and scroll values.
     135             :   void CopyValues(TextTrackRegion& aRegion);
     136             : 
     137             :   // -----helpers-------
     138           0 :   const nsAString& Scroll() const
     139             :   {
     140           0 :     return mScroll;
     141             :   }
     142             : 
     143             : private:
     144           0 :   ~TextTrackRegion() {}
     145             : 
     146             :   nsCOMPtr<nsISupports> mParent;
     147             :   double mWidth;
     148             :   long mLines;
     149             :   double mRegionAnchorX;
     150             :   double mRegionAnchorY;
     151             :   double mViewportAnchorX;
     152             :   double mViewportAnchorY;
     153             :   nsString mScroll;
     154             : 
     155             :   // Helper to ensure new value is in the range: 0.0% - 100.0%; throws
     156             :   // an IndexSizeError otherwise.
     157           0 :   inline bool InvalidValue(double aValue, ErrorResult& aRv)
     158             :   {
     159           0 :     if(aValue < 0.0  || aValue > 100.0) {
     160           0 :       aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     161           0 :       return true;
     162             :     }
     163             : 
     164           0 :     return false;
     165             :   }
     166             : 
     167             : };
     168             : 
     169             : } //namespace dom
     170             : } //namespace mozilla
     171             : 
     172             : #endif //mozilla_dom_TextTrackRegion_h

Generated by: LCOV version 1.13