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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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 nsDOMCaretPosition_h
       8             : #define nsDOMCaretPosition_h
       9             : 
      10             : #include "nsCycleCollectionParticipant.h"
      11             : #include "nsCOMPtr.h"
      12             : #include "nsINode.h"
      13             : #include "nsWrapperCache.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : class DOMRect;
      18             : } // namespace dom
      19             : } // namespace mozilla
      20             : 
      21             : /**
      22             :  * Implementation of a DOM Caret Position, which is a node and offset within
      23             :  * that node, in the DOM tree.
      24             :  *
      25             :  * http://www.w3.org/TR/cssom-view/#dom-documentview-caretrangefrompoint
      26             :  *
      27             :  * @see Document::caretPositionFromPoint(float x, float y)
      28             :  */
      29             : class nsDOMCaretPosition : public nsISupports,
      30             :                            public nsWrapperCache
      31             : {
      32             :   typedef mozilla::dom::DOMRect DOMRect;
      33             : 
      34             : public:
      35             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      36           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCaretPosition)
      37             : 
      38             :   nsDOMCaretPosition(nsINode* aNode, uint32_t aOffset);
      39             : 
      40             :   /**
      41             :    * Retrieve the offset (character position within the DOM node) of the
      42             :    * CaretPosition.
      43             :    *
      44             :    * @returns The offset within the DOM node.
      45             :    */
      46           0 :   uint32_t Offset() const { return mOffset; }
      47             : 
      48             :   /**
      49             :    * Retrieve the DOM node with which this CaretPosition was established.
      50             :    * Normally, this will be created from a point, so it will be the DOM
      51             :    * node that lies at the point specified.
      52             :    *
      53             :    * @returns The DOM node of the CaretPosition.
      54             :    *
      55             :    * @see Document::caretPositionFromPoint(float x, float y)
      56             :    */
      57             :   nsINode* GetOffsetNode() const;
      58             : 
      59             :   /**
      60             :    * Retrieve the bounding rectangle of this CaretPosition object.
      61             :    *
      62             :    * @returns An nsClientRect representing the bounding rectangle of this
      63             :    *          CaretPosition, if one can be successfully determined, otherwise
      64             :    *          nullptr.
      65             :    */
      66             :   already_AddRefed<DOMRect> GetClientRect() const;
      67             : 
      68             :   /**
      69             :    * Set the anonymous content node that is the actual parent of this
      70             :    * CaretPosition object. In situations where the DOM node for a CaretPosition
      71             :    * actually lies within an anonymous content node (e.g. a textarea), the
      72             :    * actual parent is not set as the offset node. This is used to get the
      73             :    * correct bounding box of a CaretPosition object that lies within a textarea
      74             :    * or input element.
      75             :    *
      76             :    * @param aNode A pointer to an nsINode object that is the actual element
      77             :    *        within which this CaretPosition lies, but is an anonymous content
      78             :    *        node.
      79             :    */
      80           0 :   void SetAnonymousContentNode(nsINode* aNode)
      81             :   {
      82           0 :     mAnonymousContentNode = aNode;
      83           0 :   }
      84             : 
      85           0 :   nsISupports* GetParentObject() const
      86             :   {
      87           0 :     return GetOffsetNode();
      88             :   }
      89             : 
      90             :   virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
      91             :     override final;
      92             : 
      93             : protected:
      94             :   virtual ~nsDOMCaretPosition();
      95             : 
      96             :   uint32_t mOffset;
      97             :   nsCOMPtr<nsINode> mOffsetNode;
      98             :   nsCOMPtr<nsINode> mAnonymousContentNode;
      99             : };
     100             : #endif
     101             : 

Generated by: LCOV version 1.13