1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/ipc/PBrowser.ipdl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,524 @@ 1.4 +/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */ 1.5 +/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */ 1.6 + 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +include protocol PBlob; 1.12 +include protocol PColorPicker; 1.13 +include protocol PContent; 1.14 +include protocol PDocumentRenderer; 1.15 +include protocol PContentPermissionRequest; 1.16 +include protocol PFilePicker; 1.17 +include protocol PRenderFrame; 1.18 +include protocol POfflineCacheUpdate; 1.19 +include protocol PIndexedDB; 1.20 +include DOMTypes; 1.21 +include JavaScriptTypes; 1.22 +include URIParams; 1.23 +include PContentPermission; 1.24 + 1.25 + 1.26 +using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h"; 1.27 +using struct mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h"; 1.28 +using struct gfxSize from "gfxPoint.h"; 1.29 +using CSSRect from "Units.h"; 1.30 +using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; 1.31 +using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h"; 1.32 +using struct mozilla::layers::ZoomConstraints from "FrameMetrics.h"; 1.33 +using FrameMetrics::ViewID from "FrameMetrics.h"; 1.34 +using mozilla::layout::ScrollingBehavior from "mozilla/layout/RenderFrameUtils.h"; 1.35 +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; 1.36 +using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h"; 1.37 +using nscolor from "nsColor.h"; 1.38 +using class mozilla::WidgetCompositionEvent from "ipc/nsGUIEventIPC.h"; 1.39 +using struct nsIMEUpdatePreference from "nsIWidget.h"; 1.40 +using struct nsIntPoint from "nsPoint.h"; 1.41 +using struct nsIntRect from "nsRect.h"; 1.42 +using struct nsIntSize from "nsSize.h"; 1.43 +using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h"; 1.44 +using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h"; 1.45 +using class mozilla::WidgetWheelEvent from "ipc/nsGUIEventIPC.h"; 1.46 +using struct nsRect from "nsRect.h"; 1.47 +using class mozilla::WidgetSelectionEvent from "ipc/nsGUIEventIPC.h"; 1.48 +using class mozilla::WidgetTextEvent from "ipc/nsGUIEventIPC.h"; 1.49 +using class mozilla::WidgetTouchEvent from "ipc/nsGUIEventIPC.h"; 1.50 +using struct mozilla::dom::RemoteDOMEvent from "mozilla/dom/TabMessageUtils.h"; 1.51 +using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h"; 1.52 +using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; 1.53 +using mozilla::CSSPoint from "Units.h"; 1.54 +using mozilla::CSSToScreenScale from "Units.h"; 1.55 +using mozilla::CommandInt from "mozilla/EventForwards.h"; 1.56 +using mozilla::layers::GeckoContentController::APZStateChange from "mozilla/layers/GeckoContentController.h"; 1.57 + 1.58 +namespace mozilla { 1.59 +namespace dom { 1.60 + 1.61 +struct NativeKeyBinding 1.62 +{ 1.63 + CommandInt[] singleLineCommands; 1.64 + CommandInt[] multiLineCommands; 1.65 + CommandInt[] richTextCommands; 1.66 +}; 1.67 + 1.68 +union MaybeNativeKeyBinding 1.69 +{ 1.70 + NativeKeyBinding; 1.71 + void_t; 1.72 +}; 1.73 + 1.74 +intr protocol PBrowser 1.75 +{ 1.76 + manager PContent; 1.77 + 1.78 + manages PColorPicker; 1.79 + manages PDocumentRenderer; 1.80 + manages PContentPermissionRequest; 1.81 + manages PFilePicker; 1.82 + manages PRenderFrame; 1.83 + manages POfflineCacheUpdate; 1.84 + manages PIndexedDB; 1.85 + 1.86 +both: 1.87 + AsyncMessage(nsString aMessage, ClonedMessageData aData, CpowEntry[] aCpows, 1.88 + Principal aPrincipal); 1.89 + 1.90 +parent: 1.91 + /** 1.92 + * When child sends this message, parent should move focus to 1.93 + * the next or previous focusable element. 1.94 + */ 1.95 + MoveFocus(bool forward); 1.96 + 1.97 + Event(RemoteDOMEvent aEvent); 1.98 + 1.99 + intr CreateWindow() returns (PBrowser window); 1.100 + 1.101 + sync SyncMessage(nsString aMessage, ClonedMessageData aData, 1.102 + CpowEntry[] aCpows, Principal aPrincipal) 1.103 + returns (nsString[] retval); 1.104 + 1.105 + rpc RpcMessage(nsString aMessage, ClonedMessageData aData, 1.106 + CpowEntry[] aCpows, Principal aPrincipal) 1.107 + returns (nsString[] retval); 1.108 + 1.109 + /** 1.110 + * The IME sequence number (seqno) parameter is used to make sure 1.111 + * that a notification is discarded if it arrives at the chrome process 1.112 + * too late. If the notification is late and we accept it, we will have 1.113 + * an out-of-date view of the content process, which means events that we 1.114 + * dispatch based on this out-of-date view will be wrong also. 1.115 + * (see Bug 599550 and Bug 591047 comments 44, 50, and 54) 1.116 + * 1.117 + * Chrome increments seqno and includes it in each IME event sent to 1.118 + * content, and content sends its current seqno back to chrome with each 1.119 + * notification. A notification is up-to-date only if the content 1.120 + * seqno is the same as the current chrome seqno, meaning no additional 1.121 + * event was sent to content before the notification was received 1.122 + * 1.123 + * On blur, chrome returns the current seqno to content, and content 1.124 + * uses it to discard subsequent events until the content seqno and 1.125 + * chrome seqno-on-blur match again. These events, meant for the blurred 1.126 + * textfield, are discarded to prevent events going to the wrong target 1.127 + */ 1.128 + 1.129 + /** 1.130 + * Notifies chrome that there is a focus change involving an editable 1.131 + * object (input, textarea, document, contentEditable. etc.) 1.132 + * 1.133 + * focus PR_TRUE if editable object is receiving focus 1.134 + * PR_FALSE if losing focus 1.135 + * preference Native widget preference for IME updates 1.136 + * seqno Current seqno value on the chrome side 1.137 + */ 1.138 + sync NotifyIMEFocus(bool focus) 1.139 + returns (nsIMEUpdatePreference preference, uint32_t seqno); 1.140 + 1.141 + /** 1.142 + * Notifies chrome that there has been a change in text content 1.143 + * One call can encompass both a delete and an insert operation 1.144 + * Only called when NotifyIMEFocus returns PR_TRUE for mWantUpdates 1.145 + * 1.146 + * offset Starting offset of the change 1.147 + * end Ending offset of the range deleted 1.148 + * newEnd New ending offset after insertion 1.149 + * causedByComposition true if the change is caused by composition 1.150 + * 1.151 + * for insertion, offset == end 1.152 + * for deletion, offset == newEnd 1.153 + */ 1.154 + NotifyIMETextChange(uint32_t offset, uint32_t end, uint32_t newEnd, 1.155 + bool causedByComposition); 1.156 + 1.157 + /** 1.158 + * Notifies chrome that there is a IME compostion rect updated 1.159 + * 1.160 + * offset The starting offset of this rect 1.161 + * rect The rect of first character of selected IME composition 1.162 + * caretRect The rect of IME caret 1.163 + */ 1.164 + NotifyIMESelectedCompositionRect(uint32_t offset, nsIntRect rect, nsIntRect caretRect); 1.165 + 1.166 + /** 1.167 + * Notifies chrome that there has been a change in selection 1.168 + * Only called when NotifyIMEFocus returns PR_TRUE for mWantUpdates 1.169 + * 1.170 + * seqno Current seqno value on the content side 1.171 + * anchor Offset where the selection started 1.172 + * focus Offset where the caret is 1.173 + * causedByComposition true if the change is caused by composition 1.174 + */ 1.175 + NotifyIMESelection(uint32_t seqno, uint32_t anchor, uint32_t focus, 1.176 + bool causedByComposition); 1.177 + 1.178 + /** 1.179 + * Notifies chrome to refresh its text cache 1.180 + * 1.181 + * text The entire content of the text field 1.182 + */ 1.183 + NotifyIMETextHint(nsString text); 1.184 + 1.185 + /** 1.186 + * Instructs chrome to end any pending composition 1.187 + * 1.188 + * cancel PR_TRUE if composition should be cancelled 1.189 + * composition Text to commit before ending the composition 1.190 + * 1.191 + * if cancel is PR_TRUE, 1.192 + * widget should return empty string for composition 1.193 + * if cancel is PR_FALSE, 1.194 + * widget should return the current composition text 1.195 + */ 1.196 + sync EndIMEComposition(bool cancel) returns (nsString composition); 1.197 + 1.198 + /** 1.199 + * Request that the parent process move focus to the browser's frame. If 1.200 + * canRaise is true, the window can be raised if it is inactive. 1.201 + */ 1.202 + RequestFocus(bool canRaise); 1.203 + 1.204 + sync GetInputContext() returns (int32_t IMEEnabled, int32_t IMEOpen, 1.205 + intptr_t NativeIMEContext); 1.206 + 1.207 + SetInputContext(int32_t IMEEnabled, 1.208 + int32_t IMEOpen, 1.209 + nsString type, 1.210 + nsString inputmode, 1.211 + nsString actionHint, 1.212 + int32_t cause, 1.213 + int32_t focusChange); 1.214 + 1.215 + sync IsParentWindowMainWidgetVisible() returns (bool visible); 1.216 + 1.217 + /** 1.218 + * Gets the DPI of the screen corresponding to this browser. 1.219 + */ 1.220 + sync GetDPI() returns (float value); 1.221 + 1.222 + /** 1.223 + * Gets the default scaling factor of the screen corresponding to this browser. 1.224 + */ 1.225 + sync GetDefaultScale() returns (double value); 1.226 + 1.227 + /** 1.228 + * Return native data of root widget 1.229 + */ 1.230 + sync GetWidgetNativeData() returns (WindowsHandle value); 1.231 + 1.232 + SetCursor(uint32_t value); 1.233 + SetBackgroundColor(nscolor color); 1.234 + 1.235 + /** 1.236 + * Used to set the current text of the status tooltip. 1.237 + * Nowadays this is mainly used for link locations on hover. 1.238 + */ 1.239 + SetStatus(uint32_t type, nsString status); 1.240 + 1.241 + /** 1.242 + * Show/hide a tooltip when the mouse hovers over an element in the content 1.243 + * document. 1.244 + */ 1.245 + ShowTooltip(uint32_t x, uint32_t y, nsString tooltip); 1.246 + HideTooltip(); 1.247 + 1.248 + /** 1.249 + * Create an asynchronous color picker on the parent side, 1.250 + * but don't open it yet. 1.251 + */ 1.252 + PColorPicker(nsString title, nsString initialColor); 1.253 + 1.254 + /** 1.255 + * Initiates an asynchronous request for permission for the 1.256 + * provided principal. 1.257 + * 1.258 + * @param aRequests 1.259 + * The array of permissions to request. 1.260 + * @param aPrincipal 1.261 + * The principal of the request. 1.262 + * 1.263 + * NOTE: The principal is untrusted in the parent process. Only 1.264 + * principals that can live in the content process should 1.265 + * provided. 1.266 + */ 1.267 + PContentPermissionRequest(PermissionRequest[] aRequests, Principal aPrincipal); 1.268 + 1.269 + PFilePicker(nsString aTitle, int16_t aMode); 1.270 + 1.271 + /** 1.272 + * Create a layout frame (encapsulating a remote layer tree) for 1.273 + * the page that is currently loaded in the <browser>. 1.274 + */ 1.275 + sync PRenderFrame(); 1.276 + 1.277 + sync InitRenderFrame(PRenderFrame aFrame) 1.278 + returns (ScrollingBehavior scrolling, 1.279 + TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId, 1.280 + bool success); 1.281 + 1.282 + /** 1.283 + * Starts an offline application cache update. 1.284 + * @param manifestURI 1.285 + * URI of the manifest to fetch, the application cache group ID 1.286 + * @param documentURI 1.287 + * URI of the document that referred the manifest 1.288 + * @param stickDocument 1.289 + * True if the update was initiated by a document load that referred 1.290 + * a manifest. 1.291 + * False if the update was initiated by applicationCache.update() call. 1.292 + * 1.293 + * Tells the update to carry the documentURI to a potential separate 1.294 + * update of implicit (master) items. 1.295 + * 1.296 + * Why this argument? If the document was not found in an offline cache 1.297 + * before load and refers a manifest and this manifest itself has not 1.298 + * been changed since the last fetch, we will not do the application 1.299 + * cache group update. But we must cache the document (identified by the 1.300 + * documentURI). This argument will ensure that a previously uncached 1.301 + * document will get cached and that we don't re-cache a document that 1.302 + * has already been cached (stickDocument=false). 1.303 + */ 1.304 + POfflineCacheUpdate(URIParams manifestURI, URIParams documentURI, 1.305 + bool stickDocument); 1.306 + 1.307 + /** 1.308 + * Sets "offline-app" permission for the principal. Called when we hit 1.309 + * a web app with the manifest attribute in <html> and 1.310 + * offline-apps.allow_by_default is set to true. 1.311 + */ 1.312 + SetOfflinePermission(Principal principal); 1.313 + 1.314 + sync PIndexedDB(nsCString group, nsCString asciiOrigin) 1.315 + returns (bool allowed); 1.316 + 1.317 + /** 1.318 + * window.open from inside <iframe mozbrowser> is special. When the child 1.319 + * process calls window.open, it creates a new PBrowser (in its own 1.320 + * process), then calls BrowserFrameOpenWindow on it. 1.321 + * 1.322 + * The parent process gets a chance to accept or reject the window.open 1.323 + * call, and windowOpened is set to true if we ended up going through with 1.324 + * the window.open. 1.325 + * 1.326 + * @param opener the PBrowser whose content called window.open. 1.327 + */ 1.328 + sync BrowserFrameOpenWindow(PBrowser opener, nsString aURL, 1.329 + nsString aName, nsString aFeatures) 1.330 + returns (bool windowOpened); 1.331 + 1.332 + /** 1.333 + * Instructs the TabParent to forward a request to zoom to a rect given in 1.334 + * CSS pixels. This rect is relative to the document. 1.335 + */ 1.336 + ZoomToRect(uint32_t aPresShellId, ViewID aViewId, CSSRect aRect); 1.337 + 1.338 + /** 1.339 + * We know for sure that content has either preventDefaulted or not 1.340 + * preventDefaulted. This applies to an entire batch of touch events. It is 1.341 + * expected that, if there are any DOM touch listeners, touch events will be 1.342 + * batched and only processed for panning and zooming if content does not 1.343 + * preventDefault. 1.344 + */ 1.345 + ContentReceivedTouch(ScrollableLayerGuid aGuid, bool aPreventDefault); 1.346 + 1.347 + /** 1.348 + * Updates the zoom constraints for a scrollable frame in this tab. 1.349 + * The zoom controller code lives on the parent side and so this allows it to 1.350 + * have up-to-date zoom constraints. 1.351 + */ 1.352 + UpdateZoomConstraints(uint32_t aPresShellId, ViewID aViewId, bool aIsRoot, 1.353 + ZoomConstraints aConstraints); 1.354 + 1.355 + __delete__(); 1.356 + 1.357 + ReplyKeyEvent(WidgetKeyboardEvent event); 1.358 + 1.359 + sync RequestNativeKeyBindings(WidgetKeyboardEvent event) 1.360 + returns (MaybeNativeKeyBinding bindings); 1.361 + 1.362 +child: 1.363 + /** 1.364 + * Notify the remote browser that it has been Show()n on this 1.365 + * side, with the given |visibleRect|. This message is expected 1.366 + * to trigger creation of the remote browser's "widget". 1.367 + * 1.368 + * |Show()| and |Move()| take IntSizes rather than Rects because 1.369 + * content processes always render to a virtual <0, 0> top-left 1.370 + * point. 1.371 + */ 1.372 + Show(nsIntSize size); 1.373 + 1.374 + LoadURL(nsCString uri); 1.375 + 1.376 + CacheFileDescriptor(nsString path, FileDescriptor fd); 1.377 + 1.378 + UpdateDimensions(nsRect rect, nsIntSize size, ScreenOrientation orientation) compress; 1.379 + 1.380 + UpdateFrame(FrameMetrics frame); 1.381 + 1.382 + /** 1.383 + * Acknowledge the receipt of a scroll offset update from the content 1.384 + * process. This is used to manage concurrent scroll updates from many 1.385 + * sources. 1.386 + */ 1.387 + AcknowledgeScrollUpdate(ViewID aScrollId, uint32_t aScrollGeneration); 1.388 + 1.389 + /** 1.390 + * Requests handling of a double tap. |point| is in CSS pixels, relative to 1.391 + * the scroll offset. This message is expected to round-trip back to 1.392 + * ZoomToRect() with a rect indicating where we should zoom to. 1.393 + */ 1.394 + HandleDoubleTap(CSSPoint point, ScrollableLayerGuid aGuid); 1.395 + 1.396 + /** 1.397 + * Requests handling of a single tap. |point| is in CSS pixels, relative to 1.398 + * the scroll offset. This message is expected to send a "mousedown" and 1.399 + * "mouseup" series of events at this point. 1.400 + */ 1.401 + HandleSingleTap(CSSPoint point, ScrollableLayerGuid aGuid); 1.402 + 1.403 + /** 1.404 + * Requests handling of a long tap. |point| is in CSS pixels, relative to 1.405 + * the scroll offset. This message is expected to send a "contextmenu" 1.406 + * events at this point. 1.407 + */ 1.408 + HandleLongTap(CSSPoint point, ScrollableLayerGuid aGuid); 1.409 + 1.410 + /** 1.411 + * Requests handling of releasing a long tap. |aPoint| is in CSS pixels, 1.412 + * relative to the current scroll offset. In the case the "contextmenu" 1.413 + * event generated by the preceding HandleLongTap call was not handled, 1.414 + * this message is expected to generate a "mousedown" and "mouseup" 1.415 + * series of events 1.416 + */ 1.417 + HandleLongTapUp(CSSPoint point, ScrollableLayerGuid aGuid); 1.418 + 1.419 + /** 1.420 + * Notifies the child about various APZ state changes. 1.421 + * See GeckoContentController::NotifyAPZStateChange() for details. 1.422 + */ 1.423 + NotifyAPZStateChange(ViewID aViewId, APZStateChange aChange, int aArg); 1.424 + 1.425 + /** 1.426 + * Sending an activate message moves focus to the child. 1.427 + */ 1.428 + Activate(); 1.429 + 1.430 + Deactivate(); 1.431 + 1.432 + /** 1.433 + * @see nsIDOMWindowUtils sendMouseEvent. 1.434 + */ 1.435 + MouseEvent(nsString aType, 1.436 + float aX, 1.437 + float aY, 1.438 + int32_t aButton, 1.439 + int32_t aClickCount, 1.440 + int32_t aModifiers, 1.441 + bool aIgnoreRootScrollFrame); 1.442 + 1.443 + RealMouseEvent(WidgetMouseEvent event); 1.444 + RealKeyEvent(WidgetKeyboardEvent event, MaybeNativeKeyBinding keyBinding); 1.445 + MouseWheelEvent(WidgetWheelEvent event); 1.446 + RealTouchEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid); 1.447 + // We use a separate message for touchmove events only to apply 1.448 + // compression to them. 1.449 + RealTouchMoveEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid) compress; 1.450 + 1.451 + /** 1.452 + * @see nsIDOMWindowUtils sendKeyEvent. 1.453 + */ 1.454 + KeyEvent(nsString aType, 1.455 + int32_t aKeyCode, 1.456 + int32_t aCharCode, 1.457 + int32_t aModifiers, 1.458 + bool aPreventDefault); 1.459 + 1.460 + CompositionEvent(WidgetCompositionEvent event); 1.461 + 1.462 + TextEvent(WidgetTextEvent event); 1.463 + 1.464 + SelectionEvent(WidgetSelectionEvent event); 1.465 + 1.466 + /** 1.467 + * Activate event forwarding from client to parent. 1.468 + */ 1.469 + ActivateFrameEvent(nsString aType, bool capture); 1.470 + 1.471 + LoadRemoteScript(nsString aURL, bool aRunInGlobalScope); 1.472 + 1.473 + /** 1.474 + * Create a asynchronous request to render whatever document is 1.475 + * loaded in the child when this message arrives. When the 1.476 + * request finishes, PDocumentRenderer:__delete__ is sent back to 1.477 + * this side to notify completion. 1.478 + * 1.479 + * |documentRect| is the area of the remote document to draw, 1.480 + * transformed by |transform|. The rendered area will have the 1.481 + * default background color |bgcolor|. |renderFlags| are the 1.482 + * nsIPresShell::RenderDocument() flags to use on the remote side, 1.483 + * and if true, |flushLayout| will do just that before rendering 1.484 + * the document. The rendered image will be of size |renderSize|. 1.485 + */ 1.486 + PDocumentRenderer(nsRect documentRect, Matrix transform, 1.487 + nsString bgcolor, 1.488 + uint32_t renderFlags, bool flushLayout, 1.489 + nsIntSize renderSize); 1.490 + 1.491 + /** 1.492 + * Sent by the chrome process when it no longer wants this remote 1.493 + * <browser>. The child side cleans up in response, then 1.494 + * finalizing its death by sending back __delete__() to the 1.495 + * parent. 1.496 + */ 1.497 + Destroy(); 1.498 + 1.499 + 1.500 + /** 1.501 + * Tell the child side if it has to update it's touchable region 1.502 + * to the parent. 1.503 + */ 1.504 + SetUpdateHitRegion(bool aEnabled); 1.505 + 1.506 + /** 1.507 + * Tell the child to update its docShell's active state. 1.508 + */ 1.509 + SetIsDocShellActive(bool aIsActive); 1.510 + 1.511 +/* 1.512 + * FIXME: write protocol! 1.513 + 1.514 +state LIVE: 1.515 + send LoadURL goto LIVE; 1.516 +//etc. 1.517 + send Destroy goto DYING; 1.518 + 1.519 +state DYING: 1.520 + discard send blah; 1.521 +// etc. 1.522 + recv __delete__; 1.523 + */ 1.524 +}; 1.525 + 1.526 +} 1.527 +}