LCOV - code coverage report
Current view: top level - dom/base - nsDOMCaretPosition.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 33 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 13 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             : #include "nsDOMCaretPosition.h"
       8             : 
       9             : #include "mozilla/dom/CaretPositionBinding.h"
      10             : #include "mozilla/dom/DOMRect.h"
      11             : #include "nsRange.h"
      12             : 
      13             : using namespace mozilla::dom;
      14             : 
      15           0 : nsDOMCaretPosition::nsDOMCaretPosition(nsINode* aNode, uint32_t aOffset)
      16           0 :   : mOffset(aOffset), mOffsetNode(aNode), mAnonymousContentNode(nullptr)
      17             : {
      18           0 : }
      19             : 
      20           0 : nsDOMCaretPosition::~nsDOMCaretPosition()
      21             : {
      22           0 : }
      23             : 
      24           0 : nsINode* nsDOMCaretPosition::GetOffsetNode() const
      25             : {
      26           0 :   return mOffsetNode;
      27             : }
      28             : 
      29             : already_AddRefed<DOMRect>
      30           0 : nsDOMCaretPosition::GetClientRect() const
      31             : {
      32           0 :   if (!mOffsetNode) {
      33           0 :     return nullptr;
      34             :   }
      35             : 
      36           0 :   RefPtr<DOMRect> rect;
      37           0 :   RefPtr<nsRange> domRange;
      38           0 :   nsCOMPtr<nsINode> node;
      39             : 
      40           0 :   if (mAnonymousContentNode) {
      41           0 :     node = mAnonymousContentNode;
      42             :   } else {
      43           0 :     node = mOffsetNode;
      44             :   }
      45             : 
      46           0 :   nsresult creationRv = nsRange::CreateRange(node, mOffset, node,
      47           0 :                                              mOffset,
      48           0 :                                              getter_AddRefs<nsRange>(domRange));
      49           0 :   if (!NS_SUCCEEDED(creationRv)) {
      50           0 :     return nullptr;
      51             :   }
      52             : 
      53           0 :   NS_ASSERTION(domRange, "unable to retrieve valid dom range from CaretPosition");
      54             : 
      55           0 :   rect = domRange->GetBoundingClientRect(false);
      56             : 
      57           0 :   return rect.forget();
      58             : }
      59             : 
      60             : JSObject*
      61           0 : nsDOMCaretPosition::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
      62             : {
      63           0 :   return mozilla::dom::CaretPositionBinding::Wrap(aCx, this, aGivenProto);
      64             : }
      65             : 
      66           0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCaretPosition,
      67             :                                       mOffsetNode, mAnonymousContentNode)
      68             : 
      69           0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCaretPosition)
      70           0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCaretPosition)
      71             : 
      72           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCaretPosition)
      73           0 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
      74           0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
      75           0 : NS_INTERFACE_MAP_END
      76             : 

Generated by: LCOV version 1.13