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 mozilla_dom_TextClause_h
8 #define mozilla_dom_TextClause_h
9 
10 #include "js/TypeDecls.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/ErrorResult.h"
13 #include "mozilla/dom/BindingDeclarations.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsWrapperCache.h"
16 
17 namespace mozilla {
18 namespace dom {
19 
20 class TextClause final : public nsISupports, public nsWrapperCache {
21  public:
22   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextClause)23   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextClause)
24 
25   nsPIDOMWindowInner* GetParentObject() const { return mOwner; }
26 
27   TextClause(nsPIDOMWindowInner* aWindow, const TextRange& aRange,
28              const TextRange* targetRange);
29 
30   virtual JSObject* WrapObject(JSContext* aCx,
31                                JS::Handle<JSObject*> aGivenProto) override;
32 
StartOffset()33   inline uint32_t StartOffset() const { return mStartOffset; }
34 
EndOffset()35   inline uint32_t EndOffset() const { return mEndOffset; }
36 
IsCaret()37   inline bool IsCaret() const { return mIsCaret; }
38 
IsTargetClause()39   inline bool IsTargetClause() const { return mIsTargetClause; }
40 
41  private:
42   ~TextClause();
43   nsCOMPtr<nsPIDOMWindowInner> mOwner;
44 
45   // Following members, please take look at widget/TextRange.h.
46   uint32_t mStartOffset;
47   uint32_t mEndOffset;
48   bool mIsCaret;
49   bool mIsTargetClause;
50 };
51 
52 }  // namespace dom
53 }  // namespace mozilla
54 
55 #endif  // mozilla_dom_TextClause_h
56