Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpfe/appshell/nsWebShellWindow.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef nsWebShellWindow_h__
7
#define nsWebShellWindow_h__
8
9
#include "mozilla/Mutex.h"
10
#include "nsIWebProgressListener.h"
11
#include "nsITimer.h"
12
#include "nsCOMPtr.h"
13
#include "nsXULWindow.h"
14
#include "nsIWidgetListener.h"
15
#include "nsITabParent.h"
16
17
/* Forward declarations.... */
18
class nsIURI;
19
20
struct nsWidgetInitData;
21
22
namespace mozilla {
23
class WebShellWindowTimerCallback;
24
} // namespace mozilla
25
26
class nsWebShellWindow final : public nsXULWindow,
27
                               public nsIWebProgressListener
28
{
29
public:
30
31
  // The implementation of non-refcounted nsIWidgetListener, which would hold a
32
  // strong reference on stack before calling nsWebShellWindow's
33
  // MOZ_CAN_RUN_SCRIPT methods.
34
  class WidgetListenerDelegate : public nsIWidgetListener
35
  {
36
  public:
37
    explicit WidgetListenerDelegate(nsWebShellWindow* aWebShellWindow)
38
0
      : mWebShellWindow(aWebShellWindow) {}
39
40
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
41
    virtual nsIXULWindow* GetXULWindow() override;
42
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
43
    virtual nsIPresShell* GetPresShell() override;
44
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
45
    virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) override;
46
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
47
    virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight) override;
48
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
49
    virtual bool RequestWindowClose(nsIWidget* aWidget) override;
50
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
51
    virtual void SizeModeChanged(nsSizeMode sizeMode) override;
52
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
53
    virtual void UIResolutionChanged() override;
54
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
55
    virtual void FullscreenWillChange(bool aInFullscreen) override;
56
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
57
    virtual void FullscreenChanged(bool aInFullscreen) override;
58
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
59
    virtual void OcclusionStateChanged(bool aIsFullyOccluded) override;
60
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
61
    virtual void OSToolbarButtonPressed() override;
62
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
63
    virtual bool ZLevelChanged(bool aImmediate,
64
                               nsWindowZ *aPlacement,
65
                               nsIWidget* aRequestBelow,
66
                               nsIWidget** aActualBelow) override;
67
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
68
    virtual void WindowActivated() override;
69
    MOZ_CAN_RUN_SCRIPT_BOUNDARY
70
    virtual void WindowDeactivated() override;
71
72
  private:
73
    // The lifetime of WidgetListenerDelegate is bound to nsWebShellWindow so
74
    // we just use a raw pointer here.
75
    nsWebShellWindow* mWebShellWindow;
76
  };
77
78
  explicit nsWebShellWindow(uint32_t aChromeFlags);
79
80
  // nsISupports interface...
81
  NS_DECL_ISUPPORTS_INHERITED
82
83
  // nsWebShellWindow methods...
84
  nsresult Initialize(nsIXULWindow * aParent, nsIXULWindow * aOpener,
85
                      nsIURI* aUrl,
86
                      int32_t aInitialWidth, int32_t aInitialHeight,
87
                      bool aIsHiddenWindow,
88
                      nsITabParent *aOpeningTab,
89
                      mozIDOMWindowProxy *aOpenerWIndow,
90
                      nsWidgetInitData& widgetInitData);
91
92
  nsresult Toolbar();
93
94
  // nsIWebProgressListener
95
  NS_DECL_NSIWEBPROGRESSLISTENER
96
97
  // nsIBaseWindow
98
  NS_IMETHOD Destroy() override;
99
100
  // nsIWidgetListener methods for WidgetListenerDelegate.
101
0
  nsIXULWindow* GetXULWindow() { return this; }
102
  nsIPresShell* GetPresShell();
103
  MOZ_CAN_RUN_SCRIPT
104
  bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY);
105
  MOZ_CAN_RUN_SCRIPT
106
  bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight);
107
  MOZ_CAN_RUN_SCRIPT bool RequestWindowClose(nsIWidget* aWidget);
108
  MOZ_CAN_RUN_SCRIPT void SizeModeChanged(nsSizeMode aSizeMode);
109
  MOZ_CAN_RUN_SCRIPT void UIResolutionChanged();
110
  MOZ_CAN_RUN_SCRIPT void FullscreenWillChange(bool aInFullscreen);
111
  MOZ_CAN_RUN_SCRIPT void FullscreenChanged(bool aInFullscreen);
112
  MOZ_CAN_RUN_SCRIPT void OcclusionStateChanged(bool aIsFullyOccluded);
113
  MOZ_CAN_RUN_SCRIPT void OSToolbarButtonPressed();
114
  MOZ_CAN_RUN_SCRIPT
115
  bool ZLevelChanged(bool aImmediate, nsWindowZ *aPlacement,
116
                     nsIWidget* aRequestBelow, nsIWidget** aActualBelow);
117
  MOZ_CAN_RUN_SCRIPT void WindowActivated();
118
  MOZ_CAN_RUN_SCRIPT void WindowDeactivated();
119
120
protected:
121
  friend class mozilla::WebShellWindowTimerCallback;
122
123
  virtual ~nsWebShellWindow();
124
125
  bool                     ExecuteCloseHandler();
126
  void                     ConstrainToOpenerScreen(int32_t* aX, int32_t* aY);
127
128
  nsCOMPtr<nsITimer>      mSPTimer;
129
  mozilla::Mutex          mSPTimerLock;
130
  WidgetListenerDelegate  mWidgetListenerDelegate;
131
132
  void        SetPersistenceTimer(uint32_t aDirtyFlags);
133
  void        FirePersistenceTimer();
134
};
135
136
#endif /* nsWebShellWindow_h__ */