|
1 /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */ |
|
2 /* vim: set sw=4 ts=8 et 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_TabChild_h |
|
8 #define mozilla_dom_TabChild_h |
|
9 |
|
10 #include "mozilla/dom/PBrowserChild.h" |
|
11 #include "nsIWebNavigation.h" |
|
12 #include "nsCOMPtr.h" |
|
13 #include "nsAutoPtr.h" |
|
14 #include "nsIWebBrowserChrome2.h" |
|
15 #include "nsIEmbeddingSiteWindow.h" |
|
16 #include "nsIWebBrowserChromeFocus.h" |
|
17 #include "nsIDOMEventListener.h" |
|
18 #include "nsIInterfaceRequestor.h" |
|
19 #include "nsIWindowProvider.h" |
|
20 #include "nsIDOMWindow.h" |
|
21 #include "nsIDocShell.h" |
|
22 #include "nsIInterfaceRequestorUtils.h" |
|
23 #include "nsFrameMessageManager.h" |
|
24 #include "nsIWebProgressListener.h" |
|
25 #include "nsIPresShell.h" |
|
26 #include "nsIScriptObjectPrincipal.h" |
|
27 #include "nsWeakReference.h" |
|
28 #include "nsITabChild.h" |
|
29 #include "nsITooltipListener.h" |
|
30 #include "mozilla/Attributes.h" |
|
31 #include "mozilla/dom/TabContext.h" |
|
32 #include "mozilla/DOMEventTargetHelper.h" |
|
33 #include "mozilla/EventDispatcher.h" |
|
34 #include "mozilla/EventForwards.h" |
|
35 #include "mozilla/layers/CompositorTypes.h" |
|
36 |
|
37 class nsICachedFileDescriptorListener; |
|
38 class nsIDOMWindowUtils; |
|
39 |
|
40 namespace mozilla { |
|
41 namespace layout { |
|
42 class RenderFrameChild; |
|
43 } |
|
44 |
|
45 namespace layers { |
|
46 class ActiveElementManager; |
|
47 } |
|
48 |
|
49 namespace widget { |
|
50 struct AutoCacheNativeKeyCommands; |
|
51 } |
|
52 |
|
53 namespace dom { |
|
54 |
|
55 class TabChild; |
|
56 class ClonedMessageData; |
|
57 class TabChildBase; |
|
58 |
|
59 class TabChildGlobal : public DOMEventTargetHelper, |
|
60 public nsIContentFrameMessageManager, |
|
61 public nsIScriptObjectPrincipal, |
|
62 public nsIGlobalObject |
|
63 { |
|
64 public: |
|
65 TabChildGlobal(TabChildBase* aTabChild); |
|
66 void Init(); |
|
67 NS_DECL_ISUPPORTS_INHERITED |
|
68 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper) |
|
69 NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager) |
|
70 NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) |
|
71 NS_IMETHOD SendSyncMessage(const nsAString& aMessageName, |
|
72 JS::Handle<JS::Value> aObject, |
|
73 JS::Handle<JS::Value> aRemote, |
|
74 nsIPrincipal* aPrincipal, |
|
75 JSContext* aCx, |
|
76 uint8_t aArgc, |
|
77 JS::MutableHandle<JS::Value> aRetval) |
|
78 { |
|
79 return mMessageManager |
|
80 ? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote, |
|
81 aPrincipal, aCx, aArgc, aRetval) |
|
82 : NS_ERROR_NULL_POINTER; |
|
83 } |
|
84 NS_IMETHOD SendRpcMessage(const nsAString& aMessageName, |
|
85 JS::Handle<JS::Value> aObject, |
|
86 JS::Handle<JS::Value> aRemote, |
|
87 nsIPrincipal* aPrincipal, |
|
88 JSContext* aCx, |
|
89 uint8_t aArgc, |
|
90 JS::MutableHandle<JS::Value> aRetval) |
|
91 { |
|
92 return mMessageManager |
|
93 ? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote, |
|
94 aPrincipal, aCx, aArgc, aRetval) |
|
95 : NS_ERROR_NULL_POINTER; |
|
96 } |
|
97 NS_IMETHOD GetContent(nsIDOMWindow** aContent) MOZ_OVERRIDE; |
|
98 NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) MOZ_OVERRIDE; |
|
99 NS_IMETHOD Dump(const nsAString& aStr) MOZ_OVERRIDE |
|
100 { |
|
101 return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK; |
|
102 } |
|
103 NS_IMETHOD PrivateNoteIntentionalCrash() MOZ_OVERRIDE; |
|
104 NS_IMETHOD Btoa(const nsAString& aBinaryData, |
|
105 nsAString& aAsciiBase64String) MOZ_OVERRIDE; |
|
106 NS_IMETHOD Atob(const nsAString& aAsciiString, |
|
107 nsAString& aBinaryData) MOZ_OVERRIDE; |
|
108 |
|
109 NS_IMETHOD AddEventListener(const nsAString& aType, |
|
110 nsIDOMEventListener* aListener, |
|
111 bool aUseCapture) |
|
112 { |
|
113 // By default add listeners only for trusted events! |
|
114 return DOMEventTargetHelper::AddEventListener(aType, aListener, |
|
115 aUseCapture, false, 2); |
|
116 } |
|
117 using DOMEventTargetHelper::AddEventListener; |
|
118 NS_IMETHOD AddEventListener(const nsAString& aType, |
|
119 nsIDOMEventListener* aListener, |
|
120 bool aUseCapture, bool aWantsUntrusted, |
|
121 uint8_t optional_argc) MOZ_OVERRIDE |
|
122 { |
|
123 return DOMEventTargetHelper::AddEventListener(aType, aListener, |
|
124 aUseCapture, |
|
125 aWantsUntrusted, |
|
126 optional_argc); |
|
127 } |
|
128 |
|
129 nsresult |
|
130 PreHandleEvent(EventChainPreVisitor& aVisitor) |
|
131 { |
|
132 aVisitor.mForceContentDispatch = true; |
|
133 return NS_OK; |
|
134 } |
|
135 |
|
136 virtual JSContext* GetJSContextForEventHandlers() MOZ_OVERRIDE; |
|
137 virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE; |
|
138 virtual JSObject* GetGlobalJSObject() MOZ_OVERRIDE; |
|
139 |
|
140 nsCOMPtr<nsIContentFrameMessageManager> mMessageManager; |
|
141 nsRefPtr<TabChildBase> mTabChild; |
|
142 }; |
|
143 |
|
144 class ContentListener MOZ_FINAL : public nsIDOMEventListener |
|
145 { |
|
146 public: |
|
147 ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {} |
|
148 NS_DECL_ISUPPORTS |
|
149 NS_DECL_NSIDOMEVENTLISTENER |
|
150 protected: |
|
151 TabChild* mTabChild; |
|
152 }; |
|
153 |
|
154 // This is base clase which helps to share Viewport and touch related functionality |
|
155 // between b2g/android FF/embedlite clients implementation. |
|
156 // It make sense to place in this class all helper functions, and functionality which could be shared between |
|
157 // Cross-process/Cross-thread implmentations. |
|
158 class TabChildBase : public nsISupports, |
|
159 public nsFrameScriptExecutor, |
|
160 public ipc::MessageManagerCallback |
|
161 { |
|
162 public: |
|
163 TabChildBase(); |
|
164 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
165 NS_DECL_CYCLE_COLLECTION_CLASS(TabChildBase) |
|
166 |
|
167 virtual nsIWebNavigation* WebNavigation() = 0; |
|
168 virtual nsIWidget* WebWidget() = 0; |
|
169 nsIPrincipal* GetPrincipal() { return mPrincipal; } |
|
170 bool IsAsyncPanZoomEnabled(); |
|
171 // Recalculates the display state, including the CSS |
|
172 // viewport. This should be called whenever we believe the |
|
173 // viewport data on a document may have changed. If it didn't |
|
174 // change, this function doesn't do anything. However, it should |
|
175 // not be called all the time as it is fairly expensive. |
|
176 bool HandlePossibleViewportChange(); |
|
177 virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId, |
|
178 const mozilla::layers::FrameMetrics::ViewID& aViewId, |
|
179 const bool& aIsRoot, |
|
180 const mozilla::layers::ZoomConstraints& aConstraints) = 0; |
|
181 |
|
182 nsEventStatus DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime, |
|
183 const LayoutDevicePoint& aRefPoint, |
|
184 nsIWidget* aWidget); |
|
185 |
|
186 protected: |
|
187 CSSSize GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewport); |
|
188 |
|
189 // Get the DOMWindowUtils for the top-level window in this tab. |
|
190 already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils(); |
|
191 // Get the Document for the top-level window in this tab. |
|
192 already_AddRefed<nsIDocument> GetDocument(); |
|
193 |
|
194 // Wrapper for nsIDOMWindowUtils.setCSSViewport(). This updates some state |
|
195 // variables local to this class before setting it. |
|
196 void SetCSSViewport(const CSSSize& aSize); |
|
197 |
|
198 // Wraps up a JSON object as a structured clone and sends it to the browser |
|
199 // chrome script. |
|
200 // |
|
201 // XXX/bug 780335: Do the work the browser chrome script does in C++ instead |
|
202 // so we don't need things like this. |
|
203 void DispatchMessageManagerMessage(const nsAString& aMessageName, |
|
204 const nsAString& aJSONData); |
|
205 |
|
206 nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& event); |
|
207 |
|
208 bool HasValidInnerSize(); |
|
209 void InitializeRootMetrics(); |
|
210 |
|
211 mozilla::layers::FrameMetrics ProcessUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics); |
|
212 |
|
213 bool UpdateFrameHandler(const mozilla::layers::FrameMetrics& aFrameMetrics); |
|
214 |
|
215 protected: |
|
216 float mOldViewportWidth; |
|
217 bool mContentDocumentIsDisplayed; |
|
218 nsRefPtr<TabChildGlobal> mTabChildGlobal; |
|
219 ScreenIntSize mInnerSize; |
|
220 mozilla::layers::FrameMetrics mLastRootMetrics; |
|
221 mozilla::layout::ScrollingBehavior mScrolling; |
|
222 }; |
|
223 |
|
224 class TabChild : public TabChildBase, |
|
225 public PBrowserChild, |
|
226 public nsIWebBrowserChrome2, |
|
227 public nsIEmbeddingSiteWindow, |
|
228 public nsIWebBrowserChromeFocus, |
|
229 public nsIInterfaceRequestor, |
|
230 public nsIWindowProvider, |
|
231 public nsIDOMEventListener, |
|
232 public nsIWebProgressListener, |
|
233 public nsSupportsWeakReference, |
|
234 public nsITabChild, |
|
235 public nsIObserver, |
|
236 public TabContext, |
|
237 public nsITooltipListener |
|
238 { |
|
239 typedef mozilla::dom::ClonedMessageData ClonedMessageData; |
|
240 typedef mozilla::layout::RenderFrameChild RenderFrameChild; |
|
241 typedef mozilla::layout::ScrollingBehavior ScrollingBehavior; |
|
242 typedef mozilla::layers::ActiveElementManager ActiveElementManager; |
|
243 |
|
244 public: |
|
245 /** |
|
246 * This is expected to be called off the critical path to content |
|
247 * startup. This is an opportunity to load things that are slow |
|
248 * on the critical path. |
|
249 */ |
|
250 static void PreloadSlowThings(); |
|
251 |
|
252 /** Return a TabChild with the given attributes. */ |
|
253 static already_AddRefed<TabChild> |
|
254 Create(ContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags); |
|
255 |
|
256 virtual ~TabChild(); |
|
257 |
|
258 bool IsRootContentDocument(); |
|
259 |
|
260 NS_DECL_ISUPPORTS_INHERITED |
|
261 NS_DECL_NSIWEBBROWSERCHROME |
|
262 NS_DECL_NSIWEBBROWSERCHROME2 |
|
263 NS_DECL_NSIEMBEDDINGSITEWINDOW |
|
264 NS_DECL_NSIWEBBROWSERCHROMEFOCUS |
|
265 NS_DECL_NSIINTERFACEREQUESTOR |
|
266 NS_DECL_NSIWINDOWPROVIDER |
|
267 NS_DECL_NSIDOMEVENTLISTENER |
|
268 NS_DECL_NSIWEBPROGRESSLISTENER |
|
269 NS_DECL_NSITABCHILD |
|
270 NS_DECL_NSIOBSERVER |
|
271 NS_DECL_NSITOOLTIPLISTENER |
|
272 |
|
273 /** |
|
274 * MessageManagerCallback methods that we override. |
|
275 */ |
|
276 virtual bool DoSendBlockingMessage(JSContext* aCx, |
|
277 const nsAString& aMessage, |
|
278 const mozilla::dom::StructuredCloneData& aData, |
|
279 JS::Handle<JSObject *> aCpows, |
|
280 nsIPrincipal* aPrincipal, |
|
281 InfallibleTArray<nsString>* aJSONRetVal, |
|
282 bool aIsSync) MOZ_OVERRIDE; |
|
283 virtual bool DoSendAsyncMessage(JSContext* aCx, |
|
284 const nsAString& aMessage, |
|
285 const mozilla::dom::StructuredCloneData& aData, |
|
286 JS::Handle<JSObject *> aCpows, |
|
287 nsIPrincipal* aPrincipal) MOZ_OVERRIDE; |
|
288 virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId, |
|
289 const ViewID& aViewId, |
|
290 const bool& aIsRoot, |
|
291 const ZoomConstraints& aConstraints) MOZ_OVERRIDE; |
|
292 virtual bool RecvLoadURL(const nsCString& uri) MOZ_OVERRIDE; |
|
293 virtual bool RecvCacheFileDescriptor(const nsString& aPath, |
|
294 const FileDescriptor& aFileDescriptor) |
|
295 MOZ_OVERRIDE; |
|
296 virtual bool RecvShow(const nsIntSize& size) MOZ_OVERRIDE; |
|
297 virtual bool RecvUpdateDimensions(const nsRect& rect, |
|
298 const nsIntSize& size, |
|
299 const ScreenOrientation& orientation) MOZ_OVERRIDE; |
|
300 virtual bool RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; |
|
301 virtual bool RecvAcknowledgeScrollUpdate(const ViewID& aScrollId, |
|
302 const uint32_t& aScrollGeneration) MOZ_OVERRIDE; |
|
303 virtual bool RecvHandleDoubleTap(const CSSPoint& aPoint, |
|
304 const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
|
305 virtual bool RecvHandleSingleTap(const CSSPoint& aPoint, |
|
306 const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
|
307 virtual bool RecvHandleLongTap(const CSSPoint& aPoint, |
|
308 const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
|
309 virtual bool RecvHandleLongTapUp(const CSSPoint& aPoint, |
|
310 const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
|
311 virtual bool RecvNotifyAPZStateChange(const ViewID& aViewId, |
|
312 const APZStateChange& aChange, |
|
313 const int& aArg) MOZ_OVERRIDE; |
|
314 virtual bool RecvActivate() MOZ_OVERRIDE; |
|
315 virtual bool RecvDeactivate() MOZ_OVERRIDE; |
|
316 virtual bool RecvMouseEvent(const nsString& aType, |
|
317 const float& aX, |
|
318 const float& aY, |
|
319 const int32_t& aButton, |
|
320 const int32_t& aClickCount, |
|
321 const int32_t& aModifiers, |
|
322 const bool& aIgnoreRootScrollFrame) MOZ_OVERRIDE; |
|
323 virtual bool RecvRealMouseEvent(const mozilla::WidgetMouseEvent& event) MOZ_OVERRIDE; |
|
324 virtual bool RecvRealKeyEvent(const mozilla::WidgetKeyboardEvent& event, |
|
325 const MaybeNativeKeyBinding& aBindings) MOZ_OVERRIDE; |
|
326 virtual bool RecvMouseWheelEvent(const mozilla::WidgetWheelEvent& event) MOZ_OVERRIDE; |
|
327 virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent, |
|
328 const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
|
329 virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, |
|
330 const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE; |
|
331 virtual bool RecvKeyEvent(const nsString& aType, |
|
332 const int32_t& aKeyCode, |
|
333 const int32_t& aCharCode, |
|
334 const int32_t& aModifiers, |
|
335 const bool& aPreventDefault) MOZ_OVERRIDE; |
|
336 virtual bool RecvCompositionEvent(const mozilla::WidgetCompositionEvent& event) MOZ_OVERRIDE; |
|
337 virtual bool RecvTextEvent(const mozilla::WidgetTextEvent& event) MOZ_OVERRIDE; |
|
338 virtual bool RecvSelectionEvent(const mozilla::WidgetSelectionEvent& event) MOZ_OVERRIDE; |
|
339 virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture) MOZ_OVERRIDE; |
|
340 virtual bool RecvLoadRemoteScript(const nsString& aURL, |
|
341 const bool& aRunInGlobalScope) MOZ_OVERRIDE; |
|
342 virtual bool RecvAsyncMessage(const nsString& aMessage, |
|
343 const ClonedMessageData& aData, |
|
344 const InfallibleTArray<CpowEntry>& aCpows, |
|
345 const IPC::Principal& aPrincipal) MOZ_OVERRIDE; |
|
346 |
|
347 virtual PDocumentRendererChild* |
|
348 AllocPDocumentRendererChild(const nsRect& documentRect, const gfx::Matrix& transform, |
|
349 const nsString& bgcolor, |
|
350 const uint32_t& renderFlags, const bool& flushLayout, |
|
351 const nsIntSize& renderSize) MOZ_OVERRIDE; |
|
352 virtual bool DeallocPDocumentRendererChild(PDocumentRendererChild* actor) MOZ_OVERRIDE; |
|
353 virtual bool RecvPDocumentRendererConstructor(PDocumentRendererChild* actor, |
|
354 const nsRect& documentRect, |
|
355 const gfx::Matrix& transform, |
|
356 const nsString& bgcolor, |
|
357 const uint32_t& renderFlags, |
|
358 const bool& flushLayout, |
|
359 const nsIntSize& renderSize) MOZ_OVERRIDE; |
|
360 |
|
361 virtual PColorPickerChild* |
|
362 AllocPColorPickerChild(const nsString& title, const nsString& initialColor) MOZ_OVERRIDE; |
|
363 virtual bool DeallocPColorPickerChild(PColorPickerChild* actor) MOZ_OVERRIDE; |
|
364 |
|
365 #ifdef DEBUG |
|
366 virtual PContentPermissionRequestChild* |
|
367 SendPContentPermissionRequestConstructor(PContentPermissionRequestChild* aActor, |
|
368 const InfallibleTArray<PermissionRequest>& aRequests, |
|
369 const IPC::Principal& aPrincipal); |
|
370 #endif /* DEBUG */ |
|
371 |
|
372 virtual PContentPermissionRequestChild* |
|
373 AllocPContentPermissionRequestChild(const InfallibleTArray<PermissionRequest>& aRequests, |
|
374 const IPC::Principal& aPrincipal) MOZ_OVERRIDE; |
|
375 virtual bool |
|
376 DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) MOZ_OVERRIDE; |
|
377 |
|
378 virtual PFilePickerChild* |
|
379 AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) MOZ_OVERRIDE; |
|
380 virtual bool |
|
381 DeallocPFilePickerChild(PFilePickerChild* actor) MOZ_OVERRIDE; |
|
382 |
|
383 virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdateChild( |
|
384 const URIParams& manifestURI, |
|
385 const URIParams& documentURI, |
|
386 const bool& stickDocument) MOZ_OVERRIDE; |
|
387 virtual bool |
|
388 DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) MOZ_OVERRIDE; |
|
389 |
|
390 virtual nsIWebNavigation* WebNavigation() MOZ_OVERRIDE { return mWebNav; } |
|
391 virtual nsIWidget* WebWidget() MOZ_OVERRIDE { return mWidget; } |
|
392 |
|
393 /** Return the DPI of the widget this TabChild draws to. */ |
|
394 void GetDPI(float* aDPI); |
|
395 void GetDefaultScale(double *aScale); |
|
396 |
|
397 ScreenOrientation GetOrientation() { return mOrientation; } |
|
398 |
|
399 void SetBackgroundColor(const nscolor& aColor); |
|
400 |
|
401 void NotifyPainted(); |
|
402 |
|
403 void RequestNativeKeyBindings(mozilla::widget::AutoCacheNativeKeyCommands* aAutoCache, |
|
404 WidgetKeyboardEvent* aEvent); |
|
405 |
|
406 /** Return a boolean indicating if the page has called preventDefault on |
|
407 * the event. |
|
408 */ |
|
409 bool DispatchMouseEvent(const nsString& aType, |
|
410 const CSSPoint& aPoint, |
|
411 const int32_t& aButton, |
|
412 const int32_t& aClickCount, |
|
413 const int32_t& aModifiers, |
|
414 const bool& aIgnoreRootScrollFrame, |
|
415 const unsigned short& aInputSourceArg); |
|
416 |
|
417 /** |
|
418 * Signal to this TabChild that it should be made visible: |
|
419 * activated widget, retained layer tree, etc. (Respectively, |
|
420 * made not visible.) |
|
421 */ |
|
422 void MakeVisible(); |
|
423 void MakeHidden(); |
|
424 |
|
425 // Returns true if the file descriptor was found in the cache, false |
|
426 // otherwise. |
|
427 bool GetCachedFileDescriptor(const nsAString& aPath, |
|
428 nsICachedFileDescriptorListener* aCallback); |
|
429 |
|
430 void CancelCachedFileDescriptorCallback( |
|
431 const nsAString& aPath, |
|
432 nsICachedFileDescriptorListener* aCallback); |
|
433 |
|
434 ContentChild* Manager() { return mManager; } |
|
435 |
|
436 bool GetUpdateHitRegion() { return mUpdateHitRegion; } |
|
437 |
|
438 void UpdateHitRegion(const nsRegion& aRegion); |
|
439 |
|
440 static inline TabChild* |
|
441 GetFrom(nsIDocShell* aDocShell) |
|
442 { |
|
443 nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell); |
|
444 return static_cast<TabChild*>(tc.get()); |
|
445 } |
|
446 |
|
447 static TabChild* GetFrom(nsIPresShell* aPresShell); |
|
448 static TabChild* GetFrom(uint64_t aLayersId); |
|
449 |
|
450 void DidComposite(); |
|
451 |
|
452 static inline TabChild* |
|
453 GetFrom(nsIDOMWindow* aWindow) |
|
454 { |
|
455 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow); |
|
456 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav); |
|
457 return GetFrom(docShell); |
|
458 } |
|
459 |
|
460 protected: |
|
461 virtual PRenderFrameChild* AllocPRenderFrameChild() MOZ_OVERRIDE; |
|
462 virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE; |
|
463 virtual bool RecvDestroy() MOZ_OVERRIDE; |
|
464 virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE; |
|
465 virtual bool RecvSetIsDocShellActive(const bool& aIsActive) MOZ_OVERRIDE; |
|
466 |
|
467 virtual PIndexedDBChild* AllocPIndexedDBChild(const nsCString& aGroup, |
|
468 const nsCString& aASCIIOrigin, |
|
469 bool* /* aAllowed */) MOZ_OVERRIDE; |
|
470 |
|
471 virtual bool DeallocPIndexedDBChild(PIndexedDBChild* aActor) MOZ_OVERRIDE; |
|
472 |
|
473 private: |
|
474 /** |
|
475 * Create a new TabChild object. |
|
476 * |
|
477 * |aOwnOrContainingAppId| is the app-id of our frame or of the closest app |
|
478 * frame in the hierarchy which contains us. |
|
479 * |
|
480 * |aIsBrowserElement| indicates whether we're a browser (but not an app). |
|
481 */ |
|
482 TabChild(ContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags); |
|
483 |
|
484 nsresult Init(); |
|
485 |
|
486 |
|
487 // Notify others that our TabContext has been updated. (At the moment, this |
|
488 // sets the appropriate app-id and is-browser flags on our docshell.) |
|
489 // |
|
490 // You should call this after calling TabContext::SetTabContext(). We also |
|
491 // call this during Init(). |
|
492 void NotifyTabContextUpdated(); |
|
493 |
|
494 bool UseDirectCompositor(); |
|
495 |
|
496 void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
497 |
|
498 enum FrameScriptLoading { DONT_LOAD_SCRIPTS, DEFAULT_LOAD_SCRIPTS }; |
|
499 bool InitTabChildGlobal(FrameScriptLoading aScriptLoading = DEFAULT_LOAD_SCRIPTS); |
|
500 bool InitRenderingState(); |
|
501 void DestroyWindow(); |
|
502 void SetProcessNameToAppName(); |
|
503 |
|
504 // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow(). |
|
505 void DoFakeShow(); |
|
506 |
|
507 // These methods are used for tracking synthetic mouse events |
|
508 // dispatched for compatibility. On each touch event, we |
|
509 // UpdateTapState(). If we've detected that the current gesture |
|
510 // isn't a tap, then we CancelTapTracking(). In the meantime, we |
|
511 // may detect a context-menu event, and if so we |
|
512 // FireContextMenuEvent(). |
|
513 void FireContextMenuEvent(); |
|
514 void CancelTapTracking(); |
|
515 void UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus); |
|
516 |
|
517 nsresult |
|
518 BrowserFrameProvideWindow(nsIDOMWindow* aOpener, |
|
519 nsIURI* aURI, |
|
520 const nsAString& aName, |
|
521 const nsACString& aFeatures, |
|
522 bool* aWindowIsNew, |
|
523 nsIDOMWindow** aReturn); |
|
524 |
|
525 class CachedFileDescriptorInfo; |
|
526 class CachedFileDescriptorCallbackRunnable; |
|
527 |
|
528 TextureFactoryIdentifier mTextureFactoryIdentifier; |
|
529 nsCOMPtr<nsIWebNavigation> mWebNav; |
|
530 nsCOMPtr<nsIWidget> mWidget; |
|
531 nsCOMPtr<nsIURI> mLastURI; |
|
532 RenderFrameChild* mRemoteFrame; |
|
533 nsRefPtr<ContentChild> mManager; |
|
534 uint32_t mChromeFlags; |
|
535 uint64_t mLayersId; |
|
536 nsIntRect mOuterRect; |
|
537 // When we're tracking a possible tap gesture, this is the "down" |
|
538 // point of the touchstart. |
|
539 LayoutDevicePoint mGestureDownPoint; |
|
540 // The touch identifier of the active gesture. |
|
541 int32_t mActivePointerId; |
|
542 // A timer task that fires if the tap-hold timeout is exceeded by |
|
543 // the touch we're tracking. That is, if touchend or a touchmove |
|
544 // that exceeds the gesture threshold doesn't happen. |
|
545 CancelableTask* mTapHoldTimer; |
|
546 // Whether we have already received a FileDescriptor for the app package. |
|
547 bool mAppPackageFileDescriptorRecved; |
|
548 // At present only 1 of these is really expected. |
|
549 nsAutoTArray<nsAutoPtr<CachedFileDescriptorInfo>, 1> |
|
550 mCachedFileDescriptorInfos; |
|
551 nscolor mLastBackgroundColor; |
|
552 bool mDidFakeShow; |
|
553 bool mNotified; |
|
554 bool mTriedBrowserInit; |
|
555 ScreenOrientation mOrientation; |
|
556 bool mUpdateHitRegion; |
|
557 bool mContextMenuHandled; |
|
558 bool mWaitingTouchListeners; |
|
559 void FireSingleTapEvent(LayoutDevicePoint aPoint); |
|
560 |
|
561 bool mIgnoreKeyPressEvent; |
|
562 nsRefPtr<ActiveElementManager> mActiveElementManager; |
|
563 |
|
564 DISALLOW_EVIL_CONSTRUCTORS(TabChild); |
|
565 }; |
|
566 |
|
567 } |
|
568 } |
|
569 |
|
570 #endif // mozilla_dom_TabChild_h |