зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to m-i
This commit is contained in:
Коммит
549da4455a
2
CLOBBER
2
CLOBBER
|
@ -15,4 +15,4 @@
|
|||
#
|
||||
# Note: The description below will be part of the error message shown to users.
|
||||
#
|
||||
Bug 648407 - Fold NSPR, NSS and SQLite libraries all together on B2G, Android, OSX and Windows
|
||||
Bug 851908 - The WebIDL build system has some problems picking up dependencies.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<title>&abouthome.pageTitle;</title>
|
||||
|
||||
<link rel="icon" type="image/png" id="favicon"
|
||||
href="chrome://branding/content/icon16.png"/>
|
||||
href="chrome://branding/content/icon32.png"/>
|
||||
<link rel="stylesheet" type="text/css" media="all"
|
||||
href="chrome://browser/content/abouthome/aboutHome.css"/>
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
function test1() {
|
||||
let plugin = document.getElementById('plugin');
|
||||
ok(plugin, 'got plugin element');
|
||||
let objLC = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
let objLC = SpecialPowers.wrap(plugin);
|
||||
ok(!objLC.activated, 'plugin should not be activated');
|
||||
|
||||
synthesizeMouseAtCenter(plugin, {});
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
Components.utils.import("resource:///modules/RecentWindow.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () {
|
||||
const PREF = "browser.newtab.url";
|
||||
|
@ -58,12 +59,9 @@ function getTopWin(skipPopups) {
|
|||
(!skipPopups || top.toolbar.visible))
|
||||
return top;
|
||||
|
||||
if (skipPopups) {
|
||||
return Components.classes["@mozilla.org/browser/browserglue;1"]
|
||||
.getService(Components.interfaces.nsIBrowserGlue)
|
||||
.getMostRecentBrowserWindow();
|
||||
}
|
||||
return Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
return RecentWindow.getMostRecentBrowserWindow({private: isPrivate,
|
||||
allowPopups: !skipPopups});
|
||||
}
|
||||
|
||||
function openTopWin(url) {
|
||||
|
|
|
@ -11,4 +11,5 @@ browser.jar:
|
|||
content/branding/icon48.png (icon48.png)
|
||||
content/branding/icon64.png (icon64.png)
|
||||
content/branding/icon16.png (../default16.png)
|
||||
content/branding/icon32.png (../default32.png)
|
||||
content/branding/aboutDialog.css (aboutDialog.css)
|
||||
|
|
|
@ -11,4 +11,5 @@ browser.jar:
|
|||
content/branding/icon48.png (icon48.png)
|
||||
content/branding/icon64.png (icon64.png)
|
||||
content/branding/icon16.png (../default16.png)
|
||||
content/branding/icon32.png (../default32.png)
|
||||
content/branding/aboutDialog.css (aboutDialog.css)
|
||||
|
|
|
@ -10,4 +10,5 @@ browser.jar:
|
|||
content/branding/icon48.png (icon48.png)
|
||||
content/branding/icon64.png (icon64.png)
|
||||
content/branding/icon16.png (../default16.png)
|
||||
content/branding/icon32.png (../default32.png)
|
||||
content/branding/aboutDialog.css (aboutDialog.css)
|
||||
|
|
|
@ -11,4 +11,5 @@ browser.jar:
|
|||
content/branding/icon48.png (icon48.png)
|
||||
content/branding/icon64.png (icon64.png)
|
||||
content/branding/icon16.png (../default16.png)
|
||||
content/branding/icon32.png (../default32.png)
|
||||
content/branding/aboutDialog.css (aboutDialog.css)
|
||||
|
|
|
@ -277,6 +277,7 @@ var gPrivacyPane = {
|
|||
shouldProceed = !cancelQuit.data;
|
||||
|
||||
if (shouldProceed) {
|
||||
pref.value = autoStart.hasAttribute('checked');
|
||||
document.documentElement.acceptDialog();
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Ci.nsIAppStartup);
|
||||
|
|
|
@ -280,6 +280,7 @@ var gPrivacyPane = {
|
|||
shouldProceed = !cancelQuit.data;
|
||||
|
||||
if (shouldProceed) {
|
||||
pref.value = autoStart.hasAttribute('checked');
|
||||
document.documentElement.acceptDialog();
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Ci.nsIAppStartup);
|
||||
|
|
|
@ -152,6 +152,29 @@ let Util = {
|
|||
return null;
|
||||
},
|
||||
|
||||
isTextInput: function isTextInput(aElement) {
|
||||
return ((aElement instanceof Ci.nsIDOMHTMLInputElement &&
|
||||
aElement.mozIsTextField(false)) ||
|
||||
aElement instanceof Ci.nsIDOMHTMLTextAreaElement);
|
||||
},
|
||||
|
||||
isLink: function isLink(aElement) {
|
||||
return ((aElement instanceof Ci.nsIDOMHTMLAnchorElement && aElement.href) ||
|
||||
(aElement instanceof Ci.nsIDOMHTMLAreaElement && aElement.href) ||
|
||||
aElement instanceof Ci.nsIDOMHTMLLinkElement ||
|
||||
aElement.getAttributeNS(kXLinkNamespace, "type") == "simple");
|
||||
},
|
||||
|
||||
isText: function isText(aElement) {
|
||||
return (aElement instanceof Ci.nsIDOMHTMLParagraphElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLDivElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLLIElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLPreElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLHeadingElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLTableCellElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLBodyElement);
|
||||
},
|
||||
|
||||
/*
|
||||
* Rect and nsIDOMRect utilities
|
||||
*/
|
||||
|
|
|
@ -334,13 +334,13 @@ let Content = {
|
|||
|
||||
case "click":
|
||||
if (aEvent.eventPhase == aEvent.BUBBLING_PHASE)
|
||||
this._onClick(aEvent);
|
||||
this._onClickBubble(aEvent);
|
||||
else
|
||||
this._genericMouseClick(aEvent);
|
||||
this._onClickCapture(aEvent);
|
||||
break;
|
||||
|
||||
case "DOMContentLoaded":
|
||||
this._maybeNotifyErroPage();
|
||||
this._maybeNotifyErrorPage();
|
||||
break;
|
||||
|
||||
case "pagehide":
|
||||
|
@ -350,7 +350,7 @@ let Content = {
|
|||
|
||||
case "touchstart":
|
||||
let touch = aEvent.changedTouches[0];
|
||||
this._genericMouseDown(touch.clientX, touch.clientY);
|
||||
this._onTouchStart(touch.clientX, touch.clientY);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -400,13 +400,10 @@ let Content = {
|
|||
},
|
||||
|
||||
/******************************************************
|
||||
* generic input handlers
|
||||
*
|
||||
* regardless of whether the input was received via
|
||||
* message manager or sent directly via dispatch.
|
||||
* Event handlers
|
||||
*/
|
||||
|
||||
_genericMouseDown: function _genericMouseDown(x, y) {
|
||||
_onTouchStart: function _onTouchStart(x, y) {
|
||||
let { element } = elementFromPoint(x, y);
|
||||
if (!element)
|
||||
return;
|
||||
|
@ -421,7 +418,7 @@ let Content = {
|
|||
this._doTapHighlight(element);
|
||||
},
|
||||
|
||||
_genericMouseClick: function _genericMouseClick(aEvent) {
|
||||
_onClickCapture: function _onClickCapture(aEvent) {
|
||||
ContextMenuHandler.reset();
|
||||
|
||||
let { element: element } = elementFromPoint(aEvent.clientX, aEvent.clientY);
|
||||
|
@ -443,12 +440,8 @@ let Content = {
|
|||
this.formAssistant.focusSync = false;
|
||||
},
|
||||
|
||||
/******************************************************
|
||||
* Event handlers
|
||||
*/
|
||||
|
||||
// Checks clicks we care about - events bubbling up from about pages.
|
||||
_onClick: function _onClick(aEvent) {
|
||||
_onClickBubble: function _onClickBubble(aEvent) {
|
||||
// Don't trust synthetic events
|
||||
if (!aEvent.isTrusted)
|
||||
return;
|
||||
|
@ -531,7 +524,7 @@ let Content = {
|
|||
return result;
|
||||
},
|
||||
|
||||
_maybeNotifyErroPage: function _maybeNotifyErroPage() {
|
||||
_maybeNotifyErrorPage: function _maybeNotifyErrorPage() {
|
||||
// Notify browser that an error page is being shown instead
|
||||
// of the target location. Necessary to get proper thumbnail
|
||||
// updates on chrome for error pages.
|
||||
|
|
|
@ -133,7 +133,7 @@ var ContextMenuHandler = {
|
|||
*/
|
||||
|
||||
_onSelectAll: function _onSelectAll() {
|
||||
if (this._isTextInput(this._target)) {
|
||||
if (Util.isTextInput(this._target)) {
|
||||
// select all text in the input control
|
||||
this._target.select();
|
||||
} else {
|
||||
|
@ -145,7 +145,7 @@ var ContextMenuHandler = {
|
|||
|
||||
_onPaste: function _onPaste() {
|
||||
// paste text if this is an input control
|
||||
if (this._isTextInput(this._target)) {
|
||||
if (Util.isTextInput(this._target)) {
|
||||
let edit = this._target.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
if (edit) {
|
||||
edit.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
|
||||
|
@ -161,7 +161,7 @@ var ContextMenuHandler = {
|
|||
},
|
||||
|
||||
_onCut: function _onCut() {
|
||||
if (this._isTextInput(this._target)) {
|
||||
if (Util.isTextInput(this._target)) {
|
||||
let edit = this._target.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
if (edit) {
|
||||
edit.editor.cut();
|
||||
|
@ -173,7 +173,7 @@ var ContextMenuHandler = {
|
|||
},
|
||||
|
||||
_onCopy: function _onCopy() {
|
||||
if (this._isTextInput(this._target)) {
|
||||
if (Util.isTextInput(this._target)) {
|
||||
let edit = this._target.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
if (edit) {
|
||||
edit.editor.copy();
|
||||
|
@ -281,7 +281,7 @@ var ContextMenuHandler = {
|
|||
while (elem) {
|
||||
if (elem.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) {
|
||||
// is the target a link or a descendant of a link?
|
||||
if (this._isLink(elem)) {
|
||||
if (Util.isLink(elem)) {
|
||||
// If this is an image that links to itself, don't include both link and
|
||||
// image otpions.
|
||||
if (imageUrl == this._getLinkURL(elem)) {
|
||||
|
@ -297,7 +297,7 @@ var ContextMenuHandler = {
|
|||
// mark as text so we can pickup on selection below
|
||||
isText = true;
|
||||
break;
|
||||
} else if (this._isTextInput(elem)) {
|
||||
} else if (Util.isTextInput(elem)) {
|
||||
let selectionStart = elem.selectionStart;
|
||||
let selectionEnd = elem.selectionEnd;
|
||||
|
||||
|
@ -330,7 +330,7 @@ var ContextMenuHandler = {
|
|||
state.types.push("paste");
|
||||
}
|
||||
break;
|
||||
} else if (this._isText(elem)) {
|
||||
} else if (Util.isText(elem)) {
|
||||
isText = true;
|
||||
} else if (elem instanceof Ci.nsIDOMHTMLMediaElement ||
|
||||
elem instanceof Ci.nsIDOMHTMLVideoElement) {
|
||||
|
@ -381,29 +381,6 @@ var ContextMenuHandler = {
|
|||
sendAsyncMessage("Content:ContextMenu", state);
|
||||
},
|
||||
|
||||
_isTextInput: function _isTextInput(element) {
|
||||
return ((element instanceof Ci.nsIDOMHTMLInputElement &&
|
||||
element.mozIsTextField(false)) ||
|
||||
element instanceof Ci.nsIDOMHTMLTextAreaElement);
|
||||
},
|
||||
|
||||
_isLink: function _isLink(element) {
|
||||
return ((element instanceof Ci.nsIDOMHTMLAnchorElement && element.href) ||
|
||||
(element instanceof Ci.nsIDOMHTMLAreaElement && element.href) ||
|
||||
element instanceof Ci.nsIDOMHTMLLinkElement ||
|
||||
element.getAttributeNS(kXLinkNamespace, "type") == "simple");
|
||||
},
|
||||
|
||||
_isText: function _isText(element) {
|
||||
return (element instanceof Ci.nsIDOMHTMLParagraphElement ||
|
||||
element instanceof Ci.nsIDOMHTMLDivElement ||
|
||||
element instanceof Ci.nsIDOMHTMLLIElement ||
|
||||
element instanceof Ci.nsIDOMHTMLPreElement ||
|
||||
element instanceof Ci.nsIDOMHTMLHeadingElement ||
|
||||
element instanceof Ci.nsIDOMHTMLTableCellElement ||
|
||||
element instanceof Ci.nsIDOMHTMLBodyElement);
|
||||
},
|
||||
|
||||
_getLinkURL: function ch_getLinkURL(aLink) {
|
||||
let href = aLink.href;
|
||||
if (href)
|
||||
|
|
|
@ -53,58 +53,51 @@ function FormAssistant() {
|
|||
};
|
||||
|
||||
FormAssistant.prototype = {
|
||||
_els: Cc["@mozilla.org/eventlistenerservice;1"].getService(Ci.nsIEventListenerService),
|
||||
_open: false,
|
||||
_focusSync: false,
|
||||
_debugEvents: false,
|
||||
_selectWrapper: null,
|
||||
_currentIndex: -1,
|
||||
_elements: [],
|
||||
|
||||
_currentElement: null,
|
||||
invalidSubmit: false,
|
||||
|
||||
get focusSync() {
|
||||
return this._focusSync;
|
||||
},
|
||||
|
||||
set focusSync(aVal) {
|
||||
this._focusSync = aVal;
|
||||
},
|
||||
|
||||
get currentElement() {
|
||||
return this._elements[this._currentIndex];
|
||||
return this._currentElement;
|
||||
},
|
||||
|
||||
get currentIndex() {
|
||||
return this._currentIndex;
|
||||
},
|
||||
|
||||
set currentIndex(aIndex) {
|
||||
let element = this._elements[aIndex];
|
||||
if (!element)
|
||||
return -1;
|
||||
|
||||
if (this._isVisibleElement(element)) {
|
||||
this._currentIndex = aIndex;
|
||||
gFocusManager.setFocus(element, Ci.nsIFocusManager.FLAG_NOSCROLL);
|
||||
|
||||
// To ensure we get the current caret positionning of the focused
|
||||
// element we need to delayed a bit the event
|
||||
this._executeDelayed(function(self) {
|
||||
// Bug 640870
|
||||
// Sometimes the element inner frame get destroyed while the element
|
||||
// receive the focus because the display is turned to 'none' for
|
||||
// example, in this "fun" case just do nothing if the element is hidden
|
||||
if (self._isVisibleElement(gFocusManager.focusedElement))
|
||||
sendAsyncMessage("FormAssist:Show", self._getJSON());
|
||||
});
|
||||
} else {
|
||||
// Repopulate the list of elements in the page, some could have gone
|
||||
// because of AJAX changes for example
|
||||
this._elements = [];
|
||||
let currentIndex = this._getAllElements(gFocusManager.focusedElement)
|
||||
|
||||
if (aIndex < this._currentIndex)
|
||||
this.currentIndex = currentIndex - 1;
|
||||
else if (aIndex > this._currentIndex)
|
||||
this.currentIndex = currentIndex + 1;
|
||||
else if (this._currentIndex != currentIndex)
|
||||
this.currentIndex = currentIndex;
|
||||
set currentElement(aElement) {
|
||||
if (!aElement || !this._isVisibleElement(aElement)) {
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
|
||||
this._currentElement = aElement;
|
||||
gFocusManager.setFocus(this._currentElement, Ci.nsIFocusManager.FLAG_NOSCROLL);
|
||||
|
||||
// To ensure we get the current caret positionning of the focused
|
||||
// element we need to delayed a bit the event
|
||||
this._executeDelayed(function(self) {
|
||||
// Bug 640870
|
||||
// Sometimes the element inner frame get destroyed while the element
|
||||
// receive the focus because the display is turned to 'none' for
|
||||
// example, in this "fun" case just do nothing if the element is hidden
|
||||
if (self._isVisibleElement(gFocusManager.focusedElement))
|
||||
sendAsyncMessage("FormAssist:Show", self._getJSON());
|
||||
});
|
||||
return this._currentElement;
|
||||
},
|
||||
|
||||
_open: false,
|
||||
open: function formHelperOpen(aElement, aEvent) {
|
||||
this._enabled = Services.prefs.prefHasUserValue(kPrefFormHelperEnabled) ?
|
||||
Services.prefs.getBoolPref(kPrefFormHelperEnabled) : false;
|
||||
|
||||
// If the click is on an option element we want to check if the parent
|
||||
// is a valid target.
|
||||
if (aElement instanceof HTMLOptionElement &&
|
||||
|
@ -113,8 +106,8 @@ FormAssistant.prototype = {
|
|||
aElement = aElement.parentNode;
|
||||
}
|
||||
|
||||
// Don't show the formhelper popup for multi-select boxes, except for touch.
|
||||
if (aElement instanceof HTMLSelectElement && aEvent) {
|
||||
// Don't show the formhelper popup for multi-select boxes, except for touch.
|
||||
if ((aElement.multiple || aElement.size > 1) &&
|
||||
aEvent.mozInputSource != Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) {
|
||||
return false;
|
||||
|
@ -133,70 +126,29 @@ FormAssistant.prototype = {
|
|||
if ((aElement instanceof HTMLInputElement || aElement instanceof HTMLButtonElement) &&
|
||||
passiveButtons[aElement.type] && !aElement.disabled)
|
||||
return false;
|
||||
|
||||
// Check for plugins element
|
||||
if (aElement instanceof Ci.nsIDOMHTMLEmbedElement) {
|
||||
let x = (aEvent && aEvent.clientX) || 0;
|
||||
let y = (aEvent && aEvent.clientY) || 0;
|
||||
this._executeDelayed(function(self) {
|
||||
let utils = Util.getWindowUtils(aElement.ownerDocument.defaultView);
|
||||
if (utils.IMEStatus == utils.IME_STATUS_PLUGIN) {
|
||||
let jsvar = {
|
||||
current: {
|
||||
id: aElement.id,
|
||||
name: aElement.name,
|
||||
title: "plugin",
|
||||
value: null,
|
||||
maxLength: 0,
|
||||
type: (aElement.getAttribute("type") || "").toLowerCase(),
|
||||
choices: null,
|
||||
isAutocomplete: false,
|
||||
validationMessage: null,
|
||||
list: null,
|
||||
rect: getBoundingContentRect(aElement),
|
||||
caretRect: new Rect(x, y, 1, 10),
|
||||
editable: true
|
||||
},
|
||||
hasPrevious: false,
|
||||
hasNext: false
|
||||
};
|
||||
sendAsyncMessage("FormAssist:Show", jsvar);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return this.close();
|
||||
}
|
||||
|
||||
// Look for a top editable element
|
||||
if (this._isEditable(aElement))
|
||||
if (this._isEditable(aElement)) {
|
||||
aElement = this._getTopLevelEditable(aElement);
|
||||
}
|
||||
|
||||
// There are some cases where we still want data to be sent to FormHelperUI
|
||||
// even if form assistant is disabled:
|
||||
// - the element is a choice list
|
||||
// - the element has autocomplete suggestions
|
||||
this._enabled = Services.prefs.prefHasUserValue(kPrefFormHelperEnabled) ?
|
||||
Services.prefs.getBoolPref(kPrefFormHelperEnabled) : false;
|
||||
if (!this._enabled && !this._isSelectElement(aElement) && !this._isAutocomplete(aElement)) {
|
||||
// We only work with choice lists or elements with autocomplete suggestions
|
||||
if (!this._enabled &&
|
||||
!this._isSelectElement(aElement) &&
|
||||
!this._isAutocomplete(aElement)) {
|
||||
return this.close();
|
||||
}
|
||||
|
||||
if (this._enabled) {
|
||||
this._elements = [];
|
||||
this.currentIndex = this._getAllElements(aElement);
|
||||
} else {
|
||||
this._elements = [aElement];
|
||||
this.currentIndex = 0;
|
||||
}
|
||||
|
||||
// Enable the assistant
|
||||
this.currentElement = aElement;
|
||||
return this._open = true;
|
||||
},
|
||||
|
||||
close: function close() {
|
||||
if (this._open) {
|
||||
this._currentIndex = -1;
|
||||
this._elements = [];
|
||||
this._currentElement = null;
|
||||
sendAsyncMessage("FormAssist:Hide", { });
|
||||
this._open = false;
|
||||
}
|
||||
|
@ -206,20 +158,18 @@ FormAssistant.prototype = {
|
|||
|
||||
receiveMessage: function receiveMessage(aMessage) {
|
||||
if (this._debugEvents) Util.dumpLn(aMessage.name);
|
||||
|
||||
let currentElement = this.currentElement;
|
||||
if ((!this._enabled && !this._isAutocomplete(currentElement) && !getWrapperForElement(currentElement)) || !currentElement)
|
||||
if ((!this._enabled &&
|
||||
!this._isAutocomplete(currentElement) &&
|
||||
!getWrapperForElement(currentElement)) ||
|
||||
!currentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
let json = aMessage.json;
|
||||
|
||||
switch (aMessage.name) {
|
||||
case "FormAssist:Previous":
|
||||
this.currentIndex--;
|
||||
break;
|
||||
|
||||
case "FormAssist:Next":
|
||||
this.currentIndex++;
|
||||
break;
|
||||
|
||||
case "Content:SetWindowSize":
|
||||
// If the CSS viewport change just show the current element to the new
|
||||
// position
|
||||
|
@ -233,8 +183,8 @@ FormAssistant.prototype = {
|
|||
}
|
||||
|
||||
case "FormAssist:ChoiceChange": {
|
||||
// ChoiceChange could happened once we have move to an other element or
|
||||
// to nothing, so we should keep the used wrapper in mind
|
||||
// ChoiceChange could happened once we have move to another element or
|
||||
// to nothing, so we should keep the used wrapper in mind.
|
||||
this._selectWrapper.fireOnChange();
|
||||
|
||||
// New elements can be shown when a select is updated so we need to
|
||||
|
@ -245,9 +195,7 @@ FormAssistant.prototype = {
|
|||
let currentElement = self.currentElement;
|
||||
if (!currentElement)
|
||||
return;
|
||||
|
||||
self._elements = [];
|
||||
self._currentIndex = self._getAllElements(currentElement);
|
||||
self._currentElement = currentElement;
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
@ -271,13 +219,11 @@ FormAssistant.prototype = {
|
|||
|
||||
case "FormAssist:Closed":
|
||||
currentElement.blur();
|
||||
this._currentIndex = null;
|
||||
this._open = false;
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_els: Cc["@mozilla.org/eventlistenerservice;1"].getService(Ci.nsIEventListenerService),
|
||||
_hasKeyListener: function _hasKeyListener(aElement) {
|
||||
let els = this._els;
|
||||
let listeners = els.getListenerInfoFor(aElement, {});
|
||||
|
@ -291,7 +237,6 @@ FormAssistant.prototype = {
|
|||
return false;
|
||||
},
|
||||
|
||||
focusSync: false,
|
||||
handleEvent: function formHelperHandleEvent(aEvent) {
|
||||
if (this._debugEvents) Util.dumpLn(aEvent.type, this.currentElement);
|
||||
// focus changes should be taken into account only if the user has done a
|
||||
|
@ -318,7 +263,9 @@ FormAssistant.prototype = {
|
|||
break;
|
||||
|
||||
case "focus":
|
||||
let focusedElement = gFocusManager.getFocusedElementForWindow(content, true, {}) || aEvent.target;
|
||||
let focusedElement =
|
||||
gFocusManager.getFocusedElementForWindow(content, true, {}) ||
|
||||
aEvent.target;
|
||||
|
||||
// If a body element is editable and the body is the child of an
|
||||
// iframe we can assume this is an advanced HTML editor, so let's
|
||||
|
@ -344,9 +291,8 @@ FormAssistant.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
let focusedIndex = this._getIndexForElement(focusedElement);
|
||||
if (focusedIndex != -1 && this.currentIndex != focusedIndex)
|
||||
this.currentIndex = focusedIndex;
|
||||
if (this._currentElement != focusedElement)
|
||||
this.currentElement = focusedElement;
|
||||
break;
|
||||
|
||||
case "blur":
|
||||
|
@ -370,98 +316,18 @@ FormAssistant.prototype = {
|
|||
sendAsyncMessage("FormAssist:AutoComplete", this._getJSON());
|
||||
break;
|
||||
|
||||
// key processing inside a select element are done during the keypress
|
||||
// handler, preventing this one to be fired cancel the selection change
|
||||
case "keypress":
|
||||
// There is no need to handle keys if there is not element currently
|
||||
// used by the form assistant
|
||||
if (!currentElement)
|
||||
return;
|
||||
|
||||
let formExceptions = { button: true, checkbox: true, file: true, image: true, radio: true, reset: true, submit: true };
|
||||
if (this._isSelectElement(currentElement) || formExceptions[currentElement.type] ||
|
||||
currentElement instanceof HTMLButtonElement || (currentElement.getAttribute("role") == "button" && currentElement.hasAttribute("tabindex"))) {
|
||||
switch (aEvent.keyCode) {
|
||||
case aEvent.DOM_VK_RIGHT:
|
||||
this._executeDelayed(function(self) {
|
||||
self.currentIndex++;
|
||||
});
|
||||
aEvent.stopPropagation();
|
||||
aEvent.preventDefault();
|
||||
break;
|
||||
|
||||
case aEvent.DOM_VK_LEFT:
|
||||
this._executeDelayed(function(self) {
|
||||
self.currentIndex--;
|
||||
});
|
||||
aEvent.stopPropagation();
|
||||
aEvent.preventDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "keyup":
|
||||
// There is no need to handle keys if there is not element currently
|
||||
// used by the form assistant
|
||||
if (!currentElement)
|
||||
return;
|
||||
|
||||
switch (aEvent.keyCode) {
|
||||
case aEvent.DOM_VK_DOWN:
|
||||
if (currentElement instanceof HTMLInputElement && !this._isAutocomplete(currentElement)) {
|
||||
if (this._hasKeyListener(currentElement))
|
||||
return;
|
||||
} else if (currentElement instanceof HTMLTextAreaElement) {
|
||||
let existSelection = currentElement.selectionEnd - currentElement.selectionStart;
|
||||
let isEnd = (currentElement.textLength == currentElement.selectionEnd);
|
||||
if (!isEnd || existSelection)
|
||||
return;
|
||||
} else if (getListForElement(currentElement)) {
|
||||
this.currentIndex = this.currentIndex;
|
||||
return;
|
||||
}
|
||||
if (this._isValidatable(aEvent.target)) {
|
||||
sendAsyncMessage("FormAssist:ValidationMessage", this._getJSON());
|
||||
}
|
||||
|
||||
this.currentIndex++;
|
||||
break;
|
||||
|
||||
case aEvent.DOM_VK_UP:
|
||||
if (currentElement instanceof HTMLInputElement && !this._isAutocomplete(currentElement)) {
|
||||
if (this._hasKeyListener(currentElement))
|
||||
return;
|
||||
} else if (currentElement instanceof HTMLTextAreaElement) {
|
||||
let existSelection = currentElement.selectionEnd - currentElement.selectionStart;
|
||||
let isStart = (currentElement.selectionEnd == 0);
|
||||
if (!isStart || existSelection)
|
||||
return;
|
||||
} else if (this._isSelectElement(currentElement)) {
|
||||
this.currentIndex = this.currentIndex;
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentIndex--;
|
||||
break;
|
||||
|
||||
case aEvent.DOM_VK_RETURN:
|
||||
if (!this._isVisibleElement(currentElement))
|
||||
this.close();
|
||||
break;
|
||||
|
||||
case aEvent.DOM_VK_ESCAPE:
|
||||
case aEvent.DOM_VK_TAB:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (this._isValidatable(aEvent.target)) {
|
||||
sendAsyncMessage("FormAssist:ValidationMessage", this._getJSON());
|
||||
}
|
||||
|
||||
if (this._isAutocomplete(aEvent.target)) {
|
||||
sendAsyncMessage("FormAssist:AutoComplete", this._getJSON());
|
||||
} else if (currentElement && this._isSelectElement(currentElement)) {
|
||||
this.currentIndex = this.currentIndex;
|
||||
}
|
||||
break;
|
||||
if (this._isAutocomplete(aEvent.target)) {
|
||||
sendAsyncMessage("FormAssist:AutoComplete", this._getJSON());
|
||||
}
|
||||
|
||||
let caretRect = this._getCaretRect();
|
||||
|
@ -478,30 +344,14 @@ FormAssistant.prototype = {
|
|||
timer.once(0);
|
||||
},
|
||||
|
||||
_filterEditables: function formHelperFilterEditables(aNodes) {
|
||||
let result = [];
|
||||
for (let i = 0; i < aNodes.length; i++) {
|
||||
let node = aNodes[i];
|
||||
|
||||
// Avoid checking the top level editable element of each node
|
||||
if (this._isEditable(node)) {
|
||||
let editableElement = this._getTopLevelEditable(node);
|
||||
if (result.indexOf(editableElement) == -1)
|
||||
result.push(editableElement);
|
||||
}
|
||||
else {
|
||||
result.push(node);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_isEditable: function formHelperIsEditable(aElement) {
|
||||
let canEdit = false;
|
||||
|
||||
if (aElement.isContentEditable || aElement.designMode == "on") {
|
||||
canEdit = true;
|
||||
} else if (aElement instanceof HTMLIFrameElement && (aElement.contentDocument.body.isContentEditable || aElement.contentDocument.designMode == "on")) {
|
||||
} else if (aElement instanceof HTMLIFrameElement &&
|
||||
(aElement.contentDocument.body.isContentEditable ||
|
||||
aElement.contentDocument.designMode == "on")) {
|
||||
canEdit = true;
|
||||
} else {
|
||||
canEdit = aElement.ownerDocument && aElement.ownerDocument.designMode == "on";
|
||||
|
@ -694,57 +544,6 @@ FormAssistant.prototype = {
|
|||
return associatedLabels;
|
||||
},
|
||||
|
||||
_getAllElements: function getAllElements(aElement) {
|
||||
// XXX good candidate for tracing if possible.
|
||||
// The tough ones are lenght and isVisibleElement.
|
||||
let document = aElement.ownerDocument;
|
||||
if (!document)
|
||||
return;
|
||||
|
||||
let documents = Util.getAllDocuments(document);
|
||||
|
||||
let elements = this._elements;
|
||||
for (let i = 0; i < documents.length; i++) {
|
||||
let selector = "input, button, select, textarea, [role=button], iframe, [contenteditable=true]";
|
||||
let nodes = documents[i].querySelectorAll(selector);
|
||||
nodes = this._filterRadioButtons(nodes);
|
||||
|
||||
for (let j = 0; j < nodes.length; j++) {
|
||||
let node = nodes[j];
|
||||
if (!this._isNavigableElement(node) || !this._isVisibleElement(node))
|
||||
continue;
|
||||
|
||||
elements.push(node);
|
||||
}
|
||||
}
|
||||
this._elements = this._filterEditables(elements);
|
||||
|
||||
function orderByTabIndex(a, b) {
|
||||
// for an explanation on tabbing navigation see
|
||||
// http://www.w3.org/TR/html401/interact/forms.html#h-17.11.1
|
||||
// In resume tab index navigation order is 1, 2, 3, ..., 32767, 0
|
||||
if (a.tabIndex == 0 || b.tabIndex == 0)
|
||||
return b.tabIndex;
|
||||
|
||||
return a.tabIndex > b.tabIndex;
|
||||
}
|
||||
this._elements = this._elements.sort(orderByTabIndex);
|
||||
|
||||
// retrieve the correct index
|
||||
let currentIndex = this._getIndexForElement(aElement);
|
||||
return currentIndex;
|
||||
},
|
||||
|
||||
_getIndexForElement: function(aElement) {
|
||||
let currentIndex = -1;
|
||||
let elements = this._elements;
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
if (elements[i] == aElement)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
_getJSON: function() {
|
||||
let element = this.currentElement;
|
||||
let choices = getListForElement(element);
|
||||
|
@ -767,8 +566,8 @@ FormAssistant.prototype = {
|
|||
caretRect: this._getCaretRect(),
|
||||
editable: editable
|
||||
},
|
||||
hasPrevious: !!this._elements[this._currentIndex - 1],
|
||||
hasNext: !!this._elements[this._currentIndex + 1]
|
||||
hasPrevious: false,
|
||||
hasNext: false
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -20,18 +20,21 @@ this.RecentWindow = {
|
|||
* Get the most recent browser window.
|
||||
*
|
||||
* @param aOptions an object accepting the arguments for the search.
|
||||
* Set the private property to true in order to restrict the
|
||||
* search to private windows only, or to false in order to
|
||||
* restrict the search to non-private windows only. To search
|
||||
* in both groups, don't specify the private property.
|
||||
* * private: true to restrict the search to private windows
|
||||
* only, false to restrict the search to non-private only.
|
||||
* Omit the property to search in both groups.
|
||||
* * allowPopups: true if popup windows are permissable.
|
||||
*/
|
||||
getMostRecentBrowserWindow: function RW_getMostRecentBrowserWindow(aOptions) {
|
||||
let checkPrivacy = typeof aOptions == "object" &&
|
||||
"private" in aOptions;
|
||||
|
||||
let allowPopups = typeof aOptions == "object" && !!aOptions.allowPopups;
|
||||
|
||||
function isSuitableBrowserWindow(win) {
|
||||
return (!win.closed &&
|
||||
win.toolbar.visible &&
|
||||
(allowPopups || win.toolbar.visible) &&
|
||||
(!checkPrivacy ||
|
||||
PrivateBrowsingUtils.permanentPrivateBrowsing ||
|
||||
PrivateBrowsingUtils.isWindowPrivate(win) == aOptions.private));
|
||||
|
|
|
@ -48,6 +48,11 @@
|
|||
}
|
||||
|
||||
@media (min-resolution: 2dppx) {
|
||||
.searchbar-engine-image,
|
||||
.searchbar-engine-menuitem > .menu-iconic-left > .menu-iconic-icon {
|
||||
image-rendering: -moz-crisp-edges;
|
||||
}
|
||||
|
||||
.searchbar-engine-image {
|
||||
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon@2x.png");
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ class nsIURI;
|
|||
{ 0xb2, 0xe9, 0x63, 0x52, 0x8c, 0x87, 0x99, 0x7a } }
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsCSSStyleSheet;
|
||||
|
||||
class nsIStyleSheetLinkingElement : public nsISupports {
|
||||
public:
|
||||
|
@ -28,7 +29,7 @@ public:
|
|||
* @param aStyleSheet the style sheet associated with this
|
||||
* element.
|
||||
*/
|
||||
NS_IMETHOD SetStyleSheet(nsIStyleSheet* aStyleSheet) = 0;
|
||||
NS_IMETHOD SetStyleSheet(nsCSSStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* Used to obtain the style sheet linked in by this element.
|
||||
|
|
|
@ -56,21 +56,17 @@ nsStyleLinkElement::Traverse(nsCycleCollectionTraversalCallback &cb)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStyleLinkElement::SetStyleSheet(nsIStyleSheet* aStyleSheet)
|
||||
nsStyleLinkElement::SetStyleSheet(nsCSSStyleSheet* aStyleSheet)
|
||||
{
|
||||
nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(mStyleSheet);
|
||||
if (cssSheet) {
|
||||
cssSheet->SetOwningNode(nullptr);
|
||||
if (mStyleSheet) {
|
||||
mStyleSheet->SetOwningNode(nullptr);
|
||||
}
|
||||
|
||||
mStyleSheet = aStyleSheet;
|
||||
cssSheet = do_QueryObject(mStyleSheet);
|
||||
if (cssSheet) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
CallQueryInterface(this,
|
||||
static_cast<nsIDOMNode**>(getter_AddRefs(node)));
|
||||
if (mStyleSheet) {
|
||||
nsCOMPtr<nsINode> node = do_QueryObject(this);
|
||||
if (node) {
|
||||
cssSheet->SetOwningNode(node);
|
||||
mStyleSheet->SetOwningNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,15 +93,7 @@ nsStyleLinkElement::InitStyleLinkElement(bool aDontLoadStyle)
|
|||
NS_IMETHODIMP
|
||||
nsStyleLinkElement::GetSheet(nsIDOMStyleSheet** aSheet)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSheet);
|
||||
*aSheet = nullptr;
|
||||
|
||||
if (mStyleSheet) {
|
||||
CallQueryInterface(mStyleSheet, aSheet);
|
||||
}
|
||||
|
||||
// Always return NS_OK to avoid throwing JS exceptions if mStyleSheet
|
||||
// is not a nsIDOMStyleSheet
|
||||
NS_IF_ADDREF(*aSheet = mStyleSheet);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -416,14 +404,10 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
|
|||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<nsCSSStyleSheet> cssStyleSheet = do_QueryObject(mStyleSheet);
|
||||
NS_ASSERTION(cssStyleSheet, "should only call UpdateStyleSheetScope for "
|
||||
"an nsCSSStyleSheet");
|
||||
|
||||
nsCOMPtr<nsIContent> thisContent;
|
||||
CallQueryInterface(this, getter_AddRefs(thisContent));
|
||||
|
||||
Element* oldScopeElement = cssStyleSheet->GetScopeElement();
|
||||
Element* oldScopeElement = mStyleSheet->GetScopeElement();
|
||||
Element* newScopeElement = aIsNowScoped ?
|
||||
thisContent->GetParentElement() :
|
||||
nullptr;
|
||||
|
@ -437,7 +421,7 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
|
|||
document->BeginUpdate(UPDATE_STYLE);
|
||||
document->RemoveStyleSheet(mStyleSheet);
|
||||
|
||||
cssStyleSheet->SetScopeElement(newScopeElement);
|
||||
mStyleSheet->SetScopeElement(newScopeElement);
|
||||
|
||||
document->AddStyleSheet(mStyleSheet);
|
||||
document->EndUpdate(UPDATE_STYLE);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMLinkStyle.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
|
@ -41,10 +41,10 @@ public:
|
|||
// nsIDOMLinkStyle
|
||||
NS_DECL_NSIDOMLINKSTYLE
|
||||
|
||||
nsIStyleSheet* GetSheet() { return mStyleSheet; }
|
||||
nsCSSStyleSheet* GetSheet() const { return mStyleSheet; }
|
||||
|
||||
// nsIStyleSheetLinkingElement
|
||||
NS_IMETHOD SetStyleSheet(nsIStyleSheet* aStyleSheet);
|
||||
NS_IMETHOD SetStyleSheet(nsCSSStyleSheet* aStyleSheet);
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet);
|
||||
NS_IMETHOD InitStyleLinkElement(bool aDontLoadStyle);
|
||||
NS_IMETHOD UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
|
||||
|
@ -105,7 +105,7 @@ private:
|
|||
bool* aIsAlternate,
|
||||
bool aForceUpdate);
|
||||
|
||||
nsCOMPtr<nsIStyleSheet> mStyleSheet;
|
||||
nsRefPtr<nsCSSStyleSheet> mStyleSheet;
|
||||
protected:
|
||||
bool mDontLoadStyle;
|
||||
bool mUpdatesEnabled;
|
||||
|
|
|
@ -69,43 +69,34 @@ NS_HTML_CONTENT_INTERFACE_MAP_END
|
|||
NS_IMPL_ELEMENT_CLONE(HTMLLinkElement)
|
||||
|
||||
bool
|
||||
HTMLLinkElement::GetDisabled(ErrorResult& aRv)
|
||||
HTMLLinkElement::Disabled()
|
||||
{
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetSheet());
|
||||
if (!ss) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool disabled = false;
|
||||
aRv = ss->GetDisabled(&disabled);
|
||||
return disabled;
|
||||
nsCSSStyleSheet* ss = GetSheet();
|
||||
return ss && ss->Disabled();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLLinkElement::GetDisabled(bool* aDisabled)
|
||||
HTMLLinkElement::GetMozDisabled(bool* aDisabled)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aDisabled = GetDisabled(rv);
|
||||
return rv.ErrorCode();
|
||||
*aDisabled = Disabled();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLLinkElement::SetDisabled(bool aDisabled, ErrorResult& aRv)
|
||||
HTMLLinkElement::SetDisabled(bool aDisabled)
|
||||
{
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetSheet());
|
||||
if (!ss) {
|
||||
return;
|
||||
nsCSSStyleSheet* ss = GetSheet();
|
||||
if (ss) {
|
||||
ss->SetDisabled(aDisabled);
|
||||
}
|
||||
|
||||
aRv = ss->SetDisabled(aDisabled);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLLinkElement::SetDisabled(bool aDisabled)
|
||||
HTMLLinkElement::SetMozDisabled(bool aDisabled)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetDisabled(aDisabled, rv);
|
||||
return rv.ErrorCode();
|
||||
SetDisabled(aDisabled);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ public:
|
|||
void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName);
|
||||
|
||||
// WebIDL
|
||||
bool GetDisabled(ErrorResult& aRv);
|
||||
void SetDisabled(bool aDisabled, ErrorResult& aRv);
|
||||
bool Disabled();
|
||||
void SetDisabled(bool aDisabled);
|
||||
// XPCOM GetHref is fine.
|
||||
void SetHref(const nsAString& aHref, ErrorResult& aRv)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,396 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set et sw=2 sts=2 cin:
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/HTMLSharedObjectElement.h"
|
||||
#include "mozilla/dom/HTMLEmbedElementBinding.h"
|
||||
#include "mozilla/dom/HTMLAppletElementBinding.h"
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPluginDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIDOMSVGDocument.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(SharedObject)
|
||||
|
||||
DOMCI_DATA(HTMLAppletElement, mozilla::dom::HTMLSharedObjectElement)
|
||||
DOMCI_DATA(HTMLEmbedElement, mozilla::dom::HTMLSharedObjectElement)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
HTMLSharedObjectElement::HTMLSharedObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
FromParser aFromParser)
|
||||
: nsGenericHTMLElement(aNodeInfo),
|
||||
mIsDoneAddingChildren(mNodeInfo->Equals(nsGkAtoms::embed) || !aFromParser)
|
||||
{
|
||||
RegisterFreezableElement();
|
||||
SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
|
||||
|
||||
// By default we're in the loading state
|
||||
AddStatesSilently(NS_EVENT_STATE_LOADING);
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSharedObjectElement::GetItemValueText(nsAString& aValue)
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
nsGenericHTMLElement::GetItemValueText(aValue);
|
||||
} else {
|
||||
GetSrc(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSharedObjectElement::SetItemValueText(const nsAString& aValue)
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
nsGenericHTMLElement::SetItemValueText(aValue);
|
||||
} else {
|
||||
SetSrc(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
HTMLSharedObjectElement::~HTMLSharedObjectElement()
|
||||
{
|
||||
UnregisterFreezableElement();
|
||||
DestroyImageLoadingContent();
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLSharedObjectElement::IsDoneAddingChildren()
|
||||
{
|
||||
return mIsDoneAddingChildren;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSharedObjectElement::DoneAddingChildren(bool aHaveNotified)
|
||||
{
|
||||
if (!mIsDoneAddingChildren) {
|
||||
mIsDoneAddingChildren = true;
|
||||
|
||||
// If we're already in a document, we need to trigger the load
|
||||
// Otherwise, BindToTree takes care of that.
|
||||
if (IsInDoc()) {
|
||||
StartObjectLoad(aHaveNotified);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLSharedObjectElement,
|
||||
nsGenericHTMLElement)
|
||||
nsObjectLoadingContent::Traverse(tmp, cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(HTMLSharedObjectElement, Element)
|
||||
NS_IMPL_RELEASE_INHERITED(HTMLSharedObjectElement, Element)
|
||||
|
||||
nsIClassInfo*
|
||||
HTMLSharedObjectElement::GetClassInfoInternal()
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
return NS_GetDOMClassInfoInstance(eDOMClassInfo_HTMLAppletElement_id);
|
||||
}
|
||||
if (mNodeInfo->Equals(nsGkAtoms::embed)) {
|
||||
return NS_GetDOMClassInfoInstance(eDOMClassInfo_HTMLEmbedElement_id);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLSharedObjectElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(HTMLSharedObjectElement,
|
||||
nsIDOMHTMLAppletElement)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, nsIRequestObserver)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, nsIStreamListener)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, nsIFrameLoaderOwner)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, nsIObjectLoadingContent)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, imgINotificationObserver)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, nsIImageLoadingContent)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, imgIOnloadBlocker)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, nsIInterfaceRequestor)
|
||||
NS_INTERFACE_TABLE_ENTRY(HTMLSharedObjectElement, nsIChannelEventSink)
|
||||
NS_OFFSET_AND_INTERFACE_TABLE_END
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(HTMLSharedObjectElement,
|
||||
nsGenericHTMLElement,
|
||||
nsIDOMHTMLAppletElement)
|
||||
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLAppletElement, applet)
|
||||
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLEmbedElement, embed)
|
||||
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMGetSVGDocument, embed)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_GETTER(GetClassInfoInternal)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(HTMLSharedObjectElement)
|
||||
|
||||
nsresult
|
||||
HTMLSharedObjectElement::BindToTree(nsIDocument *aDocument,
|
||||
nsIContent *aParent,
|
||||
nsIContent *aBindingParent,
|
||||
bool aCompileEventHandlers)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
aCompileEventHandlers);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
aCompileEventHandlers);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Don't kick off load from being bound to a plugin document - the plugin
|
||||
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
|
||||
// initial load.
|
||||
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument);
|
||||
|
||||
// If we already have all the children, start the load.
|
||||
if (mIsDoneAddingChildren && !pluginDoc) {
|
||||
void (HTMLSharedObjectElement::*start)() =
|
||||
&HTMLSharedObjectElement::StartObjectLoad;
|
||||
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSharedObjectElement::UnbindFromTree(bool aDeep,
|
||||
bool aNullParent)
|
||||
{
|
||||
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
||||
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
HTMLSharedObjectElement::SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
||||
nsIAtom *aPrefix, const nsAString &aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
||||
aValue, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// if aNotify is false, we are coming from the parser or some such place;
|
||||
// we'll get bound after all the attributes have been set, so we'll do the
|
||||
// object load from BindToTree/DoneAddingChildren.
|
||||
// Skip the LoadObject call in that case.
|
||||
// We also don't want to start loading the object when we're not yet in
|
||||
// a document, just in case that the caller wants to set additional
|
||||
// attributes before inserting the node into the document.
|
||||
if (aNotify && IsInDoc() && mIsDoneAddingChildren &&
|
||||
aNameSpaceID == kNameSpaceID_None && aName == URIAttrName()) {
|
||||
return LoadObject(aNotify, true);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLSharedObjectElement::IsHTMLFocusable(bool aWithMouse,
|
||||
bool *aIsFocusable,
|
||||
int32_t *aTabIndex)
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::embed) || Type() == eType_Plugin) {
|
||||
// Has plugin content: let the plugin decide what to do in terms of
|
||||
// internal focus from mouse clicks
|
||||
if (aTabIndex) {
|
||||
GetTabIndex(aTabIndex);
|
||||
}
|
||||
|
||||
*aIsFocusable = true;
|
||||
|
||||
// Let the plugin decide, so override.
|
||||
return true;
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex);
|
||||
}
|
||||
|
||||
nsIContent::IMEState
|
||||
HTMLSharedObjectElement::GetDesiredIMEState()
|
||||
{
|
||||
if (Type() == eType_Plugin) {
|
||||
return IMEState(IMEState::PLUGIN);
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::GetDesiredIMEState();
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Alt, alt)
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Archive, archive)
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Code, code)
|
||||
NS_IMPL_URI_ATTR(HTMLSharedObjectElement, CodeBase, codebase)
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Height, height)
|
||||
NS_IMPL_INT_ATTR(HTMLSharedObjectElement, Hspace, hspace)
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Name, name)
|
||||
NS_IMPL_URI_ATTR_WITH_BASE(HTMLSharedObjectElement, Object, object, codebase)
|
||||
NS_IMPL_URI_ATTR(HTMLSharedObjectElement, Src, src)
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Type, type)
|
||||
NS_IMPL_INT_ATTR(HTMLSharedObjectElement, Vspace, vspace)
|
||||
NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Width, width)
|
||||
|
||||
int32_t
|
||||
HTMLSharedObjectElement::TabIndexDefault()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLSharedObjectElement::GetSVGDocument(nsIDOMDocument **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = nullptr;
|
||||
|
||||
if (!IsInDoc()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXXbz should this use GetCurrentDoc()? sXBL/XBL2 issue!
|
||||
nsIDocument *sub_doc = OwnerDoc()->GetSubDocumentFor(this);
|
||||
if (!sub_doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(sub_doc, aResult);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLSharedObjectElement::ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom *aAttribute,
|
||||
const nsAString &aValue,
|
||||
nsAttrValue &aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::align) {
|
||||
return ParseAlignValue(aValue, aResult);
|
||||
}
|
||||
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
||||
aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesIntoRule(const nsMappedAttributes *aAttributes,
|
||||
nsRuleData *aData)
|
||||
{
|
||||
nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
HTMLSharedObjectElement::IsAttributeMapped(const nsIAtom *aAttribute) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sCommonAttributeMap,
|
||||
sImageMarginSizeAttributeMap,
|
||||
sImageBorderAttributeMap,
|
||||
sImageAlignAttributeMap,
|
||||
};
|
||||
|
||||
return FindAttributeDependence(aAttribute, map);
|
||||
}
|
||||
|
||||
|
||||
nsMapRuleToAttributesFunc
|
||||
HTMLSharedObjectElement::GetAttributeMappingFunction() const
|
||||
{
|
||||
return &MapAttributesIntoRule;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSharedObjectElement::StartObjectLoad(bool aNotify)
|
||||
{
|
||||
// BindToTree can call us asynchronously, and we may be removed from the tree
|
||||
// in the interim
|
||||
if (!IsInDoc() || !OwnerDoc()->IsActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LoadObject(aNotify);
|
||||
SetIsNetworkCreated(false);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
HTMLSharedObjectElement::IntrinsicState() const
|
||||
{
|
||||
return nsGenericHTMLElement::IntrinsicState() | ObjectState();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLSharedObjectElement::GetCapabilities() const
|
||||
{
|
||||
uint32_t capabilities = eSupportPlugins | eAllowPluginSkipChannel;
|
||||
if (mNodeInfo->Equals(nsGkAtoms::embed)) {
|
||||
capabilities |= eSupportSVG | eSupportImages;
|
||||
}
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSharedObjectElement::DestroyContent()
|
||||
{
|
||||
nsObjectLoadingContent::DestroyContent();
|
||||
nsGenericHTMLElement::DestroyContent();
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLSharedObjectElement::CopyInnerTo(Element* aDest)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
||||
CreateStaticClone(static_cast<HTMLSharedObjectElement*>(aDest));
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLSharedObjectElement::WrapNode(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
JSObject* obj;
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
obj = HTMLAppletElementBinding::Wrap(aCx, aScope, this);
|
||||
} else {
|
||||
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::embed));
|
||||
obj = HTMLEmbedElementBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
if (!obj) {
|
||||
return nullptr;
|
||||
}
|
||||
SetupProtoChain(aCx, obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLSharedObjectElement::GetCanonicalPrototype(JSContext* aCx, JSObject* aGlobal)
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
return HTMLAppletElementBinding::GetProtoObject(aCx, aGlobal);
|
||||
}
|
||||
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::embed));
|
||||
return HTMLEmbedElementBinding::GetProtoObject(aCx, aGlobal);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,256 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set et sw=2 sts=2 cin:
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_HTMLSharedObjectElement_h
|
||||
#define mozilla_dom_HTMLSharedObjectElement_h
|
||||
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsObjectLoadingContent.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIDOMHTMLAppletElement.h"
|
||||
#include "nsIDOMHTMLEmbedElement.h"
|
||||
#include "nsIDOMGetSVGDocument.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class HTMLSharedObjectElement : public nsGenericHTMLElement
|
||||
, public nsObjectLoadingContent
|
||||
, public nsIDOMHTMLAppletElement
|
||||
, public nsIDOMHTMLEmbedElement
|
||||
, public nsIDOMGetSVGDocument
|
||||
{
|
||||
public:
|
||||
HTMLSharedObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
|
||||
virtual ~HTMLSharedObjectElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
|
||||
// nsIDOMElement
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
|
||||
|
||||
virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
|
||||
|
||||
// nsIDOMHTMLAppletElement
|
||||
NS_DECL_NSIDOMHTMLAPPLETELEMENT
|
||||
|
||||
// Can't use macro for nsIDOMHTMLEmbedElement because it has conflicts with
|
||||
// NS_DECL_NSIDOMHTMLAPPLETELEMENT.
|
||||
|
||||
// nsIDOMHTMLEmbedElement
|
||||
NS_IMETHOD GetSrc(nsAString &aSrc);
|
||||
NS_IMETHOD SetSrc(const nsAString &aSrc);
|
||||
NS_IMETHOD GetType(nsAString &aType);
|
||||
NS_IMETHOD SetType(const nsAString &aType);
|
||||
|
||||
// nsIDOMGetSVGDocument
|
||||
NS_DECL_NSIDOMGETSVGDOCUMENT
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
|
||||
nsIContent *aBindingParent,
|
||||
bool aCompileEventHandlers);
|
||||
virtual void UnbindFromTree(bool aDeep = true,
|
||||
bool aNullParent = true);
|
||||
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
||||
nsIAtom *aPrefix, const nsAString &aValue,
|
||||
bool aNotify);
|
||||
|
||||
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex);
|
||||
virtual IMEState GetDesiredIMEState();
|
||||
|
||||
virtual void DoneAddingChildren(bool aHaveNotified);
|
||||
virtual bool IsDoneAddingChildren();
|
||||
|
||||
virtual bool ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom *aAttribute,
|
||||
const nsAString &aValue,
|
||||
nsAttrValue &aResult);
|
||||
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const;
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
virtual void DestroyContent();
|
||||
|
||||
// nsObjectLoadingContent
|
||||
virtual uint32_t GetCapabilities() const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
nsresult CopyInnerTo(Element* aDest);
|
||||
|
||||
void StartObjectLoad() { StartObjectLoad(true); }
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(HTMLSharedObjectElement,
|
||||
nsGenericHTMLElement)
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo()
|
||||
{
|
||||
return static_cast<nsXPCClassInfo*>(GetClassInfoInternal());
|
||||
}
|
||||
nsIClassInfo* GetClassInfoInternal();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode()
|
||||
{
|
||||
return static_cast<nsIDOMHTMLAppletElement*>(this);
|
||||
}
|
||||
|
||||
// WebIDL API for <applet>
|
||||
void GetAlign(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::align, aValue);
|
||||
}
|
||||
void SetAlign(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::align, aValue, aRv);
|
||||
}
|
||||
void GetAlt(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::alt, aValue);
|
||||
}
|
||||
void SetAlt(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::alt, aValue, aRv);
|
||||
}
|
||||
void GetArchive(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::archive, aValue);
|
||||
}
|
||||
void SetArchive(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::archive, aValue, aRv);
|
||||
}
|
||||
void GetCode(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::code, aValue);
|
||||
}
|
||||
void SetCode(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::code, aValue, aRv);
|
||||
}
|
||||
// XPCOM GetCodebase is ok; note that it's a URI attribute
|
||||
void SetCodeBase(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::codebase, aValue, aRv);
|
||||
}
|
||||
void GetHeight(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::height, aValue);
|
||||
}
|
||||
void SetHeight(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::height, aValue, aRv);
|
||||
}
|
||||
uint32_t Hspace()
|
||||
{
|
||||
return GetHTMLUnsignedIntAttr(nsGkAtoms::hspace, 0);
|
||||
}
|
||||
void SetHspace(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLUnsignedIntAttr(nsGkAtoms::hspace, aValue, aRv);
|
||||
}
|
||||
void GetName(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::name, aValue);
|
||||
}
|
||||
void SetName(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
|
||||
}
|
||||
// XPCOM GetObject is ok; note that it's a URI attribute with a weird base URI
|
||||
void SetObject(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::object, aValue, aRv);
|
||||
}
|
||||
uint32_t Vspace()
|
||||
{
|
||||
return GetHTMLUnsignedIntAttr(nsGkAtoms::vspace, 0);
|
||||
}
|
||||
void SetVspace(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLUnsignedIntAttr(nsGkAtoms::vspace, aValue, aRv);
|
||||
}
|
||||
void GetWidth(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::width, aValue);
|
||||
}
|
||||
void SetWidth(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::width, aValue, aRv);
|
||||
}
|
||||
|
||||
// WebIDL <embed> api
|
||||
// XPCOM GetSrc is ok; note that it's a URI attribute
|
||||
void SetSrc(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::src, aValue, aRv);
|
||||
}
|
||||
void GetType(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::type, aValue);
|
||||
}
|
||||
void SetType(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::type, aValue, aRv);
|
||||
}
|
||||
// width covered by <applet>
|
||||
// height covered by <applet>
|
||||
// align covered by <applet>
|
||||
// name covered by <applet>
|
||||
nsIDocument* GetSVGDocument()
|
||||
{
|
||||
return GetContentDocument();
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calls LoadObject with the correct arguments to start the plugin load.
|
||||
*/
|
||||
NS_HIDDEN_(void) StartObjectLoad(bool aNotify);
|
||||
|
||||
void GetTypeAttrValue(nsCString &aValue) const
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
aValue.AppendLiteral("application/x-java-vm");
|
||||
}
|
||||
else {
|
||||
nsAutoString type;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
|
||||
|
||||
CopyUTF16toUTF8(type, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom *URIAttrName() const
|
||||
{
|
||||
return mNodeInfo->Equals(nsGkAtoms::applet) ?
|
||||
nsGkAtoms::code :
|
||||
nsGkAtoms::src;
|
||||
}
|
||||
|
||||
// mIsDoneAddingChildren is only really used for <applet>. This boolean is
|
||||
// always true for <embed>, per the documentation in nsIContent.h.
|
||||
bool mIsDoneAddingChildren;
|
||||
|
||||
virtual void GetItemValueText(nsAString& text);
|
||||
virtual void SetItemValueText(const nsAString& text);
|
||||
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope) MOZ_OVERRIDE;
|
||||
virtual JSObject* GetCanonicalPrototype(JSContext* aCx,
|
||||
JSObject* aGlobal) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_HTMLSharedObjectElement_h
|
|
@ -61,7 +61,7 @@ NS_IMPL_ELEMENT_CLONE(HTMLStyleElement)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleElement::GetDisabled(bool* aDisabled)
|
||||
HTMLStyleElement::GetMozDisabled(bool* aDisabled)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDisabled);
|
||||
|
||||
|
@ -72,36 +72,23 @@ HTMLStyleElement::GetDisabled(bool* aDisabled)
|
|||
bool
|
||||
HTMLStyleElement::Disabled()
|
||||
{
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetSheet());
|
||||
if (!ss) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool disabled = false;
|
||||
ss->GetDisabled(&disabled);
|
||||
|
||||
return disabled;
|
||||
nsCSSStyleSheet* ss = GetSheet();
|
||||
return ss && ss->Disabled();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleElement::SetDisabled(bool aDisabled)
|
||||
HTMLStyleElement::SetMozDisabled(bool aDisabled)
|
||||
{
|
||||
ErrorResult error;
|
||||
SetDisabled(aDisabled, error);
|
||||
return error.ErrorCode();
|
||||
SetDisabled(aDisabled);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLStyleElement::SetDisabled(bool aDisabled, ErrorResult& aError)
|
||||
HTMLStyleElement::SetDisabled(bool aDisabled)
|
||||
{
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetSheet());
|
||||
if (!ss) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult result = ss->SetDisabled(aDisabled);
|
||||
if (NS_FAILED(result)) {
|
||||
aError.Throw(result);
|
||||
nsCSSStyleSheet* ss = GetSheet();
|
||||
if (ss) {
|
||||
ss->SetDisabled(aDisabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
||||
|
||||
bool Disabled();
|
||||
void SetDisabled(bool aDisabled, ErrorResult& aError);
|
||||
void SetDisabled(bool aDisabled);
|
||||
void SetMedia(const nsAString& aMedia, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::media, aMedia, aError);
|
||||
|
|
|
@ -65,6 +65,7 @@ EXPORTS_mozilla/dom = \
|
|||
HTMLScriptElement.h \
|
||||
HTMLSharedElement.h \
|
||||
HTMLSharedListElement.h \
|
||||
HTMLSharedObjectElement.h \
|
||||
HTMLSpanElement.h \
|
||||
HTMLStyleElement.h \
|
||||
HTMLTableCaptionElement.h \
|
||||
|
@ -121,7 +122,7 @@ CPPSRCS = \
|
|||
HTMLMeterElement.cpp \
|
||||
HTMLModElement.cpp \
|
||||
HTMLObjectElement.cpp \
|
||||
nsHTMLSharedObjectElement.cpp \
|
||||
HTMLSharedObjectElement.cpp \
|
||||
HTMLOptionElement.cpp \
|
||||
HTMLOptionsCollection.cpp \
|
||||
HTMLOptGroupElement.cpp \
|
||||
|
|
|
@ -1,490 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set et sw=2 sts=2 cin:
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsObjectLoadingContent.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPluginDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLAppletElement.h"
|
||||
#include "nsIDOMHTMLEmbedElement.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIDOMGetSVGDocument.h"
|
||||
#include "nsIDOMSVGDocument.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
class nsHTMLSharedObjectElement : public nsGenericHTMLElement
|
||||
, public nsObjectLoadingContent
|
||||
, public nsIDOMHTMLAppletElement
|
||||
, public nsIDOMHTMLEmbedElement
|
||||
, public nsIDOMGetSVGDocument
|
||||
{
|
||||
public:
|
||||
nsHTMLSharedObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
|
||||
virtual ~nsHTMLSharedObjectElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
|
||||
// nsIDOMElement
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
|
||||
|
||||
virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
|
||||
|
||||
// nsIDOMHTMLAppletElement
|
||||
NS_DECL_NSIDOMHTMLAPPLETELEMENT
|
||||
|
||||
// Can't use macro for nsIDOMHTMLEmbedElement because it has conflicts with
|
||||
// NS_DECL_NSIDOMHTMLAPPLETELEMENT.
|
||||
|
||||
// nsIDOMHTMLEmbedElement
|
||||
NS_IMETHOD GetSrc(nsAString &aSrc);
|
||||
NS_IMETHOD SetSrc(const nsAString &aSrc);
|
||||
NS_IMETHOD GetType(nsAString &aType);
|
||||
NS_IMETHOD SetType(const nsAString &aType);
|
||||
|
||||
// nsIDOMGetSVGDocument
|
||||
NS_DECL_NSIDOMGETSVGDOCUMENT
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
|
||||
nsIContent *aBindingParent,
|
||||
bool aCompileEventHandlers);
|
||||
virtual void UnbindFromTree(bool aDeep = true,
|
||||
bool aNullParent = true);
|
||||
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
||||
nsIAtom *aPrefix, const nsAString &aValue,
|
||||
bool aNotify);
|
||||
|
||||
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex);
|
||||
virtual IMEState GetDesiredIMEState();
|
||||
|
||||
virtual void DoneAddingChildren(bool aHaveNotified);
|
||||
virtual bool IsDoneAddingChildren();
|
||||
|
||||
virtual bool ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom *aAttribute,
|
||||
const nsAString &aValue,
|
||||
nsAttrValue &aResult);
|
||||
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const;
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
virtual void DestroyContent();
|
||||
|
||||
// nsObjectLoadingContent
|
||||
virtual uint32_t GetCapabilities() const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
nsresult CopyInnerTo(Element* aDest);
|
||||
|
||||
void StartObjectLoad() { StartObjectLoad(true); }
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLSharedObjectElement,
|
||||
nsGenericHTMLElement)
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo()
|
||||
{
|
||||
return static_cast<nsXPCClassInfo*>(GetClassInfoInternal());
|
||||
}
|
||||
nsIClassInfo* GetClassInfoInternal();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode()
|
||||
{
|
||||
return static_cast<nsIDOMHTMLAppletElement*>(this);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* Calls LoadObject with the correct arguments to start the plugin load.
|
||||
*/
|
||||
NS_HIDDEN_(void) StartObjectLoad(bool aNotify);
|
||||
|
||||
void GetTypeAttrValue(nsCString &aValue) const
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
aValue.AppendLiteral("application/x-java-vm");
|
||||
}
|
||||
else {
|
||||
nsAutoString type;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
|
||||
|
||||
CopyUTF16toUTF8(type, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom *URIAttrName() const
|
||||
{
|
||||
return mNodeInfo->Equals(nsGkAtoms::applet) ?
|
||||
nsGkAtoms::code :
|
||||
nsGkAtoms::src;
|
||||
}
|
||||
|
||||
// mIsDoneAddingChildren is only really used for <applet>. This boolean is
|
||||
// always true for <embed>, per the documentation in nsIContent.h.
|
||||
bool mIsDoneAddingChildren;
|
||||
|
||||
virtual void GetItemValueText(nsAString& text);
|
||||
virtual void SetItemValueText(const nsAString& text);
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(SharedObject)
|
||||
|
||||
|
||||
nsHTMLSharedObjectElement::nsHTMLSharedObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
FromParser aFromParser)
|
||||
: nsGenericHTMLElement(aNodeInfo),
|
||||
mIsDoneAddingChildren(mNodeInfo->Equals(nsGkAtoms::embed) || !aFromParser)
|
||||
{
|
||||
RegisterFreezableElement();
|
||||
SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
|
||||
|
||||
// By default we're in the loading state
|
||||
AddStatesSilently(NS_EVENT_STATE_LOADING);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLSharedObjectElement::GetItemValueText(nsAString& aValue)
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
nsGenericHTMLElement::GetItemValueText(aValue);
|
||||
} else {
|
||||
GetSrc(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLSharedObjectElement::SetItemValueText(const nsAString& aValue)
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
nsGenericHTMLElement::SetItemValueText(aValue);
|
||||
} else {
|
||||
SetSrc(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
nsHTMLSharedObjectElement::~nsHTMLSharedObjectElement()
|
||||
{
|
||||
UnregisterFreezableElement();
|
||||
DestroyImageLoadingContent();
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLSharedObjectElement::IsDoneAddingChildren()
|
||||
{
|
||||
return mIsDoneAddingChildren;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLSharedObjectElement::DoneAddingChildren(bool aHaveNotified)
|
||||
{
|
||||
if (!mIsDoneAddingChildren) {
|
||||
mIsDoneAddingChildren = true;
|
||||
|
||||
// If we're already in a document, we need to trigger the load
|
||||
// Otherwise, BindToTree takes care of that.
|
||||
if (IsInDoc()) {
|
||||
StartObjectLoad(aHaveNotified);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLSharedObjectElement,
|
||||
nsGenericHTMLElement)
|
||||
nsObjectLoadingContent::Traverse(tmp, cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLSharedObjectElement, Element)
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLSharedObjectElement, Element)
|
||||
|
||||
DOMCI_DATA(HTMLAppletElement, nsHTMLSharedObjectElement)
|
||||
DOMCI_DATA(HTMLEmbedElement, nsHTMLSharedObjectElement)
|
||||
|
||||
nsIClassInfo*
|
||||
nsHTMLSharedObjectElement::GetClassInfoInternal()
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
|
||||
return NS_GetDOMClassInfoInstance(eDOMClassInfo_HTMLAppletElement_id);
|
||||
}
|
||||
if (mNodeInfo->Equals(nsGkAtoms::embed)) {
|
||||
return NS_GetDOMClassInfoInstance(eDOMClassInfo_HTMLEmbedElement_id);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSharedObjectElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(nsHTMLSharedObjectElement,
|
||||
nsIDOMHTMLAppletElement)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIRequestObserver)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIStreamListener)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIFrameLoaderOwner)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIObjectLoadingContent)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, imgINotificationObserver)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIImageLoadingContent)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, imgIOnloadBlocker)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIInterfaceRequestor)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIChannelEventSink)
|
||||
NS_OFFSET_AND_INTERFACE_TABLE_END
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(nsHTMLSharedObjectElement,
|
||||
nsGenericHTMLElement,
|
||||
nsIDOMHTMLAppletElement)
|
||||
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLAppletElement, applet)
|
||||
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLEmbedElement, embed)
|
||||
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMGetSVGDocument, embed)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_GETTER(GetClassInfoInternal)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(nsHTMLSharedObjectElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLSharedObjectElement::BindToTree(nsIDocument *aDocument,
|
||||
nsIContent *aParent,
|
||||
nsIContent *aBindingParent,
|
||||
bool aCompileEventHandlers)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
aCompileEventHandlers);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
aCompileEventHandlers);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Don't kick off load from being bound to a plugin document - the plugin
|
||||
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
|
||||
// initial load.
|
||||
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument);
|
||||
|
||||
// If we already have all the children, start the load.
|
||||
if (mIsDoneAddingChildren && !pluginDoc) {
|
||||
void (nsHTMLSharedObjectElement::*start)() =
|
||||
&nsHTMLSharedObjectElement::StartObjectLoad;
|
||||
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLSharedObjectElement::UnbindFromTree(bool aDeep,
|
||||
bool aNullParent)
|
||||
{
|
||||
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
||||
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsHTMLSharedObjectElement::SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
||||
nsIAtom *aPrefix, const nsAString &aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
||||
aValue, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// if aNotify is false, we are coming from the parser or some such place;
|
||||
// we'll get bound after all the attributes have been set, so we'll do the
|
||||
// object load from BindToTree/DoneAddingChildren.
|
||||
// Skip the LoadObject call in that case.
|
||||
// We also don't want to start loading the object when we're not yet in
|
||||
// a document, just in case that the caller wants to set additional
|
||||
// attributes before inserting the node into the document.
|
||||
if (aNotify && IsInDoc() && mIsDoneAddingChildren &&
|
||||
aNameSpaceID == kNameSpaceID_None && aName == URIAttrName()) {
|
||||
return LoadObject(aNotify, true);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLSharedObjectElement::IsHTMLFocusable(bool aWithMouse,
|
||||
bool *aIsFocusable,
|
||||
int32_t *aTabIndex)
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::embed) || Type() == eType_Plugin) {
|
||||
// Has plugin content: let the plugin decide what to do in terms of
|
||||
// internal focus from mouse clicks
|
||||
if (aTabIndex) {
|
||||
GetTabIndex(aTabIndex);
|
||||
}
|
||||
|
||||
*aIsFocusable = true;
|
||||
|
||||
// Let the plugin decide, so override.
|
||||
return true;
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex);
|
||||
}
|
||||
|
||||
nsIContent::IMEState
|
||||
nsHTMLSharedObjectElement::GetDesiredIMEState()
|
||||
{
|
||||
if (Type() == eType_Plugin) {
|
||||
return IMEState(IMEState::PLUGIN);
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::GetDesiredIMEState();
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Alt, alt)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Archive, archive)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Code, code)
|
||||
NS_IMPL_URI_ATTR(nsHTMLSharedObjectElement, CodeBase, codebase)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Height, height)
|
||||
NS_IMPL_INT_ATTR(nsHTMLSharedObjectElement, Hspace, hspace)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Name, name)
|
||||
NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLSharedObjectElement, Object, object, codebase)
|
||||
NS_IMPL_URI_ATTR(nsHTMLSharedObjectElement, Src, src)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Type, type)
|
||||
NS_IMPL_INT_ATTR(nsHTMLSharedObjectElement, Vspace, vspace)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Width, width)
|
||||
|
||||
int32_t
|
||||
nsHTMLSharedObjectElement::TabIndexDefault()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSharedObjectElement::GetSVGDocument(nsIDOMDocument **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = nullptr;
|
||||
|
||||
if (!IsInDoc()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXXbz should this use GetCurrentDoc()? sXBL/XBL2 issue!
|
||||
nsIDocument *sub_doc = OwnerDoc()->GetSubDocumentFor(this);
|
||||
if (!sub_doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(sub_doc, aResult);
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLSharedObjectElement::ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom *aAttribute,
|
||||
const nsAString &aValue,
|
||||
nsAttrValue &aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::align) {
|
||||
return ParseAlignValue(aValue, aResult);
|
||||
}
|
||||
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
||||
aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesIntoRule(const nsMappedAttributes *aAttributes,
|
||||
nsRuleData *aData)
|
||||
{
|
||||
nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsHTMLSharedObjectElement::IsAttributeMapped(const nsIAtom *aAttribute) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sCommonAttributeMap,
|
||||
sImageMarginSizeAttributeMap,
|
||||
sImageBorderAttributeMap,
|
||||
sImageAlignAttributeMap,
|
||||
};
|
||||
|
||||
return FindAttributeDependence(aAttribute, map);
|
||||
}
|
||||
|
||||
|
||||
nsMapRuleToAttributesFunc
|
||||
nsHTMLSharedObjectElement::GetAttributeMappingFunction() const
|
||||
{
|
||||
return &MapAttributesIntoRule;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLSharedObjectElement::StartObjectLoad(bool aNotify)
|
||||
{
|
||||
// BindToTree can call us asynchronously, and we may be removed from the tree
|
||||
// in the interim
|
||||
if (!IsInDoc() || !OwnerDoc()->IsActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LoadObject(aNotify);
|
||||
SetIsNetworkCreated(false);
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
nsHTMLSharedObjectElement::IntrinsicState() const
|
||||
{
|
||||
return nsGenericHTMLElement::IntrinsicState() | ObjectState();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsHTMLSharedObjectElement::GetCapabilities() const
|
||||
{
|
||||
uint32_t capabilities = eSupportPlugins | eAllowPluginSkipChannel;
|
||||
if (mNodeInfo->Equals(nsGkAtoms::embed)) {
|
||||
capabilities |= eSupportSVG | eSupportImages;
|
||||
}
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLSharedObjectElement::DestroyContent()
|
||||
{
|
||||
nsObjectLoadingContent::DestroyContent();
|
||||
nsGenericHTMLElement::DestroyContent();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLSharedObjectElement::CopyInnerTo(Element* aDest)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
||||
CreateStaticClone(static_cast<nsHTMLSharedObjectElement*>(aDest));
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -247,6 +247,9 @@ MOCHITEST_FILES = \
|
|||
file_fullscreen-multiple-inner.html \
|
||||
test_li_attributes_reflection.html \
|
||||
test_link_attributes_reflection.html \
|
||||
test_object_attributes_reflection.html \
|
||||
test_embed_attributes_reflection.html \
|
||||
test_applet_attributes_reflection.html \
|
||||
test_ol_attributes_reflection.html \
|
||||
test_dl_attributes_reflection.html \
|
||||
test_ul_attributes_reflection.html \
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* OR
|
||||
* attribute Object object containing two attributes, 'content' and 'idl'
|
||||
* - otherValues Array [optional] other values to test in addition of the default ones
|
||||
* - extendedAttributes Object object which can have 'TreatNullAs': "EmptyString"
|
||||
*/
|
||||
function reflectString(aParameters)
|
||||
{
|
||||
|
@ -31,11 +32,13 @@ function reflectString(aParameters)
|
|||
? aParameters.attribute : aParameters.attribute.idl;
|
||||
var otherValues = aParameters.otherValues !== undefined
|
||||
? aParameters.otherValues : [];
|
||||
var treatNullAs = aParameters.extendedAttributes ?
|
||||
aParameters.extendedAttributes.TreatNullAs : null;
|
||||
|
||||
ok(idlAttr in element,
|
||||
idlAttr + " should be an IDL attribute of this element");
|
||||
is(typeof element[idlAttr], "string",
|
||||
idlAttr + " IDL attribute should be a string");
|
||||
"'" + idlAttr + "' IDL attribute should be a string");
|
||||
|
||||
// Tests when the attribute isn't set.
|
||||
is(element.getAttribute(contentAttr), null,
|
||||
|
@ -49,9 +52,9 @@ function reflectString(aParameters)
|
|||
*/
|
||||
element.setAttribute(contentAttr, null);
|
||||
is(element.getAttribute(contentAttr), "null",
|
||||
"null should have been stringified to 'null'");
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
is(element[idlAttr], "null",
|
||||
"null should have been stringified to 'null'");
|
||||
"null should have been stringified to 'null' for '" + idlAttr + "'");
|
||||
element.removeAttribute(contentAttr);
|
||||
|
||||
element[idlAttr] = null;
|
||||
|
@ -61,15 +64,23 @@ function reflectString(aParameters)
|
|||
input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ]
|
||||
};
|
||||
if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) {
|
||||
is(element.getAttribute(contentAttr), "null",
|
||||
"null should have been stringified to 'null'");
|
||||
is(element[idlAttr], "null", "null should have been stringified to 'null'");
|
||||
if (treatNullAs == "EmptyString") {
|
||||
is(element.getAttribute(contentAttr), "",
|
||||
"null should have been stringified to '' for '" + contentAttr + "'");
|
||||
is(element[idlAttr], "",
|
||||
"null should have been stringified to '' for '" + idlAttr + "'");
|
||||
} else {
|
||||
is(element.getAttribute(contentAttr), "null",
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
is(element[idlAttr], "null",
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
}
|
||||
element.removeAttribute(contentAttr);
|
||||
} else {
|
||||
todo_is(element.getAttribute(contentAttr), "null",
|
||||
"null should have been stringified to 'null'");
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
todo_is(element[idlAttr], "null",
|
||||
"null should have been stringified to 'null'");
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
element.removeAttribute(contentAttr);
|
||||
}
|
||||
|
||||
|
@ -106,16 +117,16 @@ function reflectString(aParameters)
|
|||
stringsToTest.forEach(function([v, r]) {
|
||||
element.setAttribute(contentAttr, v);
|
||||
is(element[idlAttr], r,
|
||||
"IDL attribute should return the value it has been set to.");
|
||||
"IDL attribute '" + idlAttr + "' should return the value it has been set to.");
|
||||
is(element.getAttribute(contentAttr), r,
|
||||
"Content attribute should return the value it has been set to.");
|
||||
"Content attribute '" + contentAttr + "'should return the value it has been set to.");
|
||||
element.removeAttribute(contentAttr);
|
||||
|
||||
element[idlAttr] = v;
|
||||
is(element[idlAttr], r,
|
||||
"IDL attribute should return the value it has been set to.");
|
||||
"IDL attribute '" + idlAttr + "' should return the value it has been set to.");
|
||||
is(element.getAttribute(contentAttr), r,
|
||||
"Content attribute should return the value it has been set to.");
|
||||
"Content attribute '" + contentAttr + "' should return the value it has been set to.");
|
||||
element.removeAttribute(contentAttr);
|
||||
});
|
||||
|
||||
|
@ -270,7 +281,7 @@ function reflectLimitedEnumerated(aParameters)
|
|||
? aParameters.unsupportedValues : [];
|
||||
|
||||
ok(idlAttr in element, idlAttr + " should be an IDL attribute of this element");
|
||||
is(typeof element[idlAttr], "string", idlAttr + " IDL attribute should be a string");
|
||||
is(typeof element[idlAttr], "string", "'" + idlAttr + "' IDL attribute should be a string");
|
||||
|
||||
// Explicitly check the default value.
|
||||
element.removeAttribute(contentAttr);
|
||||
|
@ -598,7 +609,7 @@ function reflectURL(aParameters)
|
|||
{
|
||||
var element = aParameters.element;
|
||||
var contentAttr = typeof aParameters.attribute === "string"
|
||||
? aParameters.attribute : aParameters.attribute.content;
|
||||
? aParameters.attribute : aParameters.attribute.content;
|
||||
var idlAttr = typeof aParameters.attribute === "string"
|
||||
? aParameters.attribute : aParameters.attribute.idl;
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for HTMLAppletElement attributes reflection</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="reflect.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for HTMLAppletElement attributes reflection **/
|
||||
|
||||
// .align (String)
|
||||
reflectString({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "align",
|
||||
});
|
||||
|
||||
// .alt (String)
|
||||
reflectString({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "alt",
|
||||
});
|
||||
|
||||
// .archive (String)
|
||||
reflectString({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "archive",
|
||||
});
|
||||
|
||||
// .code (String)
|
||||
reflectString({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "code",
|
||||
});
|
||||
|
||||
// .codeBase (URL)
|
||||
reflectURL({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "codeBase",
|
||||
});
|
||||
|
||||
// .height (String)
|
||||
reflectString({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "height",
|
||||
});
|
||||
|
||||
// .hspace (unsigned int)
|
||||
reflectUnsignedInt({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "hspace",
|
||||
});
|
||||
|
||||
// .name (String)
|
||||
reflectString({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "name",
|
||||
});
|
||||
|
||||
// .object (URL)
|
||||
reflectURL({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "object",
|
||||
});
|
||||
|
||||
// .vspace (unsigned int)
|
||||
reflectUnsignedInt({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "vspace",
|
||||
});
|
||||
|
||||
// .width (String)
|
||||
reflectString({
|
||||
element: document.createElement("applet"),
|
||||
attribute: "width",
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for HTMLEmbedElement attributes reflection</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="reflect.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for HTMLEmbedElement attributes reflection **/
|
||||
|
||||
// .src (URL)
|
||||
reflectURL({
|
||||
element: document.createElement("embed"),
|
||||
attribute: "src",
|
||||
});
|
||||
|
||||
// .type (String)
|
||||
reflectString({
|
||||
element: document.createElement("embed"),
|
||||
attribute: "type",
|
||||
});
|
||||
|
||||
// .width (String)
|
||||
reflectString({
|
||||
element: document.createElement("embed"),
|
||||
attribute: "width",
|
||||
});
|
||||
|
||||
// .height (String)
|
||||
reflectString({
|
||||
element: document.createElement("embed"),
|
||||
attribute: "height",
|
||||
});
|
||||
|
||||
// .align (String)
|
||||
reflectString({
|
||||
element: document.createElement("embed"),
|
||||
attribute: "align",
|
||||
});
|
||||
|
||||
// .name (String)
|
||||
reflectString({
|
||||
element: document.createElement("embed"),
|
||||
attribute: "name",
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,117 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for HTMLObjectElement attributes reflection</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="reflect.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for HTMLObjectElement attributes reflection **/
|
||||
|
||||
// .data (URL)
|
||||
reflectURL({
|
||||
element: document.createElement("object"),
|
||||
attribute: "data",
|
||||
});
|
||||
|
||||
// .type (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "type",
|
||||
});
|
||||
|
||||
// .name (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "name",
|
||||
});
|
||||
|
||||
// .useMap (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "useMap",
|
||||
});
|
||||
|
||||
// .width (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "width",
|
||||
});
|
||||
|
||||
// .height (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "height",
|
||||
});
|
||||
|
||||
// .align (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "align",
|
||||
});
|
||||
|
||||
// .archive (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "archive",
|
||||
});
|
||||
|
||||
// .code (URL)
|
||||
reflectURL({
|
||||
element: document.createElement("object"),
|
||||
attribute: "code",
|
||||
});
|
||||
|
||||
// .declare (String)
|
||||
reflectBoolean({
|
||||
element: document.createElement("object"),
|
||||
attribute: "declare",
|
||||
});
|
||||
|
||||
// .hspace (unsigned int)
|
||||
reflectUnsignedInt({
|
||||
element: document.createElement("object"),
|
||||
attribute: "hspace",
|
||||
});
|
||||
|
||||
// .standby (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "standby",
|
||||
});
|
||||
|
||||
// .vspace (unsigned int)
|
||||
reflectUnsignedInt({
|
||||
element: document.createElement("object"),
|
||||
attribute: "vspace",
|
||||
});
|
||||
|
||||
// .codeBase (URL)
|
||||
reflectURL({
|
||||
element: document.createElement("object"),
|
||||
attribute: "codeBase",
|
||||
});
|
||||
|
||||
// .codeType (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "codeType",
|
||||
});
|
||||
|
||||
// .border (String)
|
||||
reflectString({
|
||||
element: document.createElement("object"),
|
||||
attribute: "border",
|
||||
extendedAttributes: { TreatNullAs: "EmptyString" },
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -29,13 +29,7 @@ var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
|||
// We need to wait for the hidden window to load, but can't access
|
||||
// an event target for a regular event listener.
|
||||
var hidden = mainWindow.Services.appShell.hiddenPrivateDOMWindow;
|
||||
var tmp = setTimeout(function poll() {
|
||||
if (hidden.location.href != "resource://gre-resources/hiddenWindow.html" ||
|
||||
!hidden.document.body) {
|
||||
setTimeout(poll, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
mainWindow.PrivateBrowsingUtils.whenHiddenPrivateWindowReady(function(hidden) {
|
||||
var iframe = hidden.document.createElement('iframe');
|
||||
iframe.src = 'generic.html';
|
||||
hidden.document.body.appendChild(iframe);
|
||||
|
@ -46,7 +40,7 @@ var tmp = setTimeout(function poll() {
|
|||
win.close();
|
||||
win = null;
|
||||
}, false);
|
||||
}, 100);
|
||||
});
|
||||
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
is(aTopic, "last-pb-context-exited", "Unexpected observer topic");
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
#include "nsStringBuffer.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsWrapperCache;
|
||||
|
||||
// nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
|
||||
// try to use it without fixing that first.
|
||||
class nsGlobalWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -379,6 +385,52 @@ private:
|
|||
JSContext* mCx;
|
||||
};
|
||||
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(nsWrapperCache* cache)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(nsGlobalWindow* not_allowed);
|
||||
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(void* p)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Helper template for smart pointers to resolve ambiguity between
|
||||
// GetWrappeCache(void*) and GetWrapperCache(const ParentObject&).
|
||||
template <template <typename> class SmartPtr, typename T>
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(const SmartPtr<T>& aObject)
|
||||
{
|
||||
return GetWrapperCache(aObject.get());
|
||||
}
|
||||
|
||||
struct ParentObject {
|
||||
template<class T>
|
||||
ParentObject(T* aObject) :
|
||||
mObject(aObject),
|
||||
mWrapperCache(GetWrapperCache(aObject))
|
||||
{}
|
||||
|
||||
template<class T, template<typename> class SmartPtr>
|
||||
ParentObject(const SmartPtr<T>& aObject) :
|
||||
mObject(aObject.get()),
|
||||
mWrapperCache(GetWrapperCache(aObject.get()))
|
||||
{}
|
||||
|
||||
ParentObject(nsISupports* aObject, nsWrapperCache* aCache) :
|
||||
mObject(aObject),
|
||||
mWrapperCache(aCache)
|
||||
{}
|
||||
|
||||
nsISupports* const mObject;
|
||||
nsWrapperCache* const mWrapperCache;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "mozilla/dom/HTMLObjectElement.h"
|
||||
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
||||
#include "mozilla/dom/HTMLSharedObjectElement.h"
|
||||
#include "mozilla/dom/HTMLEmbedElementBinding.h"
|
||||
#include "mozilla/dom/HTMLAppletElementBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -1533,9 +1536,20 @@ ReparentWrapper(JSContext* aCx, JSObject* aObj)
|
|||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
HTMLObjectElement* htmlobject;
|
||||
nsObjectLoadingContent* htmlobject;
|
||||
nsresult rv = UnwrapObject<HTMLObjectElement>(aCx, aObj, htmlobject);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = UnwrapObject<prototypes::id::HTMLEmbedElement,
|
||||
HTMLSharedObjectElement>(aCx, aObj, htmlobject);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = UnwrapObject<prototypes::id::HTMLAppletElement,
|
||||
HTMLSharedObjectElement>(aCx, aObj, htmlobject);
|
||||
if (NS_FAILED(rv)) {
|
||||
htmlobject = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (htmlobject) {
|
||||
htmlobject->SetupProtoChain(aCx, aObj);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,6 @@
|
|||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/CallbackObject.h"
|
||||
|
||||
// nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
|
||||
// try to use it without fixing that first.
|
||||
class nsGlobalWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -682,30 +678,6 @@ NativeInterface2JSObjectAndThrowIfFailed(JSContext* aCx,
|
|||
const nsIID* aIID,
|
||||
bool aAllowNativeWrapper);
|
||||
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(nsWrapperCache* cache)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(nsGlobalWindow* not_allowed);
|
||||
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(void* p)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Helper template for smart pointers to resolve ambiguity between
|
||||
// GetWrappeCache(void*) and GetWrapperCache(const ParentObject&).
|
||||
template <template <typename> class SmartPtr, typename T>
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(const SmartPtr<T>& aObject)
|
||||
{
|
||||
return GetWrapperCache(aObject.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to handle new-binding wrap failure, by possibly falling back to
|
||||
* wrapping as a non-new-binding object.
|
||||
|
@ -827,28 +799,6 @@ FindEnumStringIndex(JSContext* cx, JS::Value v, const EnumEntry* values,
|
|||
return -1;
|
||||
}
|
||||
|
||||
struct ParentObject {
|
||||
template<class T>
|
||||
ParentObject(T* aObject) :
|
||||
mObject(aObject),
|
||||
mWrapperCache(GetWrapperCache(aObject))
|
||||
{}
|
||||
|
||||
template<class T, template<typename> class SmartPtr>
|
||||
ParentObject(const SmartPtr<T>& aObject) :
|
||||
mObject(aObject.get()),
|
||||
mWrapperCache(GetWrapperCache(aObject.get()))
|
||||
{}
|
||||
|
||||
ParentObject(nsISupports* aObject, nsWrapperCache* aCache) :
|
||||
mObject(aObject),
|
||||
mWrapperCache(aCache)
|
||||
{}
|
||||
|
||||
nsISupports* const mObject;
|
||||
nsWrapperCache* const mWrapperCache;
|
||||
};
|
||||
|
||||
inline nsWrapperCache*
|
||||
GetWrapperCache(const ParentObject& aParentObject)
|
||||
{
|
||||
|
|
|
@ -196,6 +196,11 @@ DOMInterfaces = {
|
|||
'nativeType': 'nsICSSDeclaration'
|
||||
},
|
||||
|
||||
'CSSStyleSheet': {
|
||||
'nativeType': 'nsCSSStyleSheet',
|
||||
'binaryNames': { 'ownerRule': 'DOMOwnerRule' },
|
||||
},
|
||||
|
||||
'CSSValue': {
|
||||
'concrete': False
|
||||
},
|
||||
|
@ -345,6 +350,10 @@ DOMInterfaces = {
|
|||
'wrapperCache': False
|
||||
},
|
||||
|
||||
'HTMLAppletElement': {
|
||||
'nativeType': 'mozilla::dom::HTMLSharedObjectElement'
|
||||
},
|
||||
|
||||
'HTMLBaseElement': {
|
||||
'nativeType': 'mozilla::dom::HTMLSharedElement'
|
||||
},
|
||||
|
@ -386,6 +395,10 @@ DOMInterfaces = {
|
|||
]
|
||||
},
|
||||
|
||||
'HTMLEmbedElement': {
|
||||
'nativeType': 'mozilla::dom::HTMLSharedObjectElement'
|
||||
},
|
||||
|
||||
'HTMLHeadElement': {
|
||||
'nativeType': 'mozilla::dom::HTMLSharedElement'
|
||||
},
|
||||
|
@ -626,6 +639,10 @@ DOMInterfaces = {
|
|||
'nativeType': 'nsScreen',
|
||||
},
|
||||
|
||||
'StyleSheet': {
|
||||
'nativeType': 'nsCSSStyleSheet',
|
||||
},
|
||||
|
||||
'SVGAnimatedLengthList': {
|
||||
'nativeType': 'mozilla::DOMSVGAnimatedLengthList',
|
||||
'headerFile': 'DOMSVGAnimatedLengthList.h'
|
||||
|
@ -1097,6 +1114,24 @@ DOMInterfaces = {
|
|||
'register': False,
|
||||
},
|
||||
|
||||
'TestJSImplInterface' : {
|
||||
# Keep this in sync with TestExampleInterface
|
||||
'headerFile': 'TestJSImplGenBinding.h',
|
||||
'register': False,
|
||||
'resultNotAddRefed': [ 'receiveWeakSelf', 'receiveWeakNullableSelf',
|
||||
'receiveWeakOther', 'receiveWeakNullableOther',
|
||||
'receiveWeakExternal', 'receiveWeakNullableExternal',
|
||||
'ReceiveWeakCallbackInterface',
|
||||
'ReceiveWeakNullableCallbackInterface',
|
||||
'receiveWeakCastableObjectSequence',
|
||||
'receiveWeakNullableCastableObjectSequence',
|
||||
'receiveWeakCastableObjectNullableSequence',
|
||||
'receiveWeakNullableCastableObjectNullableSequence' ],
|
||||
'binaryNames': { 'methodRenamedFrom': 'methodRenamedTo',
|
||||
'attributeGetterRenamedFrom': 'attributeGetterRenamedTo',
|
||||
'attributeRenamedFrom': 'attributeRenamedTo' }
|
||||
},
|
||||
|
||||
'TestExternalInterface' : {
|
||||
'nativeType': 'mozilla::dom::TestExternalInterface',
|
||||
'headerFile': 'TestBindingHeader.h',
|
||||
|
@ -1295,6 +1330,7 @@ addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
|||
addExternalIface('Counter')
|
||||
addExternalIface('CSSRule')
|
||||
addExternalIface('DOMError')
|
||||
addExternalIface('CSSRuleList')
|
||||
addExternalIface('DOMStringList')
|
||||
addExternalIface('File')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
|
@ -1302,6 +1338,7 @@ addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElemen
|
|||
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
|
||||
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
|
||||
addExternalIface('LockedFile')
|
||||
addExternalIface('MediaList')
|
||||
addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
|
||||
addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
|
||||
addExternalIface('MozControllers', nativeType='nsIControllers')
|
||||
|
@ -1319,7 +1356,6 @@ addExternalIface('OutputStream', nativeType='nsIOutputStream',
|
|||
addExternalIface('Principal', nativeType='nsIPrincipal',
|
||||
headerFile='nsIPrincipal.h', notflattened=True)
|
||||
addExternalIface('Selection', nativeType='nsISelection')
|
||||
addExternalIface('StyleSheet', nativeType='nsIStyleSheet')
|
||||
addExternalIface('StyleSheetList')
|
||||
addExternalIface('SVGAnimatedEnumeration', headerFile='nsIDOMSVGAnimatedEnum.h')
|
||||
addExternalIface('SVGAnimatedNumber')
|
||||
|
|
|
@ -10,7 +10,7 @@ import re
|
|||
import string
|
||||
|
||||
from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType
|
||||
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback
|
||||
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, Descriptor
|
||||
|
||||
AUTOGENERATED_WARNING_COMMENT = \
|
||||
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
|
||||
|
@ -476,8 +476,9 @@ class CGHeaders(CGWrapper):
|
|||
Generates the appropriate include statements.
|
||||
"""
|
||||
def __init__(self, descriptors, dictionaries, callbacks,
|
||||
callbackDescriptors, declareIncludes, defineIncludes, child,
|
||||
config=None):
|
||||
callbackDescriptors,
|
||||
declareIncludes, defineIncludes, child,
|
||||
config=None, anyJSImplemented=False):
|
||||
"""
|
||||
Builds a set of includes to cover |descriptors|.
|
||||
|
||||
|
@ -586,7 +587,7 @@ class CGHeaders(CGWrapper):
|
|||
# And we need BindingUtils.h so we can wrap "this" objects
|
||||
declareIncludes.add("mozilla/dom/BindingUtils.h")
|
||||
|
||||
if len(callbackDescriptors) != 0:
|
||||
if len(callbackDescriptors) != 0 or anyJSImplemented:
|
||||
# We need CallbackInterface to serve as our parent class
|
||||
declareIncludes.add("mozilla/dom/CallbackInterface.h")
|
||||
# And we need BindingUtils.h so we can wrap "this" objects
|
||||
|
@ -7075,7 +7076,8 @@ class CGBindingRoot(CGThing):
|
|||
workers=True)
|
||||
callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile,
|
||||
isCallback=True)
|
||||
|
||||
jsImplemented = config.getDescriptors(webIDLFile=webIDLFile,
|
||||
isJSImplemented=True)
|
||||
forwardDeclares = [CGClassForwardDeclare('XPCWrappedNativeScope')]
|
||||
|
||||
descriptorsForForwardDeclaration = list(descriptors)
|
||||
|
@ -7229,6 +7231,11 @@ class CGBindingRoot(CGThing):
|
|||
# Do codegen for all the callback interfaces
|
||||
cgthings.extend([CGCallbackInterface(x) for x in callbackDescriptors])
|
||||
|
||||
# Do codegen for JS implemented classes
|
||||
for x in jsImplemented:
|
||||
cgthings.append(CGCallbackInterface(x))
|
||||
cgthings.append(CGJSImplClass(x))
|
||||
|
||||
# And make sure we have the right number of newlines at the end
|
||||
curr = CGWrapper(CGList(cgthings, "\n\n"), post="\n\n")
|
||||
|
||||
|
@ -7267,7 +7274,8 @@ class CGBindingRoot(CGThing):
|
|||
'nsDOMQS.h'
|
||||
],
|
||||
curr,
|
||||
config)
|
||||
config,
|
||||
anyJSImplemented = len(jsImplemented) != 0)
|
||||
|
||||
# Add include guards.
|
||||
curr = CGIncludeGuard(prefix, curr)
|
||||
|
@ -7621,7 +7629,7 @@ class CGNativeMember(ClassMethod):
|
|||
|
||||
|
||||
class CGExampleMethod(CGNativeMember):
|
||||
def __init__(self, descriptor, method, signature, breakAfter=True):
|
||||
def __init__(self, descriptor, method, signature, isConstructor, breakAfter=True):
|
||||
CGNativeMember.__init__(self, descriptor, method,
|
||||
CGSpecializedMethod.makeNativeName(descriptor,
|
||||
method),
|
||||
|
@ -7655,38 +7663,45 @@ class CGExampleSetter(CGNativeMember):
|
|||
def define(self, cgClass):
|
||||
return ''
|
||||
|
||||
class CGExampleClass(CGClass):
|
||||
class CGBindingImplClass(CGClass):
|
||||
"""
|
||||
Codegen for the actual example class implemenation for this descriptor
|
||||
Common codegen for generating a C++ implementation of a WebIDL interface
|
||||
"""
|
||||
def __init__(self, descriptor):
|
||||
def __init__(self, descriptor, cgMethod, cgGetter, cgSetter):
|
||||
"""
|
||||
cgMethod, cgGetter and cgSetter are classes used to codegen methods,
|
||||
getters and setters.
|
||||
"""
|
||||
self.descriptor = descriptor
|
||||
self._deps = descriptor.interface.getDeps()
|
||||
|
||||
iface = descriptor.interface
|
||||
|
||||
methodDecls = []
|
||||
def appendMethod(m):
|
||||
self.methodDecls = []
|
||||
def appendMethod(m, isConstructor=False):
|
||||
sigs = m.signatures()
|
||||
for s in sigs[:-1]:
|
||||
# Don't put an empty line after overloads, until we
|
||||
# get to the last one.
|
||||
methodDecls.append(CGExampleMethod(descriptor, m, s,
|
||||
breakAfter=False))
|
||||
methodDecls.append(CGExampleMethod(descriptor, m, sigs[-1]))
|
||||
self.methodDecls.append(cgMethod(descriptor, m, s,
|
||||
isConstructor,
|
||||
breakAfter=False))
|
||||
self.methodDecls.append(cgMethod(descriptor, m, sigs[-1],
|
||||
isConstructor))
|
||||
|
||||
if iface.ctor():
|
||||
appendMethod(iface.ctor())
|
||||
appendMethod(iface.ctor(), isConstructor=True)
|
||||
for n in iface.namedConstructors:
|
||||
appendMethod(n)
|
||||
appendMethod(n, isConstructor=True)
|
||||
for m in iface.members:
|
||||
if m.isMethod():
|
||||
if m.isIdentifierLess():
|
||||
continue
|
||||
appendMethod(m)
|
||||
elif m.isAttr():
|
||||
methodDecls.append(CGExampleGetter(descriptor, m))
|
||||
self.methodDecls.append(cgGetter(descriptor, m))
|
||||
if not m.readonly:
|
||||
methodDecls.append(CGExampleSetter(descriptor, m))
|
||||
self.methodDecls.append(cgSetter(descriptor, m))
|
||||
|
||||
# Now do the special operations
|
||||
def appendSpecialOperation(name, op):
|
||||
|
@ -7719,7 +7734,7 @@ class CGExampleClass(CGClass):
|
|||
else:
|
||||
# We already added this method
|
||||
return
|
||||
methodDecls.append(
|
||||
self.methodDecls.append(
|
||||
CGNativeMember(descriptor, op,
|
||||
name,
|
||||
(returnType, args),
|
||||
|
@ -7732,7 +7747,7 @@ class CGExampleClass(CGClass):
|
|||
# If we support indexed properties, then we need a Length()
|
||||
# method so we know which indices are supported.
|
||||
if descriptor.supportsIndexedProperties():
|
||||
methodDecls.append(
|
||||
self.methodDecls.append(
|
||||
CGNativeMember(descriptor, FakeMember(),
|
||||
"Length",
|
||||
(BuiltinTypes[IDLBuiltinType.Types.unsigned_long],
|
||||
|
@ -7741,7 +7756,7 @@ class CGExampleClass(CGClass):
|
|||
# And if we support named properties we need to be able to
|
||||
# enumerate the supported names.
|
||||
if descriptor.supportsNamedProperties():
|
||||
methodDecls.append(
|
||||
self.methodDecls.append(
|
||||
CGNativeMember(
|
||||
descriptor, FakeMember(),
|
||||
"GetSupportedNames",
|
||||
|
@ -7752,18 +7767,41 @@ class CGExampleClass(CGClass):
|
|||
|
||||
wrapArgs = [Argument('JSContext*', 'aCx'),
|
||||
Argument('JSObject*', 'aScope')]
|
||||
methodDecls.insert(0,
|
||||
ClassMethod("WrapObject", "JSObject*",
|
||||
wrapArgs, virtual=descriptor.wrapperCache,
|
||||
breakAfterReturnDecl=" "))
|
||||
getParentObjectReturnType = (
|
||||
"// TODO: return something sensible here, and change the return type\n"
|
||||
"%s*" % descriptor.name)
|
||||
methodDecls.insert(0,
|
||||
ClassMethod("GetParentObject",
|
||||
getParentObjectReturnType,
|
||||
[], const=True,
|
||||
breakAfterReturnDecl=" "))
|
||||
self.methodDecls.insert(0,
|
||||
ClassMethod("WrapObject", "JSObject*",
|
||||
wrapArgs, virtual=descriptor.wrapperCache,
|
||||
breakAfterReturnDecl=" ",
|
||||
body=self.getWrapObjectBody()))
|
||||
self.methodDecls.insert(0,
|
||||
ClassMethod("GetParentObject",
|
||||
self.getGetParentObjectReturnType(),
|
||||
[], const=True,
|
||||
breakAfterReturnDecl=" ",
|
||||
body=self.getGetParentObjectBody()))
|
||||
|
||||
# Invoke CGClass.__init__ in any subclasses afterwards to do the actual codegen.
|
||||
|
||||
def getWrapObjectBody(self):
|
||||
return None
|
||||
|
||||
def getGetParentObjectReturnType(self):
|
||||
return ("// TODO: return something sensible here, and change the return type\n"
|
||||
"%s*" % self.descriptor.name)
|
||||
|
||||
def getGetParentObjectBody(self):
|
||||
return None
|
||||
|
||||
def deps(self):
|
||||
return self._deps
|
||||
|
||||
|
||||
class CGExampleClass(CGBindingImplClass):
|
||||
"""
|
||||
Codegen for the actual example class implementation for this descriptor
|
||||
"""
|
||||
def __init__(self, descriptor):
|
||||
CGBindingImplClass.__init__(self, descriptor, CGExampleMethod, CGExampleGetter, CGExampleSetter)
|
||||
|
||||
extradeclarations=(
|
||||
"public:\n"
|
||||
" NS_DECL_CYCLE_COLLECTING_ISUPPORTS\n"
|
||||
|
@ -7776,7 +7814,7 @@ class CGExampleClass(CGClass):
|
|||
constructors=[ClassConstructor([],
|
||||
visibility="public")],
|
||||
destructor=ClassDestructor(visibility="public"),
|
||||
methods=methodDecls,
|
||||
methods=self.methodDecls,
|
||||
decorators="MOZ_FINAL",
|
||||
extradeclarations=extradeclarations)
|
||||
|
||||
|
@ -7869,6 +7907,158 @@ class CGExampleRoot(CGThing):
|
|||
def define(self):
|
||||
return self.root.define()
|
||||
|
||||
|
||||
def jsImplName(name):
|
||||
return name + "JSImpl"
|
||||
|
||||
class CGJSImplMethod(CGNativeMember):
|
||||
def __init__(self, descriptor, method, signature, isConstructor, breakAfter=True):
|
||||
CGNativeMember.__init__(self, descriptor, method,
|
||||
CGSpecializedMethod.makeNativeName(descriptor,
|
||||
method),
|
||||
signature,
|
||||
descriptor.getExtendedAttributes(method),
|
||||
breakAfter=breakAfter,
|
||||
variadicIsSequence=True)
|
||||
self.signature = signature
|
||||
if isConstructor:
|
||||
self.body = self.getConstructorImpl()
|
||||
else:
|
||||
self.body = self.getImpl()
|
||||
|
||||
def getImpl(self):
|
||||
callbackArgs = [arg.name for arg in self.getArgs(self.signature[0], self.signature[1])]
|
||||
return 'return mImpl->%s(%s);' % (self.name, ", ".join(callbackArgs))
|
||||
|
||||
def getConstructorImpl(self):
|
||||
assert self.descriptor.interface.isJSImplemented()
|
||||
if self.name != 'Constructor':
|
||||
raise TypeError("Named constructors are not supported for JS implemented WebIDL. See bug 851287.")
|
||||
if len(self.signature[1]) != 0:
|
||||
raise TypeError("Constructors with arguments are unsupported. See bug 851178.")
|
||||
|
||||
return string.Template(
|
||||
""" // Get the window to use as a parent.
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.Get());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
// Get the JS implementation for the WebIDL interface.
|
||||
nsCOMPtr<nsISupports> implISupports = do_CreateInstance("${contractId}");
|
||||
MOZ_ASSERT(implISupports, "Failed to get JS implementation instance from contract ID.");
|
||||
if (!implISupports) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsIXPConnectWrappedJS> implWrapped = do_QueryInterface(implISupports);
|
||||
MOZ_ASSERT(implWrapped, "Failed to get wrapped JS from XPCOM component.");
|
||||
if (!implWrapped) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
JSObject* jsImplObj;
|
||||
if (NS_FAILED(implWrapped->GetJSObject(&jsImplObj))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
// Construct the callback interface object.
|
||||
bool initOk;
|
||||
nsRefPtr<${callbackClass}> cbImpl = new ${callbackClass}(cx, nullptr, jsImplObj, &initOk);
|
||||
if (!initOk) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
// Build the actual implementation.
|
||||
nsRefPtr<${implClass}> impl = new ${implClass}(cbImpl, window);
|
||||
return impl.forget();""").substitute({"implClass" : self.descriptor.name,
|
||||
"callbackClass" : jsImplName(self.descriptor.name),
|
||||
"contractId" : self.descriptor.interface.getJSImplementation()
|
||||
})
|
||||
|
||||
# We're always fallible
|
||||
def callbackGetterName(attr):
|
||||
return "Get" + MakeNativeName(attr.identifier.name)
|
||||
|
||||
def callbackSetterName(attr):
|
||||
return "Set" + MakeNativeName(attr.identifier.name)
|
||||
|
||||
class CGJSImplGetter(CGNativeMember):
|
||||
def __init__(self, descriptor, attr):
|
||||
CGNativeMember.__init__(self, descriptor, attr,
|
||||
CGSpecializedGetter.makeNativeName(descriptor,
|
||||
attr),
|
||||
(attr.type, []),
|
||||
descriptor.getExtendedAttributes(attr,
|
||||
getter=True))
|
||||
self.body = self.getImpl()
|
||||
|
||||
def getImpl(self):
|
||||
callbackArgs = [arg.name for arg in self.getArgs(self.member.type, [])]
|
||||
return 'return mImpl->%s(%s);' % (callbackGetterName(self.member), ", ".join(callbackArgs))
|
||||
|
||||
class CGJSImplSetter(CGNativeMember):
|
||||
def __init__(self, descriptor, attr):
|
||||
CGNativeMember.__init__(self, descriptor, attr,
|
||||
CGSpecializedSetter.makeNativeName(descriptor,
|
||||
attr),
|
||||
(BuiltinTypes[IDLBuiltinType.Types.void],
|
||||
[FakeArgument(attr.type, attr)]),
|
||||
descriptor.getExtendedAttributes(attr,
|
||||
setter=True))
|
||||
self.body = self.getImpl()
|
||||
|
||||
def getImpl(self):
|
||||
callbackArgs = [arg.name for arg in self.getArgs(BuiltinTypes[IDLBuiltinType.Types.void],
|
||||
[FakeArgument(self.member.type, self.member)])]
|
||||
return 'mImpl->%s(%s);' % (callbackSetterName(self.member), ", ".join(callbackArgs))
|
||||
|
||||
class CGJSImplClass(CGBindingImplClass):
|
||||
def __init__(self, descriptor):
|
||||
CGBindingImplClass.__init__(self, descriptor, CGJSImplMethod, CGJSImplGetter, CGJSImplSetter)
|
||||
|
||||
extradeclarations=(
|
||||
"public:\n"
|
||||
" NS_DECL_CYCLE_COLLECTING_ISUPPORTS\n"
|
||||
" NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(%s)\n"
|
||||
"\n"
|
||||
"private:\n"
|
||||
" nsRefPtr<%s> mImpl;\n"
|
||||
" nsCOMPtr<nsISupports> mParent;\n"
|
||||
"\n" % (descriptor.name, jsImplName(descriptor.name)))
|
||||
|
||||
extradefinitions= string.Template(
|
||||
"NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(${ifaceName}, mImpl, mParent)\n"
|
||||
"NS_IMPL_CYCLE_COLLECTING_ADDREF(${ifaceName})\n"
|
||||
"NS_IMPL_CYCLE_COLLECTING_RELEASE(${ifaceName})\n"
|
||||
"NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(${ifaceName})\n"
|
||||
" NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY\n"
|
||||
" NS_INTERFACE_MAP_ENTRY(nsISupports)\n"
|
||||
"NS_INTERFACE_MAP_END\n").substitute({ "ifaceName": self.descriptor.name })
|
||||
|
||||
CGClass.__init__(self, descriptor.name,
|
||||
bases=[ClassBase("nsISupports"),
|
||||
ClassBase("nsWrapperCache")],
|
||||
constructors=[ClassConstructor([Argument(jsImplName(descriptor.name) + "*", "aImpl"),
|
||||
Argument("nsISupports*", "aParent")],
|
||||
visibility="public",
|
||||
baseConstructors=["mImpl(aImpl)",
|
||||
"mParent(aParent)"],
|
||||
body="SetIsDOMBinding();")],
|
||||
methods=self.methodDecls,
|
||||
decorators="MOZ_FINAL",
|
||||
extradeclarations=extradeclarations,
|
||||
extradefinitions=extradefinitions)
|
||||
|
||||
def getWrapObjectBody(self):
|
||||
return "return %sBinding::Wrap(aCx, aScope, this);" % self.descriptor.name
|
||||
|
||||
def getGetParentObjectReturnType(self):
|
||||
return "nsISupports*"
|
||||
|
||||
def getGetParentObjectBody(self):
|
||||
return "return mParent;"
|
||||
|
||||
class CGCallback(CGClass):
|
||||
def __init__(self, idlObject, descriptorProvider, baseName, methods,
|
||||
getters=[], setters=[]):
|
||||
|
@ -7877,6 +8067,8 @@ class CGCallback(CGClass):
|
|||
name = idlObject.identifier.name
|
||||
if descriptorProvider.workers:
|
||||
name += "Workers"
|
||||
if isinstance(descriptorProvider, Descriptor) and descriptorProvider.interface.isJSImplemented():
|
||||
name = jsImplName(name)
|
||||
# For our public methods that needThisHandling we want most of the
|
||||
# same args and the same return type as what CallbackMember
|
||||
# generates. So we want to take advantage of all its
|
||||
|
@ -8039,7 +8231,7 @@ class CallbackMember(CGNativeMember):
|
|||
# will handle generating public versions that handle the "this" stuff.
|
||||
visibility = "private" if needThisHandling else "public"
|
||||
# We don't care, for callback codegen, whether our original member was
|
||||
# a method or attribure or whatnot. Just always pass FakeMember()
|
||||
# a method or attribute or whatnot. Just always pass FakeMember()
|
||||
# here.
|
||||
CGNativeMember.__init__(self, descriptorProvider, FakeMember(),
|
||||
name, (self.retvalType, args),
|
||||
|
@ -8309,8 +8501,7 @@ class CallbackGetter(CallbackMember):
|
|||
self.attrName = attr.identifier.name
|
||||
CallbackMember.__init__(self,
|
||||
(attr.type, []),
|
||||
# We're always fallible
|
||||
"Get" + MakeNativeName(attr.identifier.name),
|
||||
callbackGetterName(attr),
|
||||
descriptor,
|
||||
needThisHandling=False)
|
||||
|
||||
|
@ -8335,7 +8526,7 @@ class CallbackSetter(CallbackMember):
|
|||
CallbackMember.__init__(self,
|
||||
(BuiltinTypes[IDLBuiltinType.Types.void],
|
||||
[FakeArgument(attr.type, attr)]),
|
||||
"Set" + MakeNativeName(attr.identifier.name),
|
||||
callbackSetterName(attr),
|
||||
descriptor,
|
||||
needThisHandling=False)
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@ class Configuration:
|
|||
getter = lambda x: x.interface.isCallback()
|
||||
elif key == 'isExternal':
|
||||
getter = lambda x: x.interface.isExternal()
|
||||
elif key == 'isJSImplemented':
|
||||
getter = lambda x: x.interface.isJSImplemented()
|
||||
else:
|
||||
getter = lambda x: getattr(x, key)
|
||||
curr = filter(lambda x: getter(x) == val, curr)
|
||||
|
@ -213,7 +215,7 @@ class Descriptor(DescriptorProvider):
|
|||
# Do something sane for JSObject
|
||||
if self.nativeType == "JSObject":
|
||||
headerDefault = "jsapi.h"
|
||||
elif self.interface.isCallback():
|
||||
elif self.interface.isCallback() or self.interface.isJSImplemented():
|
||||
# A copy of CGHeaders.getDeclarationFilename; we can't
|
||||
# import it here, sadly.
|
||||
# Use our local version of the header, not the exported one, so that
|
||||
|
@ -376,8 +378,11 @@ class Descriptor(DescriptorProvider):
|
|||
else:
|
||||
add('all', [config], attribute)
|
||||
|
||||
for attribute in ['implicitJSContext', 'resultNotAddRefed']:
|
||||
addExtendedAttribute(attribute, desc.get(attribute, {}))
|
||||
if self.interface.isJSImplemented():
|
||||
addExtendedAttribute('implicitJSContext', ['constructor'])
|
||||
else:
|
||||
for attribute in ['implicitJSContext', 'resultNotAddRefed']:
|
||||
addExtendedAttribute(attribute, desc.get(attribute, {}))
|
||||
|
||||
self.binaryNames = desc.get('binaryNames', {})
|
||||
if '__legacycaller' not in self.binaryNames:
|
||||
|
@ -420,9 +425,9 @@ class Descriptor(DescriptorProvider):
|
|||
attrs.append("infallible")
|
||||
|
||||
name = member.identifier.name
|
||||
throws = self.interface.isJSImplemented() or member.getExtendedAttribute("Throws")
|
||||
if member.isMethod():
|
||||
attrs = self.extendedAttributes['all'].get(name, [])
|
||||
throws = member.getExtendedAttribute("Throws")
|
||||
maybeAppendInfallibleToAttrs(attrs, throws)
|
||||
return attrs
|
||||
|
||||
|
@ -430,7 +435,6 @@ class Descriptor(DescriptorProvider):
|
|||
assert bool(getter) != bool(setter)
|
||||
key = 'getterOnly' if getter else 'setterOnly'
|
||||
attrs = self.extendedAttributes['all'].get(name, []) + self.extendedAttributes[key].get(name, [])
|
||||
throws = member.getExtendedAttribute("Throws")
|
||||
if throws is None:
|
||||
throwsAttr = "GetterThrows" if getter else "SetterThrows"
|
||||
throws = member.getExtendedAttribute(throwsAttr)
|
||||
|
|
|
@ -319,7 +319,7 @@ class IDLUnresolvedIdentifier(IDLObject):
|
|||
[location])
|
||||
if name[0] == '_' and not allowDoubleUnderscore:
|
||||
name = name[1:]
|
||||
if name in ["constructor", "toString"] and not allowForbidden:
|
||||
if name in ["constructor", "iterator", "toString", "toJSON"] and not allowForbidden:
|
||||
raise WebIDLError("Cannot use reserved identifier '%s'" % (name),
|
||||
[location])
|
||||
|
||||
|
@ -475,6 +475,12 @@ class IDLExternalInterface(IDLObjectWithIdentifier):
|
|||
def resolve(self, parentScope):
|
||||
pass
|
||||
|
||||
def getJSImplementation(self):
|
||||
return None
|
||||
|
||||
def isJSImplemented(self):
|
||||
return False
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set()
|
||||
|
||||
|
@ -773,7 +779,7 @@ class IDLInterface(IDLObjectWithScope):
|
|||
return self._callback
|
||||
|
||||
def isSingleOperationInterface(self):
|
||||
assert self.isCallback()
|
||||
assert self.isCallback() or self.isJSImplemented()
|
||||
return (
|
||||
# Not inheriting from another interface
|
||||
not self.parent and
|
||||
|
@ -956,6 +962,17 @@ class IDLInterface(IDLObjectWithScope):
|
|||
# Put the new members at the beginning
|
||||
self.members = members + self.members
|
||||
|
||||
def getJSImplementation(self):
|
||||
classId = self.getExtendedAttribute("JSImplementation")
|
||||
if not classId:
|
||||
return classId
|
||||
assert isinstance(classId, list)
|
||||
assert len(classId) == 1
|
||||
return classId[0]
|
||||
|
||||
def isJSImplemented(self):
|
||||
return bool(self.getJSImplementation())
|
||||
|
||||
def _getDependentObjects(self):
|
||||
deps = set(self.members)
|
||||
deps.union(self.implementedInterfaces)
|
||||
|
|
|
@ -510,7 +510,7 @@ interface TestInterface {
|
|||
[SetterThrows] attribute boolean throwingSetterAttr;
|
||||
legacycaller short(unsigned long arg1, TestInterface arg2);
|
||||
|
||||
// If you add things here, add them to TestExampleGen as well
|
||||
// If you add things here, add them to TestExampleGen and TestJSImplGen as well
|
||||
};
|
||||
|
||||
interface TestParentInterface {
|
||||
|
|
|
@ -424,7 +424,7 @@ interface TestExampleInterface {
|
|||
[SetterThrows] attribute boolean throwingSetterAttr;
|
||||
legacycaller short(unsigned long arg1, TestInterface arg2);
|
||||
|
||||
// If you add things here, add them to TestCodeGen as well
|
||||
// If you add things here, add them to TestCodeGen and TestJSImplGen as well
|
||||
};
|
||||
|
||||
interface TestExampleProxyInterface {
|
||||
|
|
|
@ -0,0 +1,430 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
typedef TestJSImplInterface AnotherNameForTestJSImplInterface;
|
||||
typedef TestJSImplInterface YetAnotherNameForTestJSImplInterface;
|
||||
typedef TestJSImplInterface? NullableTestJSImplInterface;
|
||||
|
||||
callback MyTestCallback = void();
|
||||
|
||||
TestInterface implements ImplementedInterface;
|
||||
|
||||
enum MyTestEnum {
|
||||
"a",
|
||||
"b"
|
||||
};
|
||||
|
||||
[Constructor, JSImplementation="@mozilla.org/test-js-impl-interface;1"]
|
||||
interface TestJSImplInterface {
|
||||
// Integer types
|
||||
// XXXbz add tests for throwing versions of all the integer stuff
|
||||
readonly attribute byte readonlyByte;
|
||||
attribute byte writableByte;
|
||||
void passByte(byte arg);
|
||||
byte receiveByte();
|
||||
void passOptionalByte(optional byte arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
// void passOptionalByteWithDefault(optional byte arg = 0);
|
||||
void passNullableByte(byte? arg);
|
||||
void passOptionalNullableByte(optional byte? arg);
|
||||
void passVariadicByte(byte... arg);
|
||||
|
||||
readonly attribute short readonlyShort;
|
||||
attribute short writableShort;
|
||||
void passShort(short arg);
|
||||
short receiveShort();
|
||||
void passOptionalShort(optional short arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalShortWithDefault(optional short arg = 5);
|
||||
|
||||
readonly attribute long readonlyLong;
|
||||
attribute long writableLong;
|
||||
void passLong(long arg);
|
||||
long receiveLong();
|
||||
void passOptionalLong(optional long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalLongWithDefault(optional long arg = 7);
|
||||
|
||||
readonly attribute long long readonlyLongLong;
|
||||
attribute long long writableLongLong;
|
||||
void passLongLong(long long arg);
|
||||
long long receiveLongLong();
|
||||
void passOptionalLongLong(optional long long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalLongLongWithDefault(optional long long arg = -12);
|
||||
|
||||
readonly attribute octet readonlyOctet;
|
||||
attribute octet writableOctet;
|
||||
void passOctet(octet arg);
|
||||
octet receiveOctet();
|
||||
void passOptionalOctet(optional octet arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalOctetWithDefault(optional octet arg = 19);
|
||||
|
||||
readonly attribute unsigned short readonlyUnsignedShort;
|
||||
attribute unsigned short writableUnsignedShort;
|
||||
void passUnsignedShort(unsigned short arg);
|
||||
unsigned short receiveUnsignedShort();
|
||||
void passOptionalUnsignedShort(optional unsigned short arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalUnsignedShortWithDefault(optional unsigned short arg = 2);
|
||||
|
||||
readonly attribute unsigned long readonlyUnsignedLong;
|
||||
attribute unsigned long writableUnsignedLong;
|
||||
void passUnsignedLong(unsigned long arg);
|
||||
unsigned long receiveUnsignedLong();
|
||||
void passOptionalUnsignedLong(optional unsigned long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalUnsignedLongWithDefault(optional unsigned long arg = 6);
|
||||
|
||||
readonly attribute unsigned long long readonlyUnsignedLongLong;
|
||||
attribute unsigned long long writableUnsignedLongLong;
|
||||
void passUnsignedLongLong(unsigned long long arg);
|
||||
unsigned long long receiveUnsignedLongLong();
|
||||
void passOptionalUnsignedLongLong(optional unsigned long long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalUnsignedLongLongWithDefault(optional unsigned long long arg = 17);
|
||||
|
||||
attribute float writableFloat;
|
||||
attribute unrestricted float writableUnrestrictedFloat;
|
||||
attribute float? writableNullableFloat;
|
||||
attribute unrestricted float? writableNullableUnrestrictedFloat;
|
||||
attribute double writableDouble;
|
||||
attribute unrestricted double writableUnrestrictedDouble;
|
||||
attribute double? writableNullableDouble;
|
||||
attribute unrestricted double? writableNullableUnrestrictedDouble;
|
||||
void passFloat(float arg1, unrestricted float arg2,
|
||||
float? arg3, unrestricted float? arg4,
|
||||
double arg5, unrestricted double arg6,
|
||||
double? arg7, unrestricted double? arg8,
|
||||
sequence<float> arg9, sequence<unrestricted float> arg10,
|
||||
sequence<float?> arg11, sequence<unrestricted float?> arg12,
|
||||
sequence<double> arg13, sequence<unrestricted double> arg14,
|
||||
sequence<double?> arg15, sequence<unrestricted double?> arg16);
|
||||
[LenientFloat]
|
||||
void passLenientFloat(float arg1, unrestricted float arg2,
|
||||
float? arg3, unrestricted float? arg4,
|
||||
double arg5, unrestricted double arg6,
|
||||
double? arg7, unrestricted double? arg8,
|
||||
sequence<float> arg9,
|
||||
sequence<unrestricted float> arg10,
|
||||
sequence<float?> arg11,
|
||||
sequence<unrestricted float?> arg12,
|
||||
sequence<double> arg13,
|
||||
sequence<unrestricted double> arg14,
|
||||
sequence<double?> arg15,
|
||||
sequence<unrestricted double?> arg16);
|
||||
[LenientFloat]
|
||||
attribute float lenientFloatAttr;
|
||||
[LenientFloat]
|
||||
attribute double lenientDoubleAttr;
|
||||
|
||||
// Castable interface types
|
||||
// XXXbz add tests for throwing versions of all the castable interface stuff
|
||||
TestJSImplInterface receiveSelf();
|
||||
TestJSImplInterface? receiveNullableSelf();
|
||||
|
||||
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
|
||||
//TestJSImplInterface receiveWeakSelf();
|
||||
//TestJSImplInterface? receiveWeakNullableSelf();
|
||||
|
||||
// A version to test for casting to TestJSImplInterface&
|
||||
void passSelf(TestJSImplInterface arg);
|
||||
// A version we can use to test for the exact type passed in
|
||||
void passSelf2(TestJSImplInterface arg);
|
||||
void passNullableSelf(TestJSImplInterface? arg);
|
||||
attribute TestJSImplInterface nonNullSelf;
|
||||
attribute TestJSImplInterface? nullableSelf;
|
||||
// Optional arguments
|
||||
void passOptionalSelf(optional TestJSImplInterface? arg);
|
||||
void passOptionalNonNullSelf(optional TestJSImplInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalSelfWithDefault(optional TestJSImplInterface? arg = null);
|
||||
|
||||
// Non-wrapper-cache interface types
|
||||
[Creator]
|
||||
TestNonWrapperCacheInterface receiveNonWrapperCacheInterface();
|
||||
[Creator]
|
||||
TestNonWrapperCacheInterface? receiveNullableNonWrapperCacheInterface();
|
||||
|
||||
// Can't return sequences of interfaces from callback interface methods. See bug 843264.
|
||||
//[Creator]
|
||||
//sequence<TestNonWrapperCacheInterface> receiveNonWrapperCacheInterfaceSequence();
|
||||
//[Creator]
|
||||
//sequence<TestNonWrapperCacheInterface?> receiveNullableNonWrapperCacheInterfaceSequence();
|
||||
//[Creator]
|
||||
//sequence<TestNonWrapperCacheInterface>? receiveNonWrapperCacheInterfaceNullableSequence();
|
||||
//[Creator]
|
||||
//sequence<TestNonWrapperCacheInterface?>? receiveNullableNonWrapperCacheInterfaceNullableSequence();
|
||||
|
||||
// Non-castable interface types
|
||||
IndirectlyImplementedInterface receiveOther();
|
||||
IndirectlyImplementedInterface? receiveNullableOther();
|
||||
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
|
||||
//IndirectlyImplementedInterface receiveWeakOther();
|
||||
//IndirectlyImplementedInterface? receiveWeakNullableOther();
|
||||
|
||||
// A verstion to test for casting to IndirectlyImplementedInterface&
|
||||
void passOther(IndirectlyImplementedInterface arg);
|
||||
// A version we can use to test for the exact type passed in
|
||||
void passOther2(IndirectlyImplementedInterface arg);
|
||||
void passNullableOther(IndirectlyImplementedInterface? arg);
|
||||
attribute IndirectlyImplementedInterface nonNullOther;
|
||||
attribute IndirectlyImplementedInterface? nullableOther;
|
||||
// Optional arguments
|
||||
void passOptionalOther(optional IndirectlyImplementedInterface? arg);
|
||||
void passOptionalNonNullOther(optional IndirectlyImplementedInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalOtherWithDefault(optional IndirectlyImplementedInterface? arg = null);
|
||||
|
||||
// External interface types
|
||||
TestExternalInterface receiveExternal();
|
||||
TestExternalInterface? receiveNullableExternal();
|
||||
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
|
||||
//TestExternalInterface receiveWeakExternal();
|
||||
//TestExternalInterface? receiveWeakNullableExternal();
|
||||
// A verstion to test for casting to TestExternalInterface&
|
||||
void passExternal(TestExternalInterface arg);
|
||||
// A version we can use to test for the exact type passed in
|
||||
void passExternal2(TestExternalInterface arg);
|
||||
void passNullableExternal(TestExternalInterface? arg);
|
||||
attribute TestExternalInterface nonNullExternal;
|
||||
attribute TestExternalInterface? nullableExternal;
|
||||
// Optional arguments
|
||||
void passOptionalExternal(optional TestExternalInterface? arg);
|
||||
void passOptionalNonNullExternal(optional TestExternalInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalExternalWithDefault(optional TestExternalInterface? arg = null);
|
||||
|
||||
// Callback interface types
|
||||
TestCallbackInterface receiveCallbackInterface();
|
||||
TestCallbackInterface? receiveNullableCallbackInterface();
|
||||
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
|
||||
//TestCallbackInterface receiveWeakCallbackInterface();
|
||||
//TestCallbackInterface? receiveWeakNullableCallbackInterface();
|
||||
// A verstion to test for casting to TestCallbackInterface&
|
||||
void passCallbackInterface(TestCallbackInterface arg);
|
||||
// A version we can use to test for the exact type passed in
|
||||
void passCallbackInterface2(TestCallbackInterface arg);
|
||||
void passNullableCallbackInterface(TestCallbackInterface? arg);
|
||||
attribute TestCallbackInterface nonNullCallbackInterface;
|
||||
attribute TestCallbackInterface? nullableCallbackInterface;
|
||||
// Optional arguments
|
||||
void passOptionalCallbackInterface(optional TestCallbackInterface? arg);
|
||||
void passOptionalNonNullCallbackInterface(optional TestCallbackInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalCallbackInterfaceWithDefault(optional TestCallbackInterface? arg = null);
|
||||
|
||||
// Miscellaneous interface tests
|
||||
IndirectlyImplementedInterface receiveConsequentialInterface();
|
||||
void passConsequentialInterface(IndirectlyImplementedInterface arg);
|
||||
|
||||
// Sequence types
|
||||
sequence<long> receiveSequence();
|
||||
sequence<long>? receiveNullableSequence();
|
||||
sequence<long?> receiveSequenceOfNullableInts();
|
||||
sequence<long?>? receiveNullableSequenceOfNullableInts();
|
||||
void passSequence(sequence<long> arg);
|
||||
void passNullableSequence(sequence<long>? arg);
|
||||
void passSequenceOfNullableInts(sequence<long?> arg);
|
||||
void passOptionalSequenceOfNullableInts(optional sequence<long?> arg);
|
||||
void passOptionalNullableSequenceOfNullableInts(optional sequence<long?>? arg);
|
||||
// Can't return sequences of interfaces from callback interface methods. See bug 843264.
|
||||
//sequence<TestJSImplInterface> receiveCastableObjectSequence();
|
||||
//sequence<TestCallbackInterface> receiveCallbackObjectSequence();
|
||||
//sequence<TestJSImplInterface?> receiveNullableCastableObjectSequence();
|
||||
//sequence<TestCallbackInterface?> receiveNullableCallbackObjectSequence();
|
||||
//sequence<TestJSImplInterface>? receiveCastableObjectNullableSequence();
|
||||
//sequence<TestJSImplInterface?>? receiveNullableCastableObjectNullableSequence();
|
||||
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
|
||||
//sequence<TestJSImplInterface> receiveWeakCastableObjectSequence();
|
||||
//sequence<TestJSImplInterface?> receiveWeakNullableCastableObjectSequence();
|
||||
//sequence<TestJSImplInterface>? receiveWeakCastableObjectNullableSequence();
|
||||
//sequence<TestJSImplInterface?>? receiveWeakNullableCastableObjectNullableSequence();
|
||||
void passCastableObjectSequence(sequence<TestJSImplInterface> arg);
|
||||
void passNullableCastableObjectSequence(sequence<TestJSImplInterface?> arg);
|
||||
void passCastableObjectNullableSequence(sequence<TestJSImplInterface>? arg);
|
||||
void passNullableCastableObjectNullableSequence(sequence<TestJSImplInterface?>? arg);
|
||||
void passOptionalSequence(optional sequence<long> arg);
|
||||
void passOptionalNullableSequence(optional sequence<long>? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableSequenceWithDefaultValue(optional sequence<long>? arg = null);
|
||||
void passOptionalObjectSequence(optional sequence<TestJSImplInterface> arg);
|
||||
void passExternalInterfaceSequence(sequence<TestExternalInterface> arg);
|
||||
void passNullableExternalInterfaceSequence(sequence<TestExternalInterface?> arg);
|
||||
|
||||
// Can't return sequences of interfaces from callback interface methods. See bug 843264.
|
||||
//sequence<DOMString> receiveStringSequence();
|
||||
// Callback interface problem. See bug 843261.
|
||||
//void passStringSequence(sequence<DOMString> arg);
|
||||
// "Can't handle sequence member 'any'; need to sort out rooting issues"
|
||||
//sequence<any> receiveAnySequence();
|
||||
//sequence<any>? receiveNullableAnySequence();
|
||||
|
||||
// ArrayBuffer is handled differently in callback interfaces and the example generator.
|
||||
// Need to figure out what should be done there. Seems like other typed array stuff is
|
||||
// similarly not working in the JS implemented generator. Probably some other issues
|
||||
// here as well.
|
||||
// Typed array types
|
||||
//void passArrayBuffer(ArrayBuffer arg);
|
||||
//void passNullableArrayBuffer(ArrayBuffer? arg);
|
||||
//void passOptionalArrayBuffer(optional ArrayBuffer arg);
|
||||
//void passOptionalNullableArrayBuffer(optional ArrayBuffer? arg);
|
||||
//void passOptionalNullableArrayBufferWithDefaultValue(optional ArrayBuffer? arg= null);
|
||||
//void passArrayBufferView(ArrayBufferView arg);
|
||||
//void passInt8Array(Int8Array arg);
|
||||
//void passInt16Array(Int16Array arg);
|
||||
//void passInt32Array(Int32Array arg);
|
||||
//void passUint8Array(Uint8Array arg);
|
||||
//void passUint16Array(Uint16Array arg);
|
||||
//void passUint32Array(Uint32Array arg);
|
||||
//void passUint8ClampedArray(Uint8ClampedArray arg);
|
||||
//void passFloat32Array(Float32Array arg);
|
||||
//void passFloat64Array(Float64Array arg);
|
||||
//Uint8Array receiveUint8Array();
|
||||
|
||||
// String types
|
||||
void passString(DOMString arg);
|
||||
void passNullableString(DOMString? arg);
|
||||
void passOptionalString(optional DOMString arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalStringWithDefaultValue(optional DOMString arg = "abc");
|
||||
void passOptionalNullableString(optional DOMString? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null);
|
||||
void passVariadicString(DOMString... arg);
|
||||
|
||||
// Enumerated types
|
||||
void passEnum(MyTestEnum arg);
|
||||
// No support for nullable enums yet
|
||||
// void passNullableEnum(MyTestEnum? arg);
|
||||
// Optional enum arg doesn't work with callback interfaces. See bug 843355.
|
||||
//void passOptionalEnum(optional MyTestEnum arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passEnumWithDefault(optional MyTestEnum arg = "a");
|
||||
// void passOptionalNullableEnum(optional MyTestEnum? arg);
|
||||
// void passOptionalNullableEnumWithDefaultValue(optional MyTestEnum? arg = null);
|
||||
MyTestEnum receiveEnum();
|
||||
attribute MyTestEnum enumAttribute;
|
||||
readonly attribute MyTestEnum readonlyEnumAttribute;
|
||||
|
||||
// Callback types
|
||||
void passCallback(MyTestCallback arg);
|
||||
void passNullableCallback(MyTestCallback? arg);
|
||||
void passOptionalCallback(optional MyTestCallback arg);
|
||||
void passOptionalNullableCallback(optional MyTestCallback? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableCallbackWithDefaultValue(optional MyTestCallback? arg = null);
|
||||
MyTestCallback receiveCallback();
|
||||
MyTestCallback? receiveNullableCallback();
|
||||
// Hmm. These two don't work, I think because I need a locally modified version of TestTreatAsNullCallback.
|
||||
//void passNullableTreatAsNullCallback(TestTreatAsNullCallback? arg);
|
||||
//void passOptionalNullableTreatAsNullCallback(optional TestTreatAsNullCallback? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableTreatAsNullCallbackWithDefaultValue(optional TestTreatAsNullCallback? arg = null);
|
||||
|
||||
/* The rest of these are untested.
|
||||
// Any types
|
||||
void passAny(any arg);
|
||||
void passOptionalAny(optional any arg);
|
||||
void passAnyDefaultNull(optional any arg = null);
|
||||
any receiveAny();
|
||||
|
||||
// object types
|
||||
void passObject(object arg);
|
||||
void passNullableObject(object? arg);
|
||||
void passOptionalObject(optional object arg);
|
||||
void passOptionalNullableObject(optional object? arg);
|
||||
void passOptionalNullableObjectWithDefaultValue(optional object? arg = null);
|
||||
object receiveObject();
|
||||
object? receiveNullableObject();
|
||||
|
||||
// Union types
|
||||
void passUnion((object or long) arg);
|
||||
void passUnionWithNullable((object? or long) arg);
|
||||
void passNullableUnion((object or long)? arg);
|
||||
void passOptionalUnion(optional (object or long) arg);
|
||||
void passOptionalNullableUnion(optional (object or long)? arg);
|
||||
void passOptionalNullableUnionWithDefaultValue(optional (object or long)? arg = null);
|
||||
//void passUnionWithInterfaces((TestJSImplInterface or TestExternalInterface) arg);
|
||||
//void passUnionWithInterfacesAndNullable((TestJSImplInterface? or TestExternalInterface) arg);
|
||||
//void passUnionWithSequence((sequence<object> or long) arg);
|
||||
void passUnionWithArrayBuffer((ArrayBuffer or long) arg);
|
||||
void passUnionWithString((DOMString or object) arg);
|
||||
//void passUnionWithEnum((MyTestEnum or object) arg);
|
||||
// Trying to use a callback in a union won't include the test
|
||||
// headers, unfortunately, so won't compile.
|
||||
// void passUnionWithCallback((MyTestCallback or long) arg);
|
||||
void passUnionWithObject((object or long) arg);
|
||||
//void passUnionWithDict((Dict or long) arg);
|
||||
|
||||
// binaryNames tests
|
||||
void methodRenamedFrom();
|
||||
void methodRenamedFrom(byte argument);
|
||||
readonly attribute byte attributeGetterRenamedFrom;
|
||||
attribute byte attributeRenamedFrom;
|
||||
|
||||
void passDictionary(optional Dict x);
|
||||
//UNSUPPORTED Dict receiveDictionary();
|
||||
void passOtherDictionary(optional GrandparentDict x);
|
||||
void passSequenceOfDictionaries(sequence<Dict> x);
|
||||
void passDictionaryOrLong(optional Dict x);
|
||||
void passDictionaryOrLong(long x);
|
||||
|
||||
void passDictContainingDict(optional DictContainingDict arg);
|
||||
void passDictContainingSequence(optional DictContainingSequence arg);
|
||||
//UNSUPPORTED DictContainingSequence receiveDictContainingSequence();
|
||||
|
||||
// EnforceRange/Clamp tests
|
||||
void dontEnforceRangeOrClamp(byte arg);
|
||||
void doEnforceRange([EnforceRange] byte arg);
|
||||
void doClamp([Clamp] byte arg);
|
||||
|
||||
// Typedefs
|
||||
const myLong myLongConstant = 5;
|
||||
// ???? What
|
||||
void exerciseTypedefInterfaces1(AnotherNameForTestJSImplInterface arg);
|
||||
AnotherNameForTestJSImplInterface exerciseTypedefInterfaces2(NullableTestJSImplInterface arg);
|
||||
void exerciseTypedefInterfaces3(YetAnotherNameForTestJSImplInterface arg);
|
||||
|
||||
// Static methods and attributes
|
||||
static attribute boolean staticAttribute;
|
||||
static void staticMethod(boolean arg);
|
||||
static void staticMethodWithContext(any arg);
|
||||
|
||||
// Overload resolution tests
|
||||
//void overload1(DOMString... strs);
|
||||
boolean overload1(TestJSImplInterface arg);
|
||||
TestJSImplInterface overload1(DOMString strs, TestJSImplInterface arg);
|
||||
void overload2(TestJSImplInterface arg);
|
||||
void overload2(optional Dict arg);
|
||||
void overload2(DOMString arg);
|
||||
void overload3(TestJSImplInterface arg);
|
||||
void overload3(MyTestCallback arg);
|
||||
void overload3(DOMString arg);
|
||||
void overload4(TestJSImplInterface arg);
|
||||
void overload4(TestCallbackInterface arg);
|
||||
void overload4(DOMString arg);
|
||||
|
||||
// Variadic handling
|
||||
void passVariadicThirdArg(DOMString arg1, long arg2, TestJSImplInterface... arg3);
|
||||
|
||||
// Miscellania
|
||||
[LenientThis] attribute long attrWithLenientThis;
|
||||
[Unforgeable] readonly attribute long unforgeableAttr;
|
||||
[Unforgeable, ChromeOnly] readonly attribute long unforgeableAttr2;
|
||||
stringifier;
|
||||
void passRenamedInterface(TestRenamedInterface arg);
|
||||
[PutForwards=writableByte] readonly attribute TestJSImplInterface putForwardsAttr;
|
||||
[PutForwards=writableByte, LenientThis] readonly attribute TestJSImplInterface putForwardsAttr2;
|
||||
[PutForwards=writableByte, ChromeOnly] readonly attribute TestJSImplInterface putForwardsAttr3;
|
||||
[Throws] void throwingMethod();
|
||||
[Throws] attribute boolean throwingAttr;
|
||||
[GetterThrows] attribute boolean throwingGetterAttr;
|
||||
[SetterThrows] attribute boolean throwingSetterAttr;
|
||||
*/
|
||||
// If you add things here, add them to TestCodeGen as well
|
||||
};
|
|
@ -19,6 +19,7 @@
|
|||
[scriptable, uuid(ca856a0b-6786-4123-90fe-dc9c7600274e)]
|
||||
interface nsIDOMHTMLLinkElement : nsIDOMHTMLElement
|
||||
{
|
||||
[binaryname(MozDisabled)]
|
||||
attribute boolean disabled;
|
||||
attribute DOMString charset;
|
||||
attribute DOMString href;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
[scriptable, uuid(5e6c9cac-5594-4006-ae3f-ad82fb28cee9)]
|
||||
interface nsIDOMHTMLStyleElement : nsIDOMHTMLElement
|
||||
{
|
||||
[binaryname(MozDisabled)]
|
||||
attribute boolean disabled;
|
||||
attribute DOMString media;
|
||||
attribute DOMString type;
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
function go() {
|
||||
var plugin = document.getElementById('plugin');
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
var objLoadingContent = SpecialPowers.wrap(plugin);
|
||||
ok(!objLoadingContent.activated, "plugin should not be activated");
|
||||
|
||||
SimpleTest.waitForFocus(afterWindowFocus);
|
||||
|
@ -55,7 +55,7 @@
|
|||
|
||||
function afterPluginActivation() {
|
||||
var plugin = document.getElementById('plugin');
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
var objLoadingContent = SpecialPowers.wrap(plugin);
|
||||
ok(objLoadingContent.activated, "plugin should be activated now");
|
||||
|
||||
// Triggering a paint and waiting for it to be flushed makes sure
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/csswg/cssom/
|
||||
*/
|
||||
|
||||
interface CSSRuleList;
|
||||
interface CSSRule;
|
||||
|
||||
interface CSSStyleSheet : StyleSheet {
|
||||
[Pure]
|
||||
readonly attribute CSSRule? ownerRule;
|
||||
[Throws]
|
||||
readonly attribute CSSRuleList cssRules;
|
||||
[Throws]
|
||||
unsigned long insertRule(DOMString rule, unsigned long index);
|
||||
[Throws]
|
||||
void deleteRule(unsigned long index);
|
||||
};
|
|
@ -0,0 +1,43 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#the-applet-element
|
||||
*
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#the-applet-element
|
||||
[NeedNewResolve]
|
||||
interface HTMLAppletElement : HTMLElement {
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString align;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString alt;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString archive;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString code;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString codeBase;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString height;
|
||||
[Pure, SetterThrows]
|
||||
attribute unsigned long hspace;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString name;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString _object;
|
||||
[Pure, SetterThrows]
|
||||
attribute unsigned long vspace;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString width;
|
||||
};
|
||||
|
||||
HTMLAppletElement implements MozImageLoadingContent;
|
||||
HTMLAppletElement implements MozFrameLoaderOwner;
|
||||
HTMLAppletElement implements MozObjectLoadingContent;
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#the-embed-element
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#HTMLEmbedElement-partial
|
||||
*
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#the-embed-element
|
||||
[NeedNewResolve]
|
||||
interface HTMLEmbedElement : HTMLElement {
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString src;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString type;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString width;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString height;
|
||||
[Throws]
|
||||
legacycaller any (any... arguments);
|
||||
};
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#HTMLEmbedElement-partial
|
||||
partial interface HTMLEmbedElement {
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString align;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString name;
|
||||
};
|
||||
|
||||
partial interface HTMLEmbedElement {
|
||||
// nsIDOMGetSVGDocument
|
||||
Document? getSVGDocument();
|
||||
};
|
||||
|
||||
HTMLEmbedElement implements MozImageLoadingContent;
|
||||
HTMLEmbedElement implements MozFrameLoaderOwner;
|
||||
HTMLEmbedElement implements MozObjectLoadingContent;
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#the-link-element
|
||||
interface HTMLLinkElement : HTMLElement {
|
||||
[Throws]
|
||||
[Pure]
|
||||
attribute boolean disabled;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString href;
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
*/
|
||||
|
||||
interface HTMLStyleElement : HTMLElement {
|
||||
[SetterThrows]
|
||||
[Pure]
|
||||
attribute boolean disabled;
|
||||
[SetterThrows]
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString media;
|
||||
[SetterThrows]
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString type;
|
||||
[SetterThrows]
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean scoped;
|
||||
};
|
||||
HTMLStyleElement implements LinkStyle;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/csswg/cssom/
|
||||
*/
|
||||
|
||||
interface CSSRule;
|
||||
interface MediaList;
|
||||
|
||||
interface StyleSheet {
|
||||
[Constant]
|
||||
readonly attribute DOMString type;
|
||||
[Constant]
|
||||
readonly attribute DOMString? href;
|
||||
// Spec says "Node", but it can go null when the node gets a new
|
||||
// sheet. That's also why it's not [Constant]
|
||||
[Pure]
|
||||
readonly attribute Node? ownerNode;
|
||||
[Pure]
|
||||
readonly attribute StyleSheet? parentStyleSheet;
|
||||
[Pure]
|
||||
readonly attribute DOMString? title;
|
||||
[Constant]
|
||||
readonly attribute MediaList media;
|
||||
[Pure]
|
||||
attribute boolean disabled;
|
||||
};
|
|
@ -35,6 +35,7 @@ webidl_files = \
|
|||
CSS.webidl \
|
||||
CSSPrimitiveValue.webidl \
|
||||
CSSStyleDeclaration.webidl \
|
||||
CSSStyleSheet.webidl \
|
||||
CSSValue.webidl \
|
||||
CSSValueList.webidl \
|
||||
DelayNode.webidl \
|
||||
|
@ -66,6 +67,7 @@ webidl_files = \
|
|||
Function.webidl \
|
||||
GainNode.webidl \
|
||||
HTMLAnchorElement.webidl \
|
||||
HTMLAppletElement.webidl \
|
||||
HTMLAreaElement.webidl \
|
||||
HTMLBaseElement.webidl \
|
||||
HTMLBodyElement.webidl \
|
||||
|
@ -79,6 +81,7 @@ webidl_files = \
|
|||
HTMLDListElement.webidl \
|
||||
HTMLDocument.webidl \
|
||||
HTMLElement.webidl \
|
||||
HTMLEmbedElement.webidl \
|
||||
HTMLFieldSetElement.webidl \
|
||||
HTMLFontElement.webidl \
|
||||
HTMLFrameElement.webidl \
|
||||
|
@ -150,6 +153,7 @@ webidl_files = \
|
|||
RGBColor.webidl \
|
||||
RTCConfiguration.webidl \
|
||||
Screen.webidl \
|
||||
StyleSheet.webidl \
|
||||
SVGAElement.webidl \
|
||||
SVGAltGlyphElement.webidl \
|
||||
SVGAngle.webidl \
|
||||
|
@ -288,6 +292,7 @@ test_webidl_files := \
|
|||
TestCodeGen.webidl \
|
||||
TestDictionary.webidl \
|
||||
TestExampleGen.webidl \
|
||||
TestJSImplGen.webidl \
|
||||
TestTypedef.webidl \
|
||||
$(NULL)
|
||||
else
|
||||
|
|
|
@ -2424,7 +2424,7 @@ CountSheetMemory(URIPrincipalAndCORSModeHashKey* /* unused */,
|
|||
// have to worry about it here.
|
||||
// Likewise, if aSheet has an owning node, then the document that
|
||||
// node is in will report it.
|
||||
if (aSheet->GetOwningNode() || aSheet->GetParentSheet()) {
|
||||
if (aSheet->GetOwnerNode() || aSheet->GetParentSheet()) {
|
||||
return 0;
|
||||
}
|
||||
return aSheet->SizeOfIncludingThis(aMallocSizeOf);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "nsMediaFeatures.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/dom/CSSStyleSheetBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -554,12 +555,7 @@ nsMediaList::SetText(const nsAString& aMediaText)
|
|||
{
|
||||
nsCSSParser parser;
|
||||
|
||||
bool htmlMode = false;
|
||||
if (mStyleSheet) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
mStyleSheet->GetOwnerNode(getter_AddRefs(node));
|
||||
htmlMode = !!node;
|
||||
}
|
||||
bool htmlMode = mStyleSheet && mStyleSheet->GetOwnerNode();
|
||||
|
||||
return parser.ParseMediaList(aMediaText, nullptr, 0,
|
||||
this, htmlMode);
|
||||
|
@ -1036,15 +1032,16 @@ nsCSSStyleSheet::nsCSSStyleSheet(CORSMode aCORSMode)
|
|||
mScopeElement(nullptr),
|
||||
mRuleProcessors(nullptr)
|
||||
{
|
||||
|
||||
mInner = new nsCSSStyleSheetInner(this, aCORSMode);
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
|
||||
nsCSSStyleSheet* aParentToUse,
|
||||
css::ImportRule* aOwnerRuleToUse,
|
||||
nsIDocument* aDocumentToUse,
|
||||
nsIDOMNode* aOwningNodeToUse)
|
||||
nsINode* aOwningNodeToUse)
|
||||
: mTitle(aCopy.mTitle),
|
||||
mParent(aParentToUse),
|
||||
mOwnerRule(aOwnerRuleToUse),
|
||||
|
@ -1070,6 +1067,8 @@ nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
|
|||
// sheets in sync!
|
||||
aCopy.mMedia->Clone(getter_AddRefs(mMedia));
|
||||
}
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsCSSStyleSheet::~nsCSSStyleSheet()
|
||||
|
@ -1175,6 +1174,7 @@ DOMCI_DATA(CSSStyleSheet, nsCSSStyleSheet)
|
|||
|
||||
// QueryInterface implementation for nsCSSStyleSheet
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSStyleSheet)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStyleSheet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
|
||||
|
@ -1199,6 +1199,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSStyleSheet)
|
|||
tmp->DropRuleCollection();
|
||||
tmp->UnlinkInner();
|
||||
tmp->mScopeElement = nullptr;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSStyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMedia)
|
||||
|
@ -1207,8 +1208,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSStyleSheet)
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRuleCollection)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScopeElement)
|
||||
tmp->TraverseInner(cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsCSSStyleSheet)
|
||||
|
||||
nsresult
|
||||
nsCSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor)
|
||||
|
@ -1380,8 +1382,7 @@ nsCSSStyleSheet::FindOwningWindowInnerID() const
|
|||
}
|
||||
|
||||
if (windowID == 0 && mOwningNode) {
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(mOwningNode);
|
||||
windowID = node->OwnerDoc()->InnerWindowID();
|
||||
windowID = mOwningNode->OwnerDoc()->InnerWindowID();
|
||||
}
|
||||
|
||||
if (windowID == 0 && mOwnerRule) {
|
||||
|
@ -1579,7 +1580,7 @@ already_AddRefed<nsCSSStyleSheet>
|
|||
nsCSSStyleSheet::Clone(nsCSSStyleSheet* aCloneParent,
|
||||
css::ImportRule* aCloneOwnerRule,
|
||||
nsIDocument* aCloneDocument,
|
||||
nsIDOMNode* aCloneOwningNode) const
|
||||
nsINode* aCloneOwningNode) const
|
||||
{
|
||||
nsCSSStyleSheet* clone = new nsCSSStyleSheet(*this,
|
||||
aCloneParent,
|
||||
|
@ -1754,7 +1755,7 @@ nsCSSStyleSheet::GetType(nsAString& aType)
|
|||
NS_IMETHODIMP
|
||||
nsCSSStyleSheet::GetDisabled(bool* aDisabled)
|
||||
{
|
||||
*aDisabled = mDisabled;
|
||||
*aDisabled = Disabled();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1770,8 +1771,8 @@ nsCSSStyleSheet::SetDisabled(bool aDisabled)
|
|||
NS_IMETHODIMP
|
||||
nsCSSStyleSheet::GetOwnerNode(nsIDOMNode** aOwnerNode)
|
||||
{
|
||||
*aOwnerNode = mOwningNode;
|
||||
NS_IF_ADDREF(*aOwnerNode);
|
||||
nsCOMPtr<nsIDOMNode> ownerNode = do_QueryInterface(GetOwnerNode());
|
||||
ownerNode.forget(aOwnerNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1815,53 +1816,66 @@ nsCSSStyleSheet::GetTitle(nsAString& aTitle)
|
|||
NS_IMETHODIMP
|
||||
nsCSSStyleSheet::GetMedia(nsIDOMMediaList** aMedia)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMedia);
|
||||
*aMedia = nullptr;
|
||||
NS_ADDREF(*aMedia = Media());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMMediaList*
|
||||
nsCSSStyleSheet::Media()
|
||||
{
|
||||
if (!mMedia) {
|
||||
mMedia = new nsMediaList();
|
||||
NS_ENSURE_TRUE(mMedia, NS_ERROR_OUT_OF_MEMORY);
|
||||
mMedia->SetStyleSheet(this);
|
||||
}
|
||||
|
||||
*aMedia = mMedia;
|
||||
NS_ADDREF(*aMedia);
|
||||
|
||||
return NS_OK;
|
||||
return mMedia;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSStyleSheet::GetOwnerRule(nsIDOMCSSRule** aOwnerRule)
|
||||
{
|
||||
if (mOwnerRule) {
|
||||
NS_IF_ADDREF(*aOwnerRule = mOwnerRule->GetDOMRule());
|
||||
} else {
|
||||
*aOwnerRule = nullptr;
|
||||
}
|
||||
NS_IF_ADDREF(*aOwnerRule = GetOwnerRule());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMCSSRule*
|
||||
nsCSSStyleSheet::GetDOMOwnerRule() const
|
||||
{
|
||||
return mOwnerRule ? mOwnerRule->GetDOMRule() : nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules)
|
||||
{
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIDOMCSSRuleList> rules = GetCssRules(rv);
|
||||
rules.forget(aCssRules);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsIDOMCSSRuleList*
|
||||
nsCSSStyleSheet::GetCssRules(ErrorResult& aRv)
|
||||
{
|
||||
// No doing this on incomplete sheets!
|
||||
if (!mInner->mComplete) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//-- Security check: Only scripts whose principal subsumes that of the
|
||||
// style sheet can access rule collections.
|
||||
nsresult rv = SubjectSubsumesInnerPrincipal();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// OK, security check passed, so get the rule collection
|
||||
if (nullptr == mRuleCollection) {
|
||||
if (!mRuleCollection) {
|
||||
mRuleCollection = new CSSRuleListImpl(this);
|
||||
}
|
||||
|
||||
NS_ADDREF(*aCssRules = mRuleCollection);
|
||||
|
||||
return NS_OK;
|
||||
return mRuleCollection;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2252,3 +2266,10 @@ nsCSSStyleSheet::GetOriginalURI() const
|
|||
{
|
||||
return mInner->mOriginalSheetURI;
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
JSObject*
|
||||
nsCSSStyleSheet::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return CSSStyleSheetBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsString.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsXMLNameSpaceMap;
|
||||
class nsCSSRuleProcessor;
|
||||
|
@ -104,14 +105,15 @@ class CSSRuleListImpl;
|
|||
|
||||
class nsCSSStyleSheet MOZ_FINAL : public nsIStyleSheet,
|
||||
public nsIDOMCSSStyleSheet,
|
||||
public nsICSSLoaderObserver
|
||||
public nsICSSLoaderObserver,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
nsCSSStyleSheet(mozilla::CORSMode aCORSMode);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSStyleSheet,
|
||||
nsIStyleSheet)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSStyleSheet,
|
||||
nsIStyleSheet)
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID)
|
||||
|
||||
|
@ -174,8 +176,7 @@ public:
|
|||
|
||||
void SetTitle(const nsAString& aTitle) { mTitle = aTitle; }
|
||||
void SetMedia(nsMediaList* aMedia);
|
||||
void SetOwningNode(nsIDOMNode* aOwningNode) { mOwningNode = aOwningNode; /* Not ref counted */ }
|
||||
nsIDOMNode* GetOwningNode() const { return mOwningNode; }
|
||||
void SetOwningNode(nsINode* aOwningNode) { mOwningNode = aOwningNode; /* Not ref counted */ }
|
||||
|
||||
void SetOwnerRule(mozilla::css::ImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ }
|
||||
mozilla::css::ImportRule* GetOwnerRule() const { return mOwnerRule; }
|
||||
|
@ -185,7 +186,7 @@ public:
|
|||
already_AddRefed<nsCSSStyleSheet> Clone(nsCSSStyleSheet* aCloneParent,
|
||||
mozilla::css::ImportRule* aCloneOwnerRule,
|
||||
nsIDocument* aCloneDocument,
|
||||
nsIDOMNode* aCloneOwningNode) const;
|
||||
nsINode* aCloneOwningNode) const;
|
||||
|
||||
bool IsModified() const { return mDirty; }
|
||||
|
||||
|
@ -253,12 +254,57 @@ public:
|
|||
mScopeElement = aScopeElement;
|
||||
}
|
||||
|
||||
// WebIDL StyleSheet API
|
||||
// Our nsIStyleSheet::GetType is a const method, so it ends up
|
||||
// ambiguous with with the XPCOM version. Just disambiguate.
|
||||
void GetType(nsString& aType) {
|
||||
const_cast<const nsCSSStyleSheet*>(this)->GetType(aType);
|
||||
}
|
||||
// Our XPCOM GetHref is fine for WebIDL
|
||||
nsINode* GetOwnerNode() const { return mOwningNode; }
|
||||
nsCSSStyleSheet* GetParentStyleSheet() const { return mParent; }
|
||||
// Our nsIStyleSheet::GetTitle is a const method, so it ends up
|
||||
// ambiguous with with the XPCOM version. Just disambiguate.
|
||||
void GetTitle(nsString& aTitle) {
|
||||
const_cast<const nsCSSStyleSheet*>(this)->GetTitle(aTitle);
|
||||
}
|
||||
nsIDOMMediaList* Media();
|
||||
bool Disabled() const { return mDisabled; }
|
||||
// The XPCOM SetDisabled is fine for WebIDL
|
||||
|
||||
// WebIDL CSSStyleSheet API
|
||||
// Can't be inline because we can't include ImportRule here. And can't be
|
||||
// called GetOwnerRule because that would be ambiguous with the ImportRule
|
||||
// version.
|
||||
nsIDOMCSSRule* GetDOMOwnerRule() const;
|
||||
nsIDOMCSSRuleList* GetCssRules(mozilla::ErrorResult& aRv);
|
||||
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
|
||||
mozilla::ErrorResult& aRv) {
|
||||
uint32_t retval;
|
||||
aRv = InsertRule(aRule, aIndex, &retval);
|
||||
return retval;
|
||||
}
|
||||
void DeleteRule(uint32_t aIndex, mozilla::ErrorResult& aRv) {
|
||||
aRv = DeleteRule(aIndex);
|
||||
}
|
||||
|
||||
// WebIDL miscellaneous bits
|
||||
mozilla::dom::ParentObject GetParentObject() const {
|
||||
if (mOwningNode) {
|
||||
return mozilla::dom::ParentObject(mOwningNode);
|
||||
}
|
||||
|
||||
return mozilla::dom::ParentObject(static_cast<nsIStyleSheet*>(mParent),
|
||||
mParent);
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
|
||||
nsCSSStyleSheet* aParentToUse,
|
||||
mozilla::css::ImportRule* aOwnerRuleToUse,
|
||||
nsIDocument* aDocumentToUse,
|
||||
nsIDOMNode* aOwningNodeToUse);
|
||||
nsINode* aOwningNodeToUse);
|
||||
|
||||
nsCSSStyleSheet(const nsCSSStyleSheet& aCopy) MOZ_DELETE;
|
||||
nsCSSStyleSheet& operator=(const nsCSSStyleSheet& aCopy) MOZ_DELETE;
|
||||
|
@ -300,7 +346,7 @@ protected:
|
|||
|
||||
nsRefPtr<CSSRuleListImpl> mRuleCollection;
|
||||
nsIDocument* mDocument; // weak ref; parents maintain this for their children
|
||||
nsIDOMNode* mOwningNode; // weak ref
|
||||
nsINode* mOwningNode; // weak ref
|
||||
bool mDisabled;
|
||||
bool mDirty; // has been modified
|
||||
nsRefPtr<mozilla::dom::Element> mScopeElement;
|
||||
|
|
|
@ -2700,3 +2700,22 @@ vcmCreateTransportFlow(sipcc::PeerConnectionImpl *pc, int level, bool rtcp,
|
|||
}
|
||||
return flow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* vcmOnSdpParseError
|
||||
*
|
||||
* This method is called for each parsing error of SDP. It does not necessarily
|
||||
* mean the SDP read was fatal and can be called many times for the same SDP.
|
||||
*
|
||||
*/
|
||||
int vcmOnSdpParseError(const char *peerconnection, const char *message) {
|
||||
|
||||
sipcc::PeerConnectionWrapper pc(peerconnection);
|
||||
ENSURE_PC(pc, VCM_ERROR);
|
||||
|
||||
pc.impl()->OnSdpParseError(message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,18 +160,30 @@ public:
|
|||
break;
|
||||
|
||||
case SETLOCALDESC:
|
||||
// TODO: The SDP Parse error list should be copied out and sent up
|
||||
// to the Javascript layer before being cleared here.
|
||||
mPC->ClearSdpParseErrorMessages();
|
||||
mObserver->OnSetLocalDescriptionSuccess(mCode);
|
||||
break;
|
||||
|
||||
case SETREMOTEDESC:
|
||||
// TODO: The SDP Parse error list should be copied out and sent up
|
||||
// to the Javascript layer before being cleared here.
|
||||
mPC->ClearSdpParseErrorMessages();
|
||||
mObserver->OnSetRemoteDescriptionSuccess(mCode);
|
||||
break;
|
||||
|
||||
case SETLOCALDESCERROR:
|
||||
// TODO: The SDP Parse error list should be copied out and sent up
|
||||
// to the Javascript layer before being cleared here.
|
||||
mPC->ClearSdpParseErrorMessages();
|
||||
mObserver->OnSetLocalDescriptionError(mCode);
|
||||
break;
|
||||
|
||||
case SETREMOTEDESCERROR:
|
||||
// TODO: The SDP Parse error list should be copied out and sent up
|
||||
// to the Javascript layer before being cleared here.
|
||||
mPC->ClearSdpParseErrorMessages();
|
||||
mObserver->OnSetRemoteDescriptionError(mCode);
|
||||
break;
|
||||
|
||||
|
@ -1388,6 +1400,18 @@ PeerConnectionImpl::IceStreamReady(NrIceMediaStream *aStream)
|
|||
CSFLogDebug(logTag, "%s: %s", __FUNCTION__, aStream->name().c_str());
|
||||
}
|
||||
|
||||
void
|
||||
PeerConnectionImpl::OnSdpParseError(const char *message) {
|
||||
CSFLogError(logTag, "%s SDP Parse Error: %s", __FUNCTION__, message);
|
||||
// Save the parsing errors in the PC to be delivered with OnSuccess or OnError
|
||||
mSDPParseErrorMessages.push_back(message);
|
||||
}
|
||||
|
||||
void
|
||||
PeerConnectionImpl::ClearSdpParseErrorMessages() {
|
||||
mSDPParseErrorMessages.clear();
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
static nsresult
|
||||
|
|
|
@ -222,6 +222,15 @@ public:
|
|||
NS_IMETHODIMP CreateOffer(MediaConstraints& aConstraints);
|
||||
NS_IMETHODIMP CreateAnswer(MediaConstraints& aConstraints);
|
||||
|
||||
// Called whenever something is unrecognized by the parser
|
||||
// May be called more than once and does not necessarily mean
|
||||
// that parsing was stopped, only that something was unrecognized.
|
||||
void OnSdpParseError(const char* errorMessage);
|
||||
|
||||
// Called when OnLocal/RemoteDescriptionSuccess/Error
|
||||
// is called to start the list over.
|
||||
void ClearSdpParseErrorMessages();
|
||||
|
||||
private:
|
||||
PeerConnectionImpl(const PeerConnectionImpl&rhs);
|
||||
PeerConnectionImpl& operator=(PeerConnectionImpl);
|
||||
|
@ -313,6 +322,9 @@ private:
|
|||
int mNumAudioStreams;
|
||||
int mNumVideoStreams;
|
||||
|
||||
// Holder for error messages from parsing SDP
|
||||
std::vector<std::string> mSDPParseErrorMessages;
|
||||
|
||||
public:
|
||||
//these are temporary until the DataChannel Listen/Connect API is removed
|
||||
unsigned short listenPort;
|
||||
|
|
|
@ -1453,11 +1453,17 @@ sdp_result_e sdp_free_description (sdp_t *sdp_p)
|
|||
* Send SDP parsing errors to log and up to peerconnection
|
||||
*/
|
||||
void sdp_parse_error(const char *peerconnection, const char *format, ...) {
|
||||
flex_string fs;
|
||||
va_list ap;
|
||||
|
||||
/* TODO - report error up to PeerConnection here */
|
||||
flex_string_init(&fs);
|
||||
|
||||
va_start(ap, format);
|
||||
CSFLogErrorV("SDP Parse", format, ap);
|
||||
flex_string_vsprintf(&fs, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
CSFLogError("SDP Parse", "SDP Parse Error %s, pc %s", fs.buffer, peerconnection);
|
||||
vcmOnSdpParseError(peerconnection, fs.buffer);
|
||||
|
||||
flex_string_free(&fs);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
|
@ -166,22 +165,29 @@ void flex_string_append(flex_string *fs, const char *more) {
|
|||
}
|
||||
|
||||
/*
|
||||
* flex_string_sprintf
|
||||
* va_copy is part of the C99 spec but MSVC doesn't have it.
|
||||
*/
|
||||
#ifndef va_copy
|
||||
#define va_copy(d,s) ((d) = (s))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* flex_string_vsprintf
|
||||
*
|
||||
* Not thread-safe
|
||||
*/
|
||||
void flex_string_sprintf(flex_string *fs, const char *format, ...) {
|
||||
void flex_string_vsprintf(flex_string *fs, const char *format, va_list original_ap) {
|
||||
va_list ap;
|
||||
int vsnprintf_result;
|
||||
|
||||
va_start(ap, format);
|
||||
va_copy(ap, original_ap);
|
||||
vsnprintf_result = vsnprintf(fs->buffer + fs->string_length, fs->buffer_length - fs->string_length, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* Special case just for Windows where vsnprintf is broken
|
||||
and returns -1 if buffer too large unless you size it 0. */
|
||||
if (vsnprintf_result < 0) {
|
||||
va_start(ap, format);
|
||||
va_copy(ap, original_ap);
|
||||
vsnprintf_result = vsnprintf(NULL, 0, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
@ -191,10 +197,10 @@ void flex_string_sprintf(flex_string *fs, const char *format, ...) {
|
|||
flex_string_check_alloc(fs, fs->string_length + vsnprintf_result + 1);
|
||||
|
||||
/* Try again with new buffer */
|
||||
va_start(ap, format);
|
||||
va_copy(ap, original_ap);
|
||||
vsnprintf_result = vsnprintf(fs->buffer + fs->string_length, fs->buffer_length - fs->string_length, format, ap);
|
||||
MOZ_ASSERT(vsnprintf_result > 0 && vsnprintf_result < (fs->buffer_length - fs->string_length));
|
||||
va_end(ap);
|
||||
MOZ_ASSERT(vsnprintf_result > 0 && vsnprintf_result < (fs->buffer_length - fs->string_length));
|
||||
}
|
||||
|
||||
if (vsnprintf_result > 0) {
|
||||
|
@ -202,4 +208,16 @@ void flex_string_sprintf(flex_string *fs, const char *format, ...) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* flex_string_sprintf
|
||||
*
|
||||
* Not thread-safe
|
||||
*/
|
||||
void flex_string_sprintf(flex_string *fs, const char *format, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
flex_string_vsprintf(fs, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef _CPR_STRING_H_
|
||||
#define _CPR_STRING_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "cpr_types.h"
|
||||
#include "cpr_strings.h"
|
||||
|
||||
|
@ -104,6 +106,13 @@ void flex_string_check_alloc(flex_string *fs, size_t new_min_length);
|
|||
*/
|
||||
void flex_string_append(flex_string *fs, const char *more);
|
||||
|
||||
/*
|
||||
* flex_string_sprintf
|
||||
*
|
||||
* Not thread-safe
|
||||
*/
|
||||
void flex_string_vsprintf(flex_string *fs, const char *format, va_list original_ap);
|
||||
|
||||
/*
|
||||
* flex_string_sprintf
|
||||
*
|
||||
|
|
|
@ -1003,6 +1003,15 @@ int vcmDtmfBurst(int digit, int duration, int direction);
|
|||
*/
|
||||
int vcmGetILBCMode();
|
||||
|
||||
/**
|
||||
* vcmOnSdpParseError
|
||||
*
|
||||
* This method is called for each parsing error of SDP. It does not necessarily
|
||||
* mean the SDP read was fatal and can be called many times for the same SDP.
|
||||
*
|
||||
*/
|
||||
int vcmOnSdpParseError(const char *peercconnection, const char *message);
|
||||
|
||||
//Using C++ for gips. This is the end of extern "C" above.
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -42,6 +42,26 @@ this.PrivateBrowsingUtils = {
|
|||
},
|
||||
get isInTemporaryAutoStartMode() {
|
||||
return gTemporaryAutoStartMode;
|
||||
},
|
||||
|
||||
whenHiddenPrivateWindowReady: function pbu_whenHiddenPrivateWindowReady(cb) {
|
||||
Components.utils.import("resource://gre/modules/Timer.jsm");
|
||||
|
||||
let win = Services.appShell.hiddenPrivateDOMWindow;
|
||||
function isNotLoaded() {
|
||||
return ["complete", "interactive"].indexOf(win.document.readyState) == -1;
|
||||
}
|
||||
if (isNotLoaded()) {
|
||||
setTimeout(function poll() {
|
||||
if (isNotLoaded()) {
|
||||
setTimeout(poll, 100);
|
||||
return;
|
||||
}
|
||||
cb(Services.appShell.hiddenPrivateDOMWindow);
|
||||
}, 4);
|
||||
} else {
|
||||
cb(Services.appShell.hiddenPrivateDOMWindow);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче