Adobe Dreamweaver API Reference CS5 User Manual
Page 372

367
DREAMWEAVER API REFERENCE
Dynamic documents
Last updated 8/27/2013
Dreamweaver 13.1 and later
function OnMMBrowserCtrlLoaded(e)
{
liveViewWindow = cefBrowser.getWindow();
liveViewWindow.initDefaults();
}
function Init_MM_browsercontrol()
{
var cefBrowser = document.getElementById("liveBrowser");
// Add event listener is mandatory to know when the browser is ready.
cefBrowser.addEventListener("BrowserControlLoad", OnMMBrowserCtrlLoaded,false);
cefBrowser.openURL("extention.html");
}
Passing/accessing larger objects across bridging
Passing or accessing larger objects through JS-bridge can be a performance overhead. This can also cause failures
especially when there are size limitations for copying objects across processes.The following example shows how this
can be handled:
Example:
Prior to Dreamweaver 13.1
Consider the media query dialog box.
DW code (Commands\Media Query Manager.js):
gBrowserCtrl = document.getElementById("browserCtrl");
...
...
gBrowserCtrl.getWindow().parentWindow = window; // DON'T DO THIS
In <mm:browsercontrol> code, parentWindow is used to invoke a function called "onClickGridRow".
<tr id='row_UNIQUE_ID' class='gridRow' onclick='parentWindow.onClickGridRow(UNIQUE_ID)'>
<td><div id='row_UNIQUE_ID_description' class='gridDescCol'></div></td>
<td><div id='row_UNIQUE_ID_mediaQuery' class='gridMediaQueryCol'></div></td>
<td width='100%'><div id='row_UNIQUE_ID_cssFile'></div></td>
</tr>
Dreamweaver 13.1 and later
DW code:
gBrowserCtrl.getWindow().SetParentWindowOnClickGridRow( window.onClickGridRow);
mm:browsercontrol code:
function SetParentWindowOnClickGridRow(callback)
{
parentWindowOnClickGridRow = callback;
}
<tr id='row_UNIQUE_ID' class='gridRow' onclick='parentWindowOnClickGridRow(UNIQUE_ID)'>
...
Use asynchronous calls
Since CEF3 is a multi-process, asynchronous platform, synchronous APIs are no longer available. Although
synchronous calls from Dreamweaver to Render Processes (spawned off by mm:browsercontrol) are simulated,
synchronous calls from the Render Processes are not supported.The following examples illustrate how you can change
synchronous calls to asynchronous: