/src/mozilla-central/dom/ipc/TabParent.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 mozilla_tabs_TabParent_h |
8 | | #define mozilla_tabs_TabParent_h |
9 | | |
10 | | #include "js/TypeDecls.h" |
11 | | #include "LiveResizeListener.h" |
12 | | #include "mozilla/ContentCache.h" |
13 | | #include "mozilla/dom/ipc/IdType.h" |
14 | | #include "mozilla/dom/PBrowserParent.h" |
15 | | #include "mozilla/dom/PContent.h" |
16 | | #include "mozilla/dom/PFilePickerParent.h" |
17 | | #include "mozilla/dom/TabContext.h" |
18 | | #include "mozilla/EventForwards.h" |
19 | | #include "mozilla/dom/File.h" |
20 | | #include "mozilla/layers/CompositorBridgeParent.h" |
21 | | #include "mozilla/RefPtr.h" |
22 | | #include "mozilla/Move.h" |
23 | | #include "nsCOMPtr.h" |
24 | | #include "nsIAuthPromptProvider.h" |
25 | | #include "nsIBrowserDOMWindow.h" |
26 | | #include "nsIDOMEventListener.h" |
27 | | #include "nsIKeyEventInPluginCallback.h" |
28 | | #include "nsISecureBrowserUI.h" |
29 | | #include "nsITabParent.h" |
30 | | #include "nsIXULBrowserWindow.h" |
31 | | #include "nsRefreshDriver.h" |
32 | | #include "nsWeakReference.h" |
33 | | #include "Units.h" |
34 | | #include "nsIWidget.h" |
35 | | |
36 | | class nsFrameLoader; |
37 | | class nsIContent; |
38 | | class nsIPrincipal; |
39 | | class nsIURI; |
40 | | class nsILoadContext; |
41 | | class nsIDocShell; |
42 | | class nsIWebBrowserPersistDocumentReceiver; |
43 | | |
44 | | namespace mozilla { |
45 | | |
46 | | namespace a11y { |
47 | | class DocAccessibleParent; |
48 | | } |
49 | | |
50 | | namespace jsipc { |
51 | | class CpowHolder; |
52 | | } // namespace jsipc |
53 | | |
54 | | namespace layers { |
55 | | struct TextureFactoryIdentifier; |
56 | | } // namespace layers |
57 | | |
58 | | namespace layout { |
59 | | class RenderFrameParent; |
60 | | } // namespace layout |
61 | | |
62 | | namespace widget { |
63 | | struct IMENotification; |
64 | | } // namespace widget |
65 | | |
66 | | namespace gfx { |
67 | | class SourceSurface; |
68 | | class DataSourceSurface; |
69 | | } // namespace gfx |
70 | | |
71 | | namespace dom { |
72 | | |
73 | | class ClonedMessageData; |
74 | | class nsIContentParent; |
75 | | class Element; |
76 | | class DataTransfer; |
77 | | |
78 | | namespace ipc { |
79 | | class StructuredCloneData; |
80 | | } // ipc namespace |
81 | | |
82 | | class TabParent final : public PBrowserParent |
83 | | , public nsIDOMEventListener |
84 | | , public nsITabParent |
85 | | , public nsIAuthPromptProvider |
86 | | , public nsISecureBrowserUI |
87 | | , public nsIKeyEventInPluginCallback |
88 | | , public nsSupportsWeakReference |
89 | | , public TabContext |
90 | | , public LiveResizeListener |
91 | | { |
92 | | typedef mozilla::dom::ClonedMessageData ClonedMessageData; |
93 | | |
94 | | virtual ~TabParent(); |
95 | | |
96 | | public: |
97 | | // Helper class for ContentParent::RecvCreateWindow. |
98 | | struct AutoUseNewTab; |
99 | | |
100 | | // nsITabParent |
101 | | NS_DECL_NSITABPARENT |
102 | | // nsIDOMEventListener interfaces |
103 | | NS_DECL_NSIDOMEVENTLISTENER |
104 | | |
105 | | TabParent(nsIContentParent* aManager, |
106 | | const TabId& aTabId, |
107 | | const TabContext& aContext, |
108 | | uint32_t aChromeFlags); |
109 | | |
110 | | Element* GetOwnerElement() const { return mFrameElement; } |
111 | | already_AddRefed<nsPIDOMWindowOuter> GetParentWindowOuter(); |
112 | | |
113 | | void SetOwnerElement(Element* aElement); |
114 | | |
115 | | void CacheFrameLoader(nsFrameLoader* aFrameLoader); |
116 | | |
117 | 0 | nsIBrowserDOMWindow *GetBrowserDOMWindow() const { return mBrowserDOMWindow; } |
118 | | |
119 | | void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserDOMWindow) |
120 | 0 | { |
121 | 0 | mBrowserDOMWindow = aBrowserDOMWindow; |
122 | 0 | } |
123 | | |
124 | | void SetHasContentOpener(bool aHasContentOpener); |
125 | | |
126 | | void SwapFrameScriptsFrom(nsTArray<FrameScriptInfo>& aFrameScripts) |
127 | 0 | { |
128 | 0 | aFrameScripts.SwapElements(mDelayedFrameScripts); |
129 | 0 | } |
130 | | |
131 | | already_AddRefed<nsILoadContext> GetLoadContext(); |
132 | | |
133 | | already_AddRefed<nsIWidget> GetTopLevelWidget(); |
134 | | |
135 | | nsIXULBrowserWindow* GetXULBrowserWindow(); |
136 | | |
137 | | void Destroy(); |
138 | | |
139 | | void RemoveWindowListeners(); |
140 | | |
141 | | void AddWindowListeners(); |
142 | | |
143 | | virtual mozilla::ipc::IPCResult RecvMoveFocus(const bool& aForward, |
144 | | const bool& aForDocumentNavigation) override; |
145 | | |
146 | | virtual mozilla::ipc::IPCResult RecvSizeShellTo(const uint32_t& aFlags, |
147 | | const int32_t& aWidth, |
148 | | const int32_t& aHeight, |
149 | | const int32_t& aShellItemWidth, |
150 | | const int32_t& aShellItemHeight) override; |
151 | | |
152 | | virtual mozilla::ipc::IPCResult RecvDropLinks(nsTArray<nsString>&& aLinks) override; |
153 | | |
154 | | virtual mozilla::ipc::IPCResult RecvEvent(const RemoteDOMEvent& aEvent) override; |
155 | | |
156 | | virtual mozilla::ipc::IPCResult RecvReplyKeyEvent(const WidgetKeyboardEvent& aEvent) override; |
157 | | |
158 | | virtual mozilla::ipc::IPCResult |
159 | | RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent) override; |
160 | | |
161 | | virtual mozilla::ipc::IPCResult |
162 | | RecvSetHasBeforeUnload(const bool& aHasBeforeUnload) override; |
163 | | |
164 | | virtual mozilla::ipc::IPCResult |
165 | | RecvBrowserFrameOpenWindow(PBrowserParent* aOpener, |
166 | | PRenderFrameParent* aRenderFrame, |
167 | | const nsString& aURL, |
168 | | const nsString& aName, |
169 | | const nsString& aFeatures, |
170 | | BrowserFrameOpenWindowResolver&& aResolve) override; |
171 | | |
172 | | virtual mozilla::ipc::IPCResult |
173 | | RecvSyncMessage(const nsString& aMessage, |
174 | | const ClonedMessageData& aData, |
175 | | InfallibleTArray<CpowEntry>&& aCpows, |
176 | | const IPC::Principal& aPrincipal, |
177 | | nsTArray<ipc::StructuredCloneData>* aRetVal) override; |
178 | | |
179 | | virtual mozilla::ipc::IPCResult |
180 | | RecvRpcMessage(const nsString& aMessage, |
181 | | const ClonedMessageData& aData, |
182 | | InfallibleTArray<CpowEntry>&& aCpows, |
183 | | const IPC::Principal& aPrincipal, |
184 | | nsTArray<ipc::StructuredCloneData>* aRetVal) override; |
185 | | |
186 | | virtual mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMessage, |
187 | | InfallibleTArray<CpowEntry>&& aCpows, |
188 | | const IPC::Principal& aPrincipal, |
189 | | const ClonedMessageData& aData) override; |
190 | | |
191 | | virtual mozilla::ipc::IPCResult |
192 | | RecvNotifyIMEFocus(const ContentCache& aContentCache, |
193 | | const widget::IMENotification& aEventMessage, |
194 | | NotifyIMEFocusResolver&& aResolve) override; |
195 | | |
196 | | virtual mozilla::ipc::IPCResult |
197 | | RecvNotifyIMETextChange(const ContentCache& aContentCache, |
198 | | const widget::IMENotification& aEventMessage) override; |
199 | | |
200 | | virtual mozilla::ipc::IPCResult |
201 | | RecvNotifyIMECompositionUpdate(const ContentCache& aContentCache, |
202 | | const widget::IMENotification& aEventMessage) override; |
203 | | |
204 | | virtual mozilla::ipc::IPCResult |
205 | | RecvNotifyIMESelection(const ContentCache& aContentCache, |
206 | | const widget::IMENotification& aEventMessage) override; |
207 | | |
208 | | virtual mozilla::ipc::IPCResult |
209 | | RecvUpdateContentCache(const ContentCache& aContentCache) override; |
210 | | |
211 | | virtual mozilla::ipc::IPCResult |
212 | | RecvNotifyIMEMouseButtonEvent(const widget::IMENotification& aEventMessage, |
213 | | bool* aConsumedByIME) override; |
214 | | |
215 | | virtual mozilla::ipc::IPCResult |
216 | | RecvNotifyIMEPositionChange(const ContentCache& aContentCache, |
217 | | const widget::IMENotification& aEventMessage) override; |
218 | | |
219 | | virtual mozilla::ipc::IPCResult |
220 | | RecvOnEventNeedingAckHandled(const EventMessage& aMessage) override; |
221 | | |
222 | | virtual mozilla::ipc::IPCResult |
223 | | RecvRequestIMEToCommitComposition(const bool& aCancel, |
224 | | bool* aIsCommitted, |
225 | | nsString* aCommittedString) override; |
226 | | |
227 | | virtual mozilla::ipc::IPCResult |
228 | | RecvStartPluginIME(const WidgetKeyboardEvent& aKeyboardEvent, |
229 | | const int32_t& aPanelX, |
230 | | const int32_t& aPanelY, |
231 | | nsString* aCommitted) override; |
232 | | |
233 | | virtual mozilla::ipc::IPCResult RecvSetPluginFocused(const bool& aFocused) override; |
234 | | |
235 | | virtual mozilla::ipc::IPCResult RecvSetCandidateWindowForPlugin( |
236 | | const widget::CandidateWindowPosition& aPosition) override; |
237 | | virtual mozilla::ipc::IPCResult |
238 | | RecvEnableIMEForPlugin(const bool& aEnable) override; |
239 | | |
240 | | virtual mozilla::ipc::IPCResult |
241 | | RecvDefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent) override; |
242 | | |
243 | | virtual mozilla::ipc::IPCResult RecvGetInputContext( |
244 | | widget::IMEState* aIMEState) override; |
245 | | |
246 | | virtual mozilla::ipc::IPCResult RecvSetInputContext( |
247 | | const widget::InputContext& aContext, |
248 | | const widget::InputContextAction& aAction) override; |
249 | | |
250 | | // See nsIKeyEventInPluginCallback |
251 | | virtual void HandledWindowedPluginKeyEvent( |
252 | | const NativeEventData& aKeyEventData, |
253 | | bool aIsConsumed) override; |
254 | | |
255 | | virtual mozilla::ipc::IPCResult RecvOnWindowedPluginKeyEvent( |
256 | | const NativeEventData& aKeyEventData) override; |
257 | | |
258 | | virtual mozilla::ipc::IPCResult RecvRequestFocus(const bool& aCanRaise) override; |
259 | | |
260 | | virtual mozilla::ipc::IPCResult RecvLookUpDictionary( |
261 | | const nsString& aText, |
262 | | nsTArray<mozilla::FontRange>&& aFontRangeArray, |
263 | | const bool& aIsVertical, |
264 | | const LayoutDeviceIntPoint& aPoint) override; |
265 | | |
266 | | virtual mozilla::ipc::IPCResult |
267 | | RecvEnableDisableCommands(const nsString& aAction, |
268 | | nsTArray<nsCString>&& aEnabledCommands, |
269 | | nsTArray<nsCString>&& aDisabledCommands) override; |
270 | | |
271 | | virtual mozilla::ipc::IPCResult RecvSetCursor(const nsCursor& aValue, |
272 | | const bool& aForce) override; |
273 | | |
274 | | virtual mozilla::ipc::IPCResult RecvSetCustomCursor(const nsCString& aUri, |
275 | | const uint32_t& aWidth, |
276 | | const uint32_t& aHeight, |
277 | | const uint32_t& aStride, |
278 | | const gfx::SurfaceFormat& aFormat, |
279 | | const uint32_t& aHotspotX, |
280 | | const uint32_t& aHotspotY, |
281 | | const bool& aForce) override; |
282 | | |
283 | | virtual mozilla::ipc::IPCResult RecvSetStatus(const uint32_t& aType, |
284 | | const nsString& aStatus) override; |
285 | | |
286 | | virtual mozilla::ipc::IPCResult RecvShowTooltip(const uint32_t& aX, |
287 | | const uint32_t& aY, |
288 | | const nsString& aTooltip, |
289 | | const nsString& aDirection) override; |
290 | | |
291 | | virtual mozilla::ipc::IPCResult RecvHideTooltip() override; |
292 | | |
293 | | |
294 | | virtual mozilla::ipc::IPCResult RecvSetNativeChildOfShareableWindow(const uintptr_t& childWindow) override; |
295 | | |
296 | | virtual mozilla::ipc::IPCResult RecvDispatchFocusToTopLevelWindow() override; |
297 | | |
298 | | virtual mozilla::ipc::IPCResult RecvRespondStartSwipeEvent(const uint64_t& aInputBlockId, |
299 | | const bool& aStartSwipe) override; |
300 | | |
301 | | virtual mozilla::ipc::IPCResult |
302 | | RecvDispatchWheelEvent(const mozilla::WidgetWheelEvent& aEvent) override; |
303 | | |
304 | | virtual mozilla::ipc::IPCResult |
305 | | RecvDispatchMouseEvent(const mozilla::WidgetMouseEvent& aEvent) override; |
306 | | |
307 | | virtual mozilla::ipc::IPCResult |
308 | | RecvDispatchKeyboardEvent(const mozilla::WidgetKeyboardEvent& aEvent) override; |
309 | | |
310 | | virtual PColorPickerParent* |
311 | | AllocPColorPickerParent(const nsString& aTitle, |
312 | | const nsString& aInitialColor) override; |
313 | | |
314 | | virtual bool |
315 | | DeallocPColorPickerParent(PColorPickerParent* aColorPicker) override; |
316 | | |
317 | | virtual PDocAccessibleParent* |
318 | | AllocPDocAccessibleParent(PDocAccessibleParent*, const uint64_t&, |
319 | | const uint32_t&, const IAccessibleHolder&) override; |
320 | | |
321 | | virtual bool DeallocPDocAccessibleParent(PDocAccessibleParent*) override; |
322 | | |
323 | | virtual mozilla::ipc::IPCResult |
324 | | RecvPDocAccessibleConstructor(PDocAccessibleParent* aDoc, |
325 | | PDocAccessibleParent* aParentDoc, |
326 | | const uint64_t& aParentID, |
327 | | const uint32_t& aMsaaID, |
328 | | const IAccessibleHolder& aDocCOMProxy) override; |
329 | | |
330 | | /** |
331 | | * Return the top level doc accessible parent for this tab. |
332 | | */ |
333 | | a11y::DocAccessibleParent* GetTopLevelDocAccessible() const; |
334 | | |
335 | | void LoadURL(nsIURI* aURI); |
336 | | |
337 | | void InitRenderFrame(); |
338 | | |
339 | | // XXX/cjones: it's not clear what we gain by hiding these |
340 | | // message-sending functions under a layer of indirection and |
341 | | // eating the return values |
342 | | void Show(const ScreenIntSize& aSize, bool aParentIsActive); |
343 | | |
344 | | void UpdateDimensions(const nsIntRect& aRect, const ScreenIntSize& aSize); |
345 | | |
346 | | DimensionInfo GetDimensionInfo(); |
347 | | |
348 | | nsresult UpdatePosition(); |
349 | | |
350 | | void SizeModeChanged(const nsSizeMode& aSizeMode); |
351 | | |
352 | | void UIResolutionChanged(); |
353 | | |
354 | | void ThemeChanged(); |
355 | | |
356 | | void HandleAccessKey(const WidgetKeyboardEvent& aEvent, |
357 | | nsTArray<uint32_t>& aCharCodes); |
358 | | |
359 | | void Activate(); |
360 | | |
361 | | void Deactivate(); |
362 | | |
363 | | bool MapEventCoordinatesForChildProcess(mozilla::WidgetEvent* aEvent); |
364 | | |
365 | | void MapEventCoordinatesForChildProcess(const LayoutDeviceIntPoint& aOffset, |
366 | | mozilla::WidgetEvent* aEvent); |
367 | | |
368 | | LayoutDeviceToCSSScale GetLayoutDeviceToCSSScale(); |
369 | | |
370 | | virtual mozilla::ipc::IPCResult |
371 | | RecvRequestNativeKeyBindings( |
372 | | const uint32_t& aType, |
373 | | const mozilla::WidgetKeyboardEvent& aEvent, |
374 | | nsTArray<mozilla::CommandInt>* aCommands) override; |
375 | | |
376 | | virtual mozilla::ipc::IPCResult |
377 | | RecvSynthesizeNativeKeyEvent(const int32_t& aNativeKeyboardLayout, |
378 | | const int32_t& aNativeKeyCode, |
379 | | const uint32_t& aModifierFlags, |
380 | | const nsString& aCharacters, |
381 | | const nsString& aUnmodifiedCharacters, |
382 | | const uint64_t& aObserverId) override; |
383 | | |
384 | | virtual mozilla::ipc::IPCResult |
385 | | RecvSynthesizeNativeMouseEvent(const LayoutDeviceIntPoint& aPoint, |
386 | | const uint32_t& aNativeMessage, |
387 | | const uint32_t& aModifierFlags, |
388 | | const uint64_t& aObserverId) override; |
389 | | |
390 | | virtual mozilla::ipc::IPCResult |
391 | | RecvSynthesizeNativeMouseMove(const LayoutDeviceIntPoint& aPoint, |
392 | | const uint64_t& aObserverId) override; |
393 | | |
394 | | virtual mozilla::ipc::IPCResult |
395 | | RecvSynthesizeNativeMouseScrollEvent(const LayoutDeviceIntPoint& aPoint, |
396 | | const uint32_t& aNativeMessage, |
397 | | const double& aDeltaX, |
398 | | const double& aDeltaY, |
399 | | const double& aDeltaZ, |
400 | | const uint32_t& aModifierFlags, |
401 | | const uint32_t& aAdditionalFlags, |
402 | | const uint64_t& aObserverId) override; |
403 | | |
404 | | virtual mozilla::ipc::IPCResult |
405 | | RecvSynthesizeNativeTouchPoint(const uint32_t& aPointerId, |
406 | | const TouchPointerState& aPointerState, |
407 | | const LayoutDeviceIntPoint& aPoint, |
408 | | const double& aPointerPressure, |
409 | | const uint32_t& aPointerOrientation, |
410 | | const uint64_t& aObserverId) override; |
411 | | |
412 | | virtual mozilla::ipc::IPCResult |
413 | | RecvSynthesizeNativeTouchTap(const LayoutDeviceIntPoint& aPoint, |
414 | | const bool& aLongTap, |
415 | | const uint64_t& aObserverId) override; |
416 | | |
417 | | virtual mozilla::ipc::IPCResult |
418 | | RecvClearNativeTouchSequence(const uint64_t& aObserverId) override; |
419 | | |
420 | | virtual mozilla::ipc::IPCResult |
421 | | RecvSetPrefersReducedMotionOverrideForTest(const bool& aValue) override; |
422 | | virtual mozilla::ipc::IPCResult |
423 | | RecvResetPrefersReducedMotionOverrideForTest() override; |
424 | | |
425 | | void SendMouseEvent(const nsAString& aType, float aX, float aY, |
426 | | int32_t aButton, int32_t aClickCount, |
427 | | int32_t aModifiers, bool aIgnoreRootScrollFrame); |
428 | | |
429 | | /** |
430 | | * The following Send*Event() marks aEvent as posted to remote process if |
431 | | * it succeeded. So, you can check the result with |
432 | | * aEvent.HasBeenPostedToRemoteProcess(). |
433 | | */ |
434 | | void SendRealMouseEvent(WidgetMouseEvent& aEvent); |
435 | | |
436 | | void SendRealDragEvent(WidgetDragEvent& aEvent, |
437 | | uint32_t aDragAction, |
438 | | uint32_t aDropEffect, |
439 | | const nsCString& aPrincipalURISpec); |
440 | | |
441 | | void SendMouseWheelEvent(WidgetWheelEvent& aEvent); |
442 | | |
443 | | void SendRealKeyEvent(WidgetKeyboardEvent& aEvent); |
444 | | |
445 | | void SendRealTouchEvent(WidgetTouchEvent& aEvent); |
446 | | |
447 | | void SendPluginEvent(WidgetPluginEvent& aEvent); |
448 | | |
449 | | /** |
450 | | * Different from above Send*Event(), these methods return true if the |
451 | | * event has been posted to the remote process or failed to do that but |
452 | | * shouldn't be handled by following event listeners. |
453 | | * If you need to check if it's actually posted to the remote process, |
454 | | * you can refer aEvent.HasBeenPostedToRemoteProcess(). |
455 | | */ |
456 | | bool SendCompositionEvent(mozilla::WidgetCompositionEvent& aEvent); |
457 | | |
458 | | bool SendSelectionEvent(mozilla::WidgetSelectionEvent& aEvent); |
459 | | |
460 | | bool SendHandleTap(TapType aType, |
461 | | const LayoutDevicePoint& aPoint, |
462 | | Modifiers aModifiers, |
463 | | const ScrollableLayerGuid& aGuid, |
464 | | uint64_t aInputBlockId); |
465 | | |
466 | | virtual PFilePickerParent* |
467 | | AllocPFilePickerParent(const nsString& aTitle, |
468 | | const int16_t& aMode) override; |
469 | | |
470 | | virtual bool DeallocPFilePickerParent(PFilePickerParent* actor) override; |
471 | | |
472 | | virtual PIndexedDBPermissionRequestParent* |
473 | | AllocPIndexedDBPermissionRequestParent(const Principal& aPrincipal) override; |
474 | | |
475 | | virtual mozilla::ipc::IPCResult |
476 | | RecvPIndexedDBPermissionRequestConstructor( |
477 | | PIndexedDBPermissionRequestParent* aActor, |
478 | | const Principal& aPrincipal) |
479 | | override; |
480 | | |
481 | | virtual bool |
482 | | DeallocPIndexedDBPermissionRequestParent( |
483 | | PIndexedDBPermissionRequestParent* aActor) |
484 | | override; |
485 | | |
486 | | bool GetGlobalJSObject(JSContext* cx, JSObject** globalp); |
487 | | |
488 | | NS_DECL_ISUPPORTS |
489 | | NS_DECL_NSIAUTHPROMPTPROVIDER |
490 | | NS_DECL_NSISECUREBROWSERUI |
491 | | |
492 | | void StartPersistence(uint64_t aOuterWindowID, |
493 | | nsIWebBrowserPersistDocumentReceiver* aRecv, |
494 | | ErrorResult& aRv); |
495 | | |
496 | | bool HandleQueryContentEvent(mozilla::WidgetQueryContentEvent& aEvent); |
497 | | |
498 | | bool SendPasteTransferable(const IPCDataTransfer& aDataTransfer, |
499 | | const bool& aIsPrivateData, |
500 | | const IPC::Principal& aRequestingPrincipal, |
501 | | const uint32_t& aContentPolicyType); |
502 | | |
503 | | static TabParent* GetFrom(nsFrameLoader* aFrameLoader); |
504 | | |
505 | | static TabParent* GetFrom(nsITabParent* aTabParent); |
506 | | |
507 | | static TabParent* GetFrom(PBrowserParent* aTabParent); |
508 | | |
509 | | static TabParent* GetFrom(nsIContent* aContent); |
510 | | |
511 | | static TabId GetTabIdFrom(nsIDocShell* docshell); |
512 | | |
513 | | nsIContentParent* Manager() const { return mManager; } |
514 | | |
515 | | /** |
516 | | * Let managees query if Destroy() is already called so they don't send out |
517 | | * messages when the PBrowser actor is being destroyed. |
518 | | */ |
519 | | bool IsDestroyed() const { return mIsDestroyed; } |
520 | | |
521 | | // Returns the closest widget for our frameloader's content. |
522 | | already_AddRefed<nsIWidget> GetWidget() const; |
523 | | |
524 | | // Returns the top-level widget for our frameloader's document. |
525 | | already_AddRefed<nsIWidget> GetDocWidget() const; |
526 | | |
527 | | const TabId GetTabId() const |
528 | | { |
529 | | return mTabId; |
530 | | } |
531 | | |
532 | | // Returns the offset from the origin of our frameloader's nearest widget to |
533 | | // the origin of its layout frame. This offset is used to translate event |
534 | | // coordinates relative to the PuppetWidget origin in the child process. |
535 | | LayoutDeviceIntPoint GetChildProcessOffset(); |
536 | | |
537 | | // Returns the offset from the on-screen origin of our top-level window's |
538 | | // widget (including window decorations) to the origin of our frameloader's |
539 | | // nearest widget. This offset is used to translate coordinates from the |
540 | | // PuppetWidget's origin to absolute screen coordinates in the child. |
541 | | LayoutDeviceIntPoint GetClientOffset(); |
542 | | |
543 | | LayoutDevicePoint AdjustTapToChildWidget(const LayoutDevicePoint& aPoint); |
544 | | |
545 | | /** |
546 | | * Native widget remoting protocol for use with windowed plugins with e10s. |
547 | | */ |
548 | | virtual PPluginWidgetParent* AllocPPluginWidgetParent() override; |
549 | | |
550 | | virtual bool |
551 | | DeallocPPluginWidgetParent(PPluginWidgetParent* aActor) override; |
552 | | |
553 | | virtual PPaymentRequestParent* |
554 | | AllocPPaymentRequestParent() override; |
555 | | |
556 | | virtual bool |
557 | | DeallocPPaymentRequestParent(PPaymentRequestParent* aActor) override; |
558 | | |
559 | 0 | void SetInitedByParent() { mInitedByParent = true; } |
560 | | |
561 | | bool IsInitedByParent() const { return mInitedByParent; } |
562 | | |
563 | | bool SendLoadRemoteScript(const nsString& aURL, |
564 | | const bool& aRunInGlobalScope); |
565 | | |
566 | | void LayerTreeUpdate(const LayersObserverEpoch& aEpoch, bool aActive); |
567 | | |
568 | | virtual mozilla::ipc::IPCResult |
569 | | RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers, |
570 | | const uint32_t& aAction, |
571 | | const OptionalShmem& aVisualDnDData, |
572 | | const uint32_t& aStride, const gfx::SurfaceFormat& aFormat, |
573 | | const LayoutDeviceIntRect& aDragRect, |
574 | | const nsCString& aPrincipalURISpec) override; |
575 | | |
576 | | void AddInitialDnDDataTo(DataTransfer* aDataTransfer, |
577 | | nsACString& aPrincipalURISpec); |
578 | | |
579 | | bool TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface, |
580 | | LayoutDeviceIntRect* aDragRect); |
581 | | |
582 | | layout::RenderFrameParent* GetRenderFrame(); |
583 | | |
584 | | bool SetRenderFrame(PRenderFrameParent* aRFParent); |
585 | | bool GetRenderFrameInfo(TextureFactoryIdentifier* aTextureFactoryIdentifier, |
586 | | layers::LayersId* aLayersId); |
587 | | |
588 | | mozilla::ipc::IPCResult RecvEnsureLayersConnected(CompositorOptions* aCompositorOptions) override; |
589 | | |
590 | | // LiveResizeListener implementation |
591 | | void LiveResizeStarted() override; |
592 | | void LiveResizeStopped() override; |
593 | | |
594 | | void SetReadyToHandleInputEvents() { mIsReadyToHandleInputEvents = true; } |
595 | | bool IsReadyToHandleInputEvents() { return mIsReadyToHandleInputEvents; } |
596 | | |
597 | | static bool AreRecordReplayTabsActive() { |
598 | | return gNumActiveRecordReplayTabs != 0; |
599 | | } |
600 | | |
601 | | protected: |
602 | | bool ReceiveMessage(const nsString& aMessage, |
603 | | bool aSync, |
604 | | ipc::StructuredCloneData* aData, |
605 | | mozilla::jsipc::CpowHolder* aCpows, |
606 | | nsIPrincipal* aPrincipal, |
607 | | nsTArray<ipc::StructuredCloneData>* aJSONRetVal = nullptr); |
608 | | |
609 | | virtual mozilla::ipc::IPCResult RecvAsyncAuthPrompt(const nsCString& aUri, |
610 | | const nsString& aRealm, |
611 | | const uint64_t& aCallbackId) override; |
612 | | |
613 | | virtual mozilla::ipc::IPCResult Recv__delete__() override; |
614 | | |
615 | | virtual void ActorDestroy(ActorDestroyReason why) override; |
616 | | |
617 | | Element* mFrameElement; |
618 | | nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow; |
619 | | |
620 | | virtual PRenderFrameParent* AllocPRenderFrameParent() override; |
621 | | |
622 | | virtual bool DeallocPRenderFrameParent(PRenderFrameParent* aFrame) override; |
623 | | |
624 | | virtual mozilla::ipc::IPCResult RecvRemotePaintIsReady() override; |
625 | | |
626 | | virtual mozilla::ipc::IPCResult RecvRemoteIsReadyToHandleInputEvents() override; |
627 | | |
628 | | virtual mozilla::ipc::IPCResult RecvPaintWhileInterruptingJSNoOp(const LayersObserverEpoch& aEpoch) override; |
629 | | |
630 | | virtual mozilla::ipc::IPCResult RecvSetDimensions(const uint32_t& aFlags, |
631 | | const int32_t& aX, const int32_t& aY, |
632 | | const int32_t& aCx, const int32_t& aCy) override; |
633 | | |
634 | | virtual mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(const nsCString& aFirstPartyURI) override; |
635 | | |
636 | | mozilla::ipc::IPCResult |
637 | | RecvSetSystemFont(const nsCString& aFontName) override; |
638 | | mozilla::ipc::IPCResult |
639 | | RecvGetSystemFont(nsCString* aFontName) override; |
640 | | |
641 | | ContentCacheInParent mContentCache; |
642 | | |
643 | | nsIntRect mRect; |
644 | | ScreenIntSize mDimensions; |
645 | | hal::ScreenOrientation mOrientation; |
646 | | float mDPI; |
647 | | int32_t mRounding; |
648 | | CSSToLayoutDeviceScale mDefaultScale; |
649 | | bool mUpdatedDimensions; |
650 | | nsSizeMode mSizeMode; |
651 | | LayoutDeviceIntPoint mClientOffset; |
652 | | LayoutDeviceIntPoint mChromeOffset; |
653 | | |
654 | | private: |
655 | | void DestroyInternal(); |
656 | | |
657 | | void SetRenderLayersInternal(bool aEnabled, bool aForceRepaint); |
658 | | |
659 | | already_AddRefed<nsFrameLoader> |
660 | | GetFrameLoader(bool aUseCachedFrameLoaderAfterDestroy = false) const; |
661 | | |
662 | | RefPtr<nsIContentParent> mManager; |
663 | | void TryCacheDPIAndScale(); |
664 | | |
665 | | bool AsyncPanZoomEnabled() const; |
666 | | |
667 | | // Cached value indicating the docshell active state of the remote browser. |
668 | | bool mDocShellIsActive; |
669 | | |
670 | | // Update state prior to routing an APZ-aware event to the child process. |
671 | | // |aOutTargetGuid| will contain the identifier |
672 | | // of the APZC instance that handled the event. aOutTargetGuid may be null. |
673 | | // |aOutInputBlockId| will contain the identifier of the input block |
674 | | // that this event was added to, if there was one. aOutInputBlockId may be null. |
675 | | // |aOutApzResponse| will contain the response that the APZ gave when processing |
676 | | // the input block; this is used for generating appropriate pointercancel events. |
677 | | void ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid, |
678 | | uint64_t* aOutInputBlockId, |
679 | | nsEventStatus* aOutApzResponse); |
680 | | |
681 | | // When true, we've initiated normal shutdown and notified our managing PContent. |
682 | | bool mMarkedDestroying; |
683 | | // When true, the TabParent is invalid and we should not send IPC messages anymore. |
684 | | bool mIsDestroyed; |
685 | | |
686 | | uint32_t mChromeFlags; |
687 | | |
688 | | nsTArray<nsTArray<IPCDataTransferItem>> mInitialDataTransferItems; |
689 | | |
690 | | RefPtr<gfx::DataSourceSurface> mDnDVisualization; |
691 | | bool mDragValid; |
692 | | LayoutDeviceIntRect mDragRect; |
693 | | nsCString mDragPrincipalURISpec; |
694 | | |
695 | | // When true, the TabParent is initialized without child side's request. |
696 | | // When false, the TabParent is initialized by window.open() from child side. |
697 | | bool mInitedByParent; |
698 | | |
699 | | nsCOMPtr<nsILoadContext> mLoadContext; |
700 | | |
701 | | // We keep a strong reference to the frameloader after we've sent the |
702 | | // Destroy message and before we've received __delete__. This allows us to |
703 | | // dispatch message manager messages during this time. |
704 | | RefPtr<nsFrameLoader> mFrameLoader; |
705 | | |
706 | | TabId mTabId; |
707 | | |
708 | | // When loading a new tab or window via window.open, the child is |
709 | | // responsible for loading the URL it wants into the new TabChild. When the |
710 | | // parent receives the CreateWindow message, though, it sends a LoadURL |
711 | | // message, usually for about:blank. It's important for the about:blank load |
712 | | // to get processed because the Firefox frontend expects every new window to |
713 | | // immediately start loading something (see bug 1123090). However, we want |
714 | | // the child to process the LoadURL message before it returns from |
715 | | // ProvideWindow so that the URL sent from the parent doesn't override the |
716 | | // child's URL. This is not possible using our IPC mechanisms. To solve the |
717 | | // problem, we skip sending the LoadURL message in the parent and instead |
718 | | // return the URL as a result from CreateWindow. The child simulates |
719 | | // receiving a LoadURL message before returning from ProvideWindow. |
720 | | // |
721 | | // The mCreatingWindow flag is set while dispatching CreateWindow. During |
722 | | // that time, any LoadURL calls are skipped and the URL is stored in |
723 | | // mSkippedURL. |
724 | | bool mCreatingWindow; |
725 | | nsCString mDelayedURL; |
726 | | |
727 | | // When loading a new tab or window via window.open, we want to ensure that |
728 | | // frame scripts for that tab are loaded before any scripts start to run in |
729 | | // the window. We can't load the frame scripts the normal way, using |
730 | | // separate IPC messages, since they won't be processed by the child until |
731 | | // returning to the event loop, which is too late. Instead, we queue up |
732 | | // frame scripts that we intend to load and send them as part of the |
733 | | // CreateWindow response. Then TabChild loads them immediately. |
734 | | nsTArray<FrameScriptInfo> mDelayedFrameScripts; |
735 | | |
736 | | // Cached cursor setting from TabChild. When the cursor is over the tab, |
737 | | // it should take this appearance. |
738 | | nsCursor mCursor; |
739 | | nsCOMPtr<imgIContainer> mCustomCursor; |
740 | | uint32_t mCustomCursorHotspotX, mCustomCursorHotspotY; |
741 | | |
742 | | // True if the cursor changes from the TabChild should change the widget |
743 | | // cursor. This happens whenever the cursor is in the tab's region. |
744 | | bool mTabSetsCursor; |
745 | | |
746 | | bool mHasContentOpener; |
747 | | |
748 | | // When dropping links we perform a roundtrip from |
749 | | // Parent (SendRealDragEvent) -> Child -> Parent (RecvDropLinks) |
750 | | // and have to ensure that the child did not modify links to be loaded. |
751 | | bool QueryDropLinksForVerification(); |
752 | | nsTArray<nsString> mVerifyDropLinks; |
753 | | |
754 | | #ifdef DEBUG |
755 | | int32_t mActiveSupressDisplayportCount; |
756 | | #endif |
757 | | |
758 | | ShowInfo GetShowInfo(); |
759 | | |
760 | | private: |
761 | | // This is used when APZ needs to find the TabParent associated with a layer |
762 | | // to dispatch events. |
763 | | typedef nsDataHashtable<nsUint64HashKey, TabParent*> LayerToTabParentTable; |
764 | | static LayerToTabParentTable* sLayerToTabParentTable; |
765 | | |
766 | | static void AddTabParentToTable(layers::LayersId aLayersId, TabParent* aTabParent); |
767 | | |
768 | | static void RemoveTabParentFromTable(layers::LayersId aLayersId); |
769 | | |
770 | | LayersObserverEpoch mLayerTreeEpoch; |
771 | | |
772 | | // If this flag is set, then the tab's layers will be preserved even when |
773 | | // the tab's docshell is inactive. |
774 | | bool mPreserveLayers; |
775 | | |
776 | | // Holds the most recent value passed to the RenderLayers function. This |
777 | | // does not necessarily mean that the layers have finished rendering |
778 | | // and have uploaded - for that, use mHasLayers. |
779 | | bool mRenderLayers; |
780 | | |
781 | | // True if the compositor has reported that the TabChild has uploaded |
782 | | // layers. |
783 | | bool mHasLayers; |
784 | | |
785 | | // True if this TabParent has had its layer tree sent to the compositor |
786 | | // at least once. |
787 | | bool mHasPresented; |
788 | | |
789 | | // True if at least one window hosted in the TabChild has added a |
790 | | // beforeunload event listener. |
791 | | bool mHasBeforeUnload; |
792 | | |
793 | | // True when the remote browser is created and ready to handle input events. |
794 | | bool mIsReadyToHandleInputEvents; |
795 | | |
796 | | // True if we suppress the eMouseEnterIntoWidget event due to the TabChild was |
797 | | // not ready to handle it. We will resend it when the next time we fire a |
798 | | // mouse event and the TabChild is ready. |
799 | | bool mIsMouseEnterIntoWidgetEventSuppressed; |
800 | | |
801 | | // How many record/replay tabs have active docshells in this process. |
802 | | static size_t gNumActiveRecordReplayTabs; |
803 | | |
804 | | // Whether this tab is contributing to gNumActiveRecordReplayTabs. |
805 | | bool mIsActiveRecordReplayTab; |
806 | | |
807 | | // Update whether this is an active record/replay tab. |
808 | | void SetIsActiveRecordReplayTab(bool aIsActive); |
809 | | |
810 | | public: |
811 | | static TabParent* GetTabParentFromLayersId(layers::LayersId aLayersId); |
812 | | }; |
813 | | |
814 | | struct MOZ_STACK_CLASS TabParent::AutoUseNewTab final |
815 | | { |
816 | | public: |
817 | | AutoUseNewTab(TabParent* aNewTab, nsCString* aURLToLoad) |
818 | | : mNewTab(aNewTab), mURLToLoad(aURLToLoad) |
819 | 0 | { |
820 | 0 | MOZ_ASSERT(!aNewTab->mCreatingWindow); |
821 | 0 |
|
822 | 0 | aNewTab->mCreatingWindow = true; |
823 | 0 | aNewTab->mDelayedURL.Truncate(); |
824 | 0 | } |
825 | | |
826 | | ~AutoUseNewTab() |
827 | 0 | { |
828 | 0 | mNewTab->mCreatingWindow = false; |
829 | 0 | *mURLToLoad = mNewTab->mDelayedURL; |
830 | 0 | } |
831 | | |
832 | | private: |
833 | | TabParent* mNewTab; |
834 | | nsCString* mURLToLoad; |
835 | | }; |
836 | | |
837 | | } // namespace dom |
838 | | } // namespace mozilla |
839 | | |
840 | | #endif // mozilla_tabs_TabParent_h |