Bug 370760 - Wrap calls to get content properties, and expand wrappers for theses. ChatZilla only. r=gijs
git-svn-id: svn://10.0.0.236/trunk@220709 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
44d037c5a2
commit
f9f3af9dc5
@ -610,6 +610,9 @@ function getContentWindow(frame)
|
||||
if (!frame || !("contentWindow" in frame))
|
||||
return false;
|
||||
|
||||
// The "in" operator does not detect wrappedJSObject, so don't bother.
|
||||
if (frame.contentWindow.wrappedJSObject)
|
||||
return frame.contentWindow.wrappedJSObject;
|
||||
return frame.contentWindow;
|
||||
}
|
||||
catch (ex)
|
||||
@ -619,6 +622,25 @@ function getContentWindow(frame)
|
||||
}
|
||||
}
|
||||
|
||||
function getContentDocument(frame)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!frame || !("contentDocument" in frame))
|
||||
return false;
|
||||
|
||||
// The "in" operator does not detect wrappedJSObject, so don't bother.
|
||||
if (frame.contentDocument.wrappedJSObject)
|
||||
return frame.contentDocument.wrappedJSObject;
|
||||
return frame.contentDocument;
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
// throws exception is contentDocument is gone
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getPriv (priv)
|
||||
{
|
||||
if (!jsenv.HAS_SECURITYMANAGER)
|
||||
|
||||
@ -1144,7 +1144,7 @@ function cmdSync(e)
|
||||
var view = e.sourceObject;
|
||||
var window;
|
||||
if (("frame" in view) && view.frame)
|
||||
window = view.frame.contentWindow;
|
||||
window = getContentWindow(view.frame);
|
||||
|
||||
try
|
||||
{
|
||||
@ -2212,7 +2212,7 @@ function cmdGotoURL(e)
|
||||
if (e.url.search(/^x-cz-command:/i) == 0)
|
||||
{
|
||||
var ary = e.url.match(/^x-cz-command:(.*)$/i);
|
||||
e.sourceObject.frame.contentWindow.location.href =
|
||||
getContentWindow(e.sourceObject.frame).location.href =
|
||||
"javascript:void(view.dispatch('" + decodeURI(ary[1]) + "', null, true))";
|
||||
return;
|
||||
}
|
||||
@ -3025,10 +3025,9 @@ function cmdPref (e)
|
||||
function cmdPrint(e)
|
||||
{
|
||||
if (("frame" in e.sourceObject) && e.sourceObject.frame &&
|
||||
("contentWindow" in e.sourceObject.frame) &&
|
||||
e.sourceObject.frame.contentWindow)
|
||||
getContentWindow(e.sourceObject.frame))
|
||||
{
|
||||
e.sourceObject.frame.contentWindow.print();
|
||||
getContentWindow(e.sourceObject.frame).print();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3504,7 +3503,7 @@ function cmdSave(e)
|
||||
| nsIWBP.PERSIST_FLAGS_DONT_CHANGE_FILENAMES;
|
||||
|
||||
// Set the document from the current view, and set a usable title
|
||||
docToBeSaved = e.sourceObject.frame.contentDocument;
|
||||
docToBeSaved = getContentDocument(e.sourceObject.frame);
|
||||
var headElement = docToBeSaved.getElementsByTagName("HEAD")[0];
|
||||
var titleElements = docToBeSaved.getElementsByTagName("title");
|
||||
// Remove an existing title, there shouldn't be more than one.
|
||||
@ -4225,7 +4224,7 @@ function cmdDCCDecline(e)
|
||||
function cmdTextDirection(e)
|
||||
{
|
||||
var direction;
|
||||
var sourceObject = e.sourceObject.frame.contentDocument.body;
|
||||
var sourceObject = getContentDocument(e.sourceObject.frame).body;
|
||||
|
||||
switch (e.dir)
|
||||
{
|
||||
|
||||
@ -644,8 +644,8 @@ function getFindData(e)
|
||||
{
|
||||
var findData = new nsFindInstData();
|
||||
findData.browser = e.sourceObject.frame;
|
||||
findData.rootSearchWindow = e.sourceObject.frame.contentWindow;
|
||||
findData.currentSearchWindow = e.sourceObject.frame.contentWindow;
|
||||
findData.rootSearchWindow = getContentWindow(e.sourceObject.frame);
|
||||
findData.currentSearchWindow = getContentWindow(e.sourceObject.frame);
|
||||
|
||||
/* Yay, evil hacks! findData.init doesn't care about the findService, it
|
||||
* gets option settings from webBrowserFind. As we want the wrap option *on*
|
||||
@ -2876,12 +2876,11 @@ function setCurrentObject (obj)
|
||||
// Input area should have the same direction as the output area
|
||||
if (("frame" in client.currentObject) &&
|
||||
client.currentObject.frame &&
|
||||
("contentDocument" in client.currentObject.frame) &&
|
||||
client.currentObject.frame.contentDocument &&
|
||||
("body" in client.currentObject.frame.contentDocument) &&
|
||||
client.currentObject.frame.contentDocument.body)
|
||||
getContentDocument(client.currentObject.frame) &&
|
||||
("body" in getContentDocument(client.currentObject.frame)) &&
|
||||
getContentDocument(client.currentObject.frame).body)
|
||||
{
|
||||
var contentArea = client.currentObject.frame.contentDocument.body;
|
||||
var contentArea = getContentDocument(client.currentObject.frame).body;
|
||||
client.input.setAttribute("dir", contentArea.getAttribute("dir"));
|
||||
}
|
||||
client.input.focus();
|
||||
@ -3255,7 +3254,7 @@ function syncOutputFrame(obj, nesting)
|
||||
|
||||
try
|
||||
{
|
||||
if (("contentDocument" in iframe) && ("webProgress" in iframe))
|
||||
if (getContentDocument(iframe) && ("webProgress" in iframe))
|
||||
{
|
||||
var url = obj.prefs["outputWindowURL"];
|
||||
iframe.addProgressListener(client.progressListener, ALL);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user