2010-06-07 19:44:06 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<!-- ***** BEGIN LICENSE BLOCK *****
|
|
|
|
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
-
|
|
|
|
- The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
- 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
- the License. You may obtain a copy of the License at
|
|
|
|
- http://www.mozilla.org/MPL/
|
|
|
|
-
|
|
|
|
- Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
- for the specific language governing rights and limitations under the
|
|
|
|
- License.
|
|
|
|
-
|
|
|
|
- The Original Code is this file as it was released on March 28, 2001.
|
|
|
|
-
|
|
|
|
- The Initial Developer of the Original Code is
|
|
|
|
- Peter Annema.
|
|
|
|
- Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
- the Initial Developer. All Rights Reserved.
|
|
|
|
-
|
|
|
|
- Contributor(s):
|
|
|
|
- Peter Annema <disttsc@bart.nl> (Original Author of <browser>)
|
|
|
|
- Peter Parente <parente@cs.unc.edu>
|
|
|
|
- Christopher Thomas <cst@yecc.com>
|
|
|
|
- Michael Ventnor <m.ventnor@gmail.com>
|
|
|
|
- Arpad Borsos <arpad.borsos@googlemail.com>
|
|
|
|
-
|
|
|
|
- Alternatively, the contents of this file may be used under the terms of
|
|
|
|
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
- in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
- of those above. If you wish to allow use of your version of this file only
|
|
|
|
- under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
- use your version of this file under the terms of the MPL, indicate your
|
|
|
|
- decision by deleting the provisions above and replace them with the notice
|
|
|
|
- and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
- the provisions above, a recipient may use your version of this file under
|
|
|
|
- the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
-
|
|
|
|
- ***** END LICENSE BLOCK ***** -->
|
|
|
|
|
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % findBarDTD SYSTEM "chrome://global/locale/findbar.dtd" >
|
|
|
|
%findBarDTD;
|
|
|
|
]>
|
|
|
|
|
|
|
|
<bindings id="remoteBrowserBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<binding id="local-browser" extends="chrome://global/content/bindings/browser.xml#browser">
|
2010-06-07 19:44:06 -07:00
|
|
|
<implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener, nsIFrameMessageListener">
|
2010-06-16 06:53:29 -07:00
|
|
|
<field name="_securityUI">null</field>
|
|
|
|
<property name="securityUI">
|
|
|
|
<getter><![CDATA[
|
|
|
|
return this._securityUI || {};
|
|
|
|
]]></getter>
|
|
|
|
<setter><![CDATA[
|
|
|
|
this._securityUI = val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
<field name="_searchEngines">[]</field>
|
|
|
|
<property name="searchEngines"
|
|
|
|
onget="return this._searchEngines"
|
|
|
|
readonly="true"/>
|
|
|
|
|
2010-06-08 08:22:20 -07:00
|
|
|
<field name="_documentURI">null</field>
|
|
|
|
<property name="documentURI"
|
2010-09-30 06:43:49 -07:00
|
|
|
onget="return this._documentURI ? Services.io.newURI(this._documentURI, null, null) : null"
|
2010-06-08 08:22:20 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
<field name="contentWindowId">null</field>
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
<property name="messageManager"
|
|
|
|
onget="return this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<field name="_contentTitle">null</field>
|
|
|
|
|
|
|
|
<field name="_ios">
|
|
|
|
Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
|
|
|
</field>
|
|
|
|
|
2010-09-24 11:48:39 -07:00
|
|
|
<field name="_messageListenerLocal"><![CDATA[
|
|
|
|
({
|
|
|
|
self: this,
|
|
|
|
receiveMessage: function receiveMessage(aMessage) {
|
|
|
|
let self = this.self;
|
|
|
|
let json = aMessage.json;
|
|
|
|
|
|
|
|
switch (aMessage.name) {
|
|
|
|
case "DOMPopupBlocked":
|
|
|
|
self.onPopupBlocked(aMessage);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "pageshow":
|
|
|
|
self.onPageShow(aMessage);
|
|
|
|
|
|
|
|
if (self.mIconURL == "" && self._documentURI) {
|
|
|
|
// newURI call is throwing for chrome URI
|
|
|
|
try {
|
|
|
|
// Use documentURIObject in the favicon construction so that we
|
|
|
|
// do the right thing with about:-style error pages. Bug 515188
|
2010-09-29 13:03:00 -07:00
|
|
|
self.loadFavicon(self.documentURI.prePath + "/favicon.ico", null);
|
2010-08-26 16:55:32 -07:00
|
|
|
}
|
2010-09-24 11:48:39 -07:00
|
|
|
catch(e) {}
|
2010-08-26 15:51:36 -07:00
|
|
|
}
|
2010-09-24 11:48:39 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "pagehide":
|
|
|
|
self.onPageHide(aMessage);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "DOMTitleChanged":
|
|
|
|
self._contentTitle = aMessage.json.title;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "DOMLinkAdded":
|
|
|
|
let link = aMessage.json;
|
|
|
|
// ignore results from subdocuments
|
|
|
|
if (link.windowId != self.contentWindowId)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let linkType = self._getLinkType(link);
|
|
|
|
switch(linkType) {
|
|
|
|
case "icon":
|
2010-09-29 13:03:00 -07:00
|
|
|
self.loadFavicon(link.href, link.charset);
|
2010-09-24 11:48:39 -07:00
|
|
|
break;
|
|
|
|
case "search":
|
|
|
|
self._searchEngines.push({ title: link.title, href: link.href });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "MozScrolledAreaChanged":
|
|
|
|
self._contentDocumentWidth = aMessage.json.width;
|
|
|
|
self._contentDocumentHeight = aMessage.json.height;
|
|
|
|
|
|
|
|
// Recalculate whether the visible area is actually in bounds
|
|
|
|
self.scrollBy(0, 0);
|
|
|
|
self._updateCacheViewport();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
2010-06-07 19:44:06 -07:00
|
|
|
|
2010-09-29 13:03:00 -07:00
|
|
|
<method name="loadFavicon">
|
|
|
|
<parameter name="aURL"/>
|
|
|
|
<parameter name="aCharset"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
let iconURI = Services.io.newURI(aURL, aCharset, null);
|
|
|
|
if (this.shouldLoadFavicon(iconURI)) {
|
|
|
|
gFaviconService.setAndLoadFaviconForPage(this.currentURI, iconURI, true);
|
|
|
|
this.mIconURL = iconURI.spec;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.mIconURL = "";
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="shouldLoadFavicon">
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
let docURI = this.currentURI;
|
|
|
|
return (!gFaviconService.isFailedFavicon(aURI) && docURI && ("schemeIs" in docURI) &&
|
|
|
|
(docURI.schemeIs("http") || docURI.schemeIs("https") || docURI.schemeIs("about") || docURI.schemeIs("chrome")));
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
<method name="_getLinkType">
|
|
|
|
<parameter name="aLink" />
|
|
|
|
<body><![CDATA[
|
|
|
|
let type = "";
|
|
|
|
if (/\bicon\b/i(aLink.rel)) {
|
|
|
|
type = "icon";
|
|
|
|
}
|
|
|
|
else if (/\bsearch\b/i(aLink.rel) && aLink.type && aLink.title) {
|
|
|
|
let linkType = aLink.type.replace(/^\s+|\s*(?:;.*)?$/g, "").toLowerCase();
|
|
|
|
if (linkType == "application/opensearchdescription+xml" && /^(?:https?|ftp):/i.test(aLink.href)) {
|
|
|
|
type = "search";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<field name="_webProgress"><![CDATA[
|
|
|
|
({
|
2010-06-09 13:07:32 -07:00
|
|
|
_listeners: [],
|
2010-06-08 19:36:04 -07:00
|
|
|
_browser: this,
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
_init: function() {
|
2010-06-09 13:07:32 -07:00
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StateChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:ProgressChange", this);
|
2010-06-08 12:30:46 -07:00
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:LocationChange", this);
|
2010-06-09 13:07:32 -07:00
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StatusChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:SecurityChange", this);
|
|
|
|
},
|
|
|
|
|
|
|
|
addProgressListener: function(aListener, aNotifyFlags) {
|
|
|
|
function hasFilter(item) {
|
|
|
|
return item.listener == aListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._listeners.some(hasFilter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._listeners.push({
|
|
|
|
listener: aListener,
|
|
|
|
flags: aNotifyFlags
|
|
|
|
});
|
2010-07-26 17:48:46 -07:00
|
|
|
|
|
|
|
this._browser.messageManager.sendAsyncMessage("WebProgress:AddProgressListener", {
|
|
|
|
notifyFlags: aNotifyFlags,
|
|
|
|
});
|
2010-06-08 12:30:46 -07:00
|
|
|
},
|
2010-06-07 19:44:06 -07:00
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
removeProgressListener: function(aListener) {
|
2010-07-28 12:43:13 -07:00
|
|
|
let self = this;
|
2010-06-09 13:07:32 -07:00
|
|
|
function hasFilter(item) {
|
2010-07-26 17:48:46 -07:00
|
|
|
if (item.listener == aListener)
|
2010-07-28 12:43:13 -07:00
|
|
|
self._browser.messageManager.sendAsyncMessage("WebProgress:RemoveProgressListener", {
|
2010-07-26 17:48:46 -07:00
|
|
|
notifyFlags: item.flags,
|
|
|
|
});
|
2010-06-09 13:07:32 -07:00
|
|
|
return item.listener != aListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._listeners = this._listeners.filter(hasFilter);
|
|
|
|
},
|
2010-11-11 20:53:33 -08:00
|
|
|
get DOMWindow() { return null; },
|
|
|
|
get isLoadingDocument() { throw "isLoadingDocument: Invalid"; },
|
2010-06-09 13:07:32 -07:00
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
receiveMessage: function(aMessage) {
|
2010-06-09 13:07:32 -07:00
|
|
|
let args;
|
2010-06-08 12:30:46 -07:00
|
|
|
let json = aMessage.json;
|
|
|
|
switch (aMessage.name) {
|
2010-06-09 13:07:32 -07:00
|
|
|
case "WebProgress:StateChange":
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
json.stateFlags,
|
|
|
|
json.status
|
|
|
|
];
|
|
|
|
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-09 13:07:32 -07:00
|
|
|
this._notify(json.notifyFlags, "onStateChange", args);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "WebProgress:ProgressChange":
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
json.curSelf,
|
|
|
|
json.maxSelf,
|
|
|
|
json.curTotal,
|
|
|
|
json.maxTotal
|
|
|
|
];
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-09 13:07:32 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS,
|
|
|
|
"onProgressChange",
|
|
|
|
args);
|
|
|
|
break;
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
case "WebProgress:LocationChange":
|
2010-06-09 13:07:32 -07:00
|
|
|
let locationURI = this._browser._ios.newURI(json.location, null, null);
|
|
|
|
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
locationURI
|
|
|
|
];
|
|
|
|
|
2010-10-29 12:44:00 -07:00
|
|
|
if (this._browser.updateWindowId(json.windowId)) {
|
2010-06-08 12:30:46 -07:00
|
|
|
this._browser._documentURI = json.documentURI;
|
|
|
|
this._browser._searchEngines = [];
|
|
|
|
}
|
2010-06-09 13:07:32 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_LOCATION,
|
|
|
|
"onLocationChange",
|
|
|
|
args);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "WebProgress:StatusChange":
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
json.status,
|
|
|
|
json.message
|
|
|
|
];
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-09 13:07:32 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_STATUS,
|
|
|
|
"onStatusChange",
|
|
|
|
args);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "WebProgress:SecurityChange":
|
|
|
|
args = [
|
2010-06-16 06:53:29 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-09 13:07:32 -07:00
|
|
|
{},
|
|
|
|
json.state
|
|
|
|
];
|
2010-06-16 06:53:29 -07:00
|
|
|
|
|
|
|
this._browser._securityUI = {
|
|
|
|
SSLStatus: json.SSLStatus,
|
|
|
|
state: json.state
|
|
|
|
}
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-09 13:07:32 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_SECURITY,
|
|
|
|
"onSecurityChange",
|
|
|
|
args);
|
2010-06-08 12:30:46 -07:00
|
|
|
break;
|
|
|
|
}
|
2010-06-09 13:07:32 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
_notify: function(aFlags, aName, aArguments) {
|
|
|
|
this._listeners.forEach(function(item) {
|
|
|
|
if (item.flags & aFlags) {
|
|
|
|
item.listener[aName].apply(item.listener, aArguments);
|
|
|
|
}
|
|
|
|
});
|
2010-06-08 12:30:46 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
<property name="webProgress"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this._webProgress"/>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<method name="onPageShow">
|
|
|
|
<parameter name="aMessage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.attachFormFill();
|
|
|
|
if (this.pageReport) {
|
|
|
|
var json = aMessage.json;
|
|
|
|
var i = 0;
|
|
|
|
while (i < this.pageReport.length) {
|
|
|
|
// Filter out irrelevant reports.
|
|
|
|
if (this.pageReport[i].requestingWindowId == json.windowId)
|
|
|
|
i++;
|
|
|
|
else
|
|
|
|
this.pageReport.splice(i, 1);
|
|
|
|
}
|
|
|
|
if (this.pageReport.length == 0) {
|
|
|
|
this.pageReport = null;
|
|
|
|
this.updatePageReport();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onPageHide">
|
|
|
|
<parameter name="aMessage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (this.pageReport) {
|
|
|
|
this.pageReport = null;
|
|
|
|
this.updatePageReport();
|
|
|
|
}
|
|
|
|
// Delete the feeds cache if we're hiding the topmost page
|
|
|
|
// (as opposed to one of its iframes).
|
2010-06-22 06:24:02 -07:00
|
|
|
if (this.feeds && aMessage.target == this)
|
2010-06-08 12:30:46 -07:00
|
|
|
this.feeds = null;
|
2010-09-24 17:40:45 -07:00
|
|
|
|
|
|
|
if (aMessage.windowId == this.contentWindowId)
|
|
|
|
this.scale = 1;
|
2010-06-08 12:30:46 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onPopupBlocked">
|
|
|
|
<parameter name="aMessage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this.pageReport) {
|
|
|
|
this.pageReport = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
let json = aMessage.json;
|
|
|
|
// XXX Replacing requestingWindow && requestingDocument affects
|
|
|
|
// http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#500
|
|
|
|
var obj = {
|
|
|
|
requestingWindowId: json.windowId,
|
2010-07-13 07:36:09 -07:00
|
|
|
popupWindowURI: Services.io.newURI(json.popupWindowURI.spec, json.popupWindowURI.charset, null),
|
2010-06-08 12:30:46 -07:00
|
|
|
popupWindowFeatures: json.popupWindowFeatures,
|
|
|
|
popupWindowName: json.popupWindowName
|
|
|
|
};
|
|
|
|
|
|
|
|
this.pageReport.push(obj);
|
|
|
|
this.pageReport.reported = false;
|
|
|
|
this.updatePageReport();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-08-30 14:11:49 -07:00
|
|
|
<field name="_frameLoader">null</field>
|
2010-08-27 12:12:48 -07:00
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Dimensions of content window -->
|
2010-09-15 15:05:50 -07:00
|
|
|
<property name="contentWindowWidth"
|
|
|
|
onget="return this._contentWindowWidth;"
|
2010-08-27 16:25:53 -07:00
|
|
|
readonly="true"/>
|
2010-09-15 15:05:50 -07:00
|
|
|
<property name="contentWindowHeight"
|
|
|
|
onget="return this._contentWindowHeight;"
|
2010-08-27 16:25:53 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Dimensions of content document -->
|
2010-09-15 15:05:50 -07:00
|
|
|
<field name="_contentDocumentWidth">0</field>
|
|
|
|
<field name="_contentDocumentHeight">0</field>
|
|
|
|
<property name="contentDocumentWidth"
|
|
|
|
onget="return this._contentDocumentWidth;"
|
2010-08-27 08:36:11 -07:00
|
|
|
readonly="true"/>
|
2010-09-15 15:05:50 -07:00
|
|
|
<property name="contentDocumentHeight"
|
|
|
|
onget="return this._contentDocumentHeight;"
|
2010-08-27 08:36:11 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Zoom level is the ratio of device pixels to CSS pixels -->
|
2010-09-15 15:05:50 -07:00
|
|
|
<field name="_scale">1</field>
|
2010-09-01 13:35:05 -07:00
|
|
|
<property name="scale"
|
2010-09-15 15:05:50 -07:00
|
|
|
onget="return this._scale;"
|
|
|
|
onset="return this._setScale(val);"/>
|
2010-08-27 12:12:48 -07:00
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- These counters are used to update the cached viewport after they reach a certain
|
|
|
|
threshold when scrolling -->
|
|
|
|
<field name="_pendingPixelsX">0</field>
|
|
|
|
<field name="_pendingPixelsY">0</field>
|
2010-09-01 16:25:15 -07:00
|
|
|
<field name="_pendingThresholdX">0</field>
|
|
|
|
<field name="_pendingThresholdY">0</field>
|
|
|
|
<!-- This determines what percentage of cached pixels are not yet visible before the cache
|
2010-09-15 15:05:50 -07:00
|
|
|
is refreshed. For instance, if we recached at 25% and there are originally a total of
|
|
|
|
400px offscreen, we'd refresh once 100 of those pixels have been scrolled into
|
2010-09-01 16:25:15 -07:00
|
|
|
view. -->
|
2010-09-15 15:05:50 -07:00
|
|
|
<field name="_recacheRatio">1</field>
|
2010-08-30 14:11:49 -07:00
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- The cache viewport is what parts of content is cached in the parent process for
|
|
|
|
fast scrolling. This syncs that up with the current projection viewport. -->
|
|
|
|
<method name="_updateCacheViewport">
|
2010-08-30 14:11:49 -07:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-09-07 15:58:55 -07:00
|
|
|
let cacheX = this._pendingThresholdX / this._recacheRatio;
|
|
|
|
let cacheY = this._pendingThresholdY / this._recacheRatio;
|
|
|
|
let bcr = this.getBoundingClientRect();
|
2010-09-01 16:25:15 -07:00
|
|
|
|
2010-08-30 14:11:49 -07:00
|
|
|
let frameLoader = this._frameLoader;
|
2010-09-01 13:35:05 -07:00
|
|
|
this.messageManager.sendAsyncMessage("Content:SetCacheViewport", {
|
2010-09-15 15:05:50 -07:00
|
|
|
x: (frameLoader.viewportScrollX + bcr.width / 2 - cacheX) / this._scale,
|
|
|
|
y: (frameLoader.viewportScrollY + bcr.height / 2 - cacheY) / this._scale,
|
|
|
|
w: (cacheX * 2) / this._scale,
|
|
|
|
h: (cacheY * 2) / this._scale,
|
|
|
|
scale: this._scale
|
2010-08-30 14:11:49 -07:00
|
|
|
});
|
2010-09-01 13:35:05 -07:00
|
|
|
|
|
|
|
this._pendingPixelsX = 0;
|
|
|
|
this._pendingPixelsY = 0;
|
2010-08-30 14:11:49 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Synchronize the CSS viewport with the projection viewport. -->
|
2010-08-31 12:25:47 -07:00
|
|
|
<method name="_updateCSSViewport">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
|
|
|
this.messageManager.sendAsyncMessage("Content:ScrollTo", {
|
2010-09-15 15:05:50 -07:00
|
|
|
x: frameLoader.viewportScrollX / this._scale,
|
|
|
|
y: frameLoader.viewportScrollY / this._scale
|
2010-08-31 12:25:47 -07:00
|
|
|
});
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Sets the scale of CSS pixels to device pixels. Does not affect page layout. -->
|
2010-09-15 15:05:50 -07:00
|
|
|
<method name="_setScale">
|
|
|
|
<parameter name="scale"/>
|
2010-08-27 12:12:48 -07:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-09-15 17:56:47 -07:00
|
|
|
// XXX Not implemented for local browsers.
|
2010-08-27 12:12:48 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Sets size of CSS viewport, which affects how page is layout. -->
|
2010-09-15 15:05:50 -07:00
|
|
|
<method name="setWindowSize">
|
2010-08-27 15:01:32 -07:00
|
|
|
<parameter name="width"/>
|
|
|
|
<parameter name="height"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-09-15 15:05:50 -07:00
|
|
|
this._contentWindowWidth = width;
|
|
|
|
this._contentWindowHeight = height;
|
|
|
|
this.messageManager.sendAsyncMessage("Content:SetWindowSize", {
|
2010-08-27 15:01:32 -07:00
|
|
|
width: width,
|
|
|
|
height: height
|
|
|
|
});
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Scroll viewport by (x, y) device pixels. -->
|
2010-08-27 08:36:11 -07:00
|
|
|
<method name="scrollBy">
|
|
|
|
<parameter name="x"/>
|
|
|
|
<parameter name="y"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-09-30 14:34:17 -07:00
|
|
|
let position = this.getPosition();
|
|
|
|
x = Math.floor(Math.max(0, Math.min(this.contentDocumentWidth, position.x+x))-position.x);
|
|
|
|
y = Math.floor(Math.max(0, Math.min(this.contentDocumentHeight, position.y+y))-position.y);
|
2010-08-30 14:11:49 -07:00
|
|
|
this.contentWindow.scrollBy(x, y);
|
2010-08-27 08:36:11 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Scroll viewport to (x, y) offset of document in device pixels. -->
|
2010-08-27 08:36:11 -07:00
|
|
|
<method name="scrollTo">
|
|
|
|
<parameter name="x"/>
|
|
|
|
<parameter name="y"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-09-30 14:34:17 -07:00
|
|
|
x = Math.floor(Math.max(0, Math.min(this.contentDocumentWidth, x)));
|
|
|
|
y = Math.floor(Math.max(0, Math.min(this.contentDocumentHeight, y)));
|
2010-08-30 14:11:49 -07:00
|
|
|
this.contentWindow.scrollTo(x, y);
|
2010-08-27 08:36:11 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-01 13:35:05 -07:00
|
|
|
<!-- Get position of viewport in device pixels. -->
|
2010-08-27 08:36:11 -07:00
|
|
|
<method name="getPosition">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-09-15 15:05:50 -07:00
|
|
|
let scrollX = {}, scrollY = {};
|
2010-08-30 14:11:49 -07:00
|
|
|
let cwu = this.contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
|
|
|
cwu.getScrollXY(false, scrollX, scrollY);
|
2010-09-15 15:05:50 -07:00
|
|
|
return { x: scrollX.value, y: scrollY.value };
|
2010-08-27 08:36:11 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-30 09:51:34 -07:00
|
|
|
<!-- Change client coordinates in device pixels to page-relative ones in CSS px. -->
|
|
|
|
<method name="transformClientToBrowser">
|
|
|
|
<parameter name="clientX"/>
|
|
|
|
<parameter name="clientY"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let bcr = this.getBoundingClientRect();
|
|
|
|
let scroll = this.getPosition();
|
|
|
|
return { x: (clientX + scroll.x - bcr.left) / this._scale,
|
|
|
|
y: (clientY + scroll.y - bcr.top) / this._scale };
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<constructor>
|
2010-06-07 19:44:06 -07:00
|
|
|
<![CDATA[
|
2010-08-30 14:11:49 -07:00
|
|
|
this._frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
|
|
|
|
|
2010-09-01 16:25:15 -07:00
|
|
|
let prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefService)
|
|
|
|
.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
|
|
|
|
|
|
|
this._recacheRatio = Math.max(.01, Math.min(1, prefService.getIntPref("toolkit.browser.recacheRatio") / 100));
|
2010-09-03 13:52:08 -07:00
|
|
|
this._pendingThresholdX = Math.max(0, prefService.getIntPref("toolkit.browser.cachePixelX")) * this._recacheRatio;
|
|
|
|
this._pendingThresholdY = Math.max(0, prefService.getIntPref("toolkit.browser.cachePixelY")) * this._recacheRatio;
|
2010-09-01 16:25:15 -07:00
|
|
|
|
2010-08-27 08:36:11 -07:00
|
|
|
this.messageManager.loadFrameScript("chrome://browser/content/bindings/browser.js", true);
|
2010-09-24 11:48:39 -07:00
|
|
|
this.messageManager.addMessageListener("DOMTitleChanged", this._messageListenerLocal);
|
|
|
|
this.messageManager.addMessageListener("DOMLinkAdded", this._messageListenerLocal);
|
|
|
|
this.messageManager.addMessageListener("pageshow", this._messageListenerLocal);
|
|
|
|
this.messageManager.addMessageListener("pagehide", this._messageListenerLocal);
|
|
|
|
this.messageManager.addMessageListener("DOMPopupBlocked", this._messageListenerLocal);
|
|
|
|
this.messageManager.addMessageListener("MozScrolledAreaChanged", this._messageListenerLocal);
|
2010-08-27 08:36:11 -07:00
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
this._webProgress._init();
|
2010-06-07 19:44:06 -07:00
|
|
|
]]>
|
2010-06-08 12:30:46 -07:00
|
|
|
</constructor>
|
|
|
|
|
2010-10-29 12:44:00 -07:00
|
|
|
<method name="updateWindowId">
|
|
|
|
<parameter name="aNewId"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.contentWindowId != aNewId) {
|
|
|
|
this.contentWindowId = aNewId;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2010-06-08 12:30:46 -07:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="remote-browser" extends="#local-browser">
|
|
|
|
<implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener, nsIFrameMessageListener">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
throw "accessibleType: Supports Remote?";
|
|
|
|
]]>
|
2010-06-07 19:44:06 -07:00
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<property name="autoscrollEnabled">
|
2010-06-07 19:44:06 -07:00
|
|
|
<getter>
|
2010-06-08 12:30:46 -07:00
|
|
|
<![CDATA[
|
|
|
|
throw "autoscrollEnabled: Supports Remote?";
|
|
|
|
]]>
|
2010-06-07 19:44:06 -07:00
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<property name="docShell"
|
2010-11-11 20:53:33 -08:00
|
|
|
onget="return null"
|
2010-06-08 12:30:46 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<field name="_contentTitle">null</field>
|
|
|
|
|
2010-06-24 15:13:01 -07:00
|
|
|
<property name="contentTitle"
|
|
|
|
onget="return this._contentTitle;"
|
|
|
|
readonly="true"/>
|
2010-06-08 12:30:46 -07:00
|
|
|
|
|
|
|
<field name="_webNavigation"><![CDATA[
|
|
|
|
({
|
2010-06-29 06:19:50 -07:00
|
|
|
LOAD_FLAGS_MASK: 65535,
|
|
|
|
LOAD_FLAGS_NONE: 0,
|
|
|
|
LOAD_FLAGS_IS_REFRESH: 16,
|
|
|
|
LOAD_FLAGS_IS_LINK: 32,
|
|
|
|
LOAD_FLAGS_BYPASS_HISTORY: 64,
|
|
|
|
LOAD_FLAGS_REPLACE_HISTORY: 128,
|
|
|
|
LOAD_FLAGS_BYPASS_CACHE: 256,
|
|
|
|
LOAD_FLAGS_BYPASS_PROXY: 512,
|
|
|
|
LOAD_FLAGS_CHARSET_CHANGE: 1024,
|
|
|
|
LOAD_FLAGS_STOP_CONTENT: 2048,
|
|
|
|
LOAD_FLAGS_FROM_EXTERNAL: 4096,
|
|
|
|
LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP: 8192,
|
|
|
|
LOAD_FLAGS_FIRST_LOAD: 16384,
|
|
|
|
LOAD_FLAGS_ALLOW_POPUPS: 32768,
|
|
|
|
LOAD_FLAGS_BYPASS_CLASSIFIER: 65536,
|
|
|
|
LOAD_FLAGS_FORCE_ALLOW_COOKIES: 131072,
|
2010-08-26 16:55:32 -07:00
|
|
|
|
2010-06-29 06:19:50 -07:00
|
|
|
STOP_NETWORK: 1,
|
|
|
|
STOP_CONTENT: 2,
|
|
|
|
STOP_ALL: 3,
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
canGoBack: false,
|
|
|
|
canGoForward: false,
|
2010-06-24 15:13:01 -07:00
|
|
|
goBack: function() { this._sendMessage("WebNavigation:GoBack", {}); },
|
|
|
|
goForward: function() { this._sendMessage("WebNavigation:GoForward", {}); },
|
|
|
|
gotoIndex: function(aIndex) { this._sendMessage("WebNavigation:GotoIndex", {index: aIndex}); },
|
2010-06-08 12:30:46 -07:00
|
|
|
loadURI: function(aURI, aLoadFlags, aReferrer, aPostData, aHeaders) {
|
|
|
|
this._browser._contentTitle = "";
|
2010-06-24 15:13:01 -07:00
|
|
|
this._sendMessage("WebNavigation:LoadURI", {uri: aURI, flags: aLoadFlags});
|
2010-06-08 12:30:46 -07:00
|
|
|
},
|
2010-06-24 15:13:01 -07:00
|
|
|
reload: function(aReloadFlags) { this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags}); },
|
|
|
|
stop: function(aStopFlags) { this._sendMessage("WebNavigation:Stop", {flags: aStopFlags}); },
|
2010-06-25 08:28:42 -07:00
|
|
|
get document() { Components.utils.reportError("contentDocument is not available"); return null; },
|
2010-06-08 12:30:46 -07:00
|
|
|
get currentURI() {
|
|
|
|
if (!this._currentURI)
|
|
|
|
this._currentURI = this._browser._ios.newURI("about:blank", null, null);
|
|
|
|
|
|
|
|
return this._currentURI;
|
|
|
|
},
|
|
|
|
set currentURI(aURI) { this.loadURI(aURI.spec, null, null, null); },
|
|
|
|
referringURI: null,
|
2010-07-18 22:27:52 -07:00
|
|
|
get sessionHistory() { return null; },
|
|
|
|
set sessionHistory(aValue) { },
|
2010-06-08 12:30:46 -07:00
|
|
|
|
|
|
|
_currentURI: null,
|
|
|
|
_browser: this,
|
2010-06-24 15:13:01 -07:00
|
|
|
_sendMessage: function(aMessage, aData) {
|
2010-06-08 12:30:46 -07:00
|
|
|
try {
|
|
|
|
this._browser.messageManager.sendAsyncMessage(aMessage, aData);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
Components.utils.reportError(e);
|
|
|
|
}
|
2010-06-29 06:19:50 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
QueryInterface: function(aIID) {
|
|
|
|
if (aIID.equals(Components.interfaces.nsIWebNavigation) || aIID.equals(Components.interfaces.nsISupports))
|
|
|
|
return this;
|
|
|
|
throw Components.results.NS_NOINTERFACE;
|
2010-06-08 12:30:46 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
|
|
|
<property name="webNavigation"
|
|
|
|
onget="return this._webNavigation;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
<field name="_webProgress"><![CDATA[
|
|
|
|
({
|
|
|
|
_listeners: [],
|
|
|
|
_browser: this,
|
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StateChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:ProgressChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:LocationChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StatusChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:SecurityChange", this);
|
|
|
|
},
|
|
|
|
|
|
|
|
addProgressListener: function(aListener, aNotifyFlags) {
|
|
|
|
function hasFilter(item) {
|
|
|
|
return item.listener == aListener;
|
|
|
|
}
|
2010-06-09 13:07:32 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
if (this._listeners.some(hasFilter))
|
|
|
|
return;
|
2010-06-09 13:07:32 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
this._listeners.push({
|
|
|
|
listener: aListener,
|
|
|
|
flags: aNotifyFlags
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeProgressListener: function(aListener) {
|
|
|
|
function hasFilter(item) {
|
|
|
|
return item.listener != aListener;
|
|
|
|
}
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
this._listeners = this._listeners.filter(hasFilter);
|
|
|
|
},
|
2010-11-11 20:53:33 -08:00
|
|
|
get DOMWindow() { return null; },
|
|
|
|
get isLoadingDocument() { throw "isLoadingDocument: Invalid"; },
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
receiveMessage: function(aMessage) {
|
|
|
|
let args;
|
2010-06-08 08:22:20 -07:00
|
|
|
let json = aMessage.json;
|
2010-06-07 19:44:06 -07:00
|
|
|
switch (aMessage.name) {
|
|
|
|
case "WebProgress:StateChange":
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.stateFlags,
|
|
|
|
json.status
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-08 08:22:20 -07:00
|
|
|
this._notify(json.notifyFlags, "onStateChange", args);
|
2010-06-07 19:44:06 -07:00
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:ProgressChange":
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.curSelf,
|
|
|
|
json.maxSelf,
|
|
|
|
json.curTotal,
|
|
|
|
json.maxTotal
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-07 19:44:06 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS,
|
|
|
|
"onProgressChange",
|
|
|
|
args);
|
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:LocationChange":
|
2010-06-09 13:07:32 -07:00
|
|
|
let locationURI = this._browser._ios.newURI(json.location, null, null);
|
|
|
|
this._browser._webNavigation._currentURI = locationURI;
|
2010-06-08 12:30:46 -07:00
|
|
|
this._browser._webNavigation.canGoBack = json.canGoBack;
|
|
|
|
this._browser._webNavigation.canGoForward = json.canGoForward;
|
2010-06-07 19:44:06 -07:00
|
|
|
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-09 13:07:32 -07:00
|
|
|
locationURI
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-10-29 12:44:00 -07:00
|
|
|
if (this._browser.updateWindowId(json.windowId)) {
|
2010-06-08 08:22:20 -07:00
|
|
|
this._browser._documentURI = json.documentURI;
|
|
|
|
this._browser._searchEngines = [];
|
|
|
|
}
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_LOCATION,
|
|
|
|
"onLocationChange",
|
|
|
|
args);
|
|
|
|
|
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:StatusChange":
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.status,
|
|
|
|
json.message
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-07 19:44:06 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_STATUS,
|
|
|
|
"onStatusChange",
|
|
|
|
args);
|
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:SecurityChange":
|
2010-10-26 06:57:59 -07:00
|
|
|
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
|
|
|
|
.getService(Ci.nsISerializationHelper);
|
|
|
|
let SSLStatus = json.SSLStatusAsString ?
|
|
|
|
serhelper.deserializeObject(json.SSLStatusAsString) : null;
|
|
|
|
|
|
|
|
if (SSLStatus) {
|
|
|
|
SSLStatus.QueryInterface(Ci.nsISSLStatus);
|
|
|
|
if (SSLStatus) {
|
|
|
|
// We must check the Extended Validation (EV) state here, on the chrome
|
|
|
|
// process, because NSS is needed for that determination.
|
|
|
|
let ii = SSLStatus.serverCert.QueryInterface(Ci.nsIIdentityInfo);
|
|
|
|
if (ii && ii.isExtendedValidation)
|
|
|
|
json.state |= Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let data = this._getIdentityData(SSLStatus);
|
|
|
|
this._browser._securityUI = {
|
|
|
|
SSLStatus: SSLStatus ? {serverCert: data} : null,
|
|
|
|
state: json.state
|
|
|
|
}
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
args = [
|
2010-06-16 06:53:29 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.state
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-10-29 12:44:00 -07:00
|
|
|
this._browser.updateWindowId(json.windowId);
|
2010-06-07 19:44:06 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_SECURITY,
|
|
|
|
"onSecurityChange",
|
|
|
|
args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
_notify: function(aFlags, aName, aArguments) {
|
|
|
|
this._listeners.forEach(function(item) {
|
|
|
|
if (item.flags & aFlags)
|
|
|
|
item.listener[aName].apply(item.listener, aArguments);
|
|
|
|
});
|
2010-10-26 06:57:59 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to parse out the important parts of the SSL cert for use in constructing
|
|
|
|
* identity UI strings
|
|
|
|
*/
|
|
|
|
_getIdentityData: function(status) {
|
|
|
|
let result = {};
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
let cert = status.serverCert;
|
|
|
|
|
|
|
|
// Human readable name of Subject
|
|
|
|
result.subjectOrg = cert.organization;
|
|
|
|
|
|
|
|
// SubjectName fields, broken up for individual access
|
|
|
|
if (cert.subjectName) {
|
|
|
|
result.subjectNameFields = {};
|
|
|
|
cert.subjectName.split(",").forEach(function(v) {
|
|
|
|
var field = v.split("=");
|
|
|
|
if (field[1])
|
|
|
|
this[field[0]] = field[1];
|
|
|
|
}, result.subjectNameFields);
|
|
|
|
|
|
|
|
// Call out city, state, and country specifically
|
|
|
|
result.city = result.subjectNameFields.L;
|
|
|
|
result.state = result.subjectNameFields.ST;
|
|
|
|
result.country = result.subjectNameFields.C;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Human readable name of Certificate Authority
|
|
|
|
result.caOrg = cert.issuerOrganization || cert.issuerCommonName;
|
|
|
|
|
|
|
|
if (!this._overrideService)
|
|
|
|
this._overrideService = Cc["@mozilla.org/security/certoverride;1"].getService(Ci.nsICertOverrideService);
|
|
|
|
|
|
|
|
// Check whether this site is a security exception.
|
|
|
|
let currentURI = this._browser._webNavigation._currentURI;
|
|
|
|
result.isException = !!this._overrideService.hasMatchingOverride(currentURI.asciiHost, currentURI.port, cert, {}, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2010-06-07 19:44:06 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
|
|
|
<property name="contentWindow"
|
|
|
|
readonly="true"
|
2010-06-23 12:23:06 -07:00
|
|
|
onget="return null"/>
|
2010-06-07 19:44:06 -07:00
|
|
|
|
|
|
|
<property name="sessionHistory"
|
2010-11-11 20:53:33 -08:00
|
|
|
onget="return null"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="markupDocumentViewer"
|
2010-11-11 20:53:33 -08:00
|
|
|
onget="return null"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="contentViewerEdit"
|
2010-11-11 20:53:33 -08:00
|
|
|
onget="return null"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="contentViewerFile"
|
2010-11-11 20:53:33 -08:00
|
|
|
onget="return null"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="documentCharsetInfo"
|
2010-11-11 20:53:33 -08:00
|
|
|
onget="return null"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
2010-08-30 14:11:49 -07:00
|
|
|
|
2010-09-24 11:48:39 -07:00
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
|
|
|
this.messageManager.addMessageListener("scroll", this._messageListenerRemote);
|
|
|
|
]]>
|
|
|
|
</constructor>
|
|
|
|
|
2010-10-25 07:35:13 -07:00
|
|
|
<field name="scrollSync">true</field>
|
|
|
|
|
2010-09-24 11:48:39 -07:00
|
|
|
<field name="_messageListenerRemote"><![CDATA[
|
|
|
|
({
|
|
|
|
self: this,
|
|
|
|
receiveMessage: function receiveMessage(aMessage) {
|
|
|
|
let self = this.self;
|
|
|
|
let json = aMessage.json;
|
|
|
|
|
|
|
|
switch (aMessage.name) {
|
|
|
|
case "scroll":
|
2010-10-25 17:19:00 -07:00
|
|
|
if (!self.scrollSync)
|
2010-10-25 07:35:13 -07:00
|
|
|
return;
|
|
|
|
|
2010-09-24 11:48:39 -07:00
|
|
|
// When CSS scroll offset changes, we must redefine our cache viewport because
|
|
|
|
// the cache viewport coordinate system's origin is the CSS scroll offset. Setting
|
|
|
|
// _pendingPixels* guarantees that _updateCacheViewport is called in scrollTo.
|
|
|
|
self._pendingPixelsX = Number.MAX_VALUE;
|
|
|
|
self._pendingPixelsY = Number.MAX_VALUE;
|
|
|
|
|
|
|
|
// Use floor so that we always guarantee top-left corner of content is visible.
|
|
|
|
self.scrollTo(Math.floor(json.x * self.scale), Math.floor(json.y * self.scale));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
2010-09-15 17:56:47 -07:00
|
|
|
<!-- Sets the scale of CSS pixels to device pixels. Does not affect page layout. -->
|
|
|
|
<method name="_setScale">
|
|
|
|
<parameter name="scale"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (scale <= 0) throw "Bad scale given.";
|
|
|
|
|
|
|
|
this._scale = scale;
|
|
|
|
this._frameLoader.setViewportScale(scale, scale);
|
|
|
|
this._updateCacheViewport();
|
|
|
|
|
|
|
|
let event = document.createEvent("Events");
|
|
|
|
event.initEvent("ZoomChanged", true, false);
|
|
|
|
this.dispatchEvent(event);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-15 15:05:50 -07:00
|
|
|
<!-- Scroll by (x, y) device pixels -->
|
2010-08-30 14:11:49 -07:00
|
|
|
<method name="scrollBy">
|
|
|
|
<parameter name="x"/>
|
|
|
|
<parameter name="y"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
|
|
|
|
2010-09-15 15:05:50 -07:00
|
|
|
// Bounding content rectangle is in device pixels
|
2010-08-30 14:11:49 -07:00
|
|
|
let bcr = this.getBoundingClientRect();
|
|
|
|
let viewportWidth = bcr.width;
|
|
|
|
let viewportHeight = bcr.height;
|
2010-09-15 15:05:50 -07:00
|
|
|
// Calculate document dimensions in device pixels
|
|
|
|
let docWidth = this.contentDocumentWidth * this.scale;
|
|
|
|
let docHeight = this.contentDocumentHeight * this.scale;
|
2010-08-30 14:11:49 -07:00
|
|
|
|
2010-09-15 15:05:50 -07:00
|
|
|
x = Math.floor(Math.max(0, Math.min(docWidth - viewportWidth, frameLoader.viewportScrollX + x)) - frameLoader.viewportScrollX);
|
|
|
|
y = Math.floor(Math.max(0, Math.min(docHeight - viewportHeight, frameLoader.viewportScrollY + y)) - frameLoader.viewportScrollY);
|
2010-08-30 14:11:49 -07:00
|
|
|
|
|
|
|
if (x == 0 && y == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
frameLoader.scrollViewportBy(x, y);
|
|
|
|
|
2010-09-01 16:25:15 -07:00
|
|
|
// Add this to the amount of pixels we have "used" from our cache. When this hits the
|
|
|
|
// threshold, we will refresh.
|
2010-08-30 14:11:49 -07:00
|
|
|
this._pendingPixelsX += x;
|
|
|
|
this._pendingPixelsY += y;
|
|
|
|
|
2010-09-08 11:29:14 -07:00
|
|
|
if (Math.abs(this._pendingPixelsX) > Math.max(0, this._pendingThresholdX - bcr.width / 2) ||
|
|
|
|
Math.abs(this._pendingPixelsY) > Math.max(0, this._pendingThresholdY - bcr.height / 2))
|
2010-09-01 13:35:05 -07:00
|
|
|
this._updateCacheViewport();
|
2010-08-30 14:11:49 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-15 15:05:50 -07:00
|
|
|
<!-- Scroll to position (x, y) in device pixels -->
|
2010-08-30 14:11:49 -07:00
|
|
|
<method name="scrollTo">
|
|
|
|
<parameter name="x"/>
|
|
|
|
<parameter name="y"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
|
|
|
this.scrollBy(x - frameLoader.viewportScrollX, y - frameLoader.viewportScrollY);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-15 15:05:50 -07:00
|
|
|
<!-- Get position of window in device pixels -->
|
2010-08-30 14:11:49 -07:00
|
|
|
<method name="getPosition">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
2010-09-15 15:05:50 -07:00
|
|
|
return { x: frameLoader.viewportScrollX, y: frameLoader.viewportScrollY };
|
2010-08-30 14:11:49 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2010-06-07 19:44:06 -07:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|