Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/toolkit/components/find/nsWebBrowserFind.h
Line
Count
Source (jump to first uncovered line)
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 nsWebBrowserFindImpl_h__
8
#define nsWebBrowserFindImpl_h__
9
10
#include "nsIWebBrowserFind.h"
11
12
#include "nsCOMPtr.h"
13
#include "nsWeakReference.h"
14
15
#include "nsIFind.h"
16
17
#include "nsString.h"
18
19
class nsIDOMWindow;
20
21
class nsIDocShell;
22
class nsIDocument;
23
class nsRange;
24
25
namespace mozilla {
26
namespace dom {
27
class Element;
28
class Selection;
29
} // namespace dom
30
} // namespace mozilla
31
32
//*****************************************************************************
33
// class nsWebBrowserFind
34
//*****************************************************************************
35
36
class nsWebBrowserFind
37
  : public nsIWebBrowserFind
38
  , public nsIWebBrowserFindInFrames
39
{
40
public:
41
  nsWebBrowserFind();
42
43
  // nsISupports
44
  NS_DECL_ISUPPORTS
45
46
  // nsIWebBrowserFind
47
  NS_DECL_NSIWEBBROWSERFIND
48
49
  // nsIWebBrowserFindInFrames
50
  NS_DECL_NSIWEBBROWSERFINDINFRAMES
51
52
protected:
53
  virtual ~nsWebBrowserFind();
54
55
0
  bool CanFindNext() { return mSearchString.Length() != 0; }
56
57
  nsresult SearchInFrame(nsPIDOMWindowOuter* aWindow, bool aWrapping,
58
                         bool* aDidFind);
59
60
  nsresult OnStartSearchFrame(nsPIDOMWindowOuter* aWindow);
61
  nsresult OnEndSearchFrame(nsPIDOMWindowOuter* aWindow);
62
63
  already_AddRefed<mozilla::dom::Selection>
64
    GetFrameSelection(nsPIDOMWindowOuter* aWindow);
65
  nsresult ClearFrameSelection(nsPIDOMWindowOuter* aWindow);
66
67
  nsresult OnFind(nsPIDOMWindowOuter* aFoundWindow);
68
69
  void SetSelectionAndScroll(nsPIDOMWindowOuter* aWindow, nsRange* aRange);
70
71
  nsresult GetRootNode(nsIDocument* aDomDoc, mozilla::dom::Element** aNode);
72
  nsresult GetSearchLimits(nsRange* aRange,
73
                           nsRange* aStartPt, nsRange* aEndPt,
74
                           nsIDocument* aDoc, mozilla::dom::Selection* aSel,
75
                           bool aWrap);
76
  nsresult SetRangeAroundDocument(nsRange* aSearchRange,
77
                                  nsRange* aStartPoint,
78
                                  nsRange* aEndPoint,
79
                                  nsIDocument* aDoc);
80
81
protected:
82
  nsString mSearchString;
83
84
  bool mFindBackwards;
85
  bool mWrapFind;
86
  bool mEntireWord;
87
  bool mMatchCase;
88
89
  bool mSearchSubFrames;
90
  bool mSearchParentFrames;
91
92
  // These are all weak because who knows if windows can go away during our
93
  // lifetime.
94
  nsWeakPtr mCurrentSearchFrame;
95
  nsWeakPtr mRootSearchFrame;
96
  nsWeakPtr mLastFocusedWindow;
97
};
98
99
#endif