1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim: set sw=4 ts=8 et tw=80 : */
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Mozilla Content App.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * The Mozilla Foundation.
20 : * Portions created by the Initial Developer are Copyright (C) 2009
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef mozilla_tabs_TabParent_h
40 : #define mozilla_tabs_TabParent_h
41 :
42 : #include "mozilla/dom/PBrowserParent.h"
43 : #include "mozilla/dom/PContentDialogParent.h"
44 : #include "mozilla/ipc/GeckoChildProcessHost.h"
45 :
46 : #include "jsapi.h"
47 : #include "nsCOMPtr.h"
48 : #include "nsITabParent.h"
49 : #include "nsIBrowserDOMWindow.h"
50 : #include "nsWeakReference.h"
51 : #include "nsIDialogParamBlock.h"
52 : #include "nsIAuthPromptProvider.h"
53 : #include "nsISecureBrowserUI.h"
54 :
55 : class nsFrameLoader;
56 : class nsIURI;
57 : class nsIDOMElement;
58 : struct gfxMatrix;
59 :
60 : struct JSContext;
61 : struct JSObject;
62 :
63 : namespace mozilla {
64 : namespace dom {
65 :
66 0 : class ContentDialogParent : public PContentDialogParent {};
67 :
68 : class TabParent : public PBrowserParent
69 : , public nsITabParent
70 : , public nsIAuthPromptProvider
71 : , public nsISecureBrowserUI
72 : {
73 : public:
74 : TabParent();
75 : virtual ~TabParent();
76 : nsIDOMElement* GetOwnerElement() { return mFrameElement; }
77 : void SetOwnerElement(nsIDOMElement* aElement);
78 : nsIBrowserDOMWindow *GetBrowserDOMWindow() { return mBrowserDOMWindow; }
79 0 : void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserDOMWindow) {
80 0 : mBrowserDOMWindow = aBrowserDOMWindow;
81 0 : }
82 :
83 : void Destroy();
84 :
85 : virtual bool RecvMoveFocus(const bool& aForward);
86 : virtual bool RecvEvent(const RemoteDOMEvent& aEvent);
87 :
88 : virtual bool AnswerCreateWindow(PBrowserParent** retval);
89 : virtual bool RecvSyncMessage(const nsString& aMessage,
90 : const nsString& aJSON,
91 : InfallibleTArray<nsString>* aJSONRetVal);
92 : virtual bool RecvAsyncMessage(const nsString& aMessage,
93 : const nsString& aJSON);
94 : virtual bool RecvNotifyIMEFocus(const bool& aFocus,
95 : nsIMEUpdatePreference* aPreference,
96 : PRUint32* aSeqno);
97 : virtual bool RecvNotifyIMETextChange(const PRUint32& aStart,
98 : const PRUint32& aEnd,
99 : const PRUint32& aNewEnd);
100 : virtual bool RecvNotifyIMESelection(const PRUint32& aSeqno,
101 : const PRUint32& aAnchor,
102 : const PRUint32& aFocus);
103 : virtual bool RecvNotifyIMETextHint(const nsString& aText);
104 : virtual bool RecvEndIMEComposition(const bool& aCancel,
105 : nsString* aComposition);
106 : virtual bool RecvGetInputContext(PRInt32* aIMEEnabled,
107 : PRInt32* aIMEOpen);
108 : virtual bool RecvSetInputContext(const PRInt32& aIMEEnabled,
109 : const PRInt32& aIMEOpen,
110 : const nsString& aType,
111 : const nsString& aActionHint,
112 : const PRInt32& aCause,
113 : const PRInt32& aFocusChange);
114 : virtual bool RecvSetCursor(const PRUint32& aValue);
115 : virtual bool RecvSetBackgroundColor(const nscolor& aValue);
116 : virtual bool RecvGetDPI(float* aValue);
117 : virtual bool RecvGetWidgetNativeData(WindowsHandle* aValue);
118 : virtual PContentDialogParent* AllocPContentDialog(const PRUint32& aType,
119 : const nsCString& aName,
120 : const nsCString& aFeatures,
121 : const InfallibleTArray<int>& aIntParams,
122 : const InfallibleTArray<nsString>& aStringParams);
123 0 : virtual bool DeallocPContentDialog(PContentDialogParent* aDialog)
124 : {
125 0 : delete aDialog;
126 0 : return true;
127 : }
128 :
129 :
130 : void LoadURL(nsIURI* aURI);
131 : // XXX/cjones: it's not clear what we gain by hiding these
132 : // message-sending functions under a layer of indirection and
133 : // eating the return values
134 : void Show(const nsIntSize& size);
135 : void UpdateDimensions(const nsRect& rect, const nsIntSize& size);
136 : void Activate();
137 : void Deactivate();
138 :
139 : /**
140 : * Is this object active? That is, was Activate() called more recently than
141 : * Deactivate()?
142 : */
143 : bool Active();
144 :
145 : void SendMouseEvent(const nsAString& aType, float aX, float aY,
146 : PRInt32 aButton, PRInt32 aClickCount,
147 : PRInt32 aModifiers, bool aIgnoreRootScrollFrame);
148 : void SendKeyEvent(const nsAString& aType, PRInt32 aKeyCode,
149 : PRInt32 aCharCode, PRInt32 aModifiers,
150 : bool aPreventDefault);
151 : bool SendRealMouseEvent(nsMouseEvent& event);
152 : bool SendMouseScrollEvent(nsMouseScrollEvent& event);
153 : bool SendRealKeyEvent(nsKeyEvent& event);
154 :
155 : virtual PDocumentRendererParent*
156 : AllocPDocumentRenderer(const nsRect& documentRect, const gfxMatrix& transform,
157 : const nsString& bgcolor,
158 : const PRUint32& renderFlags, const bool& flushLayout,
159 : const nsIntSize& renderSize);
160 : virtual bool DeallocPDocumentRenderer(PDocumentRendererParent* actor);
161 :
162 : virtual PContentPermissionRequestParent* AllocPContentPermissionRequest(const nsCString& aType, const IPC::URI& uri);
163 : virtual bool DeallocPContentPermissionRequest(PContentPermissionRequestParent* actor);
164 :
165 : virtual POfflineCacheUpdateParent* AllocPOfflineCacheUpdate(
166 : const URI& aManifestURI,
167 : const URI& aDocumentURI,
168 : const nsCString& aClientID,
169 : const bool& stickDocument);
170 : virtual bool DeallocPOfflineCacheUpdate(POfflineCacheUpdateParent* actor);
171 :
172 : JSBool GetGlobalJSObject(JSContext* cx, JSObject** globalp);
173 :
174 : NS_DECL_ISUPPORTS
175 : NS_DECL_NSIAUTHPROMPTPROVIDER
176 : NS_DECL_NSISECUREBROWSERUI
177 :
178 : void HandleDelayedDialogs();
179 :
180 : static TabParent *GetIMETabParent() { return mIMETabParent; }
181 : bool HandleQueryContentEvent(nsQueryContentEvent& aEvent);
182 : bool SendCompositionEvent(nsCompositionEvent& event);
183 : bool SendTextEvent(nsTextEvent& event);
184 : bool SendSelectionEvent(nsSelectionEvent& event);
185 : protected:
186 : bool ReceiveMessage(const nsString& aMessage,
187 : bool aSync,
188 : const nsString& aJSON,
189 : InfallibleTArray<nsString>* aJSONRetVal = nsnull);
190 :
191 : void ActorDestroy(ActorDestroyReason why);
192 :
193 : nsIDOMElement* mFrameElement;
194 : nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
195 :
196 : struct DelayedDialogData
197 0 : {
198 0 : DelayedDialogData(PContentDialogParent* aDialog, PRUint32 aType,
199 : const nsCString& aName,
200 : const nsCString& aFeatures,
201 : nsIDialogParamBlock* aParams)
202 : : mDialog(aDialog), mType(aType), mName(aName), mFeatures(aFeatures),
203 0 : mParams(aParams) {}
204 :
205 : PContentDialogParent* mDialog;
206 : PRUint32 mType;
207 : nsCString mName;
208 : nsCString mFeatures;
209 : nsCOMPtr<nsIDialogParamBlock> mParams;
210 : };
211 : InfallibleTArray<DelayedDialogData*> mDelayedDialogs;
212 :
213 : bool ShouldDelayDialogs();
214 : bool AllowContentIME();
215 :
216 : NS_OVERRIDE
217 : virtual PRenderFrameParent* AllocPRenderFrame();
218 : NS_OVERRIDE
219 : virtual bool DeallocPRenderFrame(PRenderFrameParent* aFrame);
220 :
221 : // IME
222 : static TabParent *mIMETabParent;
223 : nsString mIMECacheText;
224 : PRUint32 mIMESelectionAnchor;
225 : PRUint32 mIMESelectionFocus;
226 : bool mIMEComposing;
227 : bool mIMECompositionEnding;
228 : // Buffer to store composition text during ResetInputState
229 : // Compositions in almost all cases are small enough for nsAutoString
230 : nsAutoString mIMECompositionText;
231 : PRUint32 mIMECompositionStart;
232 : PRUint32 mIMESeqno;
233 :
234 : float mDPI;
235 : bool mActive;
236 :
237 : private:
238 : already_AddRefed<nsFrameLoader> GetFrameLoader() const;
239 : already_AddRefed<nsIWidget> GetWidget() const;
240 : };
241 :
242 : } // namespace dom
243 : } // namespace mozilla
244 :
245 : #endif
|