mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Merge m-c to b2g-inbound to fix a CLOSED TREE
This commit is contained in:
commit
dcd4e55971
@ -67,6 +67,11 @@ MIDL_GENERATED_FILES = \
|
||||
|
||||
EMBED_MANIFEST_AT = 2
|
||||
|
||||
INSTALL_TARGETS += midl
|
||||
midl_FILES := $(filter %.h %_i.c,$(MIDL_GENERATED_FILES))
|
||||
midl_DEST = $(DIST)/include
|
||||
midl_TARGET := export
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
OS_LIBS = $(call EXPAND_LIBNAME,uuid kernel32 rpcns4 rpcrt4 ole32 oleaut32)
|
||||
|
@ -5,49 +5,5 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
MODULE = 'accessibility'
|
||||
|
||||
# Please keep this list in sync with the Makefile.in until the rest of that file
|
||||
# is ported over.
|
||||
midl_interfaces = [
|
||||
'Accessible2',
|
||||
'Accessible2_2',
|
||||
'AccessibleAction',
|
||||
'AccessibleApplication',
|
||||
'AccessibleComponent',
|
||||
'AccessibleDocument',
|
||||
'AccessibleEditableText',
|
||||
'AccessibleHyperlink',
|
||||
'AccessibleHypertext',
|
||||
'AccessibleHypertext2',
|
||||
'AccessibleImage',
|
||||
'AccessibleRelation',
|
||||
'AccessibleTable',
|
||||
'AccessibleTable2',
|
||||
'AccessibleTableCell',
|
||||
'AccessibleText',
|
||||
'AccessibleText2',
|
||||
'AccessibleValue',
|
||||
]
|
||||
|
||||
# Please keep this list in sync with the Makefile.in until the rest of that file
|
||||
# is ported over.
|
||||
midl_enums = [
|
||||
'AccessibleEventId',
|
||||
'AccessibleRole',
|
||||
'AccessibleStates',
|
||||
'IA2CommonTypes',
|
||||
]
|
||||
|
||||
headers = ['%s.h' % x for x in midl_enums]
|
||||
interfaces_h = ['%s.h' % x for x in midl_interfaces]
|
||||
interfaces_c = ['%s_i.c' % x for x in midl_interfaces]
|
||||
|
||||
# The underscore throws off sorting and EXPORTS expects sorted lists.
|
||||
interfaces_c.sort()
|
||||
|
||||
EXPORTS += headers
|
||||
EXPORTS += interfaces_h
|
||||
EXPORTS += interfaces_c
|
||||
|
||||
LIBRARY_NAME = 'IA2Marshal'
|
||||
|
||||
|
@ -60,5 +60,19 @@ register::
|
||||
|
||||
EMBED_MANIFEST_AT = 2
|
||||
|
||||
midl_exports := \
|
||||
ISimpleDOMDocument.h \
|
||||
ISimpleDOMDocument_i.c \
|
||||
ISimpleDOMNode.h \
|
||||
ISimpleDOMNode_i.c \
|
||||
ISimpleDOMText.h \
|
||||
ISimpleDOMText_i.c \
|
||||
$(NULL)
|
||||
|
||||
INSTALL_TARGETS += midl_exports
|
||||
midl_exports_FILES := $(midl_exports)
|
||||
midl_exports_DEST = $(DIST)/include
|
||||
midl_exports_TARGET := export
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
@ -6,14 +6,5 @@
|
||||
|
||||
MODULE = 'accessibility'
|
||||
|
||||
EXPORTS += [
|
||||
'ISimpleDOMDocument.h',
|
||||
'ISimpleDOMDocument_i.c',
|
||||
'ISimpleDOMNode.h',
|
||||
'ISimpleDOMNode_i.c',
|
||||
'ISimpleDOMText.h',
|
||||
'ISimpleDOMText_i.c',
|
||||
]
|
||||
|
||||
LIBRARY_NAME = 'AccessibleMarshal'
|
||||
|
||||
|
@ -11,6 +11,11 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXTRA_MDDEPEND_FILES = xpcAccEvents.pp
|
||||
|
||||
INSTALL_TARGETS += xpcaccevents
|
||||
xpcaccevents_FILES := xpcAccEvents.h
|
||||
xpcaccevents_DEST = $(DIST)/include
|
||||
xpcaccevents_TARGET := export
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
|
@ -6,10 +6,6 @@
|
||||
|
||||
MODULE = 'accessibility'
|
||||
|
||||
EXPORTS += [
|
||||
'xpcAccEvents.h',
|
||||
]
|
||||
|
||||
CPP_SOURCES += [
|
||||
'nsAccessibleRelation.cpp',
|
||||
'xpcAccEvents.cpp',
|
||||
|
@ -1075,6 +1075,7 @@ pref("devtools.inspector.enabled", true);
|
||||
pref("devtools.inspector.activeSidebar", "ruleview");
|
||||
pref("devtools.inspector.markupPreview", false);
|
||||
pref("devtools.inspector.remote", false);
|
||||
pref("devtools.inspector.show_pseudo_elements", true);
|
||||
|
||||
// Enable the Layout View
|
||||
pref("devtools.layoutview.enabled", true);
|
||||
|
@ -37,6 +37,10 @@ SocialUI = {
|
||||
Services.obs.addObserver(this, "social:provider-set", false);
|
||||
Services.obs.addObserver(this, "social:providers-changed", false);
|
||||
Services.obs.addObserver(this, "social:provider-reload", false);
|
||||
Services.obs.addObserver(this, "social:provider-installed", false);
|
||||
Services.obs.addObserver(this, "social:provider-uninstalled", false);
|
||||
Services.obs.addObserver(this, "social:provider-enabled", false);
|
||||
Services.obs.addObserver(this, "social:provider-disabled", false);
|
||||
|
||||
Services.prefs.addObserver("social.sidebar.open", this, false);
|
||||
Services.prefs.addObserver("social.toast-notifications.enabled", this, false);
|
||||
@ -62,6 +66,10 @@ SocialUI = {
|
||||
Services.obs.removeObserver(this, "social:provider-set");
|
||||
Services.obs.removeObserver(this, "social:providers-changed");
|
||||
Services.obs.removeObserver(this, "social:provider-reload");
|
||||
Services.obs.removeObserver(this, "social:provider-installed");
|
||||
Services.obs.removeObserver(this, "social:provider-uninstalled");
|
||||
Services.obs.removeObserver(this, "social:provider-enabled");
|
||||
Services.obs.removeObserver(this, "social:provider-disabled");
|
||||
|
||||
Services.prefs.removeObserver("social.sidebar.open", this);
|
||||
Services.prefs.removeObserver("social.toast-notifications.enabled", this);
|
||||
@ -76,6 +84,18 @@ SocialUI = {
|
||||
// manually :(
|
||||
try {
|
||||
switch (topic) {
|
||||
case "social:provider-installed":
|
||||
SocialStatus.setPosition(data);
|
||||
break;
|
||||
case "social:provider-uninstalled":
|
||||
SocialStatus.removePosition(data);
|
||||
break;
|
||||
case "social:provider-enabled":
|
||||
SocialStatus.populateToolbarPalette();
|
||||
break;
|
||||
case "social:provider-disabled":
|
||||
SocialStatus.removeProvider(data);
|
||||
break;
|
||||
case "social:provider-reload":
|
||||
// if the reloaded provider is our current provider, fall through
|
||||
// to social:provider-set so the ui will be reset
|
||||
@ -98,6 +118,7 @@ SocialUI = {
|
||||
SocialSidebar.update();
|
||||
SocialMark.update();
|
||||
SocialToolbar.update();
|
||||
SocialStatus.populateToolbarPalette();
|
||||
SocialMenu.populate();
|
||||
break;
|
||||
case "social:providers-changed":
|
||||
@ -106,10 +127,12 @@ SocialUI = {
|
||||
// and the multi-provider menu
|
||||
SocialToolbar.populateProviderMenus();
|
||||
SocialShare.populateProviderMenu();
|
||||
SocialStatus.populateToolbarPalette();
|
||||
break;
|
||||
|
||||
// Provider-specific notifications
|
||||
case "social:ambient-notification-changed":
|
||||
SocialStatus.updateNotification(data);
|
||||
if (this._matchesCurrentProvider(data)) {
|
||||
SocialToolbar.updateButton();
|
||||
SocialMenu.populate();
|
||||
@ -1056,6 +1079,15 @@ SocialToolbar = {
|
||||
Services.prefs.clearUserPref(CACHE_PREF_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the provider uses the new SocialStatus button, then they do not get
|
||||
// to use the ambient icons in the old toolbar button. Since the status
|
||||
// button depends on multiple workers, if not enabled we will ignore this
|
||||
// limitation. That allows a provider to migrate to the new functionality
|
||||
// once we enable multiple workers.
|
||||
if (Social.provider.statusURL && Social.allowMultipleWorkers)
|
||||
return;
|
||||
|
||||
let icons = Social.provider.ambientNotificationIcons;
|
||||
let iconNames = Object.keys(icons);
|
||||
|
||||
@ -1154,9 +1186,8 @@ SocialToolbar = {
|
||||
socialToolbarItem.insertBefore(toolbarButtons, SocialMark.button);
|
||||
|
||||
for (let frame of createdFrames) {
|
||||
if (frame.socialErrorListener) {
|
||||
if (frame.socialErrorListener)
|
||||
frame.socialErrorListener.remove();
|
||||
}
|
||||
if (frame.docShell) {
|
||||
frame.docShell.isActive = false;
|
||||
Social.setErrorListener(frame, this.setPanelErrorMessage.bind(this));
|
||||
@ -1201,11 +1232,10 @@ SocialToolbar = {
|
||||
|
||||
panel.addEventListener("popupshown", function onpopupshown() {
|
||||
panel.removeEventListener("popupshown", onpopupshown);
|
||||
// This attribute is needed on both the button and the
|
||||
// containing toolbaritem since the buttons on OS X have
|
||||
// moz-appearance:none, while their container gets
|
||||
// moz-appearance:toolbarbutton due to the way that toolbar buttons
|
||||
// get combined on OS X.
|
||||
// The "open" attribute is needed on both the button and the containing
|
||||
// toolbaritem since the buttons on OS X have moz-appearance:none, while
|
||||
// their container gets moz-appearance:toolbarbutton due to the way that
|
||||
// toolbar buttons get combined on OS X.
|
||||
aToolbarButton.setAttribute("open", "true");
|
||||
aToolbarButton.parentNode.setAttribute("open", "true");
|
||||
notificationFrame.docShell.isActive = true;
|
||||
@ -1392,4 +1422,353 @@ SocialSidebar = {
|
||||
}
|
||||
}
|
||||
|
||||
// this helper class is used by removable/customizable buttons to handle
|
||||
// location persistence and insertion into palette and/or toolbars
|
||||
|
||||
// When a provider is installed we show all their UI so the user will see the
|
||||
// functionality of what they installed. The user can later customize the UI,
|
||||
// moving buttons around or off the toolbar.
|
||||
//
|
||||
// To make this happen, on install we add a button id to the navbar currentset.
|
||||
// On enabling the provider (happens just after install) we insert the button
|
||||
// into the toolbar as well. The button is then persisted on restart (assuming
|
||||
// it was not removed).
|
||||
//
|
||||
// When a provider is disabled, we do not remove the buttons from currentset.
|
||||
// That way, if the provider is re-enabled during the same session, the buttons
|
||||
// will reappear where they were before. When a provider is uninstalled, we make
|
||||
// sure that the id is removed from currentset.
|
||||
//
|
||||
// On startup, we insert the buttons of any enabled provider into either the
|
||||
// apropriate toolbar or the palette.
|
||||
function ToolbarHelper(type, createButtonFn) {
|
||||
this._createButton = createButtonFn;
|
||||
this._type = type;
|
||||
}
|
||||
|
||||
ToolbarHelper.prototype = {
|
||||
idFromOrgin: function(origin) {
|
||||
return this._type + "-" + origin;
|
||||
},
|
||||
|
||||
// find a button either in the document or the palette
|
||||
_getExistingButton: function(id) {
|
||||
let button = document.getElementById(id);
|
||||
if (button)
|
||||
return button;
|
||||
let palette = document.getElementById("navigator-toolbox").palette;
|
||||
let paletteItem = palette.firstChild;
|
||||
while (paletteItem) {
|
||||
if (paletteItem.id == id)
|
||||
return paletteItem;
|
||||
paletteItem = paletteItem.nextSibling;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
setPersistentPosition: function(id) {
|
||||
// called when a provider is installed. add provider buttons to nav-bar
|
||||
let toolbar = document.getElementById("nav-bar");
|
||||
// first startups will not have a currentset attribute, always rely on
|
||||
// currentSet since it will be derived from the defaultset in that case.
|
||||
let currentset = toolbar.currentSet;
|
||||
if (currentset == "__empty")
|
||||
currentset = []
|
||||
else
|
||||
currentset = currentset.split(",");
|
||||
if (currentset.indexOf(id) >= 0)
|
||||
return;
|
||||
// we do not set toolbar.currentSet since that will try to add the button,
|
||||
// and we have not added it yet (happens on provider being enabled)
|
||||
currentset.push(id);
|
||||
toolbar.setAttribute("currentset", currentset.join(","));
|
||||
document.persist(toolbar.id, "currentset");
|
||||
},
|
||||
|
||||
removeProviderButton: function(origin) {
|
||||
// this will remove the button from the palette or the toolbar
|
||||
let button = this._getExistingButton(this.idFromOrgin(origin));
|
||||
if (button)
|
||||
button.parentNode.removeChild(button);
|
||||
},
|
||||
|
||||
removePersistence: function(id) {
|
||||
let persisted = document.querySelectorAll("*[currentset]");
|
||||
for (let pent of persisted) {
|
||||
// the button will have been removed, but left in the currentset attribute
|
||||
// in case the user re-enables (e.g. undo in addon manager). So we only
|
||||
// check the attribute here.
|
||||
let currentset = pent.getAttribute("currentset").split(",");
|
||||
|
||||
let pos = currentset.indexOf(id);
|
||||
if (pos >= 0) {
|
||||
currentset.splice(pos, 1);
|
||||
pent.setAttribute("currentset", currentset.join(","));
|
||||
document.persist(pent.id, "currentset");
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// if social is entirely disabled, we need to clear the palette, but leave
|
||||
// the persisted id's in place
|
||||
clearPalette: function() {
|
||||
[this.removeProviderButton(p.origin) for (p of Social.providers)];
|
||||
},
|
||||
|
||||
// should be called on startup of each window, otherwise the addon manager
|
||||
// listener will handle new activations, or enable/disabling of a provider
|
||||
// XXX we currently call more regularly, will fix during refactoring
|
||||
populatePalette: function() {
|
||||
if (!Social.enabled) {
|
||||
this.clearPalette();
|
||||
return;
|
||||
}
|
||||
let persisted = document.querySelectorAll("*[currentset]");
|
||||
let persistedById = {};
|
||||
for (let pent of persisted) {
|
||||
let pset = pent.getAttribute("currentset").split(',');
|
||||
for (let id of pset)
|
||||
persistedById[id] = pent;
|
||||
}
|
||||
|
||||
// create any buttons that do not exist yet if they have been persisted
|
||||
// as a part of the UI (otherwise they belong in the palette).
|
||||
for (let provider of Social.providers) {
|
||||
let id = this.idFromOrgin(provider.origin);
|
||||
if (this._getExistingButton(id))
|
||||
return;
|
||||
let button = this._createButton(provider);
|
||||
if (button && persistedById.hasOwnProperty(id)) {
|
||||
let parent = persistedById[id];
|
||||
let pset = persistedById[id].getAttribute("currentset").split(',');
|
||||
let pi = pset.indexOf(id) + 1;
|
||||
let next = document.getElementById(pset[pi]);
|
||||
parent.insertItem(id, next, null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SocialStatus = {
|
||||
populateToolbarPalette: function() {
|
||||
if (!Social.allowMultipleWorkers)
|
||||
return;
|
||||
this._toolbarHelper.populatePalette();
|
||||
},
|
||||
|
||||
setPosition: function(origin) {
|
||||
if (!Social.allowMultipleWorkers)
|
||||
return;
|
||||
// this is called during install, before the provider is enabled so we have
|
||||
// to use the manifest rather than the provider instance as we do elsewhere.
|
||||
let manifest = Social.getManifestByOrigin(origin);
|
||||
if (!manifest.statusURL)
|
||||
return;
|
||||
let tbh = this._toolbarHelper;
|
||||
tbh.setPersistentPosition(tbh.idFromOrgin(origin));
|
||||
},
|
||||
|
||||
removePosition: function(origin) {
|
||||
if (!Social.allowMultipleWorkers)
|
||||
return;
|
||||
let tbh = this._toolbarHelper;
|
||||
tbh.removePersistence(tbh.idFromOrgin(origin));
|
||||
},
|
||||
|
||||
removeProvider: function(origin) {
|
||||
if (!Social.allowMultipleWorkers)
|
||||
return;
|
||||
this._toolbarHelper.removeProviderButton(origin);
|
||||
},
|
||||
|
||||
get _toolbarHelper() {
|
||||
delete this._toolbarHelper;
|
||||
this._toolbarHelper = new ToolbarHelper("social-status-button", this._createButton.bind(this));
|
||||
return this._toolbarHelper;
|
||||
},
|
||||
|
||||
get _dynamicResizer() {
|
||||
delete this._dynamicResizer;
|
||||
this._dynamicResizer = new DynamicResizeWatcher();
|
||||
return this._dynamicResizer;
|
||||
},
|
||||
|
||||
_createButton: function(provider) {
|
||||
if (!provider.statusURL)
|
||||
return null;
|
||||
let palette = document.getElementById("navigator-toolbox").palette;
|
||||
let button = document.createElement("toolbarbutton");
|
||||
button.setAttribute("class", "toolbarbutton-1 social-status-button");
|
||||
button.setAttribute("type", "badged");
|
||||
button.setAttribute("removable", "true");
|
||||
button.setAttribute("image", provider.iconURL);
|
||||
button.setAttribute("label", provider.name);
|
||||
button.setAttribute("tooltiptext", provider.name);
|
||||
button.setAttribute("origin", provider.origin);
|
||||
button.setAttribute("oncommand", "SocialStatus.showPopup(this);");
|
||||
button.setAttribute("id", this._toolbarHelper.idFromOrgin(provider.origin));
|
||||
palette.appendChild(button);
|
||||
return button;
|
||||
},
|
||||
|
||||
// status panels are one-per button per-process, we swap the docshells between
|
||||
// windows when necessary
|
||||
_attachNotificatonPanel: function(aButton, provider) {
|
||||
let panel = document.getElementById("social-notification-panel");
|
||||
panel.hidden = !SocialUI.enabled;
|
||||
let notificationFrameId = "social-status-" + provider.origin;
|
||||
let frame = document.getElementById(notificationFrameId);
|
||||
|
||||
if (!frame) {
|
||||
frame = SharedFrame.createFrame(
|
||||
notificationFrameId, /* frame name */
|
||||
panel, /* parent */
|
||||
{
|
||||
"type": "content",
|
||||
"mozbrowser": "true",
|
||||
"class": "social-panel-frame",
|
||||
"id": notificationFrameId,
|
||||
"tooltip": "aHTMLTooltip",
|
||||
|
||||
// work around bug 793057 - by making the panel roughly the final size
|
||||
// we are more likely to have the anchor in the correct position.
|
||||
"style": "width: " + PANEL_MIN_WIDTH + "px;",
|
||||
|
||||
"origin": provider.origin,
|
||||
"src": provider.statusURL
|
||||
}
|
||||
);
|
||||
|
||||
if (frame.socialErrorListener)
|
||||
frame.socialErrorListener.remove();
|
||||
if (frame.docShell) {
|
||||
frame.docShell.isActive = false;
|
||||
Social.setErrorListener(frame, this.setPanelErrorMessage.bind(this));
|
||||
}
|
||||
} else {
|
||||
frame.setAttribute("origin", provider.origin);
|
||||
SharedFrame.updateURL(notificationFrameId, provider.statusURL);
|
||||
}
|
||||
aButton.setAttribute("notificationFrameId", notificationFrameId);
|
||||
},
|
||||
|
||||
updateNotification: function(origin) {
|
||||
if (!Social.allowMultipleWorkers)
|
||||
return;
|
||||
let provider = Social._getProviderFromOrigin(origin);
|
||||
let button = document.getElementById(this._toolbarHelper.idFromOrgin(provider.origin));
|
||||
if (button) {
|
||||
// we only grab the first notification, ignore all others
|
||||
let icons = provider.ambientNotificationIcons;
|
||||
let iconNames = Object.keys(icons);
|
||||
let notif = icons[iconNames[0]];
|
||||
if (!notif) {
|
||||
button.setAttribute("badge", "");
|
||||
button.setAttribute("aria-label", "");
|
||||
button.setAttribute("tooltiptext", "");
|
||||
return;
|
||||
}
|
||||
|
||||
button.style.listStyleImage = "url(" + notif.iconURL || provider.iconURL + ")";
|
||||
button.setAttribute("tooltiptext", notif.label);
|
||||
|
||||
let badge = notif.counter || "";
|
||||
button.setAttribute("badge", badge);
|
||||
let ariaLabel = notif.label;
|
||||
// if there is a badge value, we must use a localizable string to insert it.
|
||||
if (badge)
|
||||
ariaLabel = gNavigatorBundle.getFormattedString("social.aria.toolbarButtonBadgeText",
|
||||
[ariaLabel, badge]);
|
||||
button.setAttribute("aria-label", ariaLabel);
|
||||
}
|
||||
},
|
||||
|
||||
showPopup: function(aToolbarButton) {
|
||||
if (!Social.allowMultipleWorkers)
|
||||
return;
|
||||
// attach our notification panel if necessary
|
||||
let origin = aToolbarButton.getAttribute("origin");
|
||||
let provider = Social._getProviderFromOrigin(origin);
|
||||
this._attachNotificatonPanel(aToolbarButton, provider);
|
||||
|
||||
let panel = document.getElementById("social-notification-panel");
|
||||
let notificationFrameId = aToolbarButton.getAttribute("notificationFrameId");
|
||||
let notificationFrame = document.getElementById(notificationFrameId);
|
||||
|
||||
let wasAlive = SharedFrame.isGroupAlive(notificationFrameId);
|
||||
SharedFrame.setOwner(notificationFrameId, notificationFrame);
|
||||
|
||||
// Clear dimensions on all browsers so the panel size will
|
||||
// only use the selected browser.
|
||||
let frameIter = panel.firstElementChild;
|
||||
while (frameIter) {
|
||||
frameIter.collapsed = (frameIter != notificationFrame);
|
||||
frameIter = frameIter.nextElementSibling;
|
||||
}
|
||||
|
||||
function dispatchPanelEvent(name) {
|
||||
let evt = notificationFrame.contentDocument.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(name, true, true, {});
|
||||
notificationFrame.contentDocument.documentElement.dispatchEvent(evt);
|
||||
}
|
||||
|
||||
let dynamicResizer = this._dynamicResizer;
|
||||
panel.addEventListener("popuphidden", function onpopuphiding() {
|
||||
panel.removeEventListener("popuphidden", onpopuphiding);
|
||||
aToolbarButton.removeAttribute("open");
|
||||
dynamicResizer.stop();
|
||||
notificationFrame.docShell.isActive = false;
|
||||
dispatchPanelEvent("socialFrameHide");
|
||||
});
|
||||
|
||||
panel.addEventListener("popupshown", function onpopupshown() {
|
||||
panel.removeEventListener("popupshown", onpopupshown);
|
||||
// This attribute is needed on both the button and the
|
||||
// containing toolbaritem since the buttons on OS X have
|
||||
// moz-appearance:none, while their container gets
|
||||
// moz-appearance:toolbarbutton due to the way that toolbar buttons
|
||||
// get combined on OS X.
|
||||
aToolbarButton.setAttribute("open", "true");
|
||||
notificationFrame.docShell.isActive = true;
|
||||
notificationFrame.docShell.isAppTab = true;
|
||||
if (notificationFrame.contentDocument.readyState == "complete" && wasAlive) {
|
||||
dynamicResizer.start(panel, notificationFrame);
|
||||
dispatchPanelEvent("socialFrameShow");
|
||||
} else {
|
||||
// first time load, wait for load and dispatch after load
|
||||
notificationFrame.addEventListener("load", function panelBrowserOnload(e) {
|
||||
notificationFrame.removeEventListener("load", panelBrowserOnload, true);
|
||||
dynamicResizer.start(panel, notificationFrame);
|
||||
dispatchPanelEvent("socialFrameShow");
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
|
||||
let navBar = document.getElementById("nav-bar");
|
||||
let anchor = navBar.getAttribute("mode") == "text" ?
|
||||
document.getAnonymousElementByAttribute(aToolbarButton, "class", "toolbarbutton-text") :
|
||||
document.getAnonymousElementByAttribute(aToolbarButton, "class", "toolbarbutton-badge-container");
|
||||
// Bug 849216 - open the popup in a setTimeout so we avoid the auto-rollup
|
||||
// handling from preventing it being opened in some cases.
|
||||
setTimeout(function() {
|
||||
panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false);
|
||||
}, 0);
|
||||
},
|
||||
|
||||
setPanelErrorMessage: function(aNotificationFrame) {
|
||||
if (!aNotificationFrame)
|
||||
return;
|
||||
|
||||
let src = aNotificationFrame.getAttribute("src");
|
||||
aNotificationFrame.removeAttribute("src");
|
||||
aNotificationFrame.webNavigation.loadURI("about:socialerror?mode=tryAgainOnly&url=" +
|
||||
encodeURIComponent(src),
|
||||
null, null, null, null);
|
||||
let panel = aNotificationFrame.parentNode;
|
||||
sizeSocialPanelToContent(panel, aNotificationFrame);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -2214,9 +2214,10 @@ function losslessDecodeURI(aURI) {
|
||||
encodeURIComponent);
|
||||
} catch (e) {}
|
||||
|
||||
// Encode invisible characters (line and paragraph separator,
|
||||
// object replacement character) (bug 452979)
|
||||
value = value.replace(/[\v\x0c\x1c\x1d\x1e\x1f\u2028\u2029\ufffc]/g,
|
||||
// Encode invisible characters (C0/C1 control characters, U+007F [DEL],
|
||||
// U+00A0 [no-break space], line and paragraph separator,
|
||||
// object replacement character) (bug 452979, bug 909264)
|
||||
value = value.replace(/[\u0000-\u001f\u007f-\u00a0\u2028\u2029\ufffc]/g,
|
||||
encodeURIComponent);
|
||||
|
||||
// Encode default ignorable characters (bug 546013)
|
||||
|
@ -31,6 +31,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_social_multiprovider.js \
|
||||
browser_social_multiworker.js \
|
||||
browser_social_errorPage.js \
|
||||
browser_social_status.js \
|
||||
browser_social_window.js \
|
||||
social_activate.html \
|
||||
social_activate_iframe.html \
|
||||
|
@ -50,9 +50,10 @@ function installListener(next, aManifest) {
|
||||
let expectEvent = "onInstalling";
|
||||
let prefname = getManifestPrefname(aManifest);
|
||||
// wait for the actual removal to call next
|
||||
SocialService.registerProviderListener(function providerListener(topic, data) {
|
||||
if (topic == "provider-removed") {
|
||||
SocialService.registerProviderListener(function providerListener(topic, origin, providers) {
|
||||
if (topic == "provider-disabled") {
|
||||
SocialService.unregisterProviderListener(providerListener);
|
||||
is(origin, aManifest.origin, "provider disabled");
|
||||
executeSoon(next);
|
||||
}
|
||||
});
|
||||
@ -295,14 +296,15 @@ var tests = {
|
||||
Social.enabled = true;
|
||||
|
||||
// watch for the provider-update and test the new version
|
||||
SocialService.registerProviderListener(function providerListener(topic, data) {
|
||||
SocialService.registerProviderListener(function providerListener(topic, origin, providers) {
|
||||
if (topic != "provider-update")
|
||||
return;
|
||||
is(origin, addonManifest.origin, "provider updated")
|
||||
SocialService.unregisterProviderListener(providerListener);
|
||||
Services.prefs.clearUserPref("social.whitelist");
|
||||
let provider = Social._getProviderFromOrigin(addonManifest.origin);
|
||||
let provider = Social._getProviderFromOrigin(origin);
|
||||
is(provider.manifest.version, 2, "manifest version is 2");
|
||||
Social.uninstallProvider(addonManifest.origin, function() {
|
||||
Social.uninstallProvider(origin, function() {
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
});
|
||||
|
@ -155,14 +155,15 @@ var tests = {
|
||||
setManifestPref("social.manifest.blocked", manifest_bad);
|
||||
try {
|
||||
SocialService.addProvider(manifest_bad, function(provider) {
|
||||
// the act of blocking should cause a 'provider-removed' notification
|
||||
// the act of blocking should cause a 'provider-disabled' notification
|
||||
// from SocialService.
|
||||
SocialService.registerProviderListener(function providerListener(topic) {
|
||||
if (topic != "provider-removed")
|
||||
SocialService.registerProviderListener(function providerListener(topic, origin, providers) {
|
||||
if (topic != "provider-disabled")
|
||||
return;
|
||||
SocialService.unregisterProviderListener(providerListener);
|
||||
is(origin, provider.origin, "provider disabled");
|
||||
SocialService.getProvider(provider.origin, function(p) {
|
||||
ok(p==null, "blocklisted provider removed");
|
||||
ok(p == null, "blocklisted provider disabled");
|
||||
Services.prefs.clearUserPref("social.manifest.blocked");
|
||||
resetBlocklist(finish);
|
||||
});
|
||||
|
@ -19,6 +19,13 @@ function test() {
|
||||
|
||||
var tests = {
|
||||
testStatusIcons: function(next) {
|
||||
let icon = {
|
||||
name: "testIcon",
|
||||
iconURL: "chrome://browser/skin/Info.png",
|
||||
contentPanel: "https://example.com/browser/browser/base/content/test/social/social_panel.html",
|
||||
counter: 1
|
||||
};
|
||||
|
||||
let iconsReady = false;
|
||||
let gotSidebarMessage = false;
|
||||
|
||||
@ -71,7 +78,7 @@ var tests = {
|
||||
ok(true, "got sidebar message");
|
||||
gotSidebarMessage = true;
|
||||
// load a status panel
|
||||
port.postMessage({topic: "test-ambient-notification"});
|
||||
port.postMessage({topic: "test-ambient-notification", data: icon});
|
||||
checkNext();
|
||||
break;
|
||||
}
|
||||
|
220
browser/base/content/test/social/browser_social_status.js
Normal file
220
browser/base/content/test/social/browser_social_status.js
Normal file
@ -0,0 +1,220 @@
|
||||
/* 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/. */
|
||||
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
let manifest = { // builtin provider
|
||||
name: "provider example.com",
|
||||
origin: "https://example.com",
|
||||
sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
|
||||
workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
|
||||
iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
|
||||
};
|
||||
let manifest2 = { // used for testing install
|
||||
name: "provider test1",
|
||||
origin: "https://test1.example.com",
|
||||
workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js",
|
||||
statusURL: "https://test1.example.com/browser/browser/base/content/test/social/social_panel.html",
|
||||
iconURL: "https://test1.example.com/browser/browser/base/content/test/moz.png",
|
||||
version: 1
|
||||
};
|
||||
let manifest3 = { // used for testing install
|
||||
name: "provider test2",
|
||||
origin: "https://test2.example.com",
|
||||
sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html",
|
||||
iconURL: "https://test2.example.com/browser/browser/base/content/test/moz.png",
|
||||
version: 1
|
||||
};
|
||||
|
||||
|
||||
function openWindowAndWaitForInit(callback) {
|
||||
let topic = "browser-delayed-startup-finished";
|
||||
let w = OpenBrowserWindow();
|
||||
Services.obs.addObserver(function providerSet(subject, topic, data) {
|
||||
Services.obs.removeObserver(providerSet, topic);
|
||||
executeSoon(() => callback(w));
|
||||
}, topic, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
Services.prefs.setBoolPref("social.allowMultipleWorkers", true);
|
||||
let toolbar = document.getElementById("nav-bar");
|
||||
let currentsetAtStart = toolbar.currentSet;
|
||||
info("tb0 "+currentsetAtStart);
|
||||
runSocialTestWithProvider(manifest, function () {
|
||||
runSocialTests(tests, undefined, undefined, function () {
|
||||
Services.prefs.clearUserPref("social.remote-install.enabled");
|
||||
// just in case the tests failed, clear these here as well
|
||||
Services.prefs.clearUserPref("social.allowMultipleWorkers");
|
||||
Services.prefs.clearUserPref("social.whitelist");
|
||||
|
||||
// This post-test test ensures that a new window maintains the same
|
||||
// toolbar button set as when we started. That means our insert/removal of
|
||||
// persistent id's is working correctly
|
||||
is(currentsetAtStart, toolbar.currentSet, "toolbar currentset unchanged");
|
||||
openWindowAndWaitForInit(function(w1) {
|
||||
checkSocialUI(w1);
|
||||
// Sometimes the new window adds other buttons to currentSet that are
|
||||
// outside the scope of what we're checking. So we verify that all
|
||||
// buttons from startup are in currentSet for a new window, and that the
|
||||
// provider buttons are properly removed. (e.g on try, window-controls
|
||||
// was not present in currentsetAtStart, but present on the second
|
||||
// window)
|
||||
let tb1 = w1.document.getElementById("nav-bar");
|
||||
info("tb0 "+toolbar.currentSet);
|
||||
info("tb1 "+tb1.currentSet);
|
||||
let startupSet = Set(toolbar.currentSet.split(','));
|
||||
let newSet = Set(tb1.currentSet.split(','));
|
||||
let intersect = Set([x for (x of startupSet) if (newSet.has(x))]);
|
||||
info("intersect "+intersect);
|
||||
let difference = Set([x for (x of newSet) if (!startupSet.has(x))]);
|
||||
info("difference "+difference);
|
||||
is(startupSet.size, intersect.size, "new window toolbar same as old");
|
||||
// verify that our provider buttons are not in difference
|
||||
let id = SocialStatus._toolbarHelper.idFromOrgin(manifest2.origin);
|
||||
ok(!difference.has(id), "status button not persisted at end");
|
||||
w1.close();
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var tests = {
|
||||
testNoButtonOnInstall: function(next) {
|
||||
// we expect the addon install dialog to appear, we need to accept the
|
||||
// install from the dialog.
|
||||
info("Waiting for install dialog");
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
|
||||
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
})
|
||||
|
||||
let id = "social-status-button-" + manifest3.origin;
|
||||
let toolbar = document.getElementById("nav-bar");
|
||||
let currentset = toolbar.getAttribute("currentset").split(',');
|
||||
ok(currentset.indexOf(id) < 0, "button is not part of currentset at start");
|
||||
|
||||
let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
Social.installProvider(doc, manifest3, function(addonManifest) {
|
||||
// enable the provider so we know the button would have appeared
|
||||
SocialService.addBuiltinProvider(manifest3.origin, function(provider) {
|
||||
ok(provider, "provider is installed");
|
||||
currentset = toolbar.getAttribute("currentset").split(',');
|
||||
ok(currentset.indexOf(id) < 0, "button was not added to currentset");
|
||||
Social.uninstallProvider(manifest3.origin, function() {
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
testButtonOnInstall: function(next) {
|
||||
// we expect the addon install dialog to appear, we need to accept the
|
||||
// install from the dialog.
|
||||
info("Waiting for install dialog");
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
|
||||
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
})
|
||||
|
||||
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
Social.installProvider(doc, manifest2, function(addonManifest) {
|
||||
// at this point, we should have a button id in the currentset for our provider
|
||||
let id = "social-status-button-" + manifest2.origin;
|
||||
let toolbar = document.getElementById("nav-bar");
|
||||
|
||||
waitForCondition(function() {
|
||||
let currentset = toolbar.getAttribute("currentset").split(',');
|
||||
return currentset.indexOf(id) >= 0;
|
||||
},
|
||||
function() {
|
||||
// no longer need the tab
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
}, "status button added to currentset");
|
||||
});
|
||||
});
|
||||
},
|
||||
testButtonOnEnable: function(next) {
|
||||
// enable the provider now
|
||||
SocialService.addBuiltinProvider(manifest2.origin, function(provider) {
|
||||
ok(provider, "provider is installed");
|
||||
let id = "social-status-button-" + manifest2.origin;
|
||||
waitForCondition(function() { return document.getElementById(id) },
|
||||
next, "button exists after enabling social");
|
||||
});
|
||||
},
|
||||
testStatusPanel: function(next) {
|
||||
let icon = {
|
||||
name: "testIcon",
|
||||
iconURL: "chrome://browser/skin/Info.png",
|
||||
counter: 1
|
||||
};
|
||||
// click on panel to open and wait for visibility
|
||||
let provider = Social._getProviderFromOrigin(manifest2.origin);
|
||||
let id = "social-status-button-" + provider.origin;
|
||||
let btn = document.getElementById(id)
|
||||
ok(btn, "got a status button");
|
||||
let port = provider.getWorkerPort();
|
||||
|
||||
port.onmessage = function (e) {
|
||||
let topic = e.data.topic;
|
||||
switch (topic) {
|
||||
case "test-init-done":
|
||||
ok(true, "test-init-done received");
|
||||
ok(provider.profile.userName, "profile was set by test worker");
|
||||
btn.click();
|
||||
break;
|
||||
case "got-social-panel-visibility":
|
||||
ok(true, "got the panel message " + e.data.result);
|
||||
if (e.data.result == "shown") {
|
||||
let panel = document.getElementById("social-notification-panel");
|
||||
panel.hidePopup();
|
||||
} else {
|
||||
port.postMessage({topic: "test-ambient-notification", data: icon});
|
||||
port.close();
|
||||
waitForCondition(function() { return btn.getAttribute("badge"); },
|
||||
function() {
|
||||
is(btn.style.listStyleImage, "url(\"" + icon.iconURL + "\")", "notification icon updated");
|
||||
next();
|
||||
}, "button updated by notification");
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
port.postMessage({topic: "test-init"});
|
||||
},
|
||||
testButtonOnDisable: function(next) {
|
||||
// enable the provider now
|
||||
let provider = Social._getProviderFromOrigin(manifest2.origin);
|
||||
ok(provider, "provider is installed");
|
||||
SocialService.removeProvider(manifest2.origin, function() {
|
||||
let id = "social-status-button-" + manifest2.origin;
|
||||
waitForCondition(function() { return !document.getElementById(id) },
|
||||
next, "button does not exist after disabling the provider");
|
||||
});
|
||||
},
|
||||
testButtonOnUninstall: function(next) {
|
||||
Social.uninstallProvider(manifest2.origin, function() {
|
||||
// test that the button is no longer persisted
|
||||
let id = "social-status-button-" + manifest2.origin;
|
||||
let toolbar = document.getElementById("nav-bar");
|
||||
let currentset = toolbar.getAttribute("currentset").split(',');
|
||||
is(currentset.indexOf(id), -1, "button no longer in currentset");
|
||||
next();
|
||||
});
|
||||
}
|
||||
}
|
@ -177,7 +177,7 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
|
||||
cbPostTest(runNextTest);
|
||||
}
|
||||
cbPreTest(function() {
|
||||
is(providersAtStart, Social.providers.length, "pre-test: no new providers left enabled");
|
||||
info("pre-test: starting with " + Social.providers.length + " providers");
|
||||
info("sub-test " + name + " starting");
|
||||
try {
|
||||
func.call(tests, cleanupAndRunNextTest);
|
||||
|
@ -14,6 +14,7 @@ var data = {
|
||||
// at least one of these must be defined
|
||||
"sidebarURL": "/browser/browser/base/content/test/social/social_sidebar.html",
|
||||
"workerURL": "/browser/browser/base/content/test/social/social_worker.js",
|
||||
"statusURL": "/browser/browser/base/content/test/social/social_panel.html",
|
||||
|
||||
// should be available for display purposes
|
||||
"description": "A short paragraph about this provider",
|
||||
|
@ -119,13 +119,7 @@ onconnect = function(e) {
|
||||
});
|
||||
break;
|
||||
case "test-ambient-notification":
|
||||
let icon = {
|
||||
name: "testIcon",
|
||||
iconURL: "chrome://browser/skin/Info.png",
|
||||
contentPanel: "https://example.com/browser/browser/base/content/test/social/social_panel.html",
|
||||
counter: 1
|
||||
};
|
||||
apiPort.postMessage({topic: "social.ambient-notification", data: icon});
|
||||
apiPort.postMessage({topic: "social.ambient-notification", data: event.data.data});
|
||||
break;
|
||||
case "test-isVisible":
|
||||
sidebarPort.postMessage({topic: "test-isVisible"});
|
||||
|
@ -1734,15 +1734,11 @@ ContentPermissionPrompt.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionPrompt]),
|
||||
|
||||
_getBrowserForRequest: function (aRequest) {
|
||||
var browser;
|
||||
try {
|
||||
// "element" is only defined in e10s mode, otherwise it throws.
|
||||
browser = aRequest.element;
|
||||
} catch (e) {}
|
||||
// "element" is only defined in e10s mode.
|
||||
let browser = aRequest.element;
|
||||
if (!browser) {
|
||||
var requestingWindow = aRequest.window.top;
|
||||
// find the requesting browser or iframe
|
||||
browser = requestingWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
// Find the requesting browser.
|
||||
browser = aRequest.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.chromeEventHandler;
|
||||
|
@ -20,6 +20,7 @@ let { Cc, Ci, Cu } = require("chrome");
|
||||
let promise = require("sdk/core/promise");
|
||||
let Telemetry = require("devtools/shared/telemetry");
|
||||
let TargetFactory = require("devtools/framework/target").TargetFactory;
|
||||
const escodegen = require("escodegen/escodegen");
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
@ -31,6 +32,8 @@ Cu.import("resource://gre/modules/jsdebugger.jsm");
|
||||
Cu.import("resource:///modules/devtools/gDevTools.jsm");
|
||||
Cu.import("resource://gre/modules/osfile.jsm");
|
||||
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
|
||||
Cu.import("resource://gre/modules/reflect.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "VariablesView",
|
||||
"resource:///modules/devtools/VariablesView.jsm");
|
||||
@ -521,6 +524,20 @@ var Scratchpad = {
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Pretty print the source text inside the scratchpad.
|
||||
*/
|
||||
prettyPrint: function SP_prettyPrint() {
|
||||
const uglyText = this.getText();
|
||||
try {
|
||||
const ast = Reflect.parse(uglyText);
|
||||
const prettyText = escodegen.generate(ast);
|
||||
this.setText(prettyText);
|
||||
} catch (e) {
|
||||
this.writeAsErrorComment(DevToolsUtils.safeErrorString(e));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Writes out a primitive value as a comment. This handles values which are
|
||||
* to be printed directly (number, string) as well as grips to values
|
||||
|
@ -46,6 +46,7 @@
|
||||
<command id="sp-cmd-run" oncommand="Scratchpad.run();"/>
|
||||
<command id="sp-cmd-inspect" oncommand="Scratchpad.inspect();"/>
|
||||
<command id="sp-cmd-display" oncommand="Scratchpad.display();"/>
|
||||
<command id="sp-cmd-pprint" oncommand="Scratchpad.prettyPrint();"/>
|
||||
<command id="sp-cmd-contentContext" oncommand="Scratchpad.setContentContext();"/>
|
||||
<command id="sp-cmd-browserContext" oncommand="Scratchpad.setBrowserContext();" disabled="true"/>
|
||||
<command id="sp-cmd-reloadAndRun" oncommand="Scratchpad.reloadAndRun();"/>
|
||||
@ -94,6 +95,10 @@
|
||||
key="&display.key;"
|
||||
command="sp-cmd-display"
|
||||
modifiers="accel"/>
|
||||
<key id="sp-key-pprint"
|
||||
key="&pprint.key;"
|
||||
command="sp-cmd-pprint"
|
||||
modifiers="accel"/>
|
||||
<key id="sp-key-reloadAndRun"
|
||||
key="&reloadAndRun.key;"
|
||||
command="sp-cmd-reloadAndRun"
|
||||
@ -272,6 +277,11 @@
|
||||
class="devtools-toolbarbutton"
|
||||
label="&display.label;"
|
||||
command="sp-cmd-display"/>
|
||||
<toolbarspacer/>
|
||||
<toolbarbutton id="sp-toolbar-pprint"
|
||||
class="devtools-toolbarbutton"
|
||||
label="&pprint.label;"
|
||||
command="sp-cmd-pprint"/>
|
||||
</toolbar>
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_scratchpad_bug807924_cannot_convert_to_string.js \
|
||||
browser_scratchpad_long_string.js \
|
||||
browser_scratchpad_open_error_console.js \
|
||||
browser_scratchpad_pprint.js \
|
||||
head.js \
|
||||
|
||||
# Disable test due to bug 807234 becoming basically permanent
|
||||
|
@ -0,0 +1,26 @@
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
openScratchpad(runTests);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
|
||||
}
|
||||
|
||||
function runTests(sw)
|
||||
{
|
||||
const sp = sw.Scratchpad;
|
||||
sp.setText("function main() { console.log(5); }");
|
||||
sp.prettyPrint();
|
||||
const prettyText = sp.getText();
|
||||
ok(prettyText.contains("\n"));
|
||||
finish();
|
||||
}
|
@ -11,7 +11,7 @@ const promise = require("sdk/core/promise");
|
||||
|
||||
let {CssLogic} = require("devtools/styleinspector/css-logic");
|
||||
let {InplaceEditor, editableField, editableItem} = require("devtools/shared/inplace-editor");
|
||||
let {ELEMENT_STYLE} = require("devtools/server/actors/styles");
|
||||
let {ELEMENT_STYLE, PSEUDO_ELEMENTS} = require("devtools/server/actors/styles");
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
@ -203,7 +203,9 @@ ElementStyle.prototype = {
|
||||
}
|
||||
|
||||
// Mark overridden computed styles.
|
||||
this.markOverridden();
|
||||
this.markOverriddenAll();
|
||||
|
||||
this._sortRulesForPseudoElement();
|
||||
|
||||
// We're done with the previous list of rules.
|
||||
delete this._refreshRules;
|
||||
@ -215,6 +217,16 @@ ElementStyle.prototype = {
|
||||
return this.populated;
|
||||
},
|
||||
|
||||
/**
|
||||
* Put pseudo elements in front of others.
|
||||
*/
|
||||
_sortRulesForPseudoElement: function ElementStyle_sortRulesForPseudoElement()
|
||||
{
|
||||
this.rules = this.rules.sort((a, b) => {
|
||||
return (a.pseudoElement || "z") > (b.pseudoElement || "z");
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a rule if it's one we care about. Filters out duplicates and
|
||||
* inherited styles with no inherited properties.
|
||||
@ -266,22 +278,38 @@ ElementStyle.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Mark the properties listed in this.rules with an overridden flag
|
||||
* if an earlier property overrides it.
|
||||
* Calls markOverridden with all supported pseudo elements
|
||||
*/
|
||||
markOverridden: function ElementStyle_markOverridden()
|
||||
markOverriddenAll: function ElementStyle_markOverriddenAll()
|
||||
{
|
||||
this.markOverridden();
|
||||
for (let pseudo of PSEUDO_ELEMENTS) {
|
||||
this.markOverridden(pseudo);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Mark the properties listed in this.rules for a given pseudo element
|
||||
* with an overridden flag if an earlier property overrides it.
|
||||
* @param {string} pseudo
|
||||
* Which pseudo element to flag as overridden.
|
||||
* Empty string or undefined will default to no pseudo element.
|
||||
*/
|
||||
markOverridden: function ElementStyle_markOverridden(pseudo="")
|
||||
{
|
||||
// Gather all the text properties applied by these rules, ordered
|
||||
// from more- to less-specific.
|
||||
let textProps = [];
|
||||
for each (let rule in this.rules) {
|
||||
textProps = textProps.concat(rule.textProps.slice(0).reverse());
|
||||
for (let rule of this.rules) {
|
||||
if (rule.pseudoElement == pseudo) {
|
||||
textProps = textProps.concat(rule.textProps.slice(0).reverse());
|
||||
}
|
||||
}
|
||||
|
||||
// Gather all the computed properties applied by those text
|
||||
// properties.
|
||||
let computedProps = [];
|
||||
for each (let textProp in textProps) {
|
||||
for (let textProp of textProps) {
|
||||
computedProps = computedProps.concat(textProp.computed);
|
||||
}
|
||||
|
||||
@ -302,7 +330,7 @@ ElementStyle.prototype = {
|
||||
// _overriddenDirty will be set on each prop, indicating whether its
|
||||
// dirty status changed during this pass.
|
||||
let taken = {};
|
||||
for each (let computedProp in computedProps) {
|
||||
for (let computedProp of computedProps) {
|
||||
let earlier = taken[computedProp.name];
|
||||
let overridden;
|
||||
if (earlier
|
||||
@ -328,7 +356,7 @@ ElementStyle.prototype = {
|
||||
// computed properties are marked overridden. Update the text
|
||||
// property's associated editor, if any. This will clear the
|
||||
// _overriddenDirty state on all computed properties.
|
||||
for each (let textProp in textProps) {
|
||||
for (let textProp of textProps) {
|
||||
// _updatePropertyOverridden will return true if the
|
||||
// overridden state has changed for the text property.
|
||||
if (this._updatePropertyOverridden(textProp)) {
|
||||
@ -384,6 +412,7 @@ function Rule(aElementStyle, aOptions)
|
||||
this.domRule = aOptions.rule || null;
|
||||
this.style = aOptions.rule;
|
||||
this.matchedSelectors = aOptions.matchedSelectors || [];
|
||||
this.pseudoElement = aOptions.pseudoElement || "";
|
||||
|
||||
this.inherited = aOptions.inherited || null;
|
||||
this._modificationDepth = 0;
|
||||
@ -558,7 +587,7 @@ Rule.prototype = {
|
||||
textProp.priority = cssProp.priority;
|
||||
}
|
||||
|
||||
this.elementStyle.markOverridden();
|
||||
this.elementStyle.markOverriddenAll();
|
||||
|
||||
if (promise === this._applyingModifications) {
|
||||
this._applyingModifications = null;
|
||||
@ -642,7 +671,6 @@ Rule.prototype = {
|
||||
let props = [];
|
||||
|
||||
for (let line of lines) {
|
||||
dump("line: " + line + "\n");
|
||||
let [, name, value, priority] = CSS_PROP_RE.exec(line) || []
|
||||
if (!name || !value) {
|
||||
continue;
|
||||
@ -1078,6 +1106,7 @@ CssRuleView.prototype = {
|
||||
}
|
||||
this._createEditors();
|
||||
|
||||
|
||||
// Notify anyone that cares that we refreshed.
|
||||
var evt = this.doc.createEvent("Events");
|
||||
evt.initEvent("CssRuleViewRefreshed", true, false);
|
||||
@ -1132,6 +1161,59 @@ CssRuleView.prototype = {
|
||||
this.element.dispatchEvent(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Text for header that shows above rules for this element
|
||||
*/
|
||||
get selectedElementLabel ()
|
||||
{
|
||||
if (this._selectedElementLabel) {
|
||||
return this._selectedElementLabel;
|
||||
}
|
||||
this._selectedElementLabel = CssLogic.l10n("rule.selectedElement");
|
||||
return this._selectedElementLabel;
|
||||
},
|
||||
|
||||
/**
|
||||
* Text for header that shows above rules for pseudo elements
|
||||
*/
|
||||
get pseudoElementLabel ()
|
||||
{
|
||||
if (this._pseudoElementLabel) {
|
||||
return this._pseudoElementLabel;
|
||||
}
|
||||
this._pseudoElementLabel = CssLogic.l10n("rule.pseudoElement");
|
||||
return this._pseudoElementLabel;
|
||||
},
|
||||
|
||||
togglePseudoElementVisibility: function(value)
|
||||
{
|
||||
this._showPseudoElements = !!value;
|
||||
let isOpen = this.showPseudoElements;
|
||||
|
||||
Services.prefs.setBoolPref("devtools.inspector.show_pseudo_elements",
|
||||
isOpen);
|
||||
|
||||
this.element.classList.toggle("show-pseudo-elements", isOpen);
|
||||
|
||||
if (this.pseudoElementTwisty) {
|
||||
if (isOpen) {
|
||||
this.pseudoElementTwisty.setAttribute("open", "true");
|
||||
}
|
||||
else {
|
||||
this.pseudoElementTwisty.removeAttribute("open");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get showPseudoElements ()
|
||||
{
|
||||
if (this._showPseudoElements === undefined) {
|
||||
this._showPseudoElements =
|
||||
Services.prefs.getBoolPref("devtools.inspector.show_pseudo_elements");
|
||||
}
|
||||
return this._showPseudoElements;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates editor UI for each of the rules in _elementStyle.
|
||||
*/
|
||||
@ -1140,18 +1222,48 @@ CssRuleView.prototype = {
|
||||
// Run through the current list of rules, attaching
|
||||
// their editors in order. Create editors if needed.
|
||||
let lastInheritedSource = "";
|
||||
let seenPseudoElement = false;
|
||||
let seenNormalElement = false;
|
||||
|
||||
for (let rule of this._elementStyle.rules) {
|
||||
if (rule.domRule.system) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only print header for this element if there are pseudo elements
|
||||
if (seenPseudoElement && !seenNormalElement && !rule.pseudoElement) {
|
||||
seenNormalElement = true;
|
||||
let div = this.doc.createElementNS(HTML_NS, "div");
|
||||
div.className = "theme-gutter ruleview-header";
|
||||
div.textContent = this.selectedElementLabel;
|
||||
this.element.appendChild(div);
|
||||
}
|
||||
|
||||
let inheritedSource = rule.inheritedSource;
|
||||
if (inheritedSource != lastInheritedSource) {
|
||||
let h2 = this.doc.createElementNS(HTML_NS, "div");
|
||||
h2.className = "ruleview-rule-inheritance theme-gutter";
|
||||
h2.textContent = inheritedSource;
|
||||
let div = this.doc.createElementNS(HTML_NS, "div");
|
||||
div.className = "theme-gutter ruleview-header";
|
||||
div.textContent = inheritedSource;
|
||||
lastInheritedSource = inheritedSource;
|
||||
this.element.appendChild(h2);
|
||||
this.element.appendChild(div);
|
||||
}
|
||||
|
||||
if (!seenPseudoElement && rule.pseudoElement) {
|
||||
seenPseudoElement = true;
|
||||
|
||||
let div = this.doc.createElementNS(HTML_NS, "div");
|
||||
div.className = "theme-gutter ruleview-header";
|
||||
div.textContent = this.pseudoElementLabel;
|
||||
|
||||
let twisty = this.pseudoElementTwisty =
|
||||
this.doc.createElementNS(HTML_NS, "span");
|
||||
twisty.className = "ruleview-expander theme-twisty";
|
||||
twisty.addEventListener("click", () => {
|
||||
this.togglePseudoElementVisibility(!this.showPseudoElements);
|
||||
}, false);
|
||||
|
||||
div.insertBefore(twisty, div.firstChild);
|
||||
this.element.appendChild(div);
|
||||
}
|
||||
|
||||
if (!rule.editor) {
|
||||
@ -1160,6 +1272,8 @@ CssRuleView.prototype = {
|
||||
|
||||
this.element.appendChild(rule.editor.element);
|
||||
}
|
||||
|
||||
this.togglePseudoElementVisibility(this.showPseudoElements);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1227,6 +1341,9 @@ RuleEditor.prototype = {
|
||||
this.element = this.doc.createElementNS(HTML_NS, "div");
|
||||
this.element.className = "ruleview-rule theme-separator";
|
||||
this.element._ruleEditor = this;
|
||||
if (this.rule.pseudoElement) {
|
||||
this.element.classList.add("ruleview-rule-pseudo-element");
|
||||
}
|
||||
|
||||
// Give a relative position for the inplace editor's measurement
|
||||
// span to be placed absolutely against.
|
||||
@ -1358,12 +1475,15 @@ RuleEditor.prototype = {
|
||||
* Property value.
|
||||
* @param {string} aPriority
|
||||
* Property priority.
|
||||
* @return {TextProperty}
|
||||
* The new property
|
||||
*/
|
||||
addProperty: function RuleEditor_addProperty(aName, aValue, aPriority)
|
||||
{
|
||||
let prop = this.rule.createProperty(aName, aValue, aPriority);
|
||||
let editor = new TextPropertyEditor(this, prop);
|
||||
this.propertyList.appendChild(editor.element);
|
||||
return prop;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -36,3 +36,21 @@
|
||||
.ruleview-warning[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ruleview-rule-pseudo-element {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.show-pseudo-elements .ruleview-rule-pseudo-element {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ruleview .ruleview-expander {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ruleview-header {
|
||||
vertical-align:middle;
|
||||
height: 1.5em;
|
||||
line-height: 1.5em;
|
||||
}
|
@ -43,6 +43,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_bug894376_css_value_completion_new_property_value_pair.js \
|
||||
browser_bug894376_css_value_completion_existing_property_value_pair.js \
|
||||
browser_ruleview_bug_902966_revert_value_on_ESC.js \
|
||||
browser_ruleview_pseudoelement.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
@ -60,6 +61,7 @@ MOCHITEST_BROWSER_FILES += \
|
||||
browser_styleinspector_bug_677930_urls_clickable \
|
||||
browser_styleinspector_bug_677930_urls_clickable/browser_styleinspector_bug_677930_urls_clickable.css \
|
||||
test-image.png \
|
||||
browser_ruleview_pseudoelement.html \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -0,0 +1,115 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.box {
|
||||
float:left;
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
background: #ddd;
|
||||
padding: 32px;
|
||||
margin: 32px;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
* {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
nothing {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
p::-moz-selection {
|
||||
color: white;
|
||||
background: black;
|
||||
}
|
||||
p::selection {
|
||||
color: white;
|
||||
background: black;
|
||||
}
|
||||
|
||||
p:first-line {
|
||||
background: blue;
|
||||
}
|
||||
p:first-letter {
|
||||
color: red;
|
||||
font-size: 130%;
|
||||
}
|
||||
|
||||
.box:before {
|
||||
background: green;
|
||||
content: " ";
|
||||
position: absolute;
|
||||
height:32px;
|
||||
width:32px;
|
||||
}
|
||||
|
||||
.box:after {
|
||||
background: red;
|
||||
content: " ";
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
height:32px;
|
||||
width:32px;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-top: -16px;
|
||||
margin-left: -16px;
|
||||
}
|
||||
|
||||
.topleft:before {
|
||||
top:0;
|
||||
left:0;
|
||||
}
|
||||
|
||||
.topright:before {
|
||||
top:0;
|
||||
right:0;
|
||||
}
|
||||
|
||||
.bottomright:before {
|
||||
bottom:10px;
|
||||
right:10px;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.bottomright:before {
|
||||
bottom:0;
|
||||
right:0;
|
||||
}
|
||||
|
||||
.bottomleft:before {
|
||||
bottom:0;
|
||||
left:0;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ruleview pseudoelement($("test"));</h1>
|
||||
|
||||
<div id="topleft" class="box topleft">
|
||||
<p>Top Left<br />Position</p>
|
||||
</div>
|
||||
|
||||
<div id="topright" class="box topright">
|
||||
<p>Top Right<br />Position</p>
|
||||
</div>
|
||||
|
||||
<div id="bottomright" class="box bottomright">
|
||||
<p>Bottom Right<br />Position</p>
|
||||
</div>
|
||||
|
||||
<div id="bottomleft" class="box bottomleft">
|
||||
<p>Bottom Left<br />Position</p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,317 @@
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
let doc;
|
||||
let inspector;
|
||||
let view;
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/" +
|
||||
"devtools/styleinspector/test/" +
|
||||
"browser_ruleview_pseudoelement.html";
|
||||
|
||||
function testPseudoElements(aInspector, aRuleView)
|
||||
{
|
||||
inspector = aInspector;
|
||||
view = aRuleView;
|
||||
|
||||
testTopLeft();
|
||||
}
|
||||
|
||||
function testTopLeft()
|
||||
{
|
||||
testNode(doc.querySelector("#topleft"), (element, elementStyle) => {
|
||||
let elementRules = elementStyle.rules.filter((rule) => { return !rule.pseudoElement; });
|
||||
let afterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":after"; });
|
||||
let beforeRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":before"; });
|
||||
let firstLineRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-line"; });
|
||||
let firstLetterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-letter"; });
|
||||
let selectionRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":-moz-selection"; });
|
||||
|
||||
is(elementRules.length, 4, "TopLeft has the correct number of non psuedo element rules");
|
||||
is(afterRules.length, 1, "TopLeft has the correct number of :after rules");
|
||||
is(beforeRules.length, 2, "TopLeft has the correct number of :before rules");
|
||||
is(firstLineRules.length, 0, "TopLeft has the correct number of :first-line rules");
|
||||
is(firstLetterRules.length, 0, "TopLeft has the correct number of :first-letter rules");
|
||||
is(selectionRules.length, 0, "TopLeft has the correct number of :selection rules");
|
||||
|
||||
let gutters = view.element.querySelectorAll(".theme-gutter");
|
||||
is (gutters.length, 3, "There are three gutter headings");
|
||||
is (gutters[0].textContent, "Pseudo-elements", "Gutter heading is correct");
|
||||
is (gutters[1].textContent, "This Element", "Gutter heading is correct");
|
||||
is (gutters[2].textContent, "Inherited from body", "Gutter heading is correct");
|
||||
|
||||
// Make sure that clicking on the twisty hides pseudo elements
|
||||
let expander = gutters[0].querySelector(".ruleview-expander");
|
||||
ok (view.element.classList.contains("show-pseudo-elements"), "Pseudo Elements are expanded");
|
||||
expander.click();
|
||||
ok (!view.element.classList.contains("show-pseudo-elements"), "Pseudo Elements are collapsed by twisty");
|
||||
expander.click();
|
||||
ok (view.element.classList.contains("show-pseudo-elements"), "Pseudo Elements are expanded again");
|
||||
expander.click();
|
||||
|
||||
let defaultView = element.ownerDocument.defaultView;
|
||||
let elementRule = elementRules[0];
|
||||
let elementRuleView = [].filter.call(view.element.children, (e) => {
|
||||
return e._ruleEditor && e._ruleEditor.rule === elementRule;
|
||||
})[0]._ruleEditor;
|
||||
|
||||
let elementAfterRule = afterRules[0];
|
||||
let elementAfterRuleView = [].filter.call(view.element.children, (e) => {
|
||||
return e._ruleEditor && e._ruleEditor.rule === elementAfterRule;
|
||||
})[0]._ruleEditor;
|
||||
|
||||
is
|
||||
(
|
||||
convertTextPropsToString(elementAfterRule.textProps),
|
||||
"background: none repeat scroll 0% 0% red; content: \" \"; position: absolute; " +
|
||||
"border-radius: 50%; height: 32px; width: 32px; top: 50%; left: 50%; margin-top: -16px; margin-left: -16px",
|
||||
"TopLeft after properties are correct"
|
||||
);
|
||||
|
||||
let elementBeforeRule = beforeRules[0];
|
||||
let elementBeforeRuleView = [].filter.call(view.element.children, (e) => {
|
||||
return e._ruleEditor && e._ruleEditor.rule === elementBeforeRule;
|
||||
})[0]._ruleEditor;
|
||||
|
||||
is
|
||||
(
|
||||
convertTextPropsToString(elementBeforeRule.textProps),
|
||||
"top: 0px; left: 0px",
|
||||
"TopLeft before properties are correct"
|
||||
);
|
||||
|
||||
let firstProp = elementAfterRuleView.addProperty("background-color", "rgb(0, 255, 0)", "");
|
||||
let secondProp = elementAfterRuleView.addProperty("padding", "100px", "");
|
||||
|
||||
is (firstProp, elementAfterRule.textProps[elementAfterRule.textProps.length - 2],
|
||||
"First added property is on back of array");
|
||||
is (secondProp, elementAfterRule.textProps[elementAfterRule.textProps.length - 1],
|
||||
"Second added property is on back of array");
|
||||
|
||||
promiseDone(elementAfterRule._applyingModifications.then(() => {
|
||||
is(defaultView.getComputedStyle(element, ":after").getPropertyValue("background-color"),
|
||||
"rgb(0, 255, 0)", "Added property should have been used.");
|
||||
is(defaultView.getComputedStyle(element, ":after").getPropertyValue("padding-top"),
|
||||
"100px", "Added property should have been used.");
|
||||
is(defaultView.getComputedStyle(element).getPropertyValue("padding-top"),
|
||||
"32px", "Added property should not apply to element");
|
||||
|
||||
secondProp.setEnabled(false);
|
||||
|
||||
return elementAfterRule._applyingModifications;
|
||||
}).then(() => {
|
||||
is(defaultView.getComputedStyle(element, ":after").getPropertyValue("padding-top"), "0px",
|
||||
"Disabled property should have been used.");
|
||||
is(defaultView.getComputedStyle(element).getPropertyValue("padding-top"), "32px",
|
||||
"Added property should not apply to element");
|
||||
|
||||
secondProp.setEnabled(true);
|
||||
|
||||
return elementAfterRule._applyingModifications;
|
||||
}).then(() => {
|
||||
is(defaultView.getComputedStyle(element, ":after").getPropertyValue("padding-top"), "100px",
|
||||
"Enabled property should have been used.");
|
||||
is(defaultView.getComputedStyle(element).getPropertyValue("padding-top"), "32px",
|
||||
"Added property should not apply to element");
|
||||
|
||||
let firstProp = elementRuleView.addProperty("background-color", "rgb(0, 0, 255)", "");
|
||||
|
||||
return elementRule._applyingModifications;
|
||||
}).then(() => {
|
||||
is(defaultView.getComputedStyle(element).getPropertyValue("background-color"), "rgb(0, 0, 255)",
|
||||
"Added property should have been used.");
|
||||
is(defaultView.getComputedStyle(element, ":after").getPropertyValue("background-color"), "rgb(0, 255, 0)",
|
||||
"Added prop does not apply to pseudo");
|
||||
|
||||
testTopRight();
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
function testTopRight()
|
||||
{
|
||||
testNode(doc.querySelector("#topright"), (element, elementStyle) => {
|
||||
|
||||
let elementRules = elementStyle.rules.filter((rule) => { return !rule.pseudoElement; });
|
||||
let afterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":after"; });
|
||||
let beforeRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":before"; });
|
||||
let firstLineRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-line"; });
|
||||
let firstLetterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-letter"; });
|
||||
let selectionRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":-moz-selection"; });
|
||||
|
||||
is(elementRules.length, 4, "TopRight has the correct number of non psuedo element rules");
|
||||
is(afterRules.length, 1, "TopRight has the correct number of :after rules");
|
||||
is(beforeRules.length, 2, "TopRight has the correct number of :before rules");
|
||||
is(firstLineRules.length, 0, "TopRight has the correct number of :first-line rules");
|
||||
is(firstLetterRules.length, 0, "TopRight has the correct number of :first-letter rules");
|
||||
is(selectionRules.length, 0, "TopRight has the correct number of :selection rules");
|
||||
|
||||
let gutters = view.element.querySelectorAll(".theme-gutter");
|
||||
is (gutters.length, 3, "There are three gutter headings");
|
||||
is (gutters[0].textContent, "Pseudo-elements", "Gutter heading is correct");
|
||||
is (gutters[1].textContent, "This Element", "Gutter heading is correct");
|
||||
is (gutters[2].textContent, "Inherited from body", "Gutter heading is correct");
|
||||
|
||||
let expander = gutters[0].querySelector(".ruleview-expander");
|
||||
ok (!view.element.classList.contains("show-pseudo-elements"), "Pseudo Elements remain collapsed after switching element");
|
||||
expander.scrollIntoView();
|
||||
expander.click();
|
||||
ok (view.element.classList.contains("show-pseudo-elements"), "Pseudo Elements are shown again after clicking twisty");
|
||||
|
||||
testBottomRight();
|
||||
});
|
||||
}
|
||||
|
||||
function testBottomRight()
|
||||
{
|
||||
testNode(doc.querySelector("#bottomright"), (element, elementStyle) => {
|
||||
|
||||
let elementRules = elementStyle.rules.filter((rule) => { return !rule.pseudoElement; });
|
||||
let afterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":after"; });
|
||||
let beforeRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":before"; });
|
||||
let firstLineRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-line"; });
|
||||
let firstLetterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-letter"; });
|
||||
let selectionRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":-moz-selection"; });
|
||||
|
||||
is(elementRules.length, 4, "BottomRight has the correct number of non psuedo element rules");
|
||||
is(afterRules.length, 1, "BottomRight has the correct number of :after rules");
|
||||
is(beforeRules.length, 3, "BottomRight has the correct number of :before rules");
|
||||
is(firstLineRules.length, 0, "BottomRight has the correct number of :first-line rules");
|
||||
is(firstLetterRules.length, 0, "BottomRight has the correct number of :first-letter rules");
|
||||
is(selectionRules.length, 0, "BottomRight has the correct number of :selection rules");
|
||||
|
||||
testBottomLeft();
|
||||
});
|
||||
}
|
||||
|
||||
function testBottomLeft()
|
||||
{
|
||||
testNode(doc.querySelector("#bottomleft"), (element, elementStyle) => {
|
||||
|
||||
let elementRules = elementStyle.rules.filter((rule) => { return !rule.pseudoElement; });
|
||||
let afterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":after"; });
|
||||
let beforeRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":before"; });
|
||||
let firstLineRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-line"; });
|
||||
let firstLetterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-letter"; });
|
||||
let selectionRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":-moz-selection"; });
|
||||
|
||||
is(elementRules.length, 4, "BottomLeft has the correct number of non psuedo element rules");
|
||||
is(afterRules.length, 1, "BottomLeft has the correct number of :after rules");
|
||||
is(beforeRules.length, 2, "BottomLeft has the correct number of :before rules");
|
||||
is(firstLineRules.length, 0, "BottomLeft has the correct number of :first-line rules");
|
||||
is(firstLetterRules.length, 0, "BottomLeft has the correct number of :first-letter rules");
|
||||
is(selectionRules.length, 0, "BottomLeft has the correct number of :selection rules");
|
||||
|
||||
testParagraph();
|
||||
});
|
||||
}
|
||||
|
||||
function testParagraph()
|
||||
{
|
||||
testNode(doc.querySelector("#bottomleft p"), (element, elementStyle) => {
|
||||
|
||||
let elementRules = elementStyle.rules.filter((rule) => { return !rule.pseudoElement; });
|
||||
let afterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":after"; });
|
||||
let beforeRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":before"; });
|
||||
let firstLineRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-line"; });
|
||||
let firstLetterRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":first-letter"; });
|
||||
let selectionRules = elementStyle.rules.filter((rule) => { return rule.pseudoElement === ":-moz-selection"; });
|
||||
|
||||
is(elementRules.length, 3, "Paragraph has the correct number of non psuedo element rules");
|
||||
is(afterRules.length, 0, "Paragraph has the correct number of :after rules");
|
||||
is(beforeRules.length, 0, "Paragraph has the correct number of :before rules");
|
||||
is(firstLineRules.length, 1, "Paragraph has the correct number of :first-line rules");
|
||||
is(firstLetterRules.length, 1, "Paragraph has the correct number of :first-letter rules");
|
||||
is(selectionRules.length, 1, "Paragraph has the correct number of :selection rules");
|
||||
|
||||
let gutters = view.element.querySelectorAll(".theme-gutter");
|
||||
is (gutters.length, 3, "There are three gutter headings");
|
||||
is (gutters[0].textContent, "Pseudo-elements", "Gutter heading is correct");
|
||||
is (gutters[1].textContent, "This Element", "Gutter heading is correct");
|
||||
is (gutters[2].textContent, "Inherited from body", "Gutter heading is correct");
|
||||
|
||||
let elementFirstLineRule = firstLineRules[0];
|
||||
let elementFirstLineRuleView = [].filter.call(view.element.children, (e) => {
|
||||
return e._ruleEditor && e._ruleEditor.rule === elementFirstLineRule;
|
||||
})[0]._ruleEditor;
|
||||
|
||||
is
|
||||
(
|
||||
convertTextPropsToString(elementFirstLineRule.textProps),
|
||||
"background: none repeat scroll 0% 0% blue",
|
||||
"Paragraph first-line properties are correct"
|
||||
);
|
||||
|
||||
let elementFirstLetterRule = firstLetterRules[0];
|
||||
let elementFirstLetterRuleView = [].filter.call(view.element.children, (e) => {
|
||||
return e._ruleEditor && e._ruleEditor.rule === elementFirstLetterRule;
|
||||
})[0]._ruleEditor;
|
||||
|
||||
is
|
||||
(
|
||||
convertTextPropsToString(elementFirstLetterRule.textProps),
|
||||
"color: red; font-size: 130%",
|
||||
"Paragraph first-letter properties are correct"
|
||||
);
|
||||
|
||||
let elementSelectionRule = selectionRules[0];
|
||||
let elementSelectionRuleView = [].filter.call(view.element.children, (e) => {
|
||||
return e._ruleEditor && e._ruleEditor.rule === elementSelectionRule;
|
||||
})[0]._ruleEditor;
|
||||
|
||||
is
|
||||
(
|
||||
convertTextPropsToString(elementSelectionRule.textProps),
|
||||
"color: white; background: none repeat scroll 0% 0% black",
|
||||
"Paragraph first-letter properties are correct"
|
||||
);
|
||||
|
||||
testBody();
|
||||
});
|
||||
}
|
||||
|
||||
function testBody() {
|
||||
|
||||
testNode(doc.querySelector("body"), (element, elementStyle) => {
|
||||
|
||||
let gutters = view.element.querySelectorAll(".theme-gutter");
|
||||
is (gutters.length, 0, "There are no gutter headings");
|
||||
|
||||
finishTest();
|
||||
});
|
||||
|
||||
}
|
||||
function convertTextPropsToString(textProps) {
|
||||
return textProps.map((t) => {
|
||||
return t.name + ": " + t.value;
|
||||
}).join("; ");
|
||||
}
|
||||
|
||||
function testNode(node, cb)
|
||||
{
|
||||
inspector.once("inspector-updated", () => {
|
||||
cb(node, view._elementStyle)
|
||||
});
|
||||
inspector.selection.setNode(node);
|
||||
}
|
||||
|
||||
function finishTest()
|
||||
{
|
||||
doc = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function(evt) {
|
||||
gBrowser.selectedBrowser.removeEventListener(evt.type, arguments.callee, true);
|
||||
doc = content.document;
|
||||
waitForFocus(() => openRuleView(testPseudoElements), content);
|
||||
}, true);
|
||||
|
||||
content.location = TEST_URI;
|
||||
}
|
@ -65,6 +65,9 @@
|
||||
<!ENTITY display.accesskey "D">
|
||||
<!ENTITY display.key "l">
|
||||
|
||||
<!ENTITY pprint.label "Pretty Print">
|
||||
<!ENTITY pprint.key "p">
|
||||
|
||||
<!-- LOCALIZATION NOTE (environmentMenu.label, accesskey): This menu item was
|
||||
- renamed from "Context" to avoid confusion with the right-click context
|
||||
- menu in the text area. It refers to the JavaScript Environment (or context)
|
||||
|
@ -35,6 +35,14 @@ rule.sourceElement=element
|
||||
# e.g "Inherited from body#bodyID"
|
||||
rule.inheritedFrom=Inherited from %S
|
||||
|
||||
# LOCALIZATION NOTE (rule.pseudoElement): Shown for CSS rules
|
||||
# pseudo element header
|
||||
rule.pseudoElement=Pseudo-elements
|
||||
|
||||
# LOCALIZATION NOTE (rule.pseudoElement): Shown for CSS rules
|
||||
# pseudo element header
|
||||
rule.selectedElement=This Element
|
||||
|
||||
# LOCALIZATION NOTE (helpLinkTitle): For each style property
|
||||
# the user can hover it and get a help link button which allows one to
|
||||
# quickly jump to the documentation from the Mozilla Developer Network site.
|
||||
|
@ -42,32 +42,28 @@ function isSelectable(aElement) {
|
||||
// placeholder logic
|
||||
return aElement.nodeName == 'richgriditem';
|
||||
}
|
||||
|
||||
function withinCone(aLen, aHeight) {
|
||||
// check pt falls within 45deg either side of the cross axis
|
||||
return aLen > aHeight;
|
||||
}
|
||||
|
||||
function getScrollAxisFromElement(aElement) {
|
||||
let elem = aElement,
|
||||
win = elem.ownerDocument.defaultView;
|
||||
let scrollX, scrollY;
|
||||
for (; elem && 1==elem.nodeType; elem = elem.parentNode) {
|
||||
let cs = win.getComputedStyle(elem);
|
||||
scrollX = (cs.overflowX=='scroll' || cs.overflowX=='auto');
|
||||
scrollY = (cs.overflowX=='scroll' || cs.overflowX=='auto');
|
||||
if (scrollX || scrollY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return scrollX ? 'x' : 'y';
|
||||
}
|
||||
// keeping it simple - just return apparent scroll axis for the document
|
||||
let win = aElement.ownerDocument.defaultView;
|
||||
let scrollX = win.scrollMaxX,
|
||||
scrollY = win.scrollMaxY;
|
||||
// determine scroll axis from scrollable content when possible
|
||||
if (scrollX || scrollY)
|
||||
return scrollX >= scrollY ? 'x' : 'y';
|
||||
|
||||
// fall back to guessing at scroll axis from document aspect ratio
|
||||
let docElem = aElement.ownerDocument.documentElement;
|
||||
return docElem.clientWidth >= docElem.clientHeight ?
|
||||
'x' : 'y';
|
||||
}
|
||||
function pointFromTouchEvent(aEvent) {
|
||||
let touch = aEvent.touches[0];
|
||||
return { x: touch.clientX, y: touch.clientY };
|
||||
}
|
||||
|
||||
// This damping function has these important properties:
|
||||
// f(0) = 0
|
||||
// f'(0) = 1
|
||||
|
@ -169,24 +169,28 @@ this.Social = {
|
||||
}
|
||||
|
||||
// Register an observer for changes to the provider list
|
||||
SocialService.registerProviderListener(function providerListener(topic, data) {
|
||||
SocialService.registerProviderListener(function providerListener(topic, origin, providers) {
|
||||
// An engine change caused by adding/removing a provider should notify.
|
||||
// any providers we receive are enabled in the AddonsManager
|
||||
if (topic == "provider-added" || topic == "provider-removed") {
|
||||
Social._updateProviderCache(data);
|
||||
if (topic == "provider-installed" || topic == "provider-uninstalled") {
|
||||
// installed/uninstalled do not send the providers param
|
||||
Services.obs.notifyObservers(null, "social:" + topic, origin);
|
||||
return;
|
||||
}
|
||||
if (topic == "provider-enabled" || topic == "provider-disabled") {
|
||||
Social._updateProviderCache(providers);
|
||||
Social._updateWorkerState(true);
|
||||
Services.obs.notifyObservers(null, "social:providers-changed", null);
|
||||
Services.obs.notifyObservers(null, "social:" + topic, origin);
|
||||
return;
|
||||
}
|
||||
if (topic == "provider-update") {
|
||||
// a provider has self-updated its manifest, we need to update our cache
|
||||
// and reload the provider.
|
||||
let provider = data;
|
||||
SocialService.getOrderedProviderList(function(providers) {
|
||||
Social._updateProviderCache(providers);
|
||||
provider.reload();
|
||||
Services.obs.notifyObservers(null, "social:providers-changed", null);
|
||||
});
|
||||
Social._updateProviderCache(providers);
|
||||
let provider = Social._getProviderFromOrigin(origin);
|
||||
provider.reload();
|
||||
Services.obs.notifyObservers(null, "social:providers-changed", null);
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -259,6 +263,10 @@ this.Social = {
|
||||
return null;
|
||||
},
|
||||
|
||||
getManifestByOrigin: function(origin) {
|
||||
return SocialService.getManifestByOrigin(origin);
|
||||
},
|
||||
|
||||
installProvider: function(doc, data, installCallback) {
|
||||
SocialService.installProvider(doc, data, installCallback);
|
||||
},
|
||||
|
@ -14,7 +14,7 @@
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.ruleview-rule-inheritance {
|
||||
.ruleview-header {
|
||||
border-top-width: 1px;
|
||||
border-bottom-width: 1px;
|
||||
border-top-style: solid;
|
||||
|
@ -14,16 +14,20 @@
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.ruleview-rule-inheritance {
|
||||
.ruleview-header {
|
||||
border-top-width: 1px;
|
||||
border-bottom-width: 1px;
|
||||
border-top-style: solid;
|
||||
border-bottom-style: solid;
|
||||
padding: 1px 4px;
|
||||
margin-top: 4px;
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.ruleview-rule-pseudo-element {
|
||||
padding-left:20px;
|
||||
border-left: solid 10px;
|
||||
}
|
||||
|
||||
.ruleview-rule-source:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.ruleview-rule-inheritance {
|
||||
.ruleview-header {
|
||||
border-top-width: 1px;
|
||||
border-bottom-width: 1px;
|
||||
border-top-style: solid;
|
||||
|
@ -22,9 +22,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=732413
|
||||
aPrincipal is the system principal.
|
||||
**/
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
const nsIScriptSecurityManager = Components.interfaces.nsIScriptSecurityManager;
|
||||
var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
|
||||
const nsIScriptSecurityManager = SpecialPowers.Ci.nsIScriptSecurityManager;
|
||||
var secMan = SpecialPowers.Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(nsIScriptSecurityManager);
|
||||
var sysPrincipal = secMan.getSystemPrincipal();
|
||||
isnot(sysPrincipal, undefined, "Should have a principal");
|
||||
@ -33,8 +32,8 @@ is(secMan.isSystemPrincipal(sysPrincipal), true,
|
||||
"Should have system principal here");
|
||||
|
||||
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(SpecialPowers.Ci.nsIIOService);
|
||||
var inheritingURI = ioService.newURI("javascript:1+1", null, null);
|
||||
|
||||
// First try a normal call to checkLoadURIWithPrincipal
|
||||
|
@ -1590,6 +1590,7 @@ public:
|
||||
static nsresult GetUTFOrigin(nsIPrincipal* aPrincipal,
|
||||
nsString& aOrigin);
|
||||
static nsresult GetUTFOrigin(nsIURI* aURI, nsString& aOrigin);
|
||||
static void GetUTFNonNullOrigin(nsIURI* aURI, nsString& aOrigin);
|
||||
|
||||
/**
|
||||
* This method creates and dispatches "command" event, which implements
|
||||
|
@ -146,6 +146,32 @@ Link::SetProtocol(const nsAString &aProtocol)
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::SetPassword(const nsAString &aPassword)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri(GetURIToMutate());
|
||||
if (!uri) {
|
||||
// Ignore failures to be compatible with NS4.
|
||||
return;
|
||||
}
|
||||
|
||||
uri->SetPassword(NS_ConvertUTF16toUTF8(aPassword));
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::SetUsername(const nsAString &aUsername)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri(GetURIToMutate());
|
||||
if (!uri) {
|
||||
// Ignore failures to be compatible with NS4.
|
||||
return;
|
||||
}
|
||||
|
||||
uri->SetUsername(NS_ConvertUTF16toUTF8(aUsername));
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::SetHost(const nsAString &aHost)
|
||||
{
|
||||
@ -155,32 +181,7 @@ Link::SetHost(const nsAString &aHost)
|
||||
return;
|
||||
}
|
||||
|
||||
// We cannot simply call nsIURI::SetHost because that would treat the name as
|
||||
// an IPv6 address (like http:://[server:443]/). We also cannot call
|
||||
// nsIURI::SetHostPort because that isn't implemented. Sadfaces.
|
||||
|
||||
// First set the hostname.
|
||||
nsAString::const_iterator start, end;
|
||||
aHost.BeginReading(start);
|
||||
aHost.EndReading(end);
|
||||
nsAString::const_iterator iter(start);
|
||||
(void)FindCharInReadable(':', iter, end);
|
||||
NS_ConvertUTF16toUTF8 host(Substring(start, iter));
|
||||
(void)uri->SetHost(host);
|
||||
|
||||
// Also set the port if needed.
|
||||
if (iter != end) {
|
||||
iter++;
|
||||
if (iter != end) {
|
||||
nsAutoString portStr(Substring(iter, end));
|
||||
nsresult rv;
|
||||
int32_t port = portStr.ToInteger(&rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
(void)uri->SetPort(port);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
(void)uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
|
||||
SetHrefAttribute(uri);
|
||||
return;
|
||||
}
|
||||
@ -259,6 +260,21 @@ Link::SetHash(const nsAString &aHash)
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetOrigin(nsAString &aOrigin)
|
||||
{
|
||||
aOrigin.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri(GetURI());
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsString origin;
|
||||
nsContentUtils::GetUTFNonNullOrigin(uri, origin);
|
||||
aOrigin.Assign(origin);
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetProtocol(nsAString &_protocol)
|
||||
{
|
||||
@ -275,6 +291,36 @@ Link::GetProtocol(nsAString &_protocol)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetUsername(nsAString& aUsername)
|
||||
{
|
||||
aUsername.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri(GetURI());
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString username;
|
||||
uri->GetUsername(username);
|
||||
CopyASCIItoUTF16(username, aUsername);
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetPassword(nsAString &aPassword)
|
||||
{
|
||||
aPassword.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri(GetURI());
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString password;
|
||||
uri->GetPassword(password);
|
||||
CopyASCIItoUTF16(password, aPassword);
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetHost(nsAString &_host)
|
||||
{
|
||||
|
@ -54,13 +54,18 @@ public:
|
||||
* Helper methods for modifying and obtaining parts of the URI of the Link.
|
||||
*/
|
||||
void SetProtocol(const nsAString &aProtocol);
|
||||
void SetUsername(const nsAString &aUsername);
|
||||
void SetPassword(const nsAString &aPassword);
|
||||
void SetHost(const nsAString &aHost);
|
||||
void SetHostname(const nsAString &aHostname);
|
||||
void SetPathname(const nsAString &aPathname);
|
||||
void SetSearch(const nsAString &aSearch);
|
||||
void SetPort(const nsAString &aPort);
|
||||
void SetHash(const nsAString &aHash);
|
||||
void GetOrigin(nsAString &aOrigin);
|
||||
void GetProtocol(nsAString &_protocol);
|
||||
void GetUsername(nsAString &aUsername);
|
||||
void GetPassword(nsAString &aPassword);
|
||||
void GetHost(nsAString &_host);
|
||||
void GetHostname(nsAString &_hostname);
|
||||
void GetPathname(nsAString &_pathname);
|
||||
|
@ -5516,6 +5516,19 @@ nsContentUtils::GetUTFOrigin(nsIURI* aURI, nsString& aOrigin)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsContentUtils::GetUTFNonNullOrigin(nsIURI* aURI, nsString& aOrigin)
|
||||
{
|
||||
aOrigin.Truncate();
|
||||
|
||||
nsString origin;
|
||||
nsresult rv = GetUTFOrigin(aURI, origin);
|
||||
if (NS_SUCCEEDED(rv) && !origin.EqualsLiteral("null")) {
|
||||
aOrigin.Assign(origin);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsIDocument>
|
||||
nsContentUtils::GetDocumentFromScriptContext(nsIScriptContext *aScriptContext)
|
||||
|
@ -602,6 +602,9 @@ nsDOMFileFile::GetInternalStream(nsIInputStream **aStream)
|
||||
void
|
||||
nsDOMFileFile::SetPath(const nsAString& aPath)
|
||||
{
|
||||
MOZ_ASSERT(aPath.IsEmpty() ||
|
||||
aPath[aPath.Length() - 1] == PRUnichar('/'),
|
||||
"Path must end with a path separator");
|
||||
mPath = aPath;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ function modifySelection(s) {
|
||||
}
|
||||
|
||||
function getLoadContext() {
|
||||
var Ci = SpecialPowers.wrap(Components).interfaces;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
@ -35,16 +35,16 @@ function testCopyPaste (isXHTML) {
|
||||
var suppressUnicodeCheckIfHidden = !!isXHTML;
|
||||
var suppressHTMLCheck = !!isXHTML;
|
||||
|
||||
var webnav = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
var webnav = window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
|
||||
.getInterface(SpecialPowers.Ci.nsIWebNavigation)
|
||||
|
||||
var docShell = webnav.QueryInterface(Components.interfaces.nsIDocShell);
|
||||
var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
|
||||
|
||||
var documentViewer = docShell.contentViewer
|
||||
.QueryInterface(Components.interfaces.nsIContentViewerEdit);
|
||||
.QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit);
|
||||
|
||||
var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(Components.interfaces.nsIClipboard);
|
||||
var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(SpecialPowers.Ci.nsIClipboard);
|
||||
|
||||
var textarea = SpecialPowers.wrap(document.getElementById('input'));
|
||||
|
||||
@ -83,8 +83,8 @@ function testCopyPaste (isXHTML) {
|
||||
copySelectionToClipboard();
|
||||
}
|
||||
function getClipboardData(mime) {
|
||||
var transferable = Components.classes['@mozilla.org/widget/transferable;1']
|
||||
.createInstance(Components.interfaces.nsITransferable);
|
||||
var transferable = SpecialPowers.Cc['@mozilla.org/widget/transferable;1']
|
||||
.createInstance(SpecialPowers.Ci.nsITransferable);
|
||||
transferable.init(getLoadContext());
|
||||
transferable.addDataFlavor(mime);
|
||||
clipboard.getData(transferable, 1);
|
||||
@ -97,7 +97,7 @@ function testCopyPaste (isXHTML) {
|
||||
return null;
|
||||
var data = getClipboardData(mime);
|
||||
is (data.value == null ? data.value :
|
||||
data.value.QueryInterface(Components.interfaces.nsISupportsString).data,
|
||||
data.value.QueryInterface(SpecialPowers.Ci.nsISupportsString).data,
|
||||
expected,
|
||||
mime + " value in the clipboard");
|
||||
return data.value;
|
||||
@ -257,7 +257,6 @@ if (false) {
|
||||
setTimeout(function(){testSelectionToString("div11")},0);
|
||||
|
||||
setTimeout(function(){
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
copyRangeToClipboard($("div12").childNodes[0],0, $("div12").childNodes[1],2);
|
||||
testClipboardValue("text/unicode", "Xdiv12");
|
||||
testClipboardValue("text/html", "<div><p>X<span>div</span>12</p></div>");
|
||||
|
@ -134,27 +134,25 @@ function testHasRun() {
|
||||
}
|
||||
|
||||
function createFileWithData(fileData) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
|
||||
var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"].getService(SpecialPowers.Ci.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
|
||||
testFile.append("fileAPItestfile2-" + fileNum);
|
||||
fileNum++;
|
||||
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].createInstance(SpecialPowers.Ci.nsIFileOutputStream);
|
||||
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
|
||||
0666, 0);
|
||||
outStream.write(fileData, fileData.length);
|
||||
outStream.close();
|
||||
|
||||
var fileList = document.getElementById('fileList');
|
||||
fileList.value = testFile.path;
|
||||
SpecialPowers.wrap(fileList).value = testFile.path;
|
||||
|
||||
return fileList.files[0];
|
||||
}
|
||||
|
||||
function gc() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils)
|
||||
window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
|
||||
.getInterface(SpecialPowers.Ci.nsIDOMWindowUtils)
|
||||
.garbageCollect();
|
||||
}
|
||||
|
||||
|
@ -78,10 +78,10 @@ extensions.forEach(
|
||||
);
|
||||
|
||||
function createFileWithDataExt(fileData, extension) {
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
|
||||
var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"].getService(SpecialPowers.Ci.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
|
||||
testFile.append("testfile" + extension);
|
||||
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].createInstance(SpecialPowers.Ci.nsIFileOutputStream);
|
||||
outStream.init(testFile, 0x02 | 0x08 | 0x20, 0666, 0);
|
||||
outStream.write(fileData, fileData.length);
|
||||
outStream.close();
|
||||
|
@ -17,10 +17,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=270145
|
||||
<script class="testbody" type="text/javascript">
|
||||
//<![CDATA[
|
||||
function testHtmlCopyEncoder () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder;
|
||||
var encoder = Components.classes["@mozilla.org/layout/htmlCopyEncoder;1"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/htmlCopyEncoder;1"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
var out, expected;
|
||||
|
||||
var node = document.getElementById('draggable');
|
||||
|
@ -24,9 +24,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=401662
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
window.onload = function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
var encoder = Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(Ci.nsIDocumentEncoder);
|
||||
|
@ -23,8 +23,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=403852
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
|
||||
var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"].getService(SpecialPowers.Ci.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
|
||||
testFile.append("prefs.js");
|
||||
|
||||
var fileList = document.getElementById('fileList');
|
||||
|
@ -21,8 +21,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=417384
|
||||
|
||||
var expectedSerialization = "about:blank document";
|
||||
function testSerializer() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
var doc = document.getElementById('test_iframe').contentDocument;
|
||||
doc.body.textContent = expectedSerialization;
|
||||
var head1 = doc.createElement("head");
|
||||
@ -34,8 +32,8 @@ function testSerializer() {
|
||||
span.appendChild(doc.createTextNode("\nafter inner head"));
|
||||
|
||||
var encoder =
|
||||
Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
encoder.init(doc, "text/plain", 0);
|
||||
encoder.setCharset("UTF-8");
|
||||
var out = encoder.encodeToString();
|
||||
|
@ -23,17 +23,17 @@ function loadFileContent(aFile, aCharset) {
|
||||
if(aCharset == undefined)
|
||||
aCharset = 'UTF-8';
|
||||
|
||||
var baseUri = Components.classes['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(Components.interfaces.nsIURI);
|
||||
var baseUri = SpecialPowers.Cc['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(SpecialPowers.Ci.nsIURI);
|
||||
baseUri.spec = window.location.href;
|
||||
|
||||
var ios = Components.classes['@mozilla.org/network/io-service;1']
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var ios = SpecialPowers.Cc['@mozilla.org/network/io-service;1']
|
||||
.getService(SpecialPowers.Ci.nsIIOService);
|
||||
var chann = ios.newChannel(aFile, aCharset, baseUri);
|
||||
|
||||
var cis = Components.interfaces.nsIConverterInputStream;
|
||||
var cis = SpecialPowers.Ci.nsIConverterInputStream;
|
||||
|
||||
var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
var inputStream = SpecialPowers.Cc["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(cis);
|
||||
inputStream.init(chann.open(), aCharset, 1024, cis.DEFAULT_REPLACEMENT_CHARACTER);
|
||||
var str = {}, content = '';
|
||||
@ -45,10 +45,9 @@ function loadFileContent(aFile, aCharset) {
|
||||
|
||||
|
||||
function testHtmlSerializer_1 () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder
|
||||
var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=application/xhtml+xml"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=application/xhtml+xml"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
|
||||
var doc = $("testframe").contentDocument;
|
||||
var out, expected;
|
||||
|
@ -23,17 +23,17 @@ function loadFileContent(aFile, aCharset) {
|
||||
if(aCharset == undefined)
|
||||
aCharset = 'UTF-8';
|
||||
|
||||
var baseUri = Components.classes['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(Components.interfaces.nsIURI);
|
||||
var baseUri = SpecialPowers.Cc['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(SpecialPowers.Ci.nsIURI);
|
||||
baseUri.spec = window.location.href;
|
||||
|
||||
var ios = Components.classes['@mozilla.org/network/io-service;1']
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var ios = SpecialPowers.Cc['@mozilla.org/network/io-service;1']
|
||||
.getService(SpecialPowers.Ci.nsIIOService);
|
||||
var chann = ios.newChannel(aFile, aCharset, baseUri);
|
||||
|
||||
var cis = Components.interfaces.nsIConverterInputStream;
|
||||
var cis = SpecialPowers.Ci.nsIConverterInputStream;
|
||||
|
||||
var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
var inputStream = SpecialPowers.Cc["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(cis);
|
||||
inputStream.init(chann.open(), aCharset, 1024, cis.DEFAULT_REPLACEMENT_CHARACTER);
|
||||
var str = {}, content = '';
|
||||
@ -50,10 +50,9 @@ function isRoughly(actual, expected, message) {
|
||||
}
|
||||
|
||||
function testHtmlSerializer_1 () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder
|
||||
var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
|
||||
var doc = $("testframe").contentDocument;
|
||||
var out, expected;
|
||||
|
@ -23,17 +23,17 @@ function loadFileContent(aFile, aCharset) {
|
||||
if(aCharset == undefined)
|
||||
aCharset = 'UTF-8';
|
||||
|
||||
var baseUri = Components.classes['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(Components.interfaces.nsIURI);
|
||||
var baseUri = SpecialPowers.Cc['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(SpecialPowers.Ci.nsIURI);
|
||||
baseUri.spec = window.location.href;
|
||||
|
||||
var ios = Components.classes['@mozilla.org/network/io-service;1']
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var ios = SpecialPowers.Cc['@mozilla.org/network/io-service;1']
|
||||
.getService(SpecialPowers.Ci.nsIIOService);
|
||||
var chann = ios.newChannel(aFile, aCharset, baseUri);
|
||||
|
||||
var cis = Components.interfaces.nsIConverterInputStream;
|
||||
var cis = SpecialPowers.Ci.nsIConverterInputStream;
|
||||
|
||||
var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
var inputStream = SpecialPowers.Cc["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(cis);
|
||||
inputStream.init(chann.open(), aCharset, 1024, cis.DEFAULT_REPLACEMENT_CHARACTER);
|
||||
var str = {}, content = '';
|
||||
@ -50,10 +50,9 @@ function isRoughly(actual, expected, message) {
|
||||
}
|
||||
|
||||
function testHtmlSerializer_1 () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder
|
||||
var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
|
||||
var doc = $("testframe").contentDocument;
|
||||
var out, expected;
|
||||
|
@ -22,17 +22,17 @@ function loadFileContent(aFile, aCharset) {
|
||||
if (aCharset == undefined)
|
||||
aCharset = 'UTF-8';
|
||||
|
||||
var baseUri = Components.classes['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(Components.interfaces.nsIURI);
|
||||
var baseUri = SpecialPowers.Cc['@mozilla.org/network/standard-url;1']
|
||||
.createInstance(SpecialPowers.Ci.nsIURI);
|
||||
baseUri.spec = window.location.href;
|
||||
|
||||
var ios = Components.classes['@mozilla.org/network/io-service;1']
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var ios = SpecialPowers.Cc['@mozilla.org/network/io-service;1']
|
||||
.getService(SpecialPowers.Ci.nsIIOService);
|
||||
var chann = ios.newChannel(aFile, aCharset, baseUri);
|
||||
|
||||
var cis = Components.interfaces.nsIConverterInputStream;
|
||||
var cis = SpecialPowers.Ci.nsIConverterInputStream;
|
||||
|
||||
var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
var inputStream = SpecialPowers.Cc["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(cis);
|
||||
inputStream.init(chann.open(), aCharset, 1024, cis.DEFAULT_REPLACEMENT_CHARACTER);
|
||||
var str = {}, content = '';
|
||||
@ -49,10 +49,9 @@ function isRoughly(actual, expected, message) {
|
||||
}
|
||||
|
||||
function testHtmlSerializer_1 () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder
|
||||
var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
|
||||
var doc = $("testframe").contentDocument;
|
||||
var out, expected;
|
||||
|
@ -23,23 +23,21 @@ var checkedLoad = false;
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
// Content policy / factory implementation for the test
|
||||
var policyID = Components.ID("{65944d64-2390-422e-bea3-80d0af7f69ef}");
|
||||
var policyID = SpecialPowers.wrap(SpecialPowers.Components).ID("{65944d64-2390-422e-bea3-80d0af7f69ef}");
|
||||
var policyName = "@mozilla.org/498897_testpolicy;1";
|
||||
var policy = {
|
||||
// nsISupports implementation
|
||||
QueryInterface: function(iid) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
if (iid.equals(Ci.nsISupports) ||
|
||||
iid.equals(Ci.nsIFactory) ||
|
||||
iid.equals(Ci.nsIContentPolicy))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
// nsIFactory implementation
|
||||
@ -50,8 +48,6 @@ var policy = {
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad: function(contentType, contentLocation, requestOrigin, context,
|
||||
mimeTypeGuess, extra) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
if (contentLocation instanceof Ci.nsIURL &&
|
||||
contentLocation.fileName == "file_bug498897.css" &&
|
||||
requestOrigin instanceof Ci.nsIURL &&
|
||||
@ -64,13 +60,11 @@ var policy = {
|
||||
|
||||
shouldProcess: function(contentType, contentLocation, requestOrigin, context,
|
||||
mimeTypeGuess, extra) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
var componentManager = Components.manager
|
||||
var componentManager = SpecialPowers.wrap(SpecialPowers.Components).manager
|
||||
.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
componentManager.registerFactory(policyID, "Test content policy for bug 498897",
|
||||
policyName, policy);
|
||||
@ -82,15 +76,11 @@ categoryManager.addCategoryEntry("content-policy", policyName, policyName,
|
||||
|
||||
function testFinished()
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
ok(checkedLoad, "Content policy didn't get called!");
|
||||
|
||||
categoryManager.deleteCategoryEntry("content-policy", policyName, false);
|
||||
|
||||
setTimeout(function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
componentManager.unregisterFactory(policyID, policy);
|
||||
|
||||
SimpleTest.finish();
|
||||
|
@ -21,10 +21,9 @@
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function testSerializer () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder
|
||||
var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
|
||||
var parser = new DOMParser();
|
||||
var serializer = new XMLSerializer();
|
||||
|
@ -17,10 +17,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=578096
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
var file = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
@ -29,12 +27,11 @@ file.append("foo.txt");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
document.getElementById('file').value = file.path;
|
||||
SpecialPowers.wrap(document.getElementById('file')).value = file.path;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function(event) {
|
||||
if (xhr.readyState == 4) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
file.remove(false);
|
||||
ok(true, "We didn't throw! Yay!");
|
||||
SimpleTest.finish();
|
||||
|
@ -16,25 +16,24 @@
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function testCopyImage () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
// selection of the node
|
||||
var node = document.getElementById('logo');
|
||||
var webnav = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
var webnav = SpecialPowers.wrap(window)
|
||||
.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
|
||||
.getInterface(SpecialPowers.Ci.nsIWebNavigation)
|
||||
|
||||
var docShell = webnav.QueryInterface(Components.interfaces.nsIDocShell);
|
||||
var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
|
||||
|
||||
docShell.chromeEventHandler.ownerDocument.popupNode = node;
|
||||
|
||||
// let's copy the node
|
||||
var documentViewer = docShell.contentViewer
|
||||
.QueryInterface(Components.interfaces.nsIContentViewerEdit);
|
||||
.QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit);
|
||||
documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL);
|
||||
|
||||
//--------- now check the content of the clipboard
|
||||
var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(Components.interfaces.nsIClipboard);
|
||||
var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(SpecialPowers.Ci.nsIClipboard);
|
||||
|
||||
// does the clipboard contain text/unicode data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard), "clipboard contains unicode text");
|
||||
|
@ -33,7 +33,6 @@ var fileNum = 1;
|
||||
var testRanCounter = 0;
|
||||
var expectedTestCount = 0;
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
is(FileReader.EMPTY, 0, "correct EMPTY value");
|
||||
is(FileReader.LOADING, 1, "correct LOADING value");
|
||||
@ -65,7 +64,7 @@ var asciiFile = createFileWithData(testASCIIData);
|
||||
var binaryFile = createFileWithData(testBinaryData);
|
||||
|
||||
var fileList = document.getElementById('fileList');
|
||||
fileList.value = "/none/existing/path/fileAPI/testing";
|
||||
SpecialPowers.wrap(fileList).value = "/none/existing/path/fileAPI/testing";
|
||||
var nonExistingFile = fileList.files[0];
|
||||
|
||||
// Test that plain reading works and fires events as expected, both
|
||||
@ -424,18 +423,18 @@ function testHasRun() {
|
||||
}
|
||||
|
||||
function createFileWithData(fileData) {
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
|
||||
var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"].getService(SpecialPowers.Ci.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
|
||||
testFile.append("fileAPItestfile" + fileNum);
|
||||
fileNum++;
|
||||
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].createInstance(SpecialPowers.Ci.nsIFileOutputStream);
|
||||
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
|
||||
0666, 0);
|
||||
outStream.write(fileData, fileData.length);
|
||||
outStream.close();
|
||||
|
||||
var fileList = document.getElementById('fileList');
|
||||
fileList.value = testFile.path;
|
||||
SpecialPowers.wrap(fileList).value = testFile.path;
|
||||
|
||||
return fileList.files[0];
|
||||
}
|
||||
|
@ -16,10 +16,9 @@
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function testHtmlCopyEncoder () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder;
|
||||
var encoder = Components.classes["@mozilla.org/layout/htmlCopyEncoder;1"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/htmlCopyEncoder;1"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
var out, expected;
|
||||
|
||||
var node = document.getElementById('draggable');
|
||||
|
@ -16,10 +16,9 @@
|
||||
<script class="testbody" type="text/javascript">
|
||||
//<![CDATA[
|
||||
function testHtmlCopyEncoder () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const de = Components.interfaces.nsIDocumentEncoder;
|
||||
var encoder = Components.classes["@mozilla.org/layout/htmlCopyEncoder;1"]
|
||||
.createInstance(Components.interfaces.nsIDocumentEncoder);
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
var encoder = SpecialPowers.Cc["@mozilla.org/layout/htmlCopyEncoder;1"]
|
||||
.createInstance(SpecialPowers.Ci.nsIDocumentEncoder);
|
||||
var out, expected;
|
||||
|
||||
var node = document.getElementById('draggable');
|
||||
|
@ -1225,15 +1225,15 @@ function test41()
|
||||
ok(true, "test 41c close");
|
||||
|
||||
// clean up the STS state
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Ci = SpecialPowers.Ci;
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var thehost = ios.newURI("http://example.com", null, null);
|
||||
var sss = Cc["@mozilla.org/ssservice;1"].getService(Ci.nsISiteSecurityService);
|
||||
var loadContext = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
var loadContext = SpecialPowers.wrap(window)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
var flags = 0;
|
||||
if (loadContext.usePrivateBrowsing)
|
||||
flags |= Ci.nsISocketProvider.NO_PERMANENT_STORAGE;
|
||||
@ -1338,24 +1338,20 @@ function test44()
|
||||
|
||||
function createDOMFile(fileName, fileData)
|
||||
{
|
||||
// enablePrivilege is picky about where it's called? if I put it in global
|
||||
// scope at start of <script> it doesn't work...
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
// create File in profile dir
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
|
||||
var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
|
||||
testFile.append(fileName);
|
||||
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(SpecialPowers.Ci.nsIFileOutputStream);
|
||||
outStream.init(testFile, 0x02 | 0x08 | 0x20, 0666, 0);
|
||||
outStream.write(fileData, fileData.length);
|
||||
outStream.close();
|
||||
|
||||
// Set filename into DOM <input> field, as if selected by user
|
||||
var fileList = document.getElementById('fileList');
|
||||
fileList.value = testFile.path;
|
||||
SpecialPowers.wrap(fileList).value = testFile.path;
|
||||
|
||||
// return JS File object, aka Blob
|
||||
return fileList.files[0];
|
||||
|
@ -22,17 +22,13 @@ function startsWith(target, prefix)
|
||||
|
||||
function createDOMFile(fileName, fileData)
|
||||
{
|
||||
// enablePrivilege is picky about where it's called? if I put it in global
|
||||
// scope at start of <script> it doesn't work...
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
// create File in profile dir
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
|
||||
var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
|
||||
testFile.append(fileName);
|
||||
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(SpecialPowers.Ci.nsIFileOutputStream);
|
||||
outStream.init(testFile, 0x02 | 0x08 | 0x20, 0666, 0);
|
||||
if (fileData) {
|
||||
outStream.write(fileData, fileData.length);
|
||||
@ -41,7 +37,7 @@ function createDOMFile(fileName, fileData)
|
||||
|
||||
// Set filename into DOM <input> field, as if selected by user
|
||||
var fileList = document.getElementById('fileList');
|
||||
fileList.value = testFile.path;
|
||||
SpecialPowers.wrap(fileList).value = testFile.path;
|
||||
|
||||
// return JS File object, aka Blob
|
||||
return fileList.files[0];
|
||||
|
@ -874,7 +874,7 @@ CanvasRenderingContext2D::EnsureTarget()
|
||||
if (!mForceSoftware && CheckSizeForSkiaGL(size))
|
||||
{
|
||||
glContext = GLContextProvider::CreateOffscreen(gfxIntSize(size.width, size.height),
|
||||
caps, GLContext::ContextFlagsNone);
|
||||
caps, gl::ContextFlagsNone);
|
||||
}
|
||||
|
||||
if (glContext) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WebGL2Context.h"
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
|
||||
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
@ -6,8 +6,7 @@
|
||||
#ifndef WEBGLACTIVEINFO_H_
|
||||
#define WEBGLACTIVEINFO_H_
|
||||
|
||||
#include "WebGLTypes.h"
|
||||
#include "nsISupports.h"
|
||||
#include "WebGLObjectModel.h"
|
||||
#include "nsString.h"
|
||||
#include "js/TypeDecls.h"
|
||||
|
||||
@ -16,7 +15,7 @@ namespace mozilla {
|
||||
class WebGLActiveInfo MOZ_FINAL
|
||||
{
|
||||
public:
|
||||
WebGLActiveInfo(WebGLint size, WebGLenum type, const nsACString& name) :
|
||||
WebGLActiveInfo(GLint size, GLenum type, const nsACString& name) :
|
||||
mSize(size),
|
||||
mType(type),
|
||||
mName(NS_ConvertASCIItoUTF16(name))
|
||||
@ -24,11 +23,11 @@ public:
|
||||
|
||||
// WebIDL attributes
|
||||
|
||||
WebGLint Size() const {
|
||||
GLint Size() const {
|
||||
return mSize;
|
||||
}
|
||||
|
||||
WebGLenum Type() const {
|
||||
GLenum Type() const {
|
||||
return mType;
|
||||
}
|
||||
|
||||
@ -41,8 +40,8 @@ public:
|
||||
NS_INLINE_DECL_REFCOUNTING(WebGLActiveInfo)
|
||||
|
||||
protected:
|
||||
WebGLint mSize;
|
||||
WebGLenum mType;
|
||||
GLint mSize;
|
||||
GLenum mType;
|
||||
nsString mName;
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "WebGLBuffer.h"
|
||||
#include "WebGLContext.h"
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -40,10 +40,10 @@ public:
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
|
||||
GLuint GLName() const { return mGLName; }
|
||||
GLuint ByteLength() const { return mByteLength; }
|
||||
WebGLsizeiptr ByteLength() const { return mByteLength; }
|
||||
GLenum Target() const { return mTarget; }
|
||||
|
||||
void SetByteLength(GLuint byteLength) { mByteLength = byteLength; }
|
||||
void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
|
||||
|
||||
void SetTarget(GLenum target);
|
||||
|
||||
@ -51,7 +51,7 @@ public:
|
||||
|
||||
void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes);
|
||||
|
||||
bool Validate(WebGLenum type, uint32_t max_allowed, size_t first, size_t count) {
|
||||
bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count) {
|
||||
return mCache->Validate(type, max_allowed, first, count);
|
||||
}
|
||||
|
||||
@ -67,9 +67,9 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
WebGLuint mGLName;
|
||||
GLuint mGLName;
|
||||
bool mHasEverBeenBound;
|
||||
GLuint mByteLength;
|
||||
WebGLsizeiptr mByteLength;
|
||||
GLenum mTarget;
|
||||
|
||||
nsAutoPtr<WebGLElementArrayCache> mCache;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nsDisplayList.h"
|
||||
|
||||
#include "GLContextProvider.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
#include "gfxCrashReporterUtils.h"
|
||||
|
||||
@ -184,7 +185,7 @@ WebGLContext::WebGLContext()
|
||||
mContextLossTimerRunning = false;
|
||||
mDrawSinceContextLossTimerSet = false;
|
||||
mContextRestorer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
mContextStatus = ContextStable;
|
||||
mContextStatus = ContextNotLost;
|
||||
mContextLostErrorSet = false;
|
||||
mLoseContextOnHeapMinimize = false;
|
||||
mCanLoseContextInForeground = true;
|
||||
@ -530,9 +531,9 @@ WebGLContext::SetDimensions(int32_t width, int32_t height)
|
||||
|
||||
// try the default provider, whatever that is
|
||||
if (!gl && useOpenGL) {
|
||||
GLContext::ContextFlags flag = useMesaLlvmPipe
|
||||
? GLContext::ContextFlagsMesaLLVMPipe
|
||||
: GLContext::ContextFlagsNone;
|
||||
gl::ContextFlags flag = useMesaLlvmPipe
|
||||
? gl::ContextFlagsMesaLLVMPipe
|
||||
: gl::ContextFlagsNone;
|
||||
gl = gl::GLContextProvider::CreateOffscreen(size, caps, flag);
|
||||
if (gl && !InitAndValidateGL()) {
|
||||
GenerateWarning("Error during %s initialization",
|
||||
@ -844,7 +845,7 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
||||
CanvasLayer *aOldLayer,
|
||||
LayerManager *aManager)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (!mResetLayer && aOldLayer &&
|
||||
@ -899,7 +900,7 @@ void
|
||||
WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributesInitializer> &retval)
|
||||
{
|
||||
retval.SetNull();
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
dom::WebGLContextAttributes& result = retval.SetValue();
|
||||
@ -914,11 +915,11 @@ WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributesInitializ
|
||||
result.mPreserveDrawingBuffer = mOptions.preserveDrawingBuffer;
|
||||
}
|
||||
|
||||
/* [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname); */
|
||||
/* [noscript] DOMString mozGetUnderlyingParamString(in GLenum pname); */
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::MozGetUnderlyingParamString(uint32_t pname, nsAString& retval)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return NS_OK;
|
||||
|
||||
retval.SetIsVoid(true);
|
||||
@ -1156,7 +1157,7 @@ WebGLContext::PresentScreenBuffer()
|
||||
void
|
||||
WebGLContext::DummyFramebufferOperation(const char *info)
|
||||
{
|
||||
WebGLenum status = CheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
||||
GLenum status = CheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
||||
if (status == LOCAL_GL_FRAMEBUFFER_COMPLETE)
|
||||
return;
|
||||
else
|
||||
@ -1220,7 +1221,7 @@ WebGLContext::RobustnessTimerCallback(nsITimer* timer)
|
||||
SetupContextLossTimer();
|
||||
return;
|
||||
}
|
||||
mContextStatus = ContextStable;
|
||||
mContextStatus = ContextNotLost;
|
||||
nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(),
|
||||
static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement),
|
||||
NS_LITERAL_STRING("webglcontextrestored"),
|
||||
@ -1240,10 +1241,10 @@ void
|
||||
WebGLContext::MaybeRestoreContext()
|
||||
{
|
||||
// Don't try to handle it if we already know it's busted.
|
||||
if (mContextStatus != ContextStable || gl == nullptr)
|
||||
if (mContextStatus != ContextNotLost || gl == nullptr)
|
||||
return;
|
||||
|
||||
bool isEGL = gl->GetContextType() == GLContext::ContextTypeEGL,
|
||||
bool isEGL = gl->GetContextType() == gl::ContextTypeEGL,
|
||||
isANGLE = gl->IsANGLE();
|
||||
|
||||
GLContext::ContextResetARB resetStatus = GLContext::CONTEXT_NO_ERROR;
|
||||
@ -1311,6 +1312,9 @@ WebGLContext::ForceRestoreContext()
|
||||
mContextStatus = ContextLostAwaitingRestore;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::MakeContextCurrent() const { gl->MakeCurrent(); }
|
||||
|
||||
//
|
||||
// XPCOM goop
|
||||
//
|
||||
@ -1318,7 +1322,7 @@ WebGLContext::ForceRestoreContext()
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLContext)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLContext)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_12(WebGLContext,
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_13(WebGLContext,
|
||||
mCanvasElement,
|
||||
mExtensions,
|
||||
mBound2DTextures,
|
||||
@ -1329,6 +1333,7 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_12(WebGLContext,
|
||||
mBoundFramebuffer,
|
||||
mBoundRenderbuffer,
|
||||
mBoundVertexArray,
|
||||
mDefaultVertexArray,
|
||||
mActiveOcclusionQuery,
|
||||
mActiveTransformFeedbackQuery)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLQuery.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -19,7 +20,7 @@ using namespace mozilla;
|
||||
*/
|
||||
|
||||
static const char*
|
||||
GetQueryTargetEnumString(WebGLenum target)
|
||||
GetQueryTargetEnumString(GLenum target)
|
||||
{
|
||||
switch (target)
|
||||
{
|
||||
@ -56,7 +57,7 @@ SimulateOcclusionQueryTarget(const gl::GLContext* gl, GLenum target)
|
||||
already_AddRefed<WebGLQuery>
|
||||
WebGLContext::CreateQuery()
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (mActiveOcclusionQuery && !gl->IsGLES2()) {
|
||||
@ -81,7 +82,7 @@ WebGLContext::CreateQuery()
|
||||
void
|
||||
WebGLContext::DeleteQuery(WebGLQuery *query)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!query)
|
||||
@ -108,9 +109,9 @@ WebGLContext::DeleteQuery(WebGLQuery *query)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BeginQuery(WebGLenum target, WebGLQuery *query)
|
||||
WebGLContext::BeginQuery(GLenum target, WebGLQuery *query)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "beginQuery");
|
||||
@ -178,9 +179,9 @@ WebGLContext::BeginQuery(WebGLenum target, WebGLQuery *query)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::EndQuery(WebGLenum target)
|
||||
WebGLContext::EndQuery(GLenum target)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "endQuery");
|
||||
@ -222,7 +223,7 @@ WebGLContext::EndQuery(WebGLenum target)
|
||||
bool
|
||||
WebGLContext::IsQuery(WebGLQuery *query)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!query)
|
||||
@ -234,9 +235,9 @@ WebGLContext::IsQuery(WebGLQuery *query)
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLQuery>
|
||||
WebGLContext::GetQuery(WebGLenum target, WebGLenum pname)
|
||||
WebGLContext::GetQuery(GLenum target, GLenum pname)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "getQuery");
|
||||
@ -257,9 +258,9 @@ WebGLContext::GetQuery(WebGLenum target, WebGLenum pname)
|
||||
}
|
||||
|
||||
JS::Value
|
||||
WebGLContext::GetQueryObject(JSContext* cx, WebGLQuery *query, WebGLenum pname)
|
||||
WebGLContext::GetQueryObject(JSContext* cx, WebGLQuery *query, GLenum pname)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
if (!query) {
|
||||
@ -333,7 +334,7 @@ WebGLContext::GetQueryObject(JSContext* cx, WebGLQuery *query, WebGLenum pname)
|
||||
}
|
||||
|
||||
WebGLRefPtr<WebGLQuery>*
|
||||
WebGLContext::GetQueryTargetSlot(WebGLenum target, const char* infos)
|
||||
WebGLContext::GetQueryTargetSlot(GLenum target, const char* infos)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_ANY_SAMPLES_PASSED:
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "GLContext.h"
|
||||
#include "WebGLBuffer.h"
|
||||
#include "WebGLVertexArray.h"
|
||||
|
||||
@ -11,9 +12,9 @@ using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
void
|
||||
WebGLContext::BindBuffer(WebGLenum target, WebGLBuffer *buffer)
|
||||
WebGLContext::BindBuffer(GLenum target, WebGLBuffer *buffer)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObjectAllowDeletedOrNull("bindBuffer", buffer))
|
||||
@ -46,9 +47,9 @@ WebGLContext::BindBuffer(WebGLenum target, WebGLBuffer *buffer)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BindBufferBase(WebGLenum target, WebGLuint index, WebGLBuffer* buffer)
|
||||
WebGLContext::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObjectAllowDeletedOrNull("bindBufferBase", buffer))
|
||||
@ -87,10 +88,10 @@ WebGLContext::BindBufferBase(WebGLenum target, WebGLuint index, WebGLBuffer* buf
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BindBufferRange(WebGLenum target, WebGLuint index, WebGLBuffer* buffer,
|
||||
WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
|
||||
WebGLintptr offset, WebGLsizeiptr size)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObjectAllowDeletedOrNull("bindBufferRange", buffer))
|
||||
@ -113,6 +114,12 @@ WebGLContext::BindBufferRange(WebGLenum target, WebGLuint index, WebGLBuffer* bu
|
||||
} else if (target != buffer->Target()) {
|
||||
return ErrorInvalidOperation("bindBuffer: buffer already bound to a different target");
|
||||
}
|
||||
CheckedInt<WebGLsizeiptr> checked_neededByteLength = CheckedInt<WebGLsizeiptr>(offset) + size;
|
||||
if (!checked_neededByteLength.isValid() ||
|
||||
checked_neededByteLength.value() > buffer->ByteLength())
|
||||
{
|
||||
return ErrorInvalidValue("bindBufferRange: invalid range");
|
||||
}
|
||||
}
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bindBuffer");
|
||||
@ -128,10 +135,10 @@ WebGLContext::BindBufferRange(WebGLenum target, WebGLuint index, WebGLBuffer* bu
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BufferData(WebGLenum target, WebGLsizeiptr size,
|
||||
WebGLenum usage)
|
||||
WebGLContext::BufferData(GLenum target, WebGLsizeiptr size,
|
||||
GLenum usage)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferData");
|
||||
@ -146,6 +153,10 @@ WebGLContext::BufferData(WebGLenum target, WebGLsizeiptr size,
|
||||
if (!ValidateBufferUsageEnum(usage, "bufferData: usage"))
|
||||
return;
|
||||
|
||||
// careful: WebGLsizeiptr is always 64-bit, but GLsizeiptr is like intptr_t.
|
||||
if (!CheckedInt<GLsizeiptr>(size).isValid())
|
||||
return ErrorOutOfMemory("bufferData: bad size");
|
||||
|
||||
WebGLBuffer* boundBuffer = bufferSlot->get();
|
||||
|
||||
if (!boundBuffer)
|
||||
@ -173,11 +184,11 @@ WebGLContext::BufferData(WebGLenum target, WebGLsizeiptr size,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BufferData(WebGLenum target,
|
||||
WebGLContext::BufferData(GLenum target,
|
||||
const Nullable<ArrayBuffer> &maybeData,
|
||||
WebGLenum usage)
|
||||
GLenum usage)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (maybeData.IsNull()) {
|
||||
@ -193,6 +204,10 @@ WebGLContext::BufferData(WebGLenum target,
|
||||
|
||||
const ArrayBuffer& data = maybeData.Value();
|
||||
|
||||
// careful: data.Length() could conceivably be any size_t, but GLsizeiptr is like intptr_t.
|
||||
if (!CheckedInt<GLsizeiptr>(data.Length()).isValid())
|
||||
return ErrorOutOfMemory("bufferData: bad size");
|
||||
|
||||
if (!ValidateBufferUsageEnum(usage, "bufferData: usage"))
|
||||
return;
|
||||
|
||||
@ -218,10 +233,10 @@ WebGLContext::BufferData(WebGLenum target,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BufferData(WebGLenum target, const ArrayBufferView& data,
|
||||
WebGLenum usage)
|
||||
WebGLContext::BufferData(GLenum target, const ArrayBufferView& data,
|
||||
GLenum usage)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferSubData");
|
||||
@ -238,6 +253,10 @@ WebGLContext::BufferData(WebGLenum target, const ArrayBufferView& data,
|
||||
if (!boundBuffer)
|
||||
return ErrorInvalidOperation("bufferData: no buffer bound!");
|
||||
|
||||
// careful: data.Length() could conceivably be any size_t, but GLsizeiptr is like intptr_t.
|
||||
if (!CheckedInt<GLsizeiptr>(data.Length()).isValid())
|
||||
return ErrorOutOfMemory("bufferData: bad size");
|
||||
|
||||
InvalidateBufferFetching();
|
||||
MakeContextCurrent();
|
||||
|
||||
@ -257,7 +276,7 @@ void
|
||||
WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
||||
const Nullable<ArrayBuffer> &maybeData)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (maybeData.IsNull()) {
|
||||
@ -281,7 +300,7 @@ WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
||||
if (!boundBuffer)
|
||||
return ErrorInvalidOperation("bufferData: no buffer bound!");
|
||||
|
||||
CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + data.Length();
|
||||
CheckedInt<WebGLsizeiptr> checked_neededByteLength = CheckedInt<WebGLsizeiptr>(byteOffset) + data.Length();
|
||||
if (!checked_neededByteLength.isValid())
|
||||
return ErrorInvalidValue("bufferSubData: integer overflow computing the needed byte length");
|
||||
|
||||
@ -297,10 +316,10 @@ WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BufferSubData(WebGLenum target, WebGLsizeiptr byteOffset,
|
||||
WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
||||
const ArrayBufferView& data)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferSubData");
|
||||
@ -317,7 +336,7 @@ WebGLContext::BufferSubData(WebGLenum target, WebGLsizeiptr byteOffset,
|
||||
if (!boundBuffer)
|
||||
return ErrorInvalidOperation("bufferSubData: no buffer bound!");
|
||||
|
||||
CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + data.Length();
|
||||
CheckedInt<WebGLsizeiptr> checked_neededByteLength = CheckedInt<WebGLsizeiptr>(byteOffset) + data.Length();
|
||||
if (!checked_neededByteLength.isValid())
|
||||
return ErrorInvalidValue("bufferSubData: integer overflow computing the needed byte length");
|
||||
|
||||
@ -334,7 +353,7 @@ WebGLContext::BufferSubData(WebGLenum target, WebGLsizeiptr byteOffset,
|
||||
already_AddRefed<WebGLBuffer>
|
||||
WebGLContext::CreateBuffer()
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
nsRefPtr<WebGLBuffer> globj = new WebGLBuffer(this);
|
||||
@ -344,7 +363,7 @@ WebGLContext::CreateBuffer()
|
||||
void
|
||||
WebGLContext::DeleteBuffer(WebGLBuffer *buffer)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObjectAllowDeletedOrNull("deleteBuffer", buffer))
|
||||
@ -374,7 +393,7 @@ WebGLContext::DeleteBuffer(WebGLBuffer *buffer)
|
||||
bool
|
||||
WebGLContext::IsBuffer(WebGLBuffer *buffer)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
return ValidateObjectAllowDeleted("isBuffer", buffer) &&
|
||||
@ -383,7 +402,7 @@ WebGLContext::IsBuffer(WebGLBuffer *buffer)
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateBufferUsageEnum(WebGLenum target, const char *infos)
|
||||
WebGLContext::ValidateBufferUsageEnum(GLenum target, const char *infos)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_STREAM_DRAW:
|
||||
@ -440,3 +459,39 @@ WebGLContext::GetBufferSlotByTargetIndexed(GLenum target, GLuint index, const ch
|
||||
ErrorInvalidEnum("%s: target: invalid enum value 0x%x", infos, target);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GLenum
|
||||
WebGLContext::CheckedBufferData(GLenum target,
|
||||
GLsizeiptr size,
|
||||
const GLvoid *data,
|
||||
GLenum usage)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
// bug 790879
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
int64_t(size) > INT32_MAX) // the cast avoids a potential always-true warning on 32bit
|
||||
{
|
||||
GenerateWarning("Rejecting valid bufferData call with size %lu to avoid a Mac bug", size);
|
||||
return LOCAL_GL_INVALID_VALUE;
|
||||
}
|
||||
#endif
|
||||
WebGLBuffer *boundBuffer = nullptr;
|
||||
if (target == LOCAL_GL_ARRAY_BUFFER) {
|
||||
boundBuffer = mBoundArrayBuffer;
|
||||
} else if (target == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
|
||||
boundBuffer = mBoundVertexArray->mBoundElementArrayBuffer;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(boundBuffer != nullptr, "no buffer bound for this target");
|
||||
|
||||
bool sizeChanges = uint32_t(size) != boundBuffer->ByteLength();
|
||||
if (sizeChanges) {
|
||||
UpdateWebGLErrorAndClearGLError();
|
||||
gl->fBufferData(target, size, data, usage);
|
||||
GLenum error = LOCAL_GL_NO_ERROR;
|
||||
UpdateWebGLErrorAndClearGLError(&error);
|
||||
return error;
|
||||
} else {
|
||||
gl->fBufferData(target, size, data, usage);
|
||||
return LOCAL_GL_NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ CompareWebGLExtensionName(const nsACString& name, const char *other)
|
||||
JSObject*
|
||||
WebGLContext::GetExtension(JSContext *cx, const nsAString& aName, ErrorResult& rv)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
NS_LossyConvertUTF16toASCII name(aName);
|
||||
@ -257,7 +257,7 @@ void
|
||||
WebGLContext::GetSupportedExtensions(JSContext *cx, Nullable< nsTArray<nsString> > &retval)
|
||||
{
|
||||
retval.SetNull();
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
nsTArray<nsString>& arr = retval.SetValue();
|
||||
|
@ -7,13 +7,14 @@
|
||||
#include "WebGLTexture.h"
|
||||
#include "WebGLRenderbuffer.h"
|
||||
#include "WebGLFramebuffer.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
void
|
||||
WebGLContext::Clear(WebGLbitfield mask)
|
||||
WebGLContext::Clear(GLbitfield mask)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -76,8 +77,8 @@ WebGLContext::Clear(WebGLbitfield mask)
|
||||
mShouldPresent = true;
|
||||
}
|
||||
|
||||
static WebGLclampf
|
||||
GLClampFloat(WebGLclampf val)
|
||||
static GLclampf
|
||||
GLClampFloat(GLclampf val)
|
||||
{
|
||||
if (val < 0.0)
|
||||
return 0.0;
|
||||
@ -89,10 +90,10 @@ GLClampFloat(WebGLclampf val)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ClearColor(WebGLclampf r, WebGLclampf g,
|
||||
WebGLclampf b, WebGLclampf a)
|
||||
WebGLContext::ClearColor(GLclampf r, GLclampf g,
|
||||
GLclampf b, GLclampf a)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -104,9 +105,9 @@ WebGLContext::ClearColor(WebGLclampf r, WebGLclampf g,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ClearDepth(WebGLclampf v)
|
||||
WebGLContext::ClearDepth(GLclampf v)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -115,9 +116,9 @@ WebGLContext::ClearDepth(WebGLclampf v)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ClearStencil(WebGLint v)
|
||||
WebGLContext::ClearStencil(GLint v)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -128,7 +129,7 @@ WebGLContext::ClearStencil(WebGLint v)
|
||||
void
|
||||
WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboolean a)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -142,7 +143,7 @@ WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboo
|
||||
void
|
||||
WebGLContext::DepthMask(WebGLboolean b)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -227,9 +228,9 @@ WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::StencilMask(WebGLuint mask)
|
||||
WebGLContext::StencilMask(GLuint mask)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
mStencilWriteMaskFront = mask;
|
||||
@ -240,9 +241,9 @@ WebGLContext::StencilMask(WebGLuint mask)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::StencilMaskSeparate(WebGLenum face, WebGLuint mask)
|
||||
WebGLContext::StencilMaskSeparate(GLenum face, GLuint mask)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateFaceEnum(face, "stencilMaskSeparate: face"))
|
||||
|
File diff suppressed because it is too large
Load Diff
40
content/canvas/src/WebGLContextLossTimer.cpp
Normal file
40
content/canvas/src/WebGLContextLossTimer.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 "WebGLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
/* static */ void
|
||||
WebGLContext::RobustnessTimerCallbackStatic(nsITimer* timer, void *thisPointer) {
|
||||
static_cast<WebGLContext*>(thisPointer)->RobustnessTimerCallback(timer);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::SetupContextLossTimer() {
|
||||
// If the timer was already running, don't restart it here. Instead,
|
||||
// wait until the previous call is done, then fire it one more time.
|
||||
// This is an optimization to prevent unnecessary cross-communication
|
||||
// between threads.
|
||||
if (mContextLossTimerRunning) {
|
||||
mDrawSinceContextLossTimerSet = true;
|
||||
return;
|
||||
}
|
||||
|
||||
mContextRestorer->InitWithFuncCallback(RobustnessTimerCallbackStatic,
|
||||
static_cast<void*>(this),
|
||||
1000,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
mContextLossTimerRunning = true;
|
||||
mDrawSinceContextLossTimerSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::TerminateContextLossTimer() {
|
||||
if (mContextLossTimerRunning) {
|
||||
mContextRestorer->Cancel();
|
||||
mContextLossTimerRunning = false;
|
||||
}
|
||||
}
|
@ -12,14 +12,15 @@
|
||||
#include "WebGLRenderbuffer.h"
|
||||
#include "WebGLTexture.h"
|
||||
#include "WebGLVertexArray.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace dom;
|
||||
|
||||
void
|
||||
WebGLContext::Disable(WebGLenum cap)
|
||||
WebGLContext::Disable(GLenum cap)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateCapabilityEnum(cap, "disable"))
|
||||
@ -37,9 +38,9 @@ WebGLContext::Disable(WebGLenum cap)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::Enable(WebGLenum cap)
|
||||
WebGLContext::Enable(GLenum cap)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateCapabilityEnum(cap, "enable"))
|
||||
@ -69,9 +70,9 @@ StringValue(JSContext* cx, const char* chars, ErrorResult& rv)
|
||||
}
|
||||
|
||||
JS::Value
|
||||
WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
|
||||
WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -127,7 +128,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
|
||||
return JS::Int32Value(mGLMaxDrawBuffers);
|
||||
}
|
||||
else if (pname >= LOCAL_GL_DRAW_BUFFER0 &&
|
||||
pname < WebGLenum(LOCAL_GL_DRAW_BUFFER0 + mGLMaxDrawBuffers))
|
||||
pname < GLenum(LOCAL_GL_DRAW_BUFFER0 + mGLMaxDrawBuffers))
|
||||
{
|
||||
if (mBoundFramebuffer) {
|
||||
GLint iv = 0;
|
||||
@ -484,9 +485,9 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
|
||||
}
|
||||
|
||||
JS::Value
|
||||
WebGLContext::GetParameterIndexed(JSContext* cx, WebGLenum pname, WebGLuint index)
|
||||
WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -510,9 +511,9 @@ WebGLContext::GetParameterIndexed(JSContext* cx, WebGLenum pname, WebGLuint inde
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::IsEnabled(WebGLenum cap)
|
||||
WebGLContext::IsEnabled(GLenum cap)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!ValidateCapabilityEnum(cap, "isEnabled"))
|
||||
@ -523,7 +524,7 @@ WebGLContext::IsEnabled(WebGLenum cap)
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateCapabilityEnum(WebGLenum cap, const char* info)
|
||||
WebGLContext::ValidateCapabilityEnum(GLenum cap, const char* info)
|
||||
{
|
||||
switch (cap) {
|
||||
case LOCAL_GL_BLEND:
|
||||
@ -545,7 +546,7 @@ WebGLContext::ValidateCapabilityEnum(WebGLenum cap, const char* info)
|
||||
}
|
||||
|
||||
realGLboolean*
|
||||
WebGLContext::GetStateTrackingSlot(WebGLenum cap)
|
||||
WebGLContext::GetStateTrackingSlot(GLenum cap)
|
||||
{
|
||||
switch (cap) {
|
||||
case LOCAL_GL_SCISSOR_TEST:
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
#include "prprf.h"
|
||||
|
||||
@ -55,9 +56,19 @@ WebGLContext::GenerateWarning(const char *fmt, va_list ap)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ShouldGenerateWarnings() const
|
||||
{
|
||||
if (mMaxWarnings == -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mAlreadyGeneratedWarnings < mMaxWarnings;
|
||||
}
|
||||
|
||||
CheckedUint32
|
||||
WebGLContext::GetImageSize(WebGLsizei height,
|
||||
WebGLsizei width,
|
||||
WebGLContext::GetImageSize(GLsizei height,
|
||||
GLsizei width,
|
||||
uint32_t pixelSize,
|
||||
uint32_t packOrUnpackAlignment)
|
||||
{
|
||||
@ -74,7 +85,7 @@ WebGLContext::GetImageSize(WebGLsizei height,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::SynthesizeGLError(WebGLenum err)
|
||||
WebGLContext::SynthesizeGLError(GLenum err)
|
||||
{
|
||||
// If there is already a pending error, don't overwrite it;
|
||||
// but if there isn't, then we need to check for a gl error
|
||||
@ -90,7 +101,7 @@ WebGLContext::SynthesizeGLError(WebGLenum err)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::SynthesizeGLError(WebGLenum err, const char *fmt, ...)
|
||||
WebGLContext::SynthesizeGLError(GLenum err, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
@ -111,6 +122,12 @@ WebGLContext::ErrorInvalidEnum(const char *fmt, ...)
|
||||
return SynthesizeGLError(LOCAL_GL_INVALID_ENUM);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ErrorInvalidEnumInfo(const char *info, GLenum enumvalue)
|
||||
{
|
||||
return ErrorInvalidEnum("%s: invalid enum value 0x%x", info, enumvalue);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ErrorInvalidOperation(const char *fmt, ...)
|
||||
{
|
||||
@ -208,3 +225,15 @@ WebGLContext::IsTextureFormatCompressed(GLenum format)
|
||||
NS_ABORT();
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::UpdateWebGLErrorAndClearGLError(GLenum *currentGLError)
|
||||
{
|
||||
// get and clear GL error in ALL cases
|
||||
GLenum error = gl->GetAndClearError();
|
||||
if (currentGLError)
|
||||
*currentGLError = error;
|
||||
// only store in mWebGLError if is hasn't already recorded an error
|
||||
if (!mWebGLError)
|
||||
mWebGLError = error;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "WebGLRenderbuffer.h"
|
||||
#include "WebGLTexture.h"
|
||||
#include "WebGLVertexArray.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -108,7 +109,7 @@ WebGLProgram::UpdateInfo()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateBlendEquationEnum(WebGLenum mode, const char *info)
|
||||
bool WebGLContext::ValidateBlendEquationEnum(GLenum mode, const char *info)
|
||||
{
|
||||
switch (mode) {
|
||||
case LOCAL_GL_FUNC_ADD:
|
||||
@ -130,7 +131,7 @@ bool WebGLContext::ValidateBlendEquationEnum(WebGLenum mode, const char *info)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateBlendFuncDstEnum(WebGLenum factor, const char *info)
|
||||
bool WebGLContext::ValidateBlendFuncDstEnum(GLenum factor, const char *info)
|
||||
{
|
||||
switch (factor) {
|
||||
case LOCAL_GL_ZERO:
|
||||
@ -154,7 +155,7 @@ bool WebGLContext::ValidateBlendFuncDstEnum(WebGLenum factor, const char *info)
|
||||
}
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateBlendFuncSrcEnum(WebGLenum factor, const char *info)
|
||||
bool WebGLContext::ValidateBlendFuncSrcEnum(GLenum factor, const char *info)
|
||||
{
|
||||
if (factor == LOCAL_GL_SRC_ALPHA_SATURATE)
|
||||
return true;
|
||||
@ -162,7 +163,7 @@ bool WebGLContext::ValidateBlendFuncSrcEnum(WebGLenum factor, const char *info)
|
||||
return ValidateBlendFuncDstEnum(factor, info);
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateBlendFuncEnumsCompatibility(WebGLenum sfactor, WebGLenum dfactor, const char *info)
|
||||
bool WebGLContext::ValidateBlendFuncEnumsCompatibility(GLenum sfactor, GLenum dfactor, const char *info)
|
||||
{
|
||||
bool sfactorIsConstantColor = sfactor == LOCAL_GL_CONSTANT_COLOR ||
|
||||
sfactor == LOCAL_GL_ONE_MINUS_CONSTANT_COLOR;
|
||||
@ -181,7 +182,7 @@ bool WebGLContext::ValidateBlendFuncEnumsCompatibility(WebGLenum sfactor, WebGLe
|
||||
}
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateTextureTargetEnum(WebGLenum target, const char *info)
|
||||
bool WebGLContext::ValidateTextureTargetEnum(GLenum target, const char *info)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_TEXTURE_2D:
|
||||
@ -193,7 +194,7 @@ bool WebGLContext::ValidateTextureTargetEnum(WebGLenum target, const char *info)
|
||||
}
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateComparisonEnum(WebGLenum target, const char *info)
|
||||
bool WebGLContext::ValidateComparisonEnum(GLenum target, const char *info)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_NEVER:
|
||||
@ -211,7 +212,7 @@ bool WebGLContext::ValidateComparisonEnum(WebGLenum target, const char *info)
|
||||
}
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateStencilOpEnum(WebGLenum action, const char *info)
|
||||
bool WebGLContext::ValidateStencilOpEnum(GLenum action, const char *info)
|
||||
{
|
||||
switch (action) {
|
||||
case LOCAL_GL_KEEP:
|
||||
@ -229,7 +230,7 @@ bool WebGLContext::ValidateStencilOpEnum(WebGLenum action, const char *info)
|
||||
}
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateFaceEnum(WebGLenum face, const char *info)
|
||||
bool WebGLContext::ValidateFaceEnum(GLenum face, const char *info)
|
||||
{
|
||||
switch (face) {
|
||||
case LOCAL_GL_FRONT:
|
||||
@ -242,7 +243,7 @@ bool WebGLContext::ValidateFaceEnum(WebGLenum face, const char *info)
|
||||
}
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateDrawModeEnum(WebGLenum mode, const char *info)
|
||||
bool WebGLContext::ValidateDrawModeEnum(GLenum mode, const char *info)
|
||||
{
|
||||
switch (mode) {
|
||||
case LOCAL_GL_TRIANGLES:
|
||||
@ -300,7 +301,7 @@ bool WebGLContext::ValidateGLSLString(const nsAString& string, const char *info)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateTexImage2DTarget(WebGLenum target, WebGLsizei width, WebGLsizei height,
|
||||
bool WebGLContext::ValidateTexImage2DTarget(GLenum target, GLsizei width, GLsizei height,
|
||||
const char* info)
|
||||
{
|
||||
switch (target) {
|
||||
@ -325,9 +326,9 @@ bool WebGLContext::ValidateTexImage2DTarget(WebGLenum target, WebGLsizei width,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateCompressedTextureSize(WebGLenum target, WebGLint level,
|
||||
WebGLenum format,
|
||||
WebGLsizei width, WebGLsizei height, uint32_t byteLength, const char* info)
|
||||
bool WebGLContext::ValidateCompressedTextureSize(GLenum target, GLint level,
|
||||
GLenum format,
|
||||
GLsizei width, GLsizei height, uint32_t byteLength, const char* info)
|
||||
{
|
||||
if (!ValidateLevelWidthHeightForTarget(target, level, width, height, info)) {
|
||||
return false;
|
||||
@ -408,17 +409,17 @@ bool WebGLContext::ValidateCompressedTextureSize(WebGLenum target, WebGLint leve
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateLevelWidthHeightForTarget(WebGLenum target, WebGLint level, WebGLsizei width,
|
||||
WebGLsizei height, const char* info)
|
||||
bool WebGLContext::ValidateLevelWidthHeightForTarget(GLenum target, GLint level, GLsizei width,
|
||||
GLsizei height, const char* info)
|
||||
{
|
||||
WebGLsizei maxTextureSize = MaxTextureSizeForTarget(target);
|
||||
GLsizei maxTextureSize = MaxTextureSizeForTarget(target);
|
||||
|
||||
if (level < 0) {
|
||||
ErrorInvalidValue("%s: level must be >= 0", info);
|
||||
return false;
|
||||
}
|
||||
|
||||
WebGLsizei maxAllowedSize = maxTextureSize >> level;
|
||||
GLsizei maxAllowedSize = maxTextureSize >> level;
|
||||
|
||||
if (!maxAllowedSize) {
|
||||
ErrorInvalidValue("%s: 2^level exceeds maximum texture size", info);
|
||||
@ -438,7 +439,7 @@ bool WebGLContext::ValidateLevelWidthHeightForTarget(WebGLenum target, WebGLint
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t WebGLContext::GetBitsPerTexel(WebGLenum format, WebGLenum type)
|
||||
uint32_t WebGLContext::GetBitsPerTexel(GLenum format, GLenum type)
|
||||
{
|
||||
// If there is no defined format or type, we're not taking up any memory
|
||||
if (!format || !type) {
|
||||
@ -495,7 +496,7 @@ uint32_t WebGLContext::GetBitsPerTexel(WebGLenum format, WebGLenum type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateTexFormatAndType(WebGLenum format, WebGLenum type, int jsArrayType,
|
||||
bool WebGLContext::ValidateTexFormatAndType(GLenum format, GLenum type, int jsArrayType,
|
||||
uint32_t *texelSize, const char *info)
|
||||
{
|
||||
if (IsExtensionEnabled(WEBGL_depth_texture)) {
|
||||
@ -635,7 +636,7 @@ WebGLContext::ValidateUniformLocation(const char* info, WebGLUniformLocation *lo
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateSamplerUniformSetter(const char* info, WebGLUniformLocation *location, WebGLint value)
|
||||
WebGLContext::ValidateSamplerUniformSetter(const char* info, WebGLUniformLocation *location, GLint value)
|
||||
{
|
||||
if (location->Info().type != SH_SAMPLER_2D &&
|
||||
location->Info().type != SH_SAMPLER_CUBE)
|
||||
@ -654,7 +655,7 @@ WebGLContext::ValidateSamplerUniformSetter(const char* info, WebGLUniformLocatio
|
||||
bool
|
||||
WebGLContext::ValidateAttribArraySetter(const char* name, uint32_t cnt, uint32_t arrayLength)
|
||||
{
|
||||
if (!IsContextStable()) {
|
||||
if (IsContextLost()) {
|
||||
return false;
|
||||
}
|
||||
if (arrayLength < cnt) {
|
||||
@ -668,7 +669,7 @@ bool
|
||||
WebGLContext::ValidateUniformArraySetter(const char* name, uint32_t expectedElemSize, WebGLUniformLocation *location_object,
|
||||
GLint& location, uint32_t& numElementsToUpload, uint32_t arrayLength)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
if (!ValidateUniformLocation(name, location_object))
|
||||
return false;
|
||||
@ -711,7 +712,7 @@ WebGLContext::ValidateUniformMatrixArraySetter(const char* name, int dim, WebGLU
|
||||
WebGLboolean aTranspose)
|
||||
{
|
||||
uint32_t expectedElemSize = (dim)*(dim);
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
if (!ValidateUniformLocation(name, location_object))
|
||||
return false;
|
||||
@ -756,7 +757,7 @@ WebGLContext::ValidateUniformMatrixArraySetter(const char* name, int dim, WebGLU
|
||||
bool
|
||||
WebGLContext::ValidateUniformSetter(const char* name, WebGLUniformLocation *location_object, GLint& location)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
if (!ValidateUniformLocation(name, location_object))
|
||||
return false;
|
||||
@ -764,7 +765,7 @@ WebGLContext::ValidateUniformSetter(const char* name, WebGLUniformLocation *loca
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateAttribIndex(WebGLuint index, const char *info)
|
||||
bool WebGLContext::ValidateAttribIndex(GLuint index, const char *info)
|
||||
{
|
||||
return mBoundVertexArray->EnsureAttribIndex(index, info);
|
||||
}
|
||||
|
@ -7,13 +7,14 @@
|
||||
#include "WebGLBuffer.h"
|
||||
#include "WebGLVertexAttribData.h"
|
||||
#include "WebGLVertexArray.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
void
|
||||
WebGLContext::BindVertexArray(WebGLVertexArray *array)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObjectAllowDeletedOrNull("bindVertexArrayObject", array))
|
||||
@ -48,7 +49,7 @@ WebGLContext::BindVertexArray(WebGLVertexArray *array)
|
||||
already_AddRefed<WebGLVertexArray>
|
||||
WebGLContext::CreateVertexArray()
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
nsRefPtr<WebGLVertexArray> globj = new WebGLVertexArray(this);
|
||||
@ -64,7 +65,7 @@ WebGLContext::CreateVertexArray()
|
||||
void
|
||||
WebGLContext::DeleteVertexArray(WebGLVertexArray *array)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (array == nullptr)
|
||||
@ -82,7 +83,7 @@ WebGLContext::DeleteVertexArray(WebGLVertexArray *array)
|
||||
bool
|
||||
WebGLContext::IsVertexArray(WebGLVertexArray *array)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!array)
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "WebGLUniformInfo.h"
|
||||
#include "WebGLShader.h"
|
||||
#include "WebGLProgram.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace dom;
|
||||
@ -21,9 +22,9 @@ using namespace dom;
|
||||
static const int MAX_DRAW_CALLS_SINCE_FLUSH = 100;
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib1f(WebGLuint index, WebGLfloat x0)
|
||||
WebGLContext::VertexAttrib1f(GLuint index, GLfloat x0)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -41,9 +42,9 @@ WebGLContext::VertexAttrib1f(WebGLuint index, WebGLfloat x0)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib2f(WebGLuint index, WebGLfloat x0, WebGLfloat x1)
|
||||
WebGLContext::VertexAttrib2f(GLuint index, GLfloat x0, GLfloat x1)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -61,9 +62,9 @@ WebGLContext::VertexAttrib2f(WebGLuint index, WebGLfloat x0, WebGLfloat x1)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib3f(WebGLuint index, WebGLfloat x0, WebGLfloat x1, WebGLfloat x2)
|
||||
WebGLContext::VertexAttrib3f(GLuint index, GLfloat x0, GLfloat x1, GLfloat x2)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -81,10 +82,10 @@ WebGLContext::VertexAttrib3f(WebGLuint index, WebGLfloat x0, WebGLfloat x1, WebG
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib4f(WebGLuint index, WebGLfloat x0, WebGLfloat x1,
|
||||
WebGLfloat x2, WebGLfloat x3)
|
||||
WebGLContext::VertexAttrib4f(GLuint index, GLfloat x0, GLfloat x1,
|
||||
GLfloat x2, GLfloat x3)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -103,8 +104,8 @@ WebGLContext::VertexAttrib4f(WebGLuint index, WebGLfloat x0, WebGLfloat x1,
|
||||
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib1fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
const WebGLfloat* ptr)
|
||||
WebGLContext::VertexAttrib1fv_base(GLuint idx, uint32_t arrayLength,
|
||||
const GLfloat* ptr)
|
||||
{
|
||||
if (!ValidateAttribArraySetter("VertexAttrib1fv", 1, arrayLength))
|
||||
return;
|
||||
@ -114,17 +115,17 @@ WebGLContext::VertexAttrib1fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
gl->fVertexAttrib1fv(idx, ptr);
|
||||
} else {
|
||||
mVertexAttrib0Vector[0] = ptr[0];
|
||||
mVertexAttrib0Vector[1] = WebGLfloat(0);
|
||||
mVertexAttrib0Vector[2] = WebGLfloat(0);
|
||||
mVertexAttrib0Vector[3] = WebGLfloat(1);
|
||||
mVertexAttrib0Vector[1] = GLfloat(0);
|
||||
mVertexAttrib0Vector[2] = GLfloat(0);
|
||||
mVertexAttrib0Vector[3] = GLfloat(1);
|
||||
if (gl->IsGLES2())
|
||||
gl->fVertexAttrib1fv(idx, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib2fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
const WebGLfloat* ptr)
|
||||
WebGLContext::VertexAttrib2fv_base(GLuint idx, uint32_t arrayLength,
|
||||
const GLfloat* ptr)
|
||||
{
|
||||
if (!ValidateAttribArraySetter("VertexAttrib2fv", 2, arrayLength))
|
||||
return;
|
||||
@ -135,16 +136,16 @@ WebGLContext::VertexAttrib2fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
} else {
|
||||
mVertexAttrib0Vector[0] = ptr[0];
|
||||
mVertexAttrib0Vector[1] = ptr[1];
|
||||
mVertexAttrib0Vector[2] = WebGLfloat(0);
|
||||
mVertexAttrib0Vector[3] = WebGLfloat(1);
|
||||
mVertexAttrib0Vector[2] = GLfloat(0);
|
||||
mVertexAttrib0Vector[3] = GLfloat(1);
|
||||
if (gl->IsGLES2())
|
||||
gl->fVertexAttrib2fv(idx, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib3fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
const WebGLfloat* ptr)
|
||||
WebGLContext::VertexAttrib3fv_base(GLuint idx, uint32_t arrayLength,
|
||||
const GLfloat* ptr)
|
||||
{
|
||||
if (!ValidateAttribArraySetter("VertexAttrib3fv", 3, arrayLength))
|
||||
return;
|
||||
@ -156,15 +157,15 @@ WebGLContext::VertexAttrib3fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
mVertexAttrib0Vector[0] = ptr[0];
|
||||
mVertexAttrib0Vector[1] = ptr[1];
|
||||
mVertexAttrib0Vector[2] = ptr[2];
|
||||
mVertexAttrib0Vector[3] = WebGLfloat(1);
|
||||
mVertexAttrib0Vector[3] = GLfloat(1);
|
||||
if (gl->IsGLES2())
|
||||
gl->fVertexAttrib3fv(idx, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib4fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
const WebGLfloat* ptr)
|
||||
WebGLContext::VertexAttrib4fv_base(GLuint idx, uint32_t arrayLength,
|
||||
const GLfloat* ptr)
|
||||
{
|
||||
if (!ValidateAttribArraySetter("VertexAttrib4fv", 4, arrayLength))
|
||||
return;
|
||||
@ -183,9 +184,9 @@ WebGLContext::VertexAttrib4fv_base(WebGLuint idx, uint32_t arrayLength,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::EnableVertexAttribArray(WebGLuint index)
|
||||
WebGLContext::EnableVertexAttribArray(GLuint index)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
|
||||
@ -199,9 +200,9 @@ WebGLContext::EnableVertexAttribArray(WebGLuint index)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::DisableVertexAttribArray(WebGLuint index)
|
||||
WebGLContext::DisableVertexAttribArray(GLuint index)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
|
||||
@ -218,10 +219,10 @@ WebGLContext::DisableVertexAttribArray(WebGLuint index)
|
||||
|
||||
|
||||
JS::Value
|
||||
WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
|
||||
WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
if (!mBoundVertexArray->EnsureAttribIndex(index, "getVertexAttrib"))
|
||||
@ -271,7 +272,7 @@ WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
|
||||
|
||||
case LOCAL_GL_CURRENT_VERTEX_ATTRIB:
|
||||
{
|
||||
WebGLfloat vec[4] = {0, 0, 0, 1};
|
||||
GLfloat vec[4] = {0, 0, 0, 1};
|
||||
if (index) {
|
||||
gl->fGetVertexAttribfv(index, LOCAL_GL_CURRENT_VERTEX_ATTRIB, &vec[0]);
|
||||
} else {
|
||||
@ -307,9 +308,9 @@ WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
|
||||
}
|
||||
|
||||
WebGLsizeiptr
|
||||
WebGLContext::GetVertexAttribOffset(WebGLuint index, WebGLenum pname)
|
||||
WebGLContext::GetVertexAttribOffset(GLuint index, GLenum pname)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return 0;
|
||||
|
||||
if (!ValidateAttribIndex(index, "getVertexAttribOffset"))
|
||||
@ -324,17 +325,17 @@ WebGLContext::GetVertexAttribOffset(WebGLuint index, WebGLenum pname)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttribPointer(WebGLuint index, WebGLint size, WebGLenum type,
|
||||
WebGLboolean normalized, WebGLsizei stride,
|
||||
WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
||||
WebGLboolean normalized, GLsizei stride,
|
||||
WebGLintptr byteOffset)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (mBoundArrayBuffer == nullptr)
|
||||
return ErrorInvalidOperation("vertexAttribPointer: must have valid GL_ARRAY_BUFFER binding");
|
||||
|
||||
WebGLsizei requiredAlignment = 1;
|
||||
GLsizei requiredAlignment = 1;
|
||||
switch (type) {
|
||||
case LOCAL_GL_BYTE:
|
||||
case LOCAL_GL_UNSIGNED_BYTE:
|
||||
@ -353,7 +354,7 @@ WebGLContext::VertexAttribPointer(WebGLuint index, WebGLint size, WebGLenum type
|
||||
}
|
||||
|
||||
// requiredAlignment should always be a power of two.
|
||||
WebGLsizei requiredAlignmentMask = requiredAlignment - 1;
|
||||
GLsizei requiredAlignmentMask = requiredAlignment - 1;
|
||||
|
||||
if ( !mBoundVertexArray->EnsureAttribIndex(index, "vertexAttribPointer") ) {
|
||||
return;
|
||||
@ -403,9 +404,9 @@ WebGLContext::VertexAttribPointer(WebGLuint index, WebGLint size, WebGLenum type
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttribDivisor(WebGLuint index, WebGLuint divisor)
|
||||
WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if ( !mBoundVertexArray->EnsureAttribIndex(index, "vertexAttribDivisor") ) {
|
||||
@ -422,7 +423,7 @@ WebGLContext::VertexAttribDivisor(WebGLuint index, WebGLuint divisor)
|
||||
gl->fVertexAttribDivisor(index, divisor);
|
||||
}
|
||||
|
||||
bool WebGLContext::DrawArrays_check(WebGLint first, WebGLsizei count, WebGLsizei primcount, const char* info)
|
||||
bool WebGLContext::DrawArrays_check(GLint first, GLsizei count, GLsizei primcount, const char* info)
|
||||
{
|
||||
if (first < 0 || count < 0) {
|
||||
ErrorInvalidValue("%s: negative first or count", info);
|
||||
@ -498,9 +499,9 @@ bool WebGLContext::DrawArrays_check(WebGLint first, WebGLsizei count, WebGLsizei
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::DrawArrays(GLenum mode, WebGLint first, WebGLsizei count)
|
||||
WebGLContext::DrawArrays(GLenum mode, GLint first, GLsizei count)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateDrawModeEnum(mode, "drawArrays: mode"))
|
||||
@ -516,9 +517,9 @@ WebGLContext::DrawArrays(GLenum mode, WebGLint first, WebGLsizei count)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::DrawArraysInstanced(GLenum mode, WebGLint first, WebGLsizei count, WebGLsizei primcount)
|
||||
WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateDrawModeEnum(mode, "drawArraysInstanced: mode"))
|
||||
@ -534,7 +535,7 @@ WebGLContext::DrawArraysInstanced(GLenum mode, WebGLint first, WebGLsizei count,
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::DrawElements_check(WebGLsizei count, WebGLenum type, WebGLintptr byteOffset, WebGLsizei primcount, const char* info)
|
||||
WebGLContext::DrawElements_check(GLsizei count, GLenum type, WebGLintptr byteOffset, GLsizei primcount, const char* info)
|
||||
{
|
||||
if (count < 0 || byteOffset < 0) {
|
||||
ErrorInvalidValue("%s: negative count or offset", info);
|
||||
@ -557,7 +558,7 @@ WebGLContext::DrawElements_check(WebGLsizei count, WebGLenum type, WebGLintptr b
|
||||
|
||||
CheckedUint32 checked_byteCount;
|
||||
|
||||
WebGLsizei first = 0;
|
||||
GLsizei first = 0;
|
||||
|
||||
if (type == LOCAL_GL_UNSIGNED_SHORT) {
|
||||
checked_byteCount = 2 * CheckedUint32(count);
|
||||
@ -662,10 +663,10 @@ WebGLContext::DrawElements_check(WebGLsizei count, WebGLenum type, WebGLintptr b
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::DrawElements(WebGLenum mode, WebGLsizei count, WebGLenum type,
|
||||
WebGLContext::DrawElements(GLenum mode, GLsizei count, GLenum type,
|
||||
WebGLintptr byteOffset)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateDrawModeEnum(mode, "drawElements: mode"))
|
||||
@ -681,10 +682,10 @@ WebGLContext::DrawElements(WebGLenum mode, WebGLsizei count, WebGLenum type,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::DrawElementsInstanced(WebGLenum mode, WebGLsizei count, WebGLenum type,
|
||||
WebGLintptr byteOffset, WebGLsizei primcount)
|
||||
WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
|
||||
WebGLintptr byteOffset, GLsizei primcount)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateDrawModeEnum(mode, "drawElementsInstanced: mode"))
|
||||
|
@ -20,10 +20,5 @@ WebGLExtensionBase::~WebGLExtensionBase()
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLExtensionBase)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLExtensionBase)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLExtensionBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLExtensionBase)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLExtensionBase, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLExtensionBase, Release)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "WebGLTexture.h"
|
||||
#include "WebGLRenderbuffer.h"
|
||||
#include "WebGLFramebuffer.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLExtensions.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -21,22 +22,22 @@ WebGLExtensionInstancedArrays::~WebGLExtensionInstancedArrays()
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(WebGLenum mode, WebGLint first,
|
||||
WebGLsizei count, WebGLsizei primcount)
|
||||
WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(GLenum mode, GLint first,
|
||||
GLsizei count, GLsizei primcount)
|
||||
{
|
||||
mContext->DrawArraysInstanced(mode, first, count, primcount);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(WebGLenum mode, WebGLsizei count,
|
||||
WebGLenum type, WebGLintptr offset,
|
||||
WebGLsizei primcount)
|
||||
WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(GLenum mode, GLsizei count,
|
||||
GLenum type, WebGLintptr offset,
|
||||
GLsizei primcount)
|
||||
{
|
||||
mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(WebGLuint index, WebGLuint divisor)
|
||||
WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index, GLuint divisor)
|
||||
{
|
||||
mContext->VertexAttribDivisor(index, divisor);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "WebGLVertexArray.h"
|
||||
#include "WebGLExtensions.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -11,9 +11,8 @@ namespace mozilla {
|
||||
class WebGLContext;
|
||||
|
||||
class WebGLExtensionBase
|
||||
: public nsISupports
|
||||
: public nsWrapperCache
|
||||
, public WebGLContextBoundObject
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
WebGLExtensionBase(WebGLContext*);
|
||||
@ -23,8 +22,8 @@ public:
|
||||
return Context();
|
||||
}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLExtensionBase)
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLExtensionBase)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLExtensionBase)
|
||||
};
|
||||
|
||||
#define DECL_WEBGL_EXTENSION_GOOP \
|
||||
@ -196,12 +195,12 @@ public:
|
||||
WebGLExtensionInstancedArrays(WebGLContext* context);
|
||||
virtual ~WebGLExtensionInstancedArrays();
|
||||
|
||||
void DrawArraysInstancedANGLE(WebGLenum mode, WebGLint first,
|
||||
WebGLsizei count, WebGLsizei primcount);
|
||||
void DrawElementsInstancedANGLE(WebGLenum mode, WebGLsizei count,
|
||||
WebGLenum type, WebGLintptr offset,
|
||||
WebGLsizei primcount);
|
||||
void VertexAttribDivisorANGLE(WebGLuint index, WebGLuint divisor);
|
||||
void DrawArraysInstancedANGLE(GLenum mode, GLint first,
|
||||
GLsizei count, GLsizei primcount);
|
||||
void DrawElementsInstancedANGLE(GLenum mode, GLsizei count,
|
||||
GLenum type, WebGLintptr offset,
|
||||
GLsizei primcount);
|
||||
void VertexAttribDivisorANGLE(GLuint index, GLuint divisor);
|
||||
|
||||
static bool IsSupported(const WebGLContext* context);
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "WebGLTexture.h"
|
||||
#include "WebGLRenderbuffer.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -44,7 +45,7 @@ WebGLFramebuffer::Attachment::IsDeleteRequested() const {
|
||||
|
||||
bool
|
||||
WebGLFramebuffer::Attachment::HasAlpha() const {
|
||||
WebGLenum format = 0;
|
||||
GLenum format = 0;
|
||||
if (Texture() && Texture()->HasImageInfoAt(mTextureLevel, mTextureCubeMapFace))
|
||||
format = Texture()->ImageInfoAt(mTextureLevel, mTextureCubeMapFace).Format();
|
||||
else if (Renderbuffer())
|
||||
@ -57,7 +58,7 @@ WebGLFramebuffer::Attachment::HasAlpha() const {
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::Attachment::SetTexture(WebGLTexture *tex, WebGLint level, WebGLenum face) {
|
||||
WebGLFramebuffer::Attachment::SetTexture(WebGLTexture *tex, GLint level, GLenum face) {
|
||||
mTexturePtr = tex;
|
||||
mRenderbufferPtr = nullptr;
|
||||
mTextureLevel = level;
|
||||
@ -101,7 +102,7 @@ WebGLFramebuffer::Attachment::IsComplete() const {
|
||||
if (!mTexturePtr->HasImageInfoAt(0, 0))
|
||||
return false;
|
||||
|
||||
WebGLenum format = mTexturePtr->ImageInfoAt(0).Format();
|
||||
GLenum format = mTexturePtr->ImageInfoAt(0).Format();
|
||||
|
||||
if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT) {
|
||||
return format == LOCAL_GL_DEPTH_COMPONENT;
|
||||
@ -110,7 +111,7 @@ WebGLFramebuffer::Attachment::IsComplete() const {
|
||||
return format == LOCAL_GL_DEPTH_STENCIL;
|
||||
}
|
||||
else if (mAttachmentPoint >= LOCAL_GL_COLOR_ATTACHMENT0 &&
|
||||
mAttachmentPoint < WebGLenum(LOCAL_GL_COLOR_ATTACHMENT0 + WebGLContext::sMaxColorAttachments)) {
|
||||
mAttachmentPoint < GLenum(LOCAL_GL_COLOR_ATTACHMENT0 + WebGLContext::sMaxColorAttachments)) {
|
||||
return (format == LOCAL_GL_ALPHA ||
|
||||
format == LOCAL_GL_LUMINANCE ||
|
||||
format == LOCAL_GL_LUMINANCE_ALPHA ||
|
||||
@ -121,7 +122,7 @@ WebGLFramebuffer::Attachment::IsComplete() const {
|
||||
}
|
||||
|
||||
if (mRenderbufferPtr) {
|
||||
WebGLenum format = mRenderbufferPtr->InternalFormat();
|
||||
GLenum format = mRenderbufferPtr->InternalFormat();
|
||||
|
||||
if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT) {
|
||||
return format == LOCAL_GL_DEPTH_COMPONENT16;
|
||||
@ -133,7 +134,7 @@ WebGLFramebuffer::Attachment::IsComplete() const {
|
||||
return format == LOCAL_GL_DEPTH_STENCIL;
|
||||
}
|
||||
else if (mAttachmentPoint >= LOCAL_GL_COLOR_ATTACHMENT0 &&
|
||||
mAttachmentPoint < WebGLenum(LOCAL_GL_COLOR_ATTACHMENT0 + WebGLContext::sMaxColorAttachments)) {
|
||||
mAttachmentPoint < GLenum(LOCAL_GL_COLOR_ATTACHMENT0 + WebGLContext::sMaxColorAttachments)) {
|
||||
return (format == LOCAL_GL_RGB565 ||
|
||||
format == LOCAL_GL_RGB5_A1 ||
|
||||
format == LOCAL_GL_RGBA4);
|
||||
@ -157,9 +158,9 @@ WebGLFramebuffer::Delete() {
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::FramebufferRenderbuffer(WebGLenum target,
|
||||
WebGLenum attachment,
|
||||
WebGLenum rbtarget,
|
||||
WebGLFramebuffer::FramebufferRenderbuffer(GLenum target,
|
||||
GLenum attachment,
|
||||
GLenum rbtarget,
|
||||
WebGLRenderbuffer *wrb)
|
||||
{
|
||||
MOZ_ASSERT(mContext->mBoundFramebuffer == this);
|
||||
@ -197,10 +198,10 @@ WebGLFramebuffer::FramebufferRenderbuffer(WebGLenum target,
|
||||
}
|
||||
|
||||
mContext->MakeContextCurrent();
|
||||
WebGLuint parambuffername = wrb ? wrb->GLName() : 0;
|
||||
GLuint parambuffername = wrb ? wrb->GLName() : 0;
|
||||
if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
WebGLuint depthbuffername = parambuffername;
|
||||
WebGLuint stencilbuffername = parambuffername;
|
||||
GLuint depthbuffername = parambuffername;
|
||||
GLuint stencilbuffername = parambuffername;
|
||||
if (!parambuffername){
|
||||
depthbuffername = mDepthAttachment.Renderbuffer() ? mDepthAttachment.Renderbuffer()->GLName() : 0;
|
||||
stencilbuffername = mStencilAttachment.Renderbuffer() ? mStencilAttachment.Renderbuffer()->GLName() : 0;
|
||||
@ -208,7 +209,7 @@ WebGLFramebuffer::FramebufferRenderbuffer(WebGLenum target,
|
||||
mContext->gl->fFramebufferRenderbuffer(target, LOCAL_GL_DEPTH_ATTACHMENT, rbtarget, depthbuffername);
|
||||
mContext->gl->fFramebufferRenderbuffer(target, LOCAL_GL_STENCIL_ATTACHMENT, rbtarget, stencilbuffername);
|
||||
} else {
|
||||
WebGLuint renderbuffername = parambuffername;
|
||||
GLuint renderbuffername = parambuffername;
|
||||
if(!parambuffername && (attachment == LOCAL_GL_DEPTH_ATTACHMENT || attachment == LOCAL_GL_STENCIL_ATTACHMENT)){
|
||||
renderbuffername = mDepthStencilAttachment.Renderbuffer() ? mDepthStencilAttachment.Renderbuffer()->GLName() : 0;
|
||||
}
|
||||
@ -217,11 +218,11 @@ WebGLFramebuffer::FramebufferRenderbuffer(WebGLenum target,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::FramebufferTexture2D(WebGLenum target,
|
||||
WebGLenum attachment,
|
||||
WebGLenum textarget,
|
||||
WebGLFramebuffer::FramebufferTexture2D(GLenum target,
|
||||
GLenum attachment,
|
||||
GLenum textarget,
|
||||
WebGLTexture *wtex,
|
||||
WebGLint level)
|
||||
GLint level)
|
||||
{
|
||||
MOZ_ASSERT(mContext->mBoundFramebuffer == this);
|
||||
if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture",
|
||||
@ -264,10 +265,10 @@ WebGLFramebuffer::FramebufferTexture2D(WebGLenum target,
|
||||
}
|
||||
|
||||
mContext->MakeContextCurrent();
|
||||
WebGLuint paramtexturename = wtex ? wtex->GLName() : 0;
|
||||
GLuint paramtexturename = wtex ? wtex->GLName() : 0;
|
||||
if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
WebGLuint depthtexturename = paramtexturename;
|
||||
WebGLuint stenciltexturename = paramtexturename;
|
||||
GLuint depthtexturename = paramtexturename;
|
||||
GLuint stenciltexturename = paramtexturename;
|
||||
if(!paramtexturename){
|
||||
depthtexturename = mDepthAttachment.Texture() ? mDepthAttachment.Texture()->GLName() : 0;
|
||||
stenciltexturename = mStencilAttachment.Texture() ? mStencilAttachment.Texture()->GLName() : 0;
|
||||
@ -275,7 +276,7 @@ WebGLFramebuffer::FramebufferTexture2D(WebGLenum target,
|
||||
mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_DEPTH_ATTACHMENT, textarget, depthtexturename, level);
|
||||
mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_STENCIL_ATTACHMENT, textarget, stenciltexturename, level);
|
||||
} else {
|
||||
WebGLuint texturename = paramtexturename;
|
||||
GLuint texturename = paramtexturename;
|
||||
if(!paramtexturename && (attachment == LOCAL_GL_DEPTH_ATTACHMENT || attachment == LOCAL_GL_STENCIL_ATTACHMENT)){
|
||||
texturename = mDepthStencilAttachment.Texture() ? mDepthStencilAttachment.Texture()->GLName() : 0;
|
||||
}
|
||||
@ -320,7 +321,7 @@ WebGLFramebuffer::HasAttachmentsOfMismatchedDimensions() const {
|
||||
}
|
||||
|
||||
const WebGLFramebuffer::Attachment&
|
||||
WebGLFramebuffer::GetAttachment(WebGLenum attachment) const {
|
||||
WebGLFramebuffer::GetAttachment(GLenum attachment) const {
|
||||
if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT)
|
||||
return mDepthStencilAttachment;
|
||||
if (attachment == LOCAL_GL_DEPTH_ATTACHMENT)
|
||||
@ -420,7 +421,7 @@ WebGLFramebuffer::CheckAndInitializeRenderbuffers()
|
||||
|
||||
mContext->MakeContextCurrent();
|
||||
|
||||
WebGLenum status = mContext->CheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
||||
GLenum status = mContext->CheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
||||
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE)
|
||||
return false;
|
||||
|
||||
@ -471,14 +472,14 @@ WebGLFramebuffer::CheckAndInitializeRenderbuffers()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebGLFramebuffer::CheckColorAttachementNumber(WebGLenum attachment, const char * functionName) const
|
||||
bool WebGLFramebuffer::CheckColorAttachementNumber(GLenum attachment, const char * functionName) const
|
||||
{
|
||||
const char* const errorFormating = "%s: attachment: invalid enum value 0x%x";
|
||||
|
||||
if (mContext->IsExtensionEnabled(WebGLContext::WEBGL_draw_buffers))
|
||||
{
|
||||
if (attachment < LOCAL_GL_COLOR_ATTACHMENT0 ||
|
||||
attachment > WebGLenum(LOCAL_GL_COLOR_ATTACHMENT0 + mContext->mGLMaxColorAttachments))
|
||||
attachment > GLenum(LOCAL_GL_COLOR_ATTACHMENT0 + mContext->mGLMaxColorAttachments))
|
||||
{
|
||||
mContext->ErrorInvalidEnum(errorFormating, functionName, attachment);
|
||||
return false;
|
||||
|
@ -35,11 +35,11 @@ public:
|
||||
// deleting a texture or renderbuffer immediately detaches it
|
||||
WebGLRefPtr<WebGLTexture> mTexturePtr;
|
||||
WebGLRefPtr<WebGLRenderbuffer> mRenderbufferPtr;
|
||||
WebGLenum mAttachmentPoint;
|
||||
WebGLint mTextureLevel;
|
||||
WebGLenum mTextureCubeMapFace;
|
||||
GLenum mAttachmentPoint;
|
||||
GLint mTextureLevel;
|
||||
GLenum mTextureCubeMapFace;
|
||||
|
||||
Attachment(WebGLenum aAttachmentPoint = LOCAL_GL_COLOR_ATTACHMENT0)
|
||||
Attachment(GLenum aAttachmentPoint = LOCAL_GL_COLOR_ATTACHMENT0)
|
||||
: mAttachmentPoint(aAttachmentPoint)
|
||||
{}
|
||||
|
||||
@ -51,7 +51,7 @@ public:
|
||||
|
||||
bool HasAlpha() const;
|
||||
|
||||
void SetTexture(WebGLTexture *tex, WebGLint level, WebGLenum face);
|
||||
void SetTexture(WebGLTexture *tex, GLint level, GLenum face);
|
||||
void SetRenderbuffer(WebGLRenderbuffer *rb) {
|
||||
mTexturePtr = nullptr;
|
||||
mRenderbufferPtr = rb;
|
||||
@ -68,10 +68,10 @@ public:
|
||||
WebGLRenderbuffer *Renderbuffer() {
|
||||
return mRenderbufferPtr;
|
||||
}
|
||||
WebGLint TextureLevel() const {
|
||||
GLint TextureLevel() const {
|
||||
return mTextureLevel;
|
||||
}
|
||||
WebGLenum TextureCubeMapFace() const {
|
||||
GLenum TextureCubeMapFace() const {
|
||||
return mTextureCubeMapFace;
|
||||
}
|
||||
|
||||
@ -92,18 +92,18 @@ public:
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
|
||||
WebGLuint GLName() { return mGLName; }
|
||||
GLuint GLName() { return mGLName; }
|
||||
|
||||
void FramebufferRenderbuffer(WebGLenum target,
|
||||
WebGLenum attachment,
|
||||
WebGLenum rbtarget,
|
||||
void FramebufferRenderbuffer(GLenum target,
|
||||
GLenum attachment,
|
||||
GLenum rbtarget,
|
||||
WebGLRenderbuffer *wrb);
|
||||
|
||||
void FramebufferTexture2D(WebGLenum target,
|
||||
WebGLenum attachment,
|
||||
WebGLenum textarget,
|
||||
void FramebufferTexture2D(GLenum target,
|
||||
GLenum attachment,
|
||||
GLenum textarget,
|
||||
WebGLTexture *wtex,
|
||||
WebGLint level);
|
||||
GLint level);
|
||||
|
||||
bool HasIncompleteAttachment() const;
|
||||
|
||||
@ -131,7 +131,7 @@ public:
|
||||
return mDepthStencilAttachment;
|
||||
}
|
||||
|
||||
const Attachment& GetAttachment(WebGLenum attachment) const;
|
||||
const Attachment& GetAttachment(GLenum attachment) const;
|
||||
|
||||
void DetachTexture(const WebGLTexture *tex);
|
||||
|
||||
@ -153,9 +153,9 @@ public:
|
||||
|
||||
bool CheckAndInitializeRenderbuffers();
|
||||
|
||||
bool CheckColorAttachementNumber(WebGLenum attachment, const char * functionName) const;
|
||||
bool CheckColorAttachementNumber(GLenum attachment, const char * functionName) const;
|
||||
|
||||
WebGLuint mGLName;
|
||||
GLuint mGLName;
|
||||
bool mHasEverBeenBound;
|
||||
|
||||
void EnsureColorAttachments(size_t colorAttachmentId);
|
||||
|
@ -280,16 +280,16 @@ public:
|
||||
WebGLRectangleObject()
|
||||
: mWidth(0), mHeight(0) { }
|
||||
|
||||
WebGLRectangleObject(WebGLsizei width, WebGLsizei height)
|
||||
WebGLRectangleObject(GLsizei width, GLsizei height)
|
||||
: mWidth(width), mHeight(height) { }
|
||||
|
||||
WebGLsizei Width() const { return mWidth; }
|
||||
void width(WebGLsizei value) { mWidth = value; }
|
||||
GLsizei Width() const { return mWidth; }
|
||||
void width(GLsizei value) { mWidth = value; }
|
||||
|
||||
WebGLsizei Height() const { return mHeight; }
|
||||
void height(WebGLsizei value) { mHeight = value; }
|
||||
GLsizei Height() const { return mHeight; }
|
||||
void height(GLsizei value) { mHeight = value; }
|
||||
|
||||
void setDimensions(WebGLsizei width, WebGLsizei height) {
|
||||
void setDimensions(GLsizei width, GLsizei height) {
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
}
|
||||
@ -309,8 +309,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
WebGLsizei mWidth;
|
||||
WebGLsizei mHeight;
|
||||
GLsizei mWidth;
|
||||
GLsizei mHeight;
|
||||
};
|
||||
|
||||
}// namespace mozilla
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "WebGLShader.h"
|
||||
#include "WebGLProgram.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include <map>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -40,7 +41,7 @@ public:
|
||||
mAttachedShaders.Clear();
|
||||
}
|
||||
|
||||
WebGLuint GLName() { return mGLName; }
|
||||
GLuint GLName() { return mGLName; }
|
||||
const nsTArray<WebGLRefPtr<WebGLShader> >& AttachedShaders() const { return mAttachedShaders; }
|
||||
bool LinkStatus() { return mLinkStatus; }
|
||||
uint32_t Generation() const { return mGeneration.value(); }
|
||||
@ -114,7 +115,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
WebGLuint mGLName;
|
||||
GLuint mGLName;
|
||||
bool mLinkStatus;
|
||||
// attached shaders of the program object
|
||||
nsTArray<WebGLRefPtr<WebGLShader> > mAttachedShaders;
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "GLContext.h"
|
||||
#include "WebGLQuery.h"
|
||||
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -33,13 +34,17 @@ void WebGLQuery::Delete() {
|
||||
LinkedListElement<WebGLQuery>::removeFrom(mContext->mQueries);
|
||||
}
|
||||
|
||||
bool WebGLQuery::IsActive() const
|
||||
{
|
||||
WebGLRefPtr<WebGLQuery>* targetSlot = mContext->GetQueryTargetSlot(mType, "WebGLQuery::IsActive()");
|
||||
|
||||
MOZ_ASSERT(targetSlot, "unknown query object's type");
|
||||
|
||||
return *targetSlot == this;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLQuery)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLQuery)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLQuery)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLQuery)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLQuery, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLQuery, Release)
|
||||
|
@ -7,7 +7,6 @@
|
||||
#define WEBGLQUERY_H_
|
||||
|
||||
#include "WebGLObjectModel.h"
|
||||
#include "WebGLContext.h"
|
||||
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
@ -16,11 +15,10 @@
|
||||
namespace mozilla {
|
||||
|
||||
class WebGLQuery MOZ_FINAL
|
||||
: public nsISupports
|
||||
: public nsWrapperCache
|
||||
, public WebGLRefCountedObject<WebGLQuery>
|
||||
, public LinkedListElement<WebGLQuery>
|
||||
, public WebGLContextBoundObject
|
||||
, public nsWrapperCache
|
||||
{
|
||||
// -----------------------------------------------------------------------------
|
||||
// PUBLIC
|
||||
@ -39,14 +37,7 @@ public:
|
||||
// -------------------------------------------------------------------------
|
||||
// MEMBER FUNCTIONS
|
||||
|
||||
bool IsActive() const
|
||||
{
|
||||
WebGLRefPtr<WebGLQuery>* targetSlot = mContext->GetQueryTargetSlot(mType, "WebGLQuery::IsActive()");
|
||||
|
||||
MOZ_ASSERT(targetSlot, "unknown query object's type");
|
||||
|
||||
return *targetSlot == this;
|
||||
}
|
||||
bool IsActive() const;
|
||||
|
||||
bool HasEverBeenActive()
|
||||
{
|
||||
@ -70,8 +61,8 @@ public:
|
||||
virtual JSObject* WrapObject(JSContext *cx,
|
||||
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLQuery)
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLQuery)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLQuery)
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -80,8 +71,8 @@ private:
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// MEMBERS
|
||||
WebGLuint mGLName;
|
||||
WebGLenum mType;
|
||||
GLuint mGLName;
|
||||
GLenum mType;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// FRIENDSHIPS
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "WebGLRenderbuffer.h"
|
||||
#include "WebGLTexture.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -32,16 +32,16 @@ public:
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
|
||||
WebGLuint GLName() const { return mGLName; }
|
||||
GLuint GLName() const { return mGLName; }
|
||||
|
||||
bool Initialized() const { return mInitialized; }
|
||||
void SetInitialized(bool aInitialized) { mInitialized = aInitialized; }
|
||||
|
||||
WebGLenum InternalFormat() const { return mInternalFormat; }
|
||||
void SetInternalFormat(WebGLenum aInternalFormat) { mInternalFormat = aInternalFormat; }
|
||||
GLenum InternalFormat() const { return mInternalFormat; }
|
||||
void SetInternalFormat(GLenum aInternalFormat) { mInternalFormat = aInternalFormat; }
|
||||
|
||||
WebGLenum InternalFormatForGL() const { return mInternalFormatForGL; }
|
||||
void SetInternalFormatForGL(WebGLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; }
|
||||
GLenum InternalFormatForGL() const { return mInternalFormatForGL; }
|
||||
void SetInternalFormatForGL(GLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; }
|
||||
|
||||
int64_t MemoryUsage() const;
|
||||
|
||||
@ -57,9 +57,9 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
WebGLuint mGLName;
|
||||
WebGLenum mInternalFormat;
|
||||
WebGLenum mInternalFormatForGL;
|
||||
GLuint mGLName;
|
||||
GLenum mInternalFormat;
|
||||
GLenum mInternalFormatForGL;
|
||||
bool mHasEverBeenBound;
|
||||
bool mInitialized;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "WebGLContext.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -16,7 +17,7 @@ WebGLShader::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
|
||||
return dom::WebGLShaderBinding::Wrap(cx, scope, this);
|
||||
}
|
||||
|
||||
WebGLShader::WebGLShader(WebGLContext *context, WebGLenum stype)
|
||||
WebGLShader::WebGLShader(WebGLContext *context, GLenum stype)
|
||||
: WebGLContextBoundObject(context)
|
||||
, mType(stype)
|
||||
, mNeedsTranslation(true)
|
||||
|
@ -33,7 +33,7 @@ class WebGLShader MOZ_FINAL
|
||||
friend class WebGLProgram;
|
||||
|
||||
public:
|
||||
WebGLShader(WebGLContext *context, WebGLenum stype);
|
||||
WebGLShader(WebGLContext *context, GLenum stype);
|
||||
|
||||
~WebGLShader() {
|
||||
DeleteOnce();
|
||||
@ -41,8 +41,8 @@ public:
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
WebGLuint GLName() { return mGLName; }
|
||||
WebGLenum ShaderType() { return mType; }
|
||||
GLuint GLName() { return mGLName; }
|
||||
GLenum ShaderType() { return mType; }
|
||||
|
||||
void SetSource(const nsAString& src) {
|
||||
// XXX do some quick gzip here maybe -- getting this will be very rare
|
||||
@ -84,8 +84,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
WebGLuint mGLName;
|
||||
WebGLenum mType;
|
||||
GLuint mGLName;
|
||||
GLenum mType;
|
||||
nsString mSource;
|
||||
nsCString mTranslationLog; // The translation log should contain only ASCII characters
|
||||
bool mNeedsTranslation;
|
||||
|
@ -16,7 +16,7 @@ class WebGLShaderPrecisionFormat MOZ_FINAL
|
||||
: public WebGLContextBoundObject
|
||||
{
|
||||
public:
|
||||
WebGLShaderPrecisionFormat(WebGLContext *context, WebGLint rangeMin, WebGLint rangeMax, WebGLint precision) :
|
||||
WebGLShaderPrecisionFormat(WebGLContext *context, GLint rangeMin, GLint rangeMax, GLint precision) :
|
||||
WebGLContextBoundObject(context),
|
||||
mRangeMin(rangeMin),
|
||||
mRangeMax(rangeMax),
|
||||
@ -27,22 +27,22 @@ public:
|
||||
JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
|
||||
|
||||
// WebIDL WebGLShaderPrecisionFormat API
|
||||
WebGLint RangeMin() const {
|
||||
GLint RangeMin() const {
|
||||
return mRangeMin;
|
||||
}
|
||||
WebGLint RangeMax() const {
|
||||
GLint RangeMax() const {
|
||||
return mRangeMax;
|
||||
}
|
||||
WebGLint Precision() const {
|
||||
GLint Precision() const {
|
||||
return mPrecision;
|
||||
}
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(WebGLShaderPrecisionFormat)
|
||||
|
||||
protected:
|
||||
WebGLint mRangeMin;
|
||||
WebGLint mRangeMax;
|
||||
WebGLint mPrecision;
|
||||
GLint mRangeMin;
|
||||
GLint mRangeMax;
|
||||
GLint mPrecision;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLTexture.h"
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include <algorithm>
|
||||
|
||||
@ -102,7 +103,7 @@ WebGLTexture::SetDontKnowIfNeedFakeBlack() {
|
||||
}
|
||||
|
||||
void
|
||||
WebGLTexture::Bind(WebGLenum aTarget) {
|
||||
WebGLTexture::Bind(GLenum aTarget) {
|
||||
// this function should only be called by bindTexture().
|
||||
// it assumes that the GL context is already current.
|
||||
|
||||
@ -135,9 +136,9 @@ WebGLTexture::Bind(WebGLenum aTarget) {
|
||||
}
|
||||
|
||||
void
|
||||
WebGLTexture::SetImageInfo(WebGLenum aTarget, WebGLint aLevel,
|
||||
WebGLsizei aWidth, WebGLsizei aHeight,
|
||||
WebGLenum aFormat, WebGLenum aType)
|
||||
WebGLTexture::SetImageInfo(GLenum aTarget, GLint aLevel,
|
||||
GLsizei aWidth, GLsizei aHeight,
|
||||
GLenum aFormat, GLenum aType)
|
||||
{
|
||||
if ( (aTarget == LOCAL_GL_TEXTURE_2D) != (mTarget == LOCAL_GL_TEXTURE_2D) )
|
||||
return;
|
||||
@ -173,11 +174,11 @@ WebGLTexture::SetCustomMipmap() {
|
||||
ImageInfo imageInfo = ImageInfoAt(0, 0);
|
||||
NS_ASSERTION(imageInfo.IsPowerOfTwo(), "this texture is NPOT, so how could GenerateMipmap() ever accept it?");
|
||||
|
||||
WebGLsizei size = std::max(imageInfo.mWidth, imageInfo.mHeight);
|
||||
GLsizei size = std::max(imageInfo.mWidth, imageInfo.mHeight);
|
||||
|
||||
// so, the size is a power of two, let's find its log in base 2.
|
||||
size_t maxLevel = 0;
|
||||
for (WebGLsizei n = size; n > 1; n >>= 1)
|
||||
for (GLsizei n = size; n > 1; n >>= 1)
|
||||
++maxLevel;
|
||||
|
||||
EnsureMaxLevelWithCustomImagesAtLeast(maxLevel);
|
||||
|
@ -16,7 +16,7 @@
|
||||
namespace mozilla {
|
||||
|
||||
// Zero is not an integer power of two.
|
||||
inline bool is_pot_assuming_nonnegative(WebGLsizei x)
|
||||
inline bool is_pot_assuming_nonnegative(GLsizei x)
|
||||
{
|
||||
return x && (x & (x-1)) == 0;
|
||||
}
|
||||
@ -40,7 +40,7 @@ public:
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
|
||||
WebGLuint GLName() { return mGLName; }
|
||||
GLuint GLName() { return mGLName; }
|
||||
GLenum Target() const { return mTarget; }
|
||||
|
||||
WebGLContext *GetParentObject() const {
|
||||
@ -59,7 +59,7 @@ protected:
|
||||
friend class WebGLFramebuffer;
|
||||
|
||||
bool mHasEverBeenBound;
|
||||
WebGLuint mGLName;
|
||||
GLuint mGLName;
|
||||
|
||||
// we store information about the various images that are part of
|
||||
// this texture (cubemap faces, mipmap levels)
|
||||
@ -74,8 +74,8 @@ public:
|
||||
, mIsDefined(false)
|
||||
{}
|
||||
|
||||
ImageInfo(WebGLsizei width, WebGLsizei height,
|
||||
WebGLenum format, WebGLenum type)
|
||||
ImageInfo(GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type)
|
||||
: WebGLRectangleObject(width, height)
|
||||
, mFormat(format)
|
||||
, mType(type)
|
||||
@ -103,10 +103,10 @@ public:
|
||||
is_pot_assuming_nonnegative(mHeight); // negative sizes should never happen (caught in texImage2D...)
|
||||
}
|
||||
int64_t MemoryUsage() const;
|
||||
WebGLenum Format() const { return mFormat; }
|
||||
WebGLenum Type() const { return mType; }
|
||||
GLenum Format() const { return mFormat; }
|
||||
GLenum Type() const { return mType; }
|
||||
protected:
|
||||
WebGLenum mFormat, mType;
|
||||
GLenum mFormat, mType;
|
||||
bool mIsDefined;
|
||||
|
||||
friend class WebGLTexture;
|
||||
@ -132,7 +132,7 @@ public:
|
||||
ImageInfoAt(level, face).mIsDefined;
|
||||
}
|
||||
|
||||
static size_t FaceForTarget(WebGLenum target) {
|
||||
static size_t FaceForTarget(GLenum target) {
|
||||
return target == LOCAL_GL_TEXTURE_2D ? 0 : target - LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||
}
|
||||
|
||||
@ -140,8 +140,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
WebGLenum mTarget;
|
||||
WebGLenum mMinFilter, mMagFilter, mWrapS, mWrapT;
|
||||
GLenum mTarget;
|
||||
GLenum mMinFilter, mMagFilter, mWrapS, mWrapT;
|
||||
|
||||
size_t mFacesCount, mMaxLevelWithCustomImages;
|
||||
nsTArray<ImageInfo> mImageInfos;
|
||||
@ -170,29 +170,29 @@ public:
|
||||
|
||||
void SetDontKnowIfNeedFakeBlack();
|
||||
|
||||
void Bind(WebGLenum aTarget);
|
||||
void Bind(GLenum aTarget);
|
||||
|
||||
void SetImageInfo(WebGLenum aTarget, WebGLint aLevel,
|
||||
WebGLsizei aWidth, WebGLsizei aHeight,
|
||||
WebGLenum aFormat, WebGLenum aType);
|
||||
void SetImageInfo(GLenum aTarget, GLint aLevel,
|
||||
GLsizei aWidth, GLsizei aHeight,
|
||||
GLenum aFormat, GLenum aType);
|
||||
|
||||
void SetMinFilter(WebGLenum aMinFilter) {
|
||||
void SetMinFilter(GLenum aMinFilter) {
|
||||
mMinFilter = aMinFilter;
|
||||
SetDontKnowIfNeedFakeBlack();
|
||||
}
|
||||
void SetMagFilter(WebGLenum aMagFilter) {
|
||||
void SetMagFilter(GLenum aMagFilter) {
|
||||
mMagFilter = aMagFilter;
|
||||
SetDontKnowIfNeedFakeBlack();
|
||||
}
|
||||
void SetWrapS(WebGLenum aWrapS) {
|
||||
void SetWrapS(GLenum aWrapS) {
|
||||
mWrapS = aWrapS;
|
||||
SetDontKnowIfNeedFakeBlack();
|
||||
}
|
||||
void SetWrapT(WebGLenum aWrapT) {
|
||||
void SetWrapT(GLenum aWrapT) {
|
||||
mWrapT = aWrapT;
|
||||
SetDontKnowIfNeedFakeBlack();
|
||||
}
|
||||
WebGLenum MinFilter() const { return mMinFilter; }
|
||||
GLenum MinFilter() const { return mMinFilter; }
|
||||
|
||||
bool DoesMinFilterRequireMipmap() const {
|
||||
return !(mMinFilter == LOCAL_GL_NEAREST || mMinFilter == LOCAL_GL_LINEAR);
|
||||
|
@ -6,16 +6,13 @@
|
||||
#ifndef WEBGLTYPES_H_
|
||||
#define WEBGLTYPES_H_
|
||||
|
||||
// Manual reflection of WebIDL typedefs
|
||||
typedef uint32_t WebGLenum;
|
||||
typedef uint32_t WebGLbitfield;
|
||||
typedef int32_t WebGLint;
|
||||
typedef int32_t WebGLsizei;
|
||||
// Most WebIDL typedefs are identical to their OpenGL counterparts.
|
||||
#include "GLTypes.h"
|
||||
|
||||
// Manual reflection of WebIDL typedefs that are different from their
|
||||
// OpenGL counterparts.
|
||||
typedef int64_t WebGLsizeiptr;
|
||||
typedef int64_t WebGLintptr;
|
||||
typedef uint32_t WebGLuint;
|
||||
typedef float WebGLfloat;
|
||||
typedef float WebGLclampf;
|
||||
typedef bool WebGLboolean;
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "WebGLBuffer.h"
|
||||
#include "WebGLVertexArray.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -36,10 +37,10 @@ void WebGLVertexArray::Delete() {
|
||||
mAttribBuffers.Clear();
|
||||
}
|
||||
|
||||
bool WebGLVertexArray::EnsureAttribIndex(WebGLuint index, const char *info)
|
||||
bool WebGLVertexArray::EnsureAttribIndex(GLuint index, const char *info)
|
||||
{
|
||||
if (index >= WebGLuint(mContext->mGLMaxVertexAttribs)) {
|
||||
if (index == WebGLuint(-1)) {
|
||||
if (index >= GLuint(mContext->mGLMaxVertexAttribs)) {
|
||||
if (index == GLuint(-1)) {
|
||||
mContext->ErrorInvalidValue("%s: index -1 is invalid. That probably comes from a getAttribLocation() call, "
|
||||
"where this return value -1 means that the passed name didn't correspond to an active attribute in "
|
||||
"the specified program.", info);
|
||||
@ -59,10 +60,5 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(WebGLVertexArray,
|
||||
mAttribBuffers,
|
||||
mBoundElementArrayBuffer)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLVertexArray)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLVertexArray)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLVertexArray)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLVertexArray, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLVertexArray, Release)
|
||||
|
@ -17,11 +17,10 @@
|
||||
namespace mozilla {
|
||||
|
||||
class WebGLVertexArray MOZ_FINAL
|
||||
: public nsISupports
|
||||
: public nsWrapperCache
|
||||
, public WebGLRefCountedObject<WebGLVertexArray>
|
||||
, public LinkedListElement<WebGLVertexArray>
|
||||
, public WebGLContextBoundObject
|
||||
, public nsWrapperCache
|
||||
{
|
||||
// -----------------------------------------------------------------------------
|
||||
// PUBLIC
|
||||
@ -49,8 +48,8 @@ public:
|
||||
virtual JSObject* WrapObject(JSContext *cx,
|
||||
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLVertexArray)
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray)
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -58,9 +57,9 @@ public:
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
|
||||
WebGLuint GLName() const { return mGLName; }
|
||||
GLuint GLName() const { return mGLName; }
|
||||
|
||||
bool EnsureAttribIndex(WebGLuint index, const char *info);
|
||||
bool EnsureAttribIndex(GLuint index, const char *info);
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -70,7 +69,7 @@ private:
|
||||
// -------------------------------------------------------------------------
|
||||
// MEMBERS
|
||||
|
||||
WebGLuint mGLName;
|
||||
GLuint mGLName;
|
||||
bool mHasEverBeenBound;
|
||||
nsTArray<WebGLVertexAttribData> mAttribBuffers;
|
||||
WebGLRefPtr<WebGLBuffer> mBoundElementArrayBuffer;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user