This commit is contained in:
Ryan VanderMeulen 2015-08-26 14:34:15 -04:00
Родитель 4220a40a0b 813316efe8
Коммит 3e3e1cbd1d
370 изменённых файлов: 4096 добавлений и 2397 удалений

Просмотреть файл

@ -118,11 +118,11 @@ nsCoreUtils::DispatchClickEvent(nsITreeBoxObject *aTreeBoxObj,
}
void
nsCoreUtils::DispatchMouseEvent(uint32_t aEventType, int32_t aX, int32_t aY,
nsCoreUtils::DispatchMouseEvent(EventMessage aMessage, int32_t aX, int32_t aY,
nsIContent *aContent, nsIFrame *aFrame,
nsIPresShell *aPresShell, nsIWidget *aRootWidget)
{
WidgetMouseEvent event(true, aEventType, aRootWidget,
WidgetMouseEvent event(true, aMessage, aRootWidget,
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
event.refPoint = LayoutDeviceIntPoint(aX, aY);
@ -137,14 +137,14 @@ nsCoreUtils::DispatchMouseEvent(uint32_t aEventType, int32_t aX, int32_t aY,
}
void
nsCoreUtils::DispatchTouchEvent(uint32_t aEventType, int32_t aX, int32_t aY,
nsCoreUtils::DispatchTouchEvent(EventMessage aMessage, int32_t aX, int32_t aY,
nsIContent* aContent, nsIFrame* aFrame,
nsIPresShell* aPresShell, nsIWidget* aRootWidget)
{
if (!dom::TouchEvent::PrefEnabled())
return;
WidgetTouchEvent event(true, aEventType, aRootWidget);
WidgetTouchEvent event(true, aMessage, aRootWidget);
event.time = PR_IntervalNow();

Просмотреть файл

@ -6,6 +6,7 @@
#ifndef nsCoreUtils_h_
#define nsCoreUtils_h_
#include "mozilla/EventForwards.h"
#include "nsIContent.h"
#include "nsIDocument.h" // for GetShell()
#include "nsIPresShell.h"
@ -49,7 +50,7 @@ public:
/**
* Send mouse event to the given element.
*
* @param aEventType [in] an event type (see BasicEvents.h for constants)
* @param aMessage [in] an event message (see EventForwards.h)
* @param aX [in] x coordinate in dev pixels
* @param aY [in] y coordinate in dev pixels
* @param aContent [in] the element
@ -57,14 +58,15 @@ public:
* @param aPresShell [in] the presshell for the element
* @param aRootWidget [in] the root widget of the element
*/
static void DispatchMouseEvent(uint32_t aEventType, int32_t aX, int32_t aY,
static void DispatchMouseEvent(mozilla::EventMessage aMessage,
int32_t aX, int32_t aY,
nsIContent *aContent, nsIFrame *aFrame,
nsIPresShell *aPresShell, nsIWidget *aRootWidget);
/**
* Send a touch event with a single touch point to the given element.
*
* @param aEventType [in] an event type (see BasicEvents.h for constants)
* @param aMessage [in] an event message (see EventForwards.h)
* @param aX [in] x coordinate in dev pixels
* @param aY [in] y coordinate in dev pixels
* @param aContent [in] the element
@ -72,7 +74,8 @@ public:
* @param aPresShell [in] the presshell for the element
* @param aRootWidget [in] the root widget of the element
*/
static void DispatchTouchEvent(uint32_t aEventType, int32_t aX, int32_t aY,
static void DispatchTouchEvent(mozilla::EventMessage aMessage,
int32_t aX, int32_t aY,
nsIContent* aContent, nsIFrame* aFrame,
nsIPresShell* aPresShell, nsIWidget* aRootWidget);

Просмотреть файл

@ -47,6 +47,9 @@ LOCAL_INCLUDES += [
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True
include('/ipc/chromium/chromium-config.mozbuild')

Просмотреть файл

@ -62,4 +62,7 @@ include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True

Просмотреть файл

@ -21,4 +21,7 @@ LOCAL_INCLUDES += [
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True

Просмотреть файл

@ -75,6 +75,9 @@ if CONFIG['OS_ARCH'] == 'WINNT':
'version',
]
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True
JS_PREFERENCE_FILES += [

Просмотреть файл

@ -84,4 +84,7 @@ if CONFIG['HAVE_CLOCK_MONOTONIC']:
JAR_MANIFESTS += ['jar.mn']
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True

Просмотреть файл

@ -7566,6 +7566,16 @@ var TabContextMenu = {
// Hide "Move to Group" if it's a pinned tab.
document.getElementById("context_tabViewMenu").hidden =
(this.contextTab.pinned || !TabView.firstUseExperienced);
// Adjust the state of the toggle mute menu item.
let toggleMute = document.getElementById("context_toggleMuteTab");
if (this.contextTab.hasAttribute("muted")) {
toggleMute.label = gNavigatorBundle.getString("unmuteTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("unmuteTab.accesskey");
} else {
toggleMute.label = gNavigatorBundle.getString("muteTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("muteTab.accesskey");
}
}
};

Просмотреть файл

@ -83,6 +83,7 @@
onpopuphidden="if (event.target == this) TabContextMenu.contextTab = null;">
<menuitem id="context_reloadTab" label="&reloadTab.label;" accesskey="&reloadTab.accesskey;"
oncommand="gBrowser.reloadTab(TabContextMenu.contextTab);"/>
<menuitem id="context_toggleMuteTab" oncommand="TabContextMenu.contextTab.toggleMuteAudio();"/>
<menuseparator/>
<menuitem id="context_pinTab" label="&pinTab.label;"
accesskey="&pinTab.accesskey;"

Просмотреть файл

@ -76,6 +76,27 @@ function get_tab_attributes(tab) {
return attributes;
}
function* test_muting_using_menu(tab, expectMuted) {
// Show the popup menu
let contextMenu = document.getElementById("tabContextMenu");
let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
EventUtils.synthesizeMouseAtCenter(tab, {type: "contextmenu", button: 2});
yield popupShownPromise;
// Check the menu
let expectedLabel = expectMuted ? "Unmute Tab" : "Mute Tab";
let toggleMute = document.getElementById("context_toggleMuteTab");
is(toggleMute.label, expectedLabel, "Correct label expected");
is(toggleMute.accessKey, "M", "Correct accessKey expected");
// Click on the menu and wait for the tab to be muted.
let mutedPromise = get_wait_for_mute_promise(tab, !expectMuted);
let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
EventUtils.synthesizeMouseAtCenter(toggleMute, {});
yield popupHiddenPromise;
yield mutedPromise;
}
function* test_playing_icon_on_tab(tab, browser, isPinned) {
let icon = document.getAnonymousElementByAttribute(tab, "anonid",
isPinned ? "overlay-icon" : "soundplaying-icon");
@ -120,6 +141,12 @@ function* test_playing_icon_on_tab(tab, browser, isPinned) {
ok(!tab.hasAttribute("muted") &&
!tab.hasAttribute("soundplaying"), "Tab should not be be muted or playing");
// Make sure it's possible to mute using the context menu.
yield test_muting_using_menu(tab, false);
// Make sure it's possible to unmute using the context menu.
yield test_muting_using_menu(tab, true);
}
function* test_swapped_browser(oldTab, newBrowser, isPlaying) {

Просмотреть файл

@ -34,7 +34,6 @@ support-files =
plugin_test.html
plugin_test2.html
plugin_test3.html
plugin_test_w_src.html
plugin_two_types.html
plugin_unknown.html
plugin_crashCommentAndURL.html
@ -76,12 +75,6 @@ skip-if = !crashreporter
[browser_pluginCrashCommentAndURL.js]
skip-if = !crashreporter
[browser_pageInfo_plugins.js]
[browser_pluginplaypreview.js]
skip-if = e10s # bug 1148827
[browser_pluginplaypreview2.js]
skip-if = e10s # bug 1148827
[browser_pluginplaypreview3.js]
skip-if = e10s # bug 1148827
[browser_pluginCrashReportNonDeterminism.js]
skip-if = !crashreporter || os == 'linux' # Bug 1152811

Просмотреть файл

@ -1,317 +0,0 @@
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir;
var gTestBrowser = null;
var gNextTest = null;
var gNextTestSkip = 0;
var gPlayPreviewPluginActualEvents = 0;
var gPlayPreviewPluginExpectedEvents = 1;
var gPlayPreviewRegistration = null;
function registerPlayPreview(mimeType, targetUrl) {
function StreamConverterFactory() {}
StreamConverterFactory.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
_targetConstructor: null,
register: function register(targetConstructor) {
this._targetConstructor = targetConstructor;
var proto = targetConstructor.prototype;
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(proto.classID, proto.classDescription,
proto.contractID, this);
},
unregister: function unregister() {
var proto = this._targetConstructor.prototype;
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(proto.classID, this);
this._targetConstructor = null;
},
// nsIFactory
createInstance: function createInstance(aOuter, iid) {
if (aOuter !== null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return (new (this._targetConstructor)).QueryInterface(iid);
},
// nsIFactory
lockFactory: function lockFactory(lock) {
// No longer used as of gecko 1.7.
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
}
};
function OverlayStreamConverter() {}
OverlayStreamConverter.prototype = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsISupports,
Ci.nsIStreamConverter,
Ci.nsIStreamListener,
Ci.nsIRequestObserver
]),
classID: Components.ID('{4c6030f7-e20a-264f-0f9b-ada3a9e97384}'),
classDescription: 'overlay-test-data Component',
contractID: '@mozilla.org/streamconv;1?from=application/x-moz-playpreview&to=*/*',
// nsIStreamConverter::convert
convert: function(aFromStream, aFromType, aToType, aCtxt) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
// nsIStreamConverter::asyncConvertData
asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
var isValidRequest = false;
try {
var request = aCtxt;
request.QueryInterface(Ci.nsIChannel);
var spec = request.URI.spec;
var expectedSpec = 'data:application/x-moz-playpreview;,' + mimeType;
isValidRequest = (spec == expectedSpec);
} catch (e) { }
if (!isValidRequest)
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
// Store the listener passed to us
this.listener = aListener;
},
// nsIStreamListener::onDataAvailable
onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
// Do nothing since all the data loading is handled by the viewer.
ok(false, "onDataAvailable should not be called");
},
// nsIRequestObserver::onStartRequest
onStartRequest: function(aRequest, aContext) {
// Setup the request so we can use it below.
aRequest.QueryInterface(Ci.nsIChannel);
// Cancel the request so the viewer can handle it.
aRequest.cancel(Cr.NS_BINDING_ABORTED);
// Create a new channel that is viewer loaded as a resource.
var ioService = Services.io;
var channel = ioService.newChannel2(targetUrl,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
channel.asyncOpen(this.listener, aContext);
},
// nsIRequestObserver::onStopRequest
onStopRequest: function(aRequest, aContext, aStatusCode) {
// Do nothing.
}
};
var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
ph.registerPlayPreviewMimeType(mimeType, true); // ignoring CTP rules
var factory = new StreamConverterFactory();
factory.register(OverlayStreamConverter);
return (gPlayPreviewRegistration = {
unregister: function() {
ph.unregisterPlayPreviewMimeType(mimeType);
factory.unregister();
gPlayPreviewRegistration = null;
}
});
}
function unregisterPlayPreview() {
gPlayPreviewRegistration.unregister();
}
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import("resource://gre/modules/Services.jsm");
function test() {
waitForExplicitFinish();
registerCleanupFunction(function() {
if (gPlayPreviewRegistration)
gPlayPreviewRegistration.unregister();
Services.prefs.clearUserPref("plugins.click_to_play");
});
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("load", pageLoad, true);
gTestBrowser.addEventListener("PluginBindingAttached", handleBindingAttached, true, true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
registerPlayPreview('application/x-test', 'about:');
prepareTest(test1a, gTestRoot + "plugin_test.html", 1);
}
function finishTest() {
gTestBrowser.removeEventListener("load", pageLoad, true);
gTestBrowser.removeEventListener("PluginBindingAttached", handleBindingAttached, true, true);
gBrowser.removeCurrentTab();
window.focus();
finish();
}
function handleBindingAttached(evt) {
if (evt.target instanceof Ci.nsIObjectLoadingContent &&
evt.target.pluginFallbackType == Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW)
gPlayPreviewPluginActualEvents++;
}
function pageLoad() {
// The plugin events are async dispatched and can come after the load event
// This just allows the events to fire before we then go on to test the states
// iframe might triggers load event as well, making sure we skip some to let
// all iframes on the page be loaded as well
if (gNextTestSkip) {
gNextTestSkip--;
return;
}
executeSoon(gNextTest);
}
function prepareTest(nextTest, url, skip) {
gNextTest = nextTest;
gNextTestSkip = skip;
gTestBrowser.contentWindow.location = url;
}
// Tests a page with normal play preview registration (1/2)
function test1a() {
var notificationBox = gBrowser.getNotificationBox(gTestBrowser);
ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 1a, Should not have displayed the blocked plugin notification");
var pluginInfo = getTestPlugin();
ok(pluginInfo, "Should have a test plugin");
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 1a, plugin fallback type should be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 1a, Plugin should not be activated");
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "previewPluginContent");
ok(overlay, "Test 1a, the overlay div is expected");
var iframe = overlay.getElementsByClassName("previewPluginContentFrame")[0];
ok(iframe && iframe.localName == "iframe", "Test 1a, the overlay iframe is expected");
var iframeHref = iframe.contentWindow.location.href;
ok(iframeHref == "about:", "Test 1a, the overlay about: content is expected");
var rect = iframe.getBoundingClientRect();
ok(rect.width == 200, "Test 1a, Plugin with id=" + plugin.id + " overlay rect should have 200px width before being replaced by actual plugin");
ok(rect.height == 200, "Test 1a, Plugin with id=" + plugin.id + " overlay rect should have 200px height before being replaced by actual plugin");
var e = overlay.ownerDocument.createEvent("CustomEvent");
e.initCustomEvent("MozPlayPlugin", true, true, null);
overlay.dispatchEvent(e);
var condition = function() objLoadingContent.activated;
waitForCondition(condition, test1b, "Test 1a, Waited too long for plugin to stop play preview");
}
// Tests that activating via MozPlayPlugin through the notification works (part 2/2)
function test1b() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 1b, Plugin should be activated");
is(gPlayPreviewPluginActualEvents, gPlayPreviewPluginExpectedEvents,
"There should be exactly one PluginPlayPreview event");
unregisterPlayPreview();
prepareTest(test2, gTestRoot + "plugin_test.html");
}
// Tests a page with a working plugin in it -- the mime type was just unregistered.
function test2() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 2, Plugin should be activated");
registerPlayPreview('application/x-unknown', 'about:');
prepareTest(test3, gTestRoot + "plugin_test.html");
}
// Tests a page with a working plugin in it -- diffent play preview type is reserved.
function test3() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 3, Plugin should be activated");
unregisterPlayPreview();
registerPlayPreview('application/x-test', 'about:');
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
prepareTest(test4a, gTestRoot + "plugin_test.html", 1);
}
// Test a fallback to the click-to-play
function test4a() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 4a, plugin fallback type should be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 4a, Plugin should not be activated");
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "previewPluginContent");
ok(overlay, "Test 4a, the overlay div is expected");
var e = overlay.ownerDocument.createEvent("CustomEvent");
e.initCustomEvent("MozPlayPlugin", true, true, true);
overlay.dispatchEvent(e);
var condition = function() objLoadingContent.pluginFallbackType == Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY;
waitForCondition(condition, test4b, "Test 4a, Waited too long for plugin to stop play preview");
}
function test4b() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.pluginFallbackType != Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 4b, plugin fallback type should not be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 4b, Plugin should not be activated");
prepareTest(test5a, gTestRoot + "plugin_test.html", 1);
}
// Test a bypass of the click-to-play
function test5a() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 5a, plugin fallback type should be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 5a, Plugin should not be activated");
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "previewPluginContent");
ok(overlay, "Test 5a, the overlay div is expected");
var e = overlay.ownerDocument.createEvent("CustomEvent");
e.initCustomEvent("MozPlayPlugin", true, true, false);
overlay.dispatchEvent(e);
var condition = function() objLoadingContent.activated;
waitForCondition(condition, test5b, "Test 5a, Waited too long for plugin to stop play preview");
}
function test5b() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 5b, Plugin should be activated");
finishTest();
}

Просмотреть файл

@ -1,171 +0,0 @@
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir;
var gTestBrowser = null;
var gNextTest = null;
var gNextTestSkip = 0;
var gPlayPreviewPluginActualEvents = 0;
var gPlayPreviewPluginExpectedEvents = 1;
var gPlayPreviewRegistration = null;
function registerPlayPreview(mimeType, targetUrl) {
var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
ph.registerPlayPreviewMimeType(mimeType, false, targetUrl);
return (gPlayPreviewRegistration = {
unregister: function() {
ph.unregisterPlayPreviewMimeType(mimeType);
gPlayPreviewRegistration = null;
}
});
}
function unregisterPlayPreview() {
gPlayPreviewRegistration.unregister();
}
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import("resource://gre/modules/Services.jsm");
function test() {
waitForExplicitFinish();
registerCleanupFunction(function() {
if (gPlayPreviewRegistration)
gPlayPreviewRegistration.unregister();
Services.prefs.clearUserPref("plugins.click_to_play");
});
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("load", pageLoad, true);
gTestBrowser.addEventListener("PluginBindingAttached", handleBindingAttached, true, true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
registerPlayPreview('application/x-test', 'about:');
prepareTest(test1a, gTestRoot + "plugin_test.html", 1);
}
function finishTest() {
gTestBrowser.removeEventListener("load", pageLoad, true);
gTestBrowser.removeEventListener("PluginBindingAttached", handleBindingAttached, true, true);
gBrowser.removeCurrentTab();
window.focus();
finish();
}
function handleBindingAttached(evt) {
if (evt.target instanceof Ci.nsIObjectLoadingContent &&
evt.target.pluginFallbackType == Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW)
gPlayPreviewPluginActualEvents++;
}
function pageLoad() {
// The plugin events are async dispatched and can come after the load event
// This just allows the events to fire before we then go on to test the states
// iframe might triggers load event as well, making sure we skip some to let
// all iframes on the page be loaded as well
if (gNextTestSkip) {
gNextTestSkip--;
return;
}
executeSoon(gNextTest);
}
function prepareTest(nextTest, url, skip) {
gNextTest = nextTest;
gNextTestSkip = skip;
gTestBrowser.contentWindow.location = url;
}
// Tests a page with normal play preview registration (1/2)
function test1a() {
var notificationBox = gBrowser.getNotificationBox(gTestBrowser);
ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 1a, Should not have displayed the blocked plugin notification");
var pluginInfo = getTestPlugin();
ok(pluginInfo, "Should have a test plugin");
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 1a, plugin fallback type should be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 1a, Plugin should not be activated");
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "previewPluginContent");
ok(overlay, "Test 1a, the overlay div is expected");
var iframe = overlay.getElementsByClassName("previewPluginContentFrame")[0];
ok(iframe && iframe.localName == "iframe", "Test 1a, the overlay iframe is expected");
var iframeHref = iframe.contentWindow.location.href;
ok(iframeHref == "about:", "Test 1a, the overlay about: content is expected");
var rect = iframe.getBoundingClientRect();
ok(rect.width == 200, "Test 1a, Plugin with id=" + plugin.id + " overlay rect should have 200px width before being replaced by actual plugin");
ok(rect.height == 200, "Test 1a, Plugin with id=" + plugin.id + " overlay rect should have 200px height before being replaced by actual plugin");
var e = overlay.ownerDocument.createEvent("CustomEvent");
e.initCustomEvent("MozPlayPlugin", true, true, null);
overlay.dispatchEvent(e);
var condition = function() objLoadingContent.activated;
waitForCondition(condition, test1b, "Test 1a, Waited too long for plugin to stop play preview");
}
// Tests that activating via MozPlayPlugin through the notification works (part 2/2)
function test1b() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 1b, Plugin should be activated");
is(gPlayPreviewPluginActualEvents, gPlayPreviewPluginExpectedEvents,
"There should be exactly one PluginPlayPreview event");
unregisterPlayPreview();
prepareTest(test2, gTestRoot + "plugin_test.html");
}
// Tests a page with a working plugin in it -- the mime type was just unregistered.
function test2() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.pluginFallbackType != Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 2, plugin fallback type should not be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 2, Plugin should not be activated");
registerPlayPreview('application/x-unknown', 'about:');
prepareTest(test3, gTestRoot + "plugin_test.html");
}
// Tests a page with a working plugin in it -- diffent play preview type is reserved.
function test3() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.pluginFallbackType != Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 3, plugin fallback type should not be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 3, Plugin should not be activated");
unregisterPlayPreview();
registerPlayPreview('application/x-test', 'about:');
Services.prefs.setBoolPref("plugins.click_to_play", false);
var plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
prepareTest(test4, gTestRoot + "plugin_test.html");
}
// Tests a page with a working plugin in it -- click-to-play is off
function test4() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 4, Plugin should be activated");
finishTest();
}

Просмотреть файл

@ -1,130 +0,0 @@
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir;
var gTestBrowser = null;
var gNextTest = null;
var gNextTestSkip = 0;
var gPlayPreviewRegistration = null;
var gTestPluginType = 'application/x-test';
var gTestPluginPreviewUrl = 'about:';
function registerPlayPreview(whitelist) {
var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
ph.registerPlayPreviewMimeType(gTestPluginType, true,
gTestPluginPreviewUrl, whitelist);
return (gPlayPreviewRegistration = {
unregister: function() {
ph.unregisterPlayPreviewMimeType(gTestPluginType);
gPlayPreviewRegistration = null;
}
});
}
function unregisterPlayPreview() {
gPlayPreviewRegistration.unregister();
}
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import("resource://gre/modules/Services.jsm");
function test() {
waitForExplicitFinish();
registerCleanupFunction(function() {
if (gPlayPreviewRegistration) {
gPlayPreviewRegistration.unregister();
}
});
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("load", pageLoad, true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
registerPlayPreview('@*plugin_test.html');
prepareTest(test1a, gTestRoot + "plugin_test.html", 1);
}
function finishTest() {
gTestBrowser.removeEventListener("load", pageLoad, true);
gBrowser.removeCurrentTab();
window.focus();
finish();
}
function pageLoad() {
// The plugin events are async dispatched and can come after the load event
// This just allows the events to fire before we then go on to test the states
// iframe might triggers load event as well, making sure we skip some to let
// all iframes on the page be loaded as well
if (gNextTestSkip) {
gNextTestSkip--;
return;
}
executeSoon(gNextTest);
}
function prepareTest(nextTest, url, skip) {
gNextTest = nextTest;
gNextTestSkip = skip;
gTestBrowser.contentWindow.location = url;
}
// Tests plugin on a whitelisted page.
function test1a() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW, "Test 1a, plugin fallback type should be PLUGIN_PLAY_PREVIEW");
ok(!objLoadingContent.activated, "Test 1a, Plugin should not be activated");
unregisterPlayPreview();
registerPlayPreview('@*plugin_wrong.html');
var plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
prepareTest(test1b, gTestRoot + "plugin_test.html");
}
// Tests plugin on a non-whitelisted page.
function test1b() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 1b, Plugin should be activated");
unregisterPlayPreview();
registerPlayPreview('*browser_pluginplaypreview3.js');
var plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
prepareTest(test2a, gTestRoot + "plugin_test_w_src.html");
}
// Tests plugin with whitelisted src/data.
function test2a() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 2a, Plugin should not be activated");
unregisterPlayPreview();
registerPlayPreview('*plugin_test_w_src.html');
var plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
prepareTest(test2b, gTestRoot + "plugin_test_w_src.html");
}
// Tests plugin with non-whitelisted src/data.
function test2b() {
var plugin = gTestBrowser.contentDocument.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 2b, Plugin should be activated");
finishTest();
}

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" src="browser_pluginplaypreview3.js" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -20,13 +20,14 @@ support-files =
[browser_435851_copy_query.js]
[browser_475045.js]
[browser_555547.js]
[browser_bookmarkProperties_addFolderDefaultButton.js]
[browser_bookmarkProperties_addKeywordForThisSearch.js]
[browser_bookmarkProperties_readOnlyRoot.js]
[browser_bookmarklet_windowOpen.js]
support-files =
pageopeningwindow.html
[browser_bookmarkProperties_addFolderDefaultButton.js]
[browser_bookmarkProperties_addKeywordForThisSearch.js]
[browser_bookmarkProperties_readOnlyRoot.js]
[browser_bookmarksProperties.js]
skip-if = (os == 'win' && os_version == "6.2") # Bug 1178709
[browser_drag_bookmarks_on_toolbar.js]
skip-if = e10s # Bug ?????? - test fails - "Number of dragged items should be the same. - Got 0, expected 1"
[browser_forgetthissite_single.js]

Просмотреть файл

@ -771,3 +771,8 @@ e10s.accessibilityNotice.disableAndRestart.label = Disable and Restart
e10s.accessibilityNotice.disableAndRestart.accesskey = R
e10s.accessibilityNotice.dontDisable.label = Don't Disable
e10s.accessibilityNotice.dontDisable.accesskey = D
muteTab.label = Mute Tab
muteTab.accesskey = M
unmuteTab.label = Unmute Tab
unmuteTab.accesskey = M

Просмотреть файл

@ -311,8 +311,6 @@ PluginContent.prototype = {
return "PluginVulnerableUpdatable";
case Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE:
return "PluginVulnerableNoUpdate";
case Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW:
return "PluginPlayPreview";
default:
// Not all states map to a handler
return null;
@ -417,10 +415,6 @@ PluginContent.prototype = {
shouldShowNotification = true;
break;
case "PluginPlayPreview":
this._handlePlayPreviewEvent(plugin);
break;
case "PluginDisabled":
let manageLink = this.getPluginUI(plugin, "managePluginsLink");
this.addLinkClickCallback(manageLink, "forwardCallback", "managePlugins");
@ -531,12 +525,6 @@ PluginContent.prototype = {
objLoadingContent.pluginFallbackType >= Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY &&
objLoadingContent.pluginFallbackType <= Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE;
if (objLoadingContent.pluginFallbackType == Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW) {
// checking if play preview is subject to CTP rules
let playPreviewInfo = pluginHost.getPlayPreviewInfo(objLoadingContent.actualType);
isFallbackTypeValid = !playPreviewInfo.ignoreCTP;
}
return !objLoadingContent.activated &&
pluginPermission != Ci.nsIPermissionManager.DENY_ACTION &&
isFallbackTypeValid;
@ -549,17 +537,6 @@ PluginContent.prototype = {
}
},
stopPlayPreview: function (plugin, playPlugin) {
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
if (objLoadingContent.activated)
return;
if (playPlugin)
objLoadingContent.playPlugin();
else
objLoadingContent.cancelPlayPreview();
},
// Forward a link click callback to the chrome process.
forwardCallback: function (name) {
this.global.sendAsyncMessage("PluginContent:LinkClickCallback", { name: name });
@ -641,49 +618,6 @@ PluginContent.prototype = {
}
},
_handlePlayPreviewEvent: function (plugin) {
let doc = plugin.ownerDocument;
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
let pluginInfo = this._getPluginInfo(plugin);
let playPreviewInfo = pluginHost.getPlayPreviewInfo(pluginInfo.mimetype);
let previewContent = this.getPluginUI(plugin, "previewPluginContent");
let iframe = previewContent.getElementsByClassName("previewPluginContentFrame")[0];
if (!iframe) {
// lazy initialization of the iframe
iframe = doc.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
iframe.className = "previewPluginContentFrame";
previewContent.appendChild(iframe);
// Force a style flush, so that we ensure our binding is attached.
plugin.clientTop;
}
iframe.src = playPreviewInfo.redirectURL;
// MozPlayPlugin event can be dispatched from the extension chrome
// code to replace the preview content with the native plugin
let playPluginHandler = (event) => {
if (!event.isTrusted)
return;
previewContent.removeEventListener("MozPlayPlugin", playPluginHandler, true);
let playPlugin = !event.detail;
this.stopPlayPreview(plugin, playPlugin);
// cleaning up: removes overlay iframe from the DOM
let iframe = previewContent.getElementsByClassName("previewPluginContentFrame")[0];
if (iframe)
previewContent.removeChild(iframe);
};
previewContent.addEventListener("MozPlayPlugin", playPluginHandler, true);
if (!playPreviewInfo.ignoreCTP) {
this._showClickToPlayNotification(plugin, false);
}
},
reshowClickToPlayNotification: function () {
let contentWindow = this.global.content;
let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)

Просмотреть файл

@ -291,6 +291,7 @@ if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then
fi
(export AR="$AR"
export RANLIB="$RANLIB"
export CC="$CC"
export CXX="$CXX"
export LD="$LD"

Просмотреть файл

@ -25,4 +25,7 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True

Просмотреть файл

@ -51,6 +51,9 @@ EXTRA_PP_JS_MODULES += [
'Webapps.jsm',
]
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True
FINAL_LIBRARY = 'xul'

Просмотреть файл

@ -21,6 +21,9 @@ UNIFIED_SOURCES += [
'ArchiveZipFile.cpp',
]
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

Просмотреть файл

@ -833,6 +833,8 @@ nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor)
}
}
break;
default:
break;
}
if (stopEvent) {

Просмотреть файл

@ -132,7 +132,6 @@ void
StructuredCloneHelperInternal::Shutdown()
{
#ifdef DEBUG
MOZ_ASSERT(!mShutdownCalled, "Shutdown already called!");
mShutdownCalled = true;
#endif
@ -170,7 +169,6 @@ StructuredCloneHelperInternal::Read(JSContext* aCx,
MOZ_ASSERT(!mShutdownCalled, "This method cannot be called after Shutdown.");
bool ok = mBuffer->read(aCx, aValue, &gCallbacks, this);
mBuffer = nullptr;
return ok;
}
@ -254,7 +252,11 @@ StructuredCloneHelper::Read(nsISupports* aParent,
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
}
mBlobImplArray.Clear();
// If we are tranferring something, we cannot call 'Read()' more than once.
if (mSupportsTransferring) {
mBlobImplArray.Clear();
Shutdown();
}
}
void
@ -264,6 +266,19 @@ StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
size_t aBufferLength,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv)
{
ReadFromBuffer(aParent, aCx, aBuffer, aBufferLength,
JS_STRUCTURED_CLONE_VERSION, aValue, aRv);
}
void
StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
JSContext* aCx,
uint64_t* aBuffer,
size_t aBufferLength,
uint32_t aAlgorithmVersion,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv)
{
MOZ_ASSERT(!mBuffer, "ReadFromBuffer() must be called without a Write().");
MOZ_ASSERT(aBuffer);
@ -271,9 +286,8 @@ StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
mozilla::AutoRestore<nsISupports*> guard(mParent);
mParent = aParent;
if (!JS_ReadStructuredClone(aCx, aBuffer, aBufferLength,
JS_STRUCTURED_CLONE_VERSION, aValue,
&gCallbacks, this)) {
if (!JS_ReadStructuredClone(aCx, aBuffer, aBufferLength, aAlgorithmVersion,
aValue, &gCallbacks, this)) {
JS_ClearPendingException(aCx);
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
}

Просмотреть файл

@ -160,10 +160,24 @@ public:
JS::MutableHandle<JS::Value> aValue,
ErrorResult &aRv);
void ReadFromBuffer(nsISupports* aParent,
JSContext* aCx,
uint64_t* aBuffer,
size_t aBufferLength,
uint32_t aAlgorithmVersion,
JS::MutableHandle<JS::Value> aValue,
ErrorResult &aRv);
// Use this method to free a buffer generated by MoveToBuffer().
void FreeBuffer(uint64_t* aBuffer,
size_t aBufferLength);
bool HasClonedDOMObjects() const
{
return !mBlobImplArray.IsEmpty() ||
!mClonedImages.IsEmpty();
}
nsTArray<nsRefPtr<BlobImpl>>& BlobImpls()
{
MOZ_ASSERT(mSupportsCloning, "Blobs cannot be taken/set if cloning is not supported.");

Просмотреть файл

@ -666,15 +666,15 @@ nsContentUtils::InitializeModifierStrings()
}
// Because of SVG/SMIL we have several atoms mapped to the same
// id, but we can rely on ID_TO_EVENT to map id to only one atom.
// id, but we can rely on MESSAGE_TO_EVENT to map id to only one atom.
static bool
ShouldAddEventToStringEventTable(const EventNameMapping& aMapping)
{
switch(aMapping.mId) {
#define ID_TO_EVENT(name_, id_, type_, struct_) \
case id_: return nsGkAtoms::on##name_ == aMapping.mAtom;
switch(aMapping.mMessage) {
#define MESSAGE_TO_EVENT(name_, message_, type_, struct_) \
case message_: return nsGkAtoms::on##name_ == aMapping.mAtom;
#include "mozilla/EventNameList.h"
#undef ID_TO_EVENT
#undef MESSAGE_TO_EVENT
default:
break;
}
@ -687,8 +687,8 @@ nsContentUtils::InitializeEventTable() {
NS_ASSERTION(!sStringEventTable, "EventTable already initialized!");
static const EventNameMapping eventArray[] = {
#define EVENT(name_, _id, _type, _class) \
{ nsGkAtoms::on##name_, _id, _type, _class },
#define EVENT(name_, _message, _type, _class) \
{ nsGkAtoms::on##name_, _type, _message, _class },
#define WINDOW_ONLY_EVENT EVENT
#define NON_IDL_EVENT EVENT
#include "mozilla/EventNameList.h"
@ -724,9 +724,9 @@ nsContentUtils::InitializeTouchEventTable()
if (!sEventTableInitialized && sAtomEventTable && sStringEventTable) {
sEventTableInitialized = true;
static const EventNameMapping touchEventArray[] = {
#define EVENT(name_, _id, _type, _class)
#define TOUCH_EVENT(name_, _id, _type, _class) \
{ nsGkAtoms::on##name_, _id, _type, _class },
#define EVENT(name_, _message, _type, _class)
#define TOUCH_EVENT(name_, _message, _type, _class) \
{ nsGkAtoms::on##name_, _type, _message, _class },
#include "mozilla/EventNameList.h"
#undef TOUCH_EVENT
#undef EVENT
@ -3655,13 +3655,13 @@ nsContentUtils::IsEventAttributeName(nsIAtom* aName, int32_t aType)
}
// static
uint32_t
nsContentUtils::GetEventId(nsIAtom* aName)
EventMessage
nsContentUtils::GetEventMessage(nsIAtom* aName)
{
if (aName) {
EventNameMapping mapping;
if (sAtomEventTable->Get(aName, &mapping)) {
return mapping.mId;
return mapping.mMessage;
}
}
@ -3680,14 +3680,15 @@ nsContentUtils::GetEventClassID(const nsAString& aName)
}
nsIAtom*
nsContentUtils::GetEventIdAndAtom(const nsAString& aName,
mozilla::EventClassID aEventClassID,
uint32_t* aEventID)
nsContentUtils::GetEventMessageAndAtom(const nsAString& aName,
mozilla::EventClassID aEventClassID,
EventMessage* aEventMessage)
{
EventNameMapping mapping;
if (sStringEventTable->Get(aName, &mapping)) {
*aEventID = mapping.mEventClassID == aEventClassID ? mapping.mId :
NS_USER_DEFINED_EVENT;
*aEventMessage =
mapping.mEventClassID == aEventClassID ? mapping.mMessage :
NS_USER_DEFINED_EVENT;
return mapping.mAtom;
}
@ -3700,11 +3701,11 @@ nsContentUtils::GetEventIdAndAtom(const nsAString& aName,
}
}
*aEventID = NS_USER_DEFINED_EVENT;
*aEventMessage = NS_USER_DEFINED_EVENT;
nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aName);
sUserDefinedEvents->AppendObject(atom);
mapping.mAtom = atom;
mapping.mId = NS_USER_DEFINED_EVENT;
mapping.mMessage = NS_USER_DEFINED_EVENT;
mapping.mType = EventNameType_None;
mapping.mEventClassID = eBasicEventClass;
sStringEventTable->Put(aName, mapping);
@ -7706,7 +7707,7 @@ nsContentUtils::SendKeyEvent(nsIWidget* aWidget,
if (!aWidget)
return NS_ERROR_FAILURE;
int32_t msg;
EventMessage msg;
if (aType.EqualsLiteral("keydown"))
msg = NS_KEY_DOWN;
else if (aType.EqualsLiteral("keyup"))
@ -7819,7 +7820,7 @@ nsContentUtils::SendMouseEvent(nsCOMPtr<nsIPresShell> aPresShell,
if (!widget)
return NS_ERROR_FAILURE;
int32_t msg;
EventMessage msg;
bool contextMenuKey = false;
if (aType.EqualsLiteral("mousedown"))
msg = NS_MOUSE_BUTTON_DOWN;

Просмотреть файл

@ -165,8 +165,8 @@ struct EventNameMapping
// This holds pointers to nsGkAtoms members, and is therefore safe as a
// non-owning reference.
nsIAtom* MOZ_NON_OWNING_REF mAtom;
uint32_t mId;
int32_t mType;
mozilla::EventMessage mMessage;
mozilla::EventClassID mEventClassID;
};
@ -1100,13 +1100,13 @@ public:
static bool IsEventAttributeName(nsIAtom* aName, int32_t aType);
/**
* Return the event id for the event with the given name. The name is the
* event name with the 'on' prefix. Returns NS_USER_DEFINED_EVENT if the
* Return the event message for the event with the given name. The name is
* the event name with the 'on' prefix. Returns NS_USER_DEFINED_EVENT if the
* event doesn't match a known event name.
*
* @param aName the event name to look up
*/
static uint32_t GetEventId(nsIAtom* aName);
static mozilla::EventMessage GetEventMessage(nsIAtom* aName);
/**
* Return the EventClassID for the event with the given name. The name is the
@ -1118,7 +1118,7 @@ public:
static mozilla::EventClassID GetEventClassID(const nsAString& aName);
/**
* Return the event id and atom for the event with the given name.
* Return the event message and atom for the event with the given name.
* The name is the event name *without* the 'on' prefix.
* Returns NS_USER_DEFINED_EVENT on the aEventID if the
* event doesn't match a known event name in the category.
@ -1126,9 +1126,9 @@ public:
* @param aName the event name to look up
* @param aEventClassID only return event id for aEventClassID
*/
static nsIAtom* GetEventIdAndAtom(const nsAString& aName,
mozilla::EventClassID aEventClassID,
uint32_t* aEventID);
static nsIAtom* GetEventMessageAndAtom(const nsAString& aName,
mozilla::EventClassID aEventClassID,
mozilla::EventMessage* aEventMessage);
/**
* Used only during traversal of the XPCOM graph by the cycle
@ -1696,16 +1696,12 @@ public:
/**
* Convert ASCII A-Z to a-z.
* @return NS_OK on success, or NS_ERROR_OUT_OF_MEMORY if making the string
* writable needs to allocate memory and that allocation fails.
*/
static void ASCIIToLower(nsAString& aStr);
static void ASCIIToLower(const nsAString& aSource, nsAString& aDest);
/**
* Convert ASCII a-z to A-Z.
* @return NS_OK on success, or NS_ERROR_OUT_OF_MEMORY if making the string
* writable needs to allocate memory and that allocation fails.
*/
static void ASCIIToUpper(nsAString& aStr);
static void ASCIIToUpper(const nsAString& aSource, nsAString& aDest);

Просмотреть файл

@ -621,14 +621,18 @@ IsSelectionInsideRuby(nsISelection* aSelection)
}
bool
nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPresShell* aPresShell,
nsISelection* aSelection, bool* aActionTaken)
nsCopySupport::FireClipboardEvent(EventMessage aEventMessage,
int32_t aClipboardType,
nsIPresShell* aPresShell,
nsISelection* aSelection,
bool* aActionTaken)
{
if (aActionTaken) {
*aActionTaken = false;
}
NS_ASSERTION(aType == NS_CUT || aType == NS_COPY || aType == NS_PASTE,
NS_ASSERTION(aEventMessage == NS_CUT || aEventMessage == NS_COPY ||
aEventMessage == NS_PASTE,
"Invalid clipboard event type");
nsCOMPtr<nsIPresShell> presShell = aPresShell;
@ -684,10 +688,11 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
nsRefPtr<DataTransfer> clipboardData;
if (chromeShell || Preferences::GetBool("dom.event.clipboardevents.enabled", true)) {
clipboardData =
new DataTransfer(piWindow, aType, aType == NS_PASTE, aClipboardType);
new DataTransfer(piWindow, aEventMessage, aEventMessage == NS_PASTE,
aClipboardType);
nsEventStatus status = nsEventStatus_eIgnore;
InternalClipboardEvent evt(true, aType);
InternalClipboardEvent evt(true, aEventMessage);
evt.clipboardData = clipboardData;
EventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt,
nullptr, &status);
@ -698,7 +703,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
// No need to do anything special during a paste. Either an event listener
// took care of it and cancelled the event, or the caller will handle it.
// Return true to indicate that the event wasn't cancelled.
if (aType == NS_PASTE) {
if (aEventMessage == NS_PASTE) {
// Clear and mark the clipboardData as readonly. This prevents someone
// from reading the clipboard contents after the paste event has fired.
if (clipboardData) {
@ -738,7 +743,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
// when cutting non-editable content, do nothing
// XXX this is probably the wrong editable flag to check
if (aType != NS_CUT || content->IsEditable()) {
if (aEventMessage != NS_CUT || content->IsEditable()) {
// get the data from the selection if any
bool isCollapsed;
sel->GetIsCollapsed(&isCollapsed);

Просмотреть файл

@ -6,7 +6,7 @@
#ifndef nsCopySupport_h__
#define nsCopySupport_h__
#include "nscore.h"
#include "mozilla/EventForwards.h"
class nsINode;
class nsISelection;
@ -64,7 +64,7 @@ class nsCopySupport
/**
* Fires a cut, copy or paste event, on the given presshell, depending
* on the value of aType, which should be either NS_CUT, NS_COPY or
* on the value of aEventMessage, which should be either NS_CUT, NS_COPY or
* NS_PASTE, and perform the default copy action if the event was not
* cancelled.
*
@ -88,7 +88,7 @@ class nsCopySupport
*
* If the event is cancelled or an error occurs, false will be returned.
*/
static bool FireClipboardEvent(int32_t aType,
static bool FireClipboardEvent(mozilla::EventMessage aEventMessage,
int32_t aClipboardType,
nsIPresShell* aPresShell,
nsISelection* aSelection,

Просмотреть файл

@ -700,7 +700,7 @@ nsDOMWindowUtils::SendPointerEventCommon(const nsAString& aType,
return NS_ERROR_FAILURE;
}
int32_t msg;
EventMessage msg;
if (aType.EqualsLiteral("pointerdown")) {
msg = NS_POINTER_DOWN;
} else if (aType.EqualsLiteral("pointerup")) {
@ -979,7 +979,7 @@ nsDOMWindowUtils::SendTouchEventCommon(const nsAString& aType,
if (!widget) {
return NS_ERROR_NULL_POINTER;
}
int32_t msg;
EventMessage msg;
if (aType.EqualsLiteral("touchstart")) {
msg = NS_TOUCH_START;
} else if (aType.EqualsLiteral("touchmove")) {
@ -1314,7 +1314,7 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
if (!widget)
return NS_ERROR_FAILURE;
int32_t msg;
EventMessage msg;
if (aType.EqualsLiteral("MozSwipeGestureStart"))
msg = NS_SIMPLE_GESTURE_SWIPE_START;
else if (aType.EqualsLiteral("MozSwipeGestureUpdate"))
@ -1941,13 +1941,28 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
return NS_ERROR_FAILURE;
}
if (aType != NS_QUERY_SELECTED_TEXT &&
aType != NS_QUERY_TEXT_CONTENT &&
aType != NS_QUERY_CARET_RECT &&
aType != NS_QUERY_TEXT_RECT &&
aType != NS_QUERY_EDITOR_RECT &&
aType != NS_QUERY_CHARACTER_AT_POINT) {
return NS_ERROR_INVALID_ARG;
EventMessage message;
switch (aType) {
case QUERY_SELECTED_TEXT:
message = NS_QUERY_SELECTED_TEXT;
break;
case QUERY_TEXT_CONTENT:
message = NS_QUERY_TEXT_CONTENT;
break;
case QUERY_CARET_RECT:
message = NS_QUERY_CARET_RECT;
break;
case QUERY_TEXT_RECT:
message = NS_QUERY_TEXT_RECT;
break;
case QUERY_EDITOR_RECT:
message = NS_QUERY_EDITOR_RECT;
break;
case QUERY_CHARACTER_AT_POINT:
message = NS_QUERY_CHARACTER_AT_POINT;
break;
default:
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIWidget> targetWidget = widget;
@ -1956,7 +1971,7 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
bool useNativeLineBreak =
!(aAdditionalFlags & QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK);
if (aType == QUERY_CHARACTER_AT_POINT) {
if (message == NS_QUERY_CHARACTER_AT_POINT) {
// Looking for the widget at the point.
WidgetQueryContentEvent dummyEvent(true, NS_QUERY_CONTENT_STATE, widget);
dummyEvent.mUseNativeLineBreak = useNativeLineBreak;
@ -1983,10 +1998,10 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
pt += widget->WidgetToScreenOffset() - targetWidget->WidgetToScreenOffset();
WidgetQueryContentEvent queryEvent(true, aType, targetWidget);
WidgetQueryContentEvent queryEvent(true, message, targetWidget);
InitEvent(queryEvent, &pt);
switch (aType) {
switch (message) {
case NS_QUERY_TEXT_CONTENT:
queryEvent.InitForQueryTextContent(aOffset, aLength, useNativeLineBreak);
break;
@ -2056,7 +2071,7 @@ nsDOMWindowUtils::SendContentCommandEvent(const nsAString& aType,
if (!widget)
return NS_ERROR_FAILURE;
int32_t msg;
EventMessage msg;
if (aType.EqualsLiteral("cut"))
msg = NS_CONTENT_COMMAND_CUT;
else if (aType.EqualsLiteral("copy"))

Просмотреть файл

@ -97,25 +97,29 @@ PRLogModuleInfo* gFocusNavigationLog;
struct nsDelayedBlurOrFocusEvent
{
nsDelayedBlurOrFocusEvent(uint32_t aType,
nsDelayedBlurOrFocusEvent(EventMessage aEventMessage,
nsIPresShell* aPresShell,
nsIDocument* aDocument,
EventTarget* aTarget)
: mType(aType),
mPresShell(aPresShell),
mDocument(aDocument),
mTarget(aTarget) { }
: mPresShell(aPresShell)
, mDocument(aDocument)
, mTarget(aTarget)
, mEventMessage(aEventMessage)
{
}
nsDelayedBlurOrFocusEvent(const nsDelayedBlurOrFocusEvent& aOther)
: mType(aOther.mType),
mPresShell(aOther.mPresShell),
mDocument(aOther.mDocument),
mTarget(aOther.mTarget) { }
: mPresShell(aOther.mPresShell)
, mDocument(aOther.mDocument)
, mTarget(aOther.mTarget)
, mEventMessage(aOther.mEventMessage)
{
}
uint32_t mType;
nsCOMPtr<nsIPresShell> mPresShell;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<EventTarget> mTarget;
EventMessage mEventMessage;
};
inline void ImplCycleCollectionUnlink(nsDelayedBlurOrFocusEvent& aField)
@ -1038,11 +1042,11 @@ nsFocusManager::FireDelayedEvents(nsIDocument* aDocument)
mDelayedBlurFocusEvents.RemoveElementAt(i);
--i;
} else if (!aDocument->EventHandlingSuppressed()) {
uint32_t type = mDelayedBlurFocusEvents[i].mType;
EventMessage message = mDelayedBlurFocusEvents[i].mEventMessage;
nsCOMPtr<EventTarget> target = mDelayedBlurFocusEvents[i].mTarget;
nsCOMPtr<nsIPresShell> presShell = mDelayedBlurFocusEvents[i].mPresShell;
mDelayedBlurFocusEvents.RemoveElementAt(i);
SendFocusOrBlurEvent(type, presShell, aDocument, target, 0, false);
SendFocusOrBlurEvent(message, presShell, aDocument, target, 0, false);
--i;
}
}
@ -1961,15 +1965,20 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
class FocusBlurEvent : public nsRunnable
{
public:
FocusBlurEvent(nsISupports* aTarget, uint32_t aType,
FocusBlurEvent(nsISupports* aTarget, EventMessage aEventMessage,
nsPresContext* aContext, bool aWindowRaised,
bool aIsRefocus)
: mTarget(aTarget), mType(aType), mContext(aContext),
mWindowRaised(aWindowRaised), mIsRefocus(aIsRefocus) {}
: mTarget(aTarget)
, mContext(aContext)
, mEventMessage(aEventMessage)
, mWindowRaised(aWindowRaised)
, mIsRefocus(aIsRefocus)
{
}
NS_IMETHOD Run()
{
InternalFocusEvent event(true, mType);
InternalFocusEvent event(true, mEventMessage);
event.mFlags.mBubbles = false;
event.fromRaise = mWindowRaised;
event.isRefocus = mIsRefocus;
@ -1977,14 +1986,14 @@ public:
}
nsCOMPtr<nsISupports> mTarget;
uint32_t mType;
nsRefPtr<nsPresContext> mContext;
EventMessage mEventMessage;
bool mWindowRaised;
bool mIsRefocus;
};
void
nsFocusManager::SendFocusOrBlurEvent(uint32_t aType,
nsFocusManager::SendFocusOrBlurEvent(EventMessage aEventMessage,
nsIPresShell* aPresShell,
nsIDocument* aDocument,
nsISupports* aTarget,
@ -1992,7 +2001,8 @@ nsFocusManager::SendFocusOrBlurEvent(uint32_t aType,
bool aWindowRaised,
bool aIsRefocus)
{
NS_ASSERTION(aType == NS_FOCUS_CONTENT || aType == NS_BLUR_CONTENT,
NS_ASSERTION(aEventMessage == NS_FOCUS_CONTENT ||
aEventMessage == NS_BLUR_CONTENT,
"Wrong event type for SendFocusOrBlurEvent");
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
@ -2015,7 +2025,7 @@ nsFocusManager::SendFocusOrBlurEvent(uint32_t aType,
for (uint32_t i = mDelayedBlurFocusEvents.Length(); i > 0; --i) {
// if this event was already queued, remove it and append it to the end
if (mDelayedBlurFocusEvents[i - 1].mType == aType &&
if (mDelayedBlurFocusEvents[i - 1].mEventMessage == aEventMessage &&
mDelayedBlurFocusEvents[i - 1].mPresShell == aPresShell &&
mDelayedBlurFocusEvents[i - 1].mDocument == aDocument &&
mDelayedBlurFocusEvents[i - 1].mTarget == eventTarget) {
@ -2024,23 +2034,25 @@ nsFocusManager::SendFocusOrBlurEvent(uint32_t aType,
}
mDelayedBlurFocusEvents.AppendElement(
nsDelayedBlurOrFocusEvent(aType, aPresShell, aDocument, eventTarget));
nsDelayedBlurOrFocusEvent(aEventMessage, aPresShell,
aDocument, eventTarget));
return;
}
#ifdef ACCESSIBILITY
nsAccessibilityService* accService = GetAccService();
if (accService) {
if (aType == NS_FOCUS_CONTENT)
if (aEventMessage == NS_FOCUS_CONTENT) {
accService->NotifyOfDOMFocus(aTarget);
else
} else {
accService->NotifyOfDOMBlur(aTarget);
}
}
#endif
if (!dontDispatchEvent) {
nsContentUtils::AddScriptRunner(
new FocusBlurEvent(aTarget, aType, aPresShell->GetPresContext(),
new FocusBlurEvent(aTarget, aEventMessage, aPresShell->GetPresContext(),
aWindowRaised, aIsRefocus));
}
}

Просмотреть файл

@ -280,12 +280,12 @@ protected:
/**
* Fires a focus or blur event at aTarget.
*
* aType should be either NS_FOCUS_CONTENT or NS_BLUR_CONTENT. For blur
* events, aFocusMethod should normally be non-zero.
* aEventMessage should be either NS_FOCUS_CONTENT or NS_BLUR_CONTENT.
* For blur events, aFocusMethod should normally be non-zero.
*
* aWindowRaised should only be true if called from WindowRaised.
*/
void SendFocusOrBlurEvent(uint32_t aType,
void SendFocusOrBlurEvent(mozilla::EventMessage aEventMessage,
nsIPresShell* aPresShell,
nsIDocument* aDocument,
nsISupports* aTarget,

Просмотреть файл

@ -3044,7 +3044,7 @@ nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
NS_PRECONDITION(IsInnerWindow(), "PreHandleEvent is used on outer window!?");
static uint32_t count = 0;
uint32_t msg = aVisitor.mEvent->mMessage;
EventMessage msg = aVisitor.mEvent->mMessage;
aVisitor.mCanHandle = true;
aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
@ -6618,7 +6618,6 @@ nsGlobalWindow::FinishFullscreenChange(bool aIsFullscreen)
} else if (mWakeLock && !mFullScreen) {
ErrorResult rv;
mWakeLock->Unlock(rv);
NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
mWakeLock = nullptr;
}
}
@ -14533,7 +14532,7 @@ nsGlobalWindow::GetIsPrerendered()
#ifdef MOZ_B2G
void
nsGlobalWindow::EnableNetworkEvent(uint32_t aType)
nsGlobalWindow::EnableNetworkEvent(EventMessage aEventMessage)
{
MOZ_ASSERT(IsInnerWindow());
@ -14558,7 +14557,7 @@ nsGlobalWindow::EnableNetworkEvent(uint32_t aType)
return;
}
switch (aType) {
switch (aEventMessage) {
case NS_NETWORK_UPLOAD_EVENT:
if (!mNetworkUploadObserverEnabled) {
mNetworkUploadObserverEnabled = true;
@ -14571,11 +14570,13 @@ nsGlobalWindow::EnableNetworkEvent(uint32_t aType)
os->AddObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC, false);
}
break;
default:
break;
}
}
void
nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
nsGlobalWindow::DisableNetworkEvent(EventMessage aEventMessage)
{
MOZ_ASSERT(IsInnerWindow());
@ -14584,7 +14585,7 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
return;
}
switch (aType) {
switch (aEventMessage) {
case NS_NETWORK_UPLOAD_EVENT:
if (mNetworkUploadObserverEnabled) {
mNetworkUploadObserverEnabled = false;
@ -14597,6 +14598,8 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC);
}
break;
default:
break;
}
}
#endif // MOZ_B2G

Просмотреть файл

@ -677,8 +677,9 @@ public:
#ifdef MOZ_B2G
// Inner windows only.
virtual void EnableNetworkEvent(uint32_t aType) override;
virtual void DisableNetworkEvent(uint32_t aType) override;
virtual void EnableNetworkEvent(mozilla::EventMessage aEventMessage) override;
virtual void DisableNetworkEvent(
mozilla::EventMessage aEventMessage) override;
#endif // MOZ_B2G
virtual nsresult SetArguments(nsIArray* aArguments) override;

Просмотреть файл

@ -520,13 +520,15 @@ nsClipboardCommand::DoCommand(const char *aCommandName, nsISupports *aContext)
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
int32_t eventType = NS_COPY;
EventMessage eventMessage = NS_COPY;
if (strcmp(aCommandName, "cmd_cut") == 0) {
eventType = NS_CUT;
eventMessage = NS_CUT;
}
bool actionTaken = false;
nsCopySupport::FireClipboardEvent(eventType, nsIClipboard::kGlobalClipboard, presShell, nullptr, &actionTaken);
nsCopySupport::FireClipboardEvent(eventMessage,
nsIClipboard::kGlobalClipboard,
presShell, nullptr, &actionTaken);
if (!strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) {
dom::Selection *sel =

Просмотреть файл

@ -25,7 +25,7 @@ class nsNPAPIPluginInstance;
* interface to mirror this interface when changing it.
*/
[scriptable, uuid(5efbd411-5bbe-4de1-9f3a-1c3459696eb2)]
[scriptable, uuid(2eb3195e-3eea-4083-bb1d-d2d70fa35ccb)]
interface nsIObjectLoadingContent : nsISupports
{
/**
@ -65,8 +65,6 @@ interface nsIObjectLoadingContent : nsISupports
const unsigned long PLUGIN_VULNERABLE_UPDATABLE = 9;
// The plugin is vulnerable (no update available)
const unsigned long PLUGIN_VULNERABLE_NO_UPDATE = 10;
// The plugin is in play preview mode
const unsigned long PLUGIN_PLAY_PREVIEW = 11;
/**
* The actual mime type (the one we got back from the network
@ -128,8 +126,7 @@ interface nsIObjectLoadingContent : nsISupports
in boolean submittedCrashReport);
/**
* This method will play a plugin that has been stopped by the
* click-to-play plugins or play-preview features.
* This method will play a plugin that has been stopped by click-to-play.
*/
void playPlugin();
@ -144,7 +141,7 @@ interface nsIObjectLoadingContent : nsISupports
/**
* This attribute will return true if the current content type has been
* activated, either explicitly or by passing checks that would have it be
* click-to-play or play-preview.
* click-to-play.
*/
readonly attribute boolean activated;
@ -184,11 +181,6 @@ interface nsIObjectLoadingContent : nsISupports
*/
readonly attribute bool hasRunningPlugin;
/**
* This method will disable the play-preview plugin state.
*/
void cancelPlayPreview();
/**
* If this plugin runs out-of-process, it has a runID to differentiate
* between different times the plugin process has been instantiated.

Просмотреть файл

@ -715,7 +715,6 @@ nsObjectLoadingContent::nsObjectLoadingContent()
, mInstantiating(false)
, mNetworkCreated(true)
, mActivated(false)
, mPlayPreviewCanceled(false)
, mIsStopping(false)
, mIsLoading(false)
, mScriptRequested(false) {}
@ -1406,8 +1405,6 @@ nsObjectLoadingContent::ObjectState() const
return NS_EVENT_STATE_USERDISABLED;
case eFallbackClickToPlay:
return NS_EVENT_STATE_TYPE_CLICK_TO_PLAY;
case eFallbackPlayPreview:
return NS_EVENT_STATE_TYPE_PLAY_PREVIEW;
case eFallbackDisabled:
return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_DISABLED;
case eFallbackBlocklisted:
@ -3122,7 +3119,7 @@ nsObjectLoadingContent::PlayPlugin()
LOG(("OBJLC [%p]: Activated by user", this));
}
// If we're in a click-to-play or play preview state, we need to reload
// If we're in a click-to-play state, reload.
// Fallback types >= eFallbackClickToPlay are plugin-replacement types, see
// header
if (mType == eType_Null && mFallbackType >= eFallbackClickToPlay) {
@ -3137,7 +3134,6 @@ nsObjectLoadingContent::Reload(bool aClearActivation)
{
if (aClearActivation) {
mActivated = false;
mPlayPreviewCanceled = false;
}
return LoadObject(true, true);
@ -3177,22 +3173,6 @@ nsObjectLoadingContent::GetHasRunningPlugin(bool *aHasPlugin)
return NS_OK;
}
NS_IMETHODIMP
nsObjectLoadingContent::CancelPlayPreview()
{
if (!nsContentUtils::IsCallerChrome())
return NS_ERROR_NOT_AVAILABLE;
mPlayPreviewCanceled = true;
// If we're in play preview state already, reload
if (mType == eType_Null && mFallbackType == eFallbackPlayPreview) {
return LoadObject(true, true);
}
return NS_OK;
}
NS_IMETHODIMP
nsObjectLoadingContent::GetRunID(uint32_t* aRunID)
{
@ -3238,31 +3218,6 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
nsCOMPtr<nsIPluginPlayPreviewInfo> playPreviewInfo;
bool isPlayPreviewSpecified = NS_SUCCEEDED(pluginHost->GetPlayPreviewInfo(
mContentType, getter_AddRefs(playPreviewInfo)));
if (isPlayPreviewSpecified) {
// Checking PlayPreview whitelist as well.
nsCString uriSpec, baseSpec;
if (mURI) {
mURI->GetSpec(uriSpec);
}
if (mBaseURI) {
mBaseURI->GetSpec(baseSpec);
}
playPreviewInfo->CheckWhitelist(baseSpec, uriSpec, &isPlayPreviewSpecified);
}
bool ignoreCTP = false;
if (isPlayPreviewSpecified) {
playPreviewInfo->GetIgnoreCTP(&ignoreCTP);
}
if (isPlayPreviewSpecified && !mPlayPreviewCanceled &&
ignoreCTP) {
// play preview in ignoreCTP mode is shown even if the native plugin
// is not present/installed
aReason = eFallbackPlayPreview;
return false;
}
// at this point if it's not a plugin, we let it play/fallback
if (!aIgnoreCurrentType && mType != eType_Plugin) {
return true;
@ -3272,8 +3227,6 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
// * Assume a default of click-to-play
// * If globally disabled, per-site permissions cannot override.
// * If blocklisted, override the reason with the blocklist reason
// * If not blocklisted but playPreview, override the reason with the
// playPreview reason.
// * Check per-site permissions and follow those if specified.
// * Honor per-plugin disabled permission
// * Blocklisted plugins are forced to CtP
@ -3309,12 +3262,6 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
aReason = eFallbackVulnerableNoUpdate;
}
if (aReason == eFallbackClickToPlay && isPlayPreviewSpecified &&
!mPlayPreviewCanceled && !ignoreCTP) {
// play preview in click-to-play mode is shown instead of standard CTP UI
aReason = eFallbackPlayPreview;
}
// Check the permission manager for permission based on the principal of
// the toplevel content.

Просмотреть файл

@ -94,9 +94,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent
eFallbackVulnerableUpdatable = nsIObjectLoadingContent::PLUGIN_VULNERABLE_UPDATABLE,
// The plugin is vulnerable (no update available)
eFallbackVulnerableNoUpdate = nsIObjectLoadingContent::PLUGIN_VULNERABLE_NO_UPDATE,
// The plugin is disabled and play preview content is displayed until
// the extension code enables it by sending the MozPlayPlugin event
eFallbackPlayPreview = nsIObjectLoadingContent::PLUGIN_PLAY_PREVIEW
};
nsObjectLoadingContent();
@ -225,10 +222,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent
{
return !!mInstanceOwner;
}
void CancelPlayPreview(mozilla::ErrorResult& aRv)
{
aRv = CancelPlayPreview();
}
void SwapFrameLoaders(nsXULElement& aOtherOwner, mozilla::ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
@ -622,16 +615,13 @@ class nsObjectLoadingContent : public nsImageLoadingContent
// activated by PlayPlugin(). (see ShouldPlay())
bool mActivated : 1;
// Used to keep track of whether or not a plugin is blocked by play-preview.
bool mPlayPreviewCanceled : 1;
// Protects DoStopPlugin from reentry (bug 724781).
bool mIsStopping : 1;
// Protects LoadObject from re-entry
bool mIsLoading : 1;
// For plugin stand-in types (click-to-play, play preview, ...) tracks
// For plugin stand-in types (click-to-play) tracks
// whether content js has tried to access the plugin script object.
bool mScriptRequested : 1;

Просмотреть файл

@ -62,8 +62,8 @@ enum UIStateChangeType
};
#define NS_PIDOMWINDOW_IID \
{ 0x2aebbbd7, 0x154b, 0x4341, \
{ 0x8d, 0x02, 0x7f, 0x70, 0xf8, 0x3e, 0xf7, 0xa1 } }
{ 0x052e675a, 0xacd3, 0x48d1, \
{ 0x8a, 0xcd, 0xbf, 0xff, 0xbd, 0x24, 0x4c, 0xed } }
class nsPIDOMWindow : public nsIDOMWindowInternal
{
@ -643,7 +643,7 @@ public:
*
* Inner windows only.
*/
virtual void EnableNetworkEvent(uint32_t aType) = 0;
virtual void EnableNetworkEvent(mozilla::EventMessage aEventMessage) = 0;
/**
* Tell the window that it should stop to listen to the network event of the
@ -651,7 +651,7 @@ public:
*
* Inner windows only.
*/
virtual void DisableNetworkEvent(uint32_t aType) = 0;
virtual void DisableNetworkEvent(mozilla::EventMessage aEventMessage) = 0;
#endif // MOZ_B2G
/**

Просмотреть файл

@ -59,10 +59,10 @@ nsScriptElement::ScriptEvaluated(nsresult aResult,
nsContentUtils::GetContextForContent(cont);
nsEventStatus status = nsEventStatus_eIgnore;
uint32_t type = NS_SUCCEEDED(aResult) ? NS_LOAD : NS_LOAD_ERROR;
WidgetEvent event(true, type);
EventMessage message = NS_SUCCEEDED(aResult) ? NS_LOAD : NS_LOAD_ERROR;
WidgetEvent event(true, message);
// Load event doesn't bubble.
event.mFlags.mBubbles = (type != NS_LOAD);
event.mFlags.mBubbles = (message != NS_LOAD);
EventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status);
}

Просмотреть файл

@ -636,7 +636,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
sriMetadata);
request->mURI = scriptURI;
request->mIsInline = false;
request->mLoading = true;
request->mProgress = nsScriptLoadRequest::Progress_Loading;
request->mReferrerPolicy = ourRefPolicy;
// set aScriptFromHead to false so we don't treat non preloaded scripts as
@ -651,14 +651,21 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
}
}
// Should still be in loading stage of script.
NS_ASSERTION(!request->InCompilingStage(),
"Request should not yet be in compiling stage.");
request->mJSVersion = version;
if (aElement->GetScriptAsync()) {
request->mIsAsync = true;
if (!request->mLoading) {
if (request->IsDoneLoading()) {
mLoadedAsyncRequests.AppendElement(request);
// The script is available already. Run it ASAP when the event
// loop gets a chance to spin.
// KVKV TODO: Instead of processing immediately, try off-thread-parsing
// it and only schedule a ProcessRequest if that fails.
ProcessPendingRequestsAsync();
} else {
mLoadingAsyncRequests.AppendElement(request);
@ -671,7 +678,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
// http://lists.w3.org/Archives/Public/public-html/2010Oct/0088.html
request->mIsNonAsyncScriptInserted = true;
mNonAsyncExternalScriptInsertedRequests.AppendElement(request);
if (!request->mLoading) {
if (request->IsDoneLoading()) {
// The script is available already. Run it ASAP when the event
// loop gets a chance to spin.
ProcessPendingRequestsAsync();
@ -700,14 +707,14 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
"Parser-blocking scripts and XSLT scripts in the same doc!");
request->mIsXSLT = true;
mXSLTRequests.AppendElement(request);
if (!request->mLoading) {
if (request->IsDoneLoading()) {
// The script is available already. Run it ASAP when the event
// loop gets a chance to spin.
ProcessPendingRequestsAsync();
}
return true;
}
if (!request->mLoading && ReadyToExecuteScripts()) {
if (request->IsDoneLoading() && ReadyToExecuteScripts()) {
// The request has already been loaded and there are no pending style
// sheets. If the script comes from the network stream, cheat for
// performance reasons and avoid a trip through the event loop.
@ -750,7 +757,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
request = new nsScriptLoadRequest(aElement, version, CORS_NONE,
SRIMetadata()); // SRI doesn't apply
request->mJSVersion = version;
request->mLoading = false;
request->mProgress = nsScriptLoadRequest::Progress_DoneLoading;
request->mIsInline = true;
request->mURI = mDocument->GetDocumentURI();
request->mLineNo = aElement->GetScriptLineNumber();
@ -819,9 +826,11 @@ public:
} /* anonymous namespace */
nsresult
nsScriptLoader::ProcessOffThreadRequest(nsScriptLoadRequest* aRequest, void **aOffThreadToken)
nsScriptLoader::ProcessOffThreadRequest(nsScriptLoadRequest* aRequest)
{
nsresult rv = ProcessRequest(aRequest, aOffThreadToken);
MOZ_ASSERT(aRequest->mProgress == nsScriptLoadRequest::Progress_Compiling);
aRequest->mProgress = nsScriptLoadRequest::Progress_DoneCompiling;
nsresult rv = ProcessRequest(aRequest);
mDocument->UnblockOnload(false);
return rv;
}
@ -853,14 +862,8 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run()
nsRefPtr<nsScriptLoadRequest> request = mRequest.forget();
nsRefPtr<nsScriptLoader> loader = mLoader.forget();
nsresult rv = loader->ProcessOffThreadRequest(request, &mToken);
if (mToken) {
// The result of the off thread parse was not actually needed to process
// the request (disappearing window, some other error, ...). Finish the
// request to avoid leaks in the JS engine.
JS::FinishOffThreadScript(nullptr, xpc::GetJSRuntime(), mToken);
}
request->mOffThreadToken = mToken;
nsresult rv = loader->ProcessOffThreadRequest(request);
return rv;
}
@ -911,23 +914,38 @@ nsScriptLoader::AttemptAsyncScriptParse(nsScriptLoadRequest* aRequest)
}
mDocument->BlockOnload();
aRequest->mProgress = nsScriptLoadRequest::Progress_Compiling;
unused << runnable.forget();
return NS_OK;
}
nsresult
nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest, void **aOffThreadToken)
nsScriptLoader::CompileOffThreadOrProcessRequest(nsScriptLoadRequest* aRequest)
{
NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
"Processing requests when running scripts is unsafe.");
NS_ASSERTION(!aRequest->mOffThreadToken,
"Candidate for off-thread compile is already parsed off-thread");
NS_ASSERTION(!aRequest->InCompilingStage(),
"Candidate for off-thread compile is already in compiling stage.");
if (!aOffThreadToken) {
nsresult rv = AttemptAsyncScriptParse(aRequest);
if (rv != NS_ERROR_FAILURE)
return rv;
nsresult rv = AttemptAsyncScriptParse(aRequest);
if (rv != NS_ERROR_FAILURE) {
return rv;
}
return ProcessRequest(aRequest);
}
nsresult
nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
{
NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
"Processing requests when running scripts is unsafe.");
NS_ASSERTION(aRequest->IsReadyToRun(),
"Processing a request that is not ready to run.");
NS_ENSURE_ARG(aRequest);
nsAutoString textData;
const char16_t* scriptBuf = nullptr;
@ -995,7 +1013,7 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest, void **aOffThreadT
doc->BeginEvaluatingExternalScript();
}
aRequest->mElement->BeginEvaluating();
rv = EvaluateScript(aRequest, srcBuf, aOffThreadToken);
rv = EvaluateScript(aRequest, srcBuf);
aRequest->mElement->EndEvaluating();
if (doc) {
doc->EndEvaluatingExternalScript();
@ -1013,6 +1031,15 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest, void **aOffThreadT
mCurrentParserInsertedScript = oldParserInsertedScript;
}
if (aRequest->mOffThreadToken) {
// The request was parsed off-main-thread, but the result of the off
// thread parse was not actually needed to process the request
// (disappearing window, some other error, ...). Finish the
// request to avoid leaks in the JS engine.
JS::FinishOffThreadScript(nullptr, xpc::GetJSRuntime(), aRequest->mOffThreadToken);
aRequest->mOffThreadToken = nullptr;
}
return rv;
}
@ -1103,8 +1130,7 @@ nsScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI &jsapi,
nsresult
nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
JS::SourceBufferHolder& aSrcBuf,
void** aOffThreadToken)
JS::SourceBufferHolder& aSrcBuf)
{
// We need a document to evaluate scripts.
if (!mDocument) {
@ -1169,7 +1195,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
JS::CompileOptions options(entryScript.cx());
FillCompileOptionsForRequest(entryScript, aRequest, global, &options);
rv = nsJSUtils::EvaluateString(entryScript.cx(), aSrcBuf, global, options,
aOffThreadToken);
aRequest->OffThreadTokenPtr());
}
context->SetProcessingScriptTag(oldProcessingScriptTag);
@ -1191,8 +1217,9 @@ void
nsScriptLoader::ProcessPendingRequests()
{
nsRefPtr<nsScriptLoadRequest> request;
if (mParserBlockingRequest &&
!mParserBlockingRequest->mLoading &&
mParserBlockingRequest->IsReadyToRun() &&
ReadyToExecuteScripts()) {
request.swap(mParserBlockingRequest);
UnblockParser(request);
@ -1202,18 +1229,18 @@ nsScriptLoader::ProcessPendingRequests()
while (ReadyToExecuteScripts() &&
!mXSLTRequests.isEmpty() &&
!mXSLTRequests.getFirst()->mLoading) {
mXSLTRequests.getFirst()->IsReadyToRun()) {
request = mXSLTRequests.StealFirst();
ProcessRequest(request);
}
while (mEnabled && !mLoadedAsyncRequests.isEmpty()) {
request = mLoadedAsyncRequests.StealFirst();
ProcessRequest(request);
CompileOffThreadOrProcessRequest(request);
}
while (mEnabled && !mNonAsyncExternalScriptInsertedRequests.isEmpty() &&
!mNonAsyncExternalScriptInsertedRequests.getFirst()->mLoading) {
mNonAsyncExternalScriptInsertedRequests.getFirst()->IsReadyToRun()) {
// Violate the HTML5 spec and execute these in the insertion order in
// order to make LABjs and the "order" plug-in for RequireJS work with
// their Gecko-sniffed code path. See
@ -1223,7 +1250,7 @@ nsScriptLoader::ProcessPendingRequests()
}
if (mDocumentParsingDone && mXSLTRequests.isEmpty()) {
while (!mDeferRequests.isEmpty() && !mDeferRequests.getFirst()->mLoading) {
while (!mDeferRequests.isEmpty() && mDeferRequests.getFirst()->IsReadyToRun()) {
request = mDeferRequests.StealFirst();
ProcessRequest(request);
}
@ -1436,10 +1463,16 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
NS_ASSERTION(request, "null request in stream complete handler");
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
nsCOMPtr<nsIHttpChannel> httpChannel;
{
nsCOMPtr<nsIRequest> req;
aLoader->GetRequest(getter_AddRefs(req));
httpChannel = do_QueryInterface(req);
} // throw away req, we only need the channel
nsresult rv = NS_ERROR_SRI_CORRUPT;
if (request->mIntegrity.IsEmpty() ||
NS_SUCCEEDED(SRICheck::VerifyIntegrity(request->mIntegrity,
request->mURI,
NS_SUCCEEDED(SRICheck::VerifyIntegrity(request->mIntegrity, httpChannel,
request->mCORSMode, aStringLen,
aString, mDocument))) {
rv = PrepareLoadedRequest(request, aLoader, aStatus, aStringLen, aString);
@ -1592,7 +1625,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
"aRequest should be pending!");
// Mark this as loaded
aRequest->mLoading = false;
aRequest->mProgress = nsScriptLoadRequest::Progress_DoneLoading;
// And if it's async, move it to the loaded list. aRequest->mIsAsync really
// _should_ be in a list, but the consequences if it's not are bad enough we
@ -1661,7 +1694,7 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
sriMetadata);
request->mURI = aURI;
request->mIsInline = false;
request->mLoading = true;
request->mProgress = nsScriptLoadRequest::Progress_Loading;
request->mReferrerPolicy = aReferrerPolicy;
nsresult rv = StartLoad(request, aType, aScriptFromHead);

Просмотреть файл

@ -60,7 +60,7 @@ public:
mozilla::CORSMode aCORSMode,
const mozilla::dom::SRIMetadata &aIntegrity)
: mElement(aElement),
mLoading(true),
mProgress(Progress_Loading),
mIsInline(true),
mHasSourceMapURL(false),
mIsDefer(false),
@ -68,6 +68,7 @@ public:
mIsNonAsyncScriptInserted(false),
mIsXSLT(false),
mIsCanceled(false),
mOffThreadToken(nullptr),
mScriptTextBuf(nullptr),
mScriptTextLength(0),
mJSVersion(aVersion),
@ -104,11 +105,33 @@ public:
return mIsCanceled;
}
void** OffThreadTokenPtr()
{
return mOffThreadToken ? &mOffThreadToken : nullptr;
}
enum Progress {
Progress_Loading,
Progress_DoneLoading,
Progress_Compiling,
Progress_DoneCompiling
};
bool IsReadyToRun() {
return mProgress == Progress_DoneLoading ||
mProgress == Progress_DoneCompiling;
}
bool IsDoneLoading() {
return mProgress == Progress_DoneLoading;
}
bool InCompilingStage() {
return (mProgress == Progress_Compiling) || (mProgress == Progress_DoneCompiling);
}
using super::getNext;
using super::isInList;
nsCOMPtr<nsIScriptElement> mElement;
bool mLoading; // Are we still waiting for a load to complete?
Progress mProgress; // Are we still waiting for a load to complete?
bool mIsInline; // Is the script inline or loaded?
bool mHasSourceMapURL; // Does the HTTP header have a source map url?
bool mIsDefer; // True if we live in mDeferRequests.
@ -116,6 +139,7 @@ public:
bool mIsNonAsyncScriptInserted; // True if we live in mNonAsyncExternalScriptInsertedRequests
bool mIsXSLT; // True if we live in mXSLTRequests.
bool mIsCanceled; // True if we have been explicitly canceled.
void* mOffThreadToken; // Off-thread parsing token.
nsString mSourceMapURL; // Holds source map url for loaded scripts
char16_t* mScriptTextBuf; // Holds script text for non-inline scripts. Don't
size_t mScriptTextLength; // use nsString so we can give ownership to jsapi.
@ -385,8 +409,7 @@ public:
* Process a request that was deferred so that the script could be compiled
* off thread.
*/
nsresult ProcessOffThreadRequest(nsScriptLoadRequest *aRequest,
void **aOffThreadToken);
nsresult ProcessOffThreadRequest(nsScriptLoadRequest *aRequest);
bool AddPendingChildLoader(nsScriptLoader* aChild) {
return mPendingChildLoaders.AppendElement(aChild) != nullptr;
@ -446,15 +469,14 @@ private:
}
nsresult AttemptAsyncScriptParse(nsScriptLoadRequest* aRequest);
nsresult ProcessRequest(nsScriptLoadRequest* aRequest,
void **aOffThreadToken = nullptr);
nsresult ProcessRequest(nsScriptLoadRequest* aRequest);
nsresult CompileOffThreadOrProcessRequest(nsScriptLoadRequest* aRequest);
void FireScriptAvailable(nsresult aResult,
nsScriptLoadRequest* aRequest);
void FireScriptEvaluated(nsresult aResult,
nsScriptLoadRequest* aRequest);
nsresult EvaluateScript(nsScriptLoadRequest* aRequest,
JS::SourceBufferHolder& aSrcBuf,
void **aOffThreadToken);
JS::SourceBufferHolder& aSrcBuf);
already_AddRefed<nsIScriptGlobalObject> GetScriptGlobalObject();
void FillCompileOptionsForRequest(const mozilla::dom::AutoJSAPI &jsapi,

Просмотреть файл

@ -13,14 +13,14 @@
#include "nsServiceManagerUtils.h"
#include "nsContentUtils.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "js/StructuredClone.h"
#include "xpcpublic.h"
#include "mozilla/Base64.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/ScriptSettings.h"
using namespace mozilla;
using namespace mozilla::dom;
NS_IMPL_ADDREF(nsStructuredCloneContainer)
NS_IMPL_RELEASE(nsStructuredCloneContainer)
@ -31,53 +31,44 @@ NS_INTERFACE_MAP_BEGIN(nsStructuredCloneContainer)
NS_INTERFACE_MAP_END
nsStructuredCloneContainer::nsStructuredCloneContainer()
: mData(nullptr), mSize(0), mVersion(0)
: StructuredCloneHelper(CloningSupported, TransferringNotSupported)
, mState(eNotInitialized) , mData(nullptr), mSize(0), mVersion(0)
{
}
nsStructuredCloneContainer::~nsStructuredCloneContainer()
{
free(mData);
if (mData) {
free(mData);
}
}
nsresult
NS_IMETHODIMP
nsStructuredCloneContainer::InitFromJSVal(JS::Handle<JS::Value> aData,
JSContext* aCx)
{
NS_ENSURE_STATE(!mData);
uint64_t* jsBytes = nullptr;
bool success = JS_WriteStructuredClone(aCx, aData, &jsBytes, &mSize,
nullptr, nullptr,
JS::UndefinedHandleValue);
NS_ENSURE_STATE(success);
NS_ENSURE_STATE(jsBytes);
// Copy jsBytes into our own buffer.
mData = (uint64_t*) malloc(mSize);
if (!mData) {
mSize = 0;
mVersion = 0;
JS_ClearStructuredClone(jsBytes, mSize, nullptr, nullptr);
if (mState != eNotInitialized) {
return NS_ERROR_FAILURE;
}
else {
mVersion = JS_STRUCTURED_CLONE_VERSION;
ErrorResult rv;
Write(aCx, aData, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
memcpy(mData, jsBytes, mSize);
JS_ClearStructuredClone(jsBytes, mSize, nullptr, nullptr);
mState = eInitializedFromJSVal;
return NS_OK;
}
nsresult
NS_IMETHODIMP
nsStructuredCloneContainer::InitFromBase64(const nsAString &aData,
uint32_t aFormatVersion,
JSContext *aCx)
JSContext* aCx)
{
NS_ENSURE_STATE(!mData);
if (mState != eNotInitialized) {
return NS_ERROR_FAILURE;
}
NS_ConvertUTF16toUTF8 data(aData);
@ -92,6 +83,8 @@ nsStructuredCloneContainer::InitFromBase64(const nsAString &aData,
mSize = binaryData.Length();
mVersion = aFormatVersion;
mState = eInitializedFromBase64;
return NS_OK;
}
@ -101,31 +94,45 @@ nsStructuredCloneContainer::DeserializeToJsval(JSContext* aCx,
{
aValue.setNull();
JS::Rooted<JS::Value> jsStateObj(aCx);
bool hasTransferable = false;
bool success = JS_ReadStructuredClone(aCx, mData, mSize, mVersion,
&jsStateObj, nullptr, nullptr) &&
JS_StructuredCloneHasTransferables(mData, mSize,
&hasTransferable);
// We want to be sure that mData doesn't contain transferable objects
MOZ_ASSERT(!hasTransferable);
NS_ENSURE_STATE(success && !hasTransferable);
if (mState == eInitializedFromJSVal) {
ErrorResult rv;
Read(nullptr, aCx, &jsStateObj, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
} else {
MOZ_ASSERT(mState == eInitializedFromBase64);
MOZ_ASSERT(mData);
ErrorResult rv;
ReadFromBuffer(nullptr, aCx, mData, mSize, mVersion, &jsStateObj, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
}
aValue.set(jsStateObj);
return NS_OK;
}
nsresult
nsStructuredCloneContainer::DeserializeToVariant(JSContext *aCx,
nsIVariant **aData)
NS_IMETHODIMP
nsStructuredCloneContainer::DeserializeToVariant(JSContext* aCx,
nsIVariant** aData)
{
NS_ENSURE_STATE(mData);
NS_ENSURE_ARG_POINTER(aData);
*aData = nullptr;
if (mState == eNotInitialized) {
return NS_ERROR_FAILURE;
}
// Deserialize to a JS::Value.
JS::Rooted<JS::Value> jsStateObj(aCx);
nsresult rv = DeserializeToJsval(aCx, &jsStateObj);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// Now wrap the JS::Value as an nsIVariant.
nsCOMPtr<nsIVariant> varStateObj;
@ -134,31 +141,64 @@ nsStructuredCloneContainer::DeserializeToVariant(JSContext *aCx,
xpconnect->JSValToVariant(aCx, jsStateObj, getter_AddRefs(varStateObj));
NS_ENSURE_STATE(varStateObj);
NS_ADDREF(*aData = varStateObj);
varStateObj.forget(aData);
return NS_OK;
}
nsresult
NS_IMETHODIMP
nsStructuredCloneContainer::GetDataAsBase64(nsAString &aOut)
{
NS_ENSURE_STATE(mData);
aOut.Truncate();
nsAutoCString binaryData(reinterpret_cast<char*>(mData), mSize);
if (mState == eNotInitialized) {
return NS_ERROR_FAILURE;
}
uint64_t* data;
size_t size;
if (mState == eInitializedFromJSVal) {
if (HasClonedDOMObjects()) {
return NS_ERROR_FAILURE;
}
data = BufferData();
size = BufferSize();
} else {
MOZ_ASSERT(mState == eInitializedFromBase64);
MOZ_ASSERT(mData);
data = mData;
size = mSize;
}
nsAutoCString binaryData(reinterpret_cast<char*>(data), size);
nsAutoCString base64Data;
nsresult rv = Base64Encode(binaryData, base64Data);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
aOut.Assign(NS_ConvertASCIItoUTF16(base64Data));
CopyASCIItoUTF16(base64Data, aOut);
return NS_OK;
}
nsresult
nsStructuredCloneContainer::GetSerializedNBytes(uint64_t *aSize)
NS_IMETHODIMP
nsStructuredCloneContainer::GetSerializedNBytes(uint64_t* aSize)
{
NS_ENSURE_STATE(mData);
NS_ENSURE_ARG_POINTER(aSize);
if (mState == eNotInitialized) {
return NS_ERROR_FAILURE;
}
if (mState == eInitializedFromJSVal) {
*aSize = BufferSize();
return NS_OK;
}
MOZ_ASSERT(mState == eInitializedFromBase64);
// mSize is a size_t, while aSize is a uint64_t. We rely on an implicit cast
// here so that we'll get a compile error if a size_t-to-uint64_t cast is
// narrowing.
@ -167,11 +207,21 @@ nsStructuredCloneContainer::GetSerializedNBytes(uint64_t *aSize)
return NS_OK;
}
nsresult
nsStructuredCloneContainer::GetFormatVersion(uint32_t *aFormatVersion)
NS_IMETHODIMP
nsStructuredCloneContainer::GetFormatVersion(uint32_t* aFormatVersion)
{
NS_ENSURE_STATE(mData);
NS_ENSURE_ARG_POINTER(aFormatVersion);
if (mState == eNotInitialized) {
return NS_ERROR_FAILURE;
}
if (mState == eInitializedFromJSVal) {
*aFormatVersion = JS_STRUCTURED_CLONE_VERSION;
return NS_OK;
}
MOZ_ASSERT(mState == eInitializedFromBase64);
*aFormatVersion = mVersion;
return NS_OK;
}

Просмотреть файл

@ -9,6 +9,7 @@
#include "nsIStructuredCloneContainer.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#define NS_STRUCTUREDCLONECONTAINER_CONTRACTID \
"@mozilla.org/docshell/structured-clone-container;1"
@ -20,7 +21,9 @@
{0xb8, 0x5f, 0x13, 0xce, 0xd8, 0x89, 0xee, 0xec} \
}
class nsStructuredCloneContainer final : public nsIStructuredCloneContainer
class nsStructuredCloneContainer final
: public nsIStructuredCloneContainer
, public mozilla::dom::StructuredCloneHelper
{
public:
nsStructuredCloneContainer();
@ -31,6 +34,12 @@ class nsStructuredCloneContainer final : public nsIStructuredCloneContainer
private:
~nsStructuredCloneContainer();
enum {
eNotInitialized = 0,
eInitializedFromJSVal,
eInitializedFromBase64,
} mState;
uint64_t* mData;
// This needs to be size_t rather than a PR-type so it matches the JS API.

Просмотреть файл

@ -740,19 +740,21 @@ skip-if = buildapp == 'b2g' || buildapp == 'mulet' || toolkit == 'android' || e1
[test_ipc_messagemanager_blob.html]
skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 936226
[test_meta_viewport0.html]
skip-if = buildapp != 'b2g' # meta-viewport tag support is only on b2g
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_meta_viewport1.html]
skip-if = buildapp != 'b2g' # meta-viewport tag support is only on b2g
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_meta_viewport2.html]
skip-if = buildapp != 'b2g' # meta-viewport tag support is only on b2g
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_meta_viewport3.html]
skip-if = buildapp != 'b2g' # meta-viewport tag support is only on b2g
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_meta_viewport4.html]
skip-if = buildapp != 'b2g' # meta-viewport tag support is only on b2g
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_meta_viewport5.html]
skip-if = buildapp != 'b2g' # meta-viewport tag support is only on b2g
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_meta_viewport6.html]
skip-if = buildapp != 'b2g' # meta-viewport tag support is only on b2g
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_meta_viewport7.html]
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
[test_mozfiledataurl.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT
[test_mozMatchesSelector.html]

Просмотреть файл

@ -0,0 +1,114 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>meta viewport test</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta name="viewport" content="width=320">
<script src="viewport_helpers.js"></script>
</head>
<body>
<p>Dynamic viewport updates</p>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
let tests = [];
tests.push(function test1() {
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
function() {
updateViewport("width=device-width");
let info = getViewportInfo(800, 480);
is(info.defaultZoom, 1, "initial zoom is 100%");
is(info.width, 800, "width is the same as the displayWidth");
is(info.height, 480, "height is the same as the displayHeight");
is(info.autoSize, true, "width=device-width enables autoSize");
is(info.allowZoom, true, "zooming is enabled by default");
info = getViewportInfo(900, 600);
is(info.width, 900, "changing the displayWidth changes the width");
is(info.height, 600, "changing the displayHeight changes the height");
nextTest();
});
});
tests.push(function test2() {
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
function() {
updateViewport("width=320");
let info = getViewportInfo(800, 80);
is(info.defaultZoom, 2.5, "initial zoom fits the displayWidth");
is(info.width, 320, "width is set explicitly");
is(info.height, 40, "height is at the absolute minimum");
is(info.autoSize, false, "width=device-width enables autoSize");
is(info.allowZoom, true, "zooming is enabled by default");
info = getViewportInfo(480, 800);
is(info.defaultZoom, 1.5, "initial zoom fits the new displayWidth");
is(info.width, 320, "explicit width is unchanged");
is(info.height, 533, "height changes proportional to displayHeight");
nextTest();
});
});
tests.push(function test3() {
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
function() {
updateViewport("user-scalable=no");
let info = getViewportInfo(800, 480);
is(info.allowZoom, false, "zooming is explicitly disabled");
nextTest();
});
});
tests.push(function test4() {
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
function() {
updateViewport("user-scalable=yes");
let info = getViewportInfo(800, 480);
is(info.allowZoom, true, "zooming is explicitly allowed");
nextTest();
});
});
function getViewportInfo(aDisplayWidth, aDisplayHeight) {
let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
width = {}, height = {}, autoSize = {};
let cwu = SpecialPowers.getDOMWindowUtils(window);
cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
minZoom, maxZoom, width, height, autoSize);
return {
defaultZoom: defaultZoom.value,
minZoom: minZoom.value,
maxZoom: maxZoom.value,
width: width.value,
height: height.value,
autoSize: autoSize.value,
allowZoom: allowZoom.value
};
}
function updateViewport(content) {
let meta = document.querySelector("meta[name=viewport]");
meta.content = content;
}
function nextTest() {
if (tests.length) {
(tests.shift())();
} else {
SimpleTest.finish();
}
}
addEventListener("load", nextTest);
</script>
</body>
</html>

Просмотреть файл

@ -51,6 +51,7 @@ MSG_DEF(MSG_NOT_DATE, 1, JSEXN_TYPEERR, "{0} is not a date.")
MSG_DEF(MSG_INVALID_ADVANCE_COUNT, 0, JSEXN_TYPEERR, "0 (Zero) is not a valid advance count.")
MSG_DEF(MSG_DEFINEPROPERTY_ON_GSP, 0, JSEXN_TYPEERR, "Not allowed to define a property on the named properties object.")
MSG_DEF(MSG_INVALID_URL, 1, JSEXN_TYPEERR, "{0} is not a valid URL.")
MSG_DEF(MSG_URL_HAS_CREDENTIALS, 1, JSEXN_TYPEERR, "{0} is an url with embedded credentials.")
MSG_DEF(MSG_METADATA_NOT_CONFIGURED, 0, JSEXN_TYPEERR, "Either size or lastModified should be true.")
MSG_DEF(MSG_INVALID_READ_SIZE, 0, JSEXN_TYPEERR, "0 (Zero) is not a valid read size.")
MSG_DEF(MSG_HEADERS_IMMUTABLE, 0, JSEXN_TYPEERR, "Headers are immutable and cannot be modified.")

Просмотреть файл

@ -7,14 +7,6 @@
#ifndef DOM_CAMERA_CAMERACOMMON_H
#define DOM_CAMERA_CAMERACOMMON_H
#ifndef __func__
#ifdef __FUNCTION__
#define __func__ __FUNCTION__
#else
#define __func__ __FILE__
#endif
#endif
#include "mozilla/Logging.h"
extern PRLogModuleInfo* GetCameraLog();

Просмотреть файл

@ -8,6 +8,9 @@ GeckoCppUnitTests([
'TestWebGLElementArrayCache',
])
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

Просмотреть файл

@ -9,6 +9,7 @@
class nsPIDOMWindow;
#include "mozilla/Attributes.h"
#include "mozilla/Logging.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
#include "DOMRequest.h"
@ -42,11 +43,6 @@ class Blob;
//#define DS_LOGGING 1
#ifdef DS_LOGGING
/* Polyfill __func__ on MSVC to pass to the log. */
#ifdef _MSC_VER
#define __func__ __FUNCTION__
#endif
#define DS_LOG_DEBUG(msg, ...) printf_stderr("[%s:%d] " msg "\n", __func__, __LINE__, ##__VA_ARGS__)
#define DS_LOG_INFO DS_LOG_DEBUG
#define DS_LOG_WARN DS_LOG_DEBUG

Просмотреть файл

@ -15,7 +15,7 @@ AnimationEvent::AnimationEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalAnimationEvent* aEvent)
: Event(aOwner, aPresContext,
aEvent ? aEvent : new InternalAnimationEvent(false, 0))
aEvent ? aEvent : new InternalAnimationEvent(false, NS_EVENT_NULL))
{
if (aEvent) {
mEventIsInternal = false;

Просмотреть файл

@ -17,7 +17,8 @@ BeforeAfterKeyboardEvent::BeforeAfterKeyboardEvent(
InternalBeforeAfterKeyboardEvent* aEvent)
: KeyboardEvent(aOwner, aPresContext,
aEvent ? aEvent :
new InternalBeforeAfterKeyboardEvent(false, 0,
new InternalBeforeAfterKeyboardEvent(false,
NS_EVENT_NULL,
nullptr))
{
MOZ_ASSERT(mEvent->mClass == eBeforeAfterKeyboardEventClass,

Просмотреть файл

@ -16,7 +16,7 @@ ClipboardEvent::ClipboardEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalClipboardEvent* aEvent)
: Event(aOwner, aPresContext,
aEvent ? aEvent : new InternalClipboardEvent(false, 0))
aEvent ? aEvent : new InternalClipboardEvent(false, NS_EVENT_NULL))
{
if (aEvent) {
mEventIsInternal = false;

Просмотреть файл

@ -15,7 +15,8 @@ CompositionEvent::CompositionEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetCompositionEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetCompositionEvent(false, 0, nullptr))
aEvent ? aEvent :
new WidgetCompositionEvent(false, NS_EVENT_NULL, nullptr))
{
NS_ASSERTION(mEvent->mClass == eCompositionEventClass,
"event type mismatch");

Просмотреть файл

@ -155,9 +155,9 @@ DataTransfer::Constructor(const GlobalObject& aGlobal,
return nullptr;
}
uint32_t eventType = nsContentUtils::GetEventId(eventTypeAtom);
EventMessage eventMessage = nsContentUtils::GetEventMessage(eventTypeAtom);
nsRefPtr<DataTransfer> transfer = new DataTransfer(aGlobal.GetAsSupports(),
eventType, aIsExternal,
eventMessage, aIsExternal,
-1);
return transfer.forget();
}

Просмотреть файл

@ -16,7 +16,8 @@ DragEvent::DragEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetDragEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetDragEvent(false, 0, nullptr))
aEvent ? aEvent :
new WidgetDragEvent(false, NS_EVENT_NULL, nullptr))
{
if (aEvent) {
mEventIsInternal = false;

Просмотреть файл

@ -106,7 +106,7 @@ Event::ConstructorInit(EventTarget* aOwner,
...
}
*/
mEvent = new WidgetEvent(false, 0);
mEvent = new WidgetEvent(false, NS_EVENT_NULL);
mEvent->time = PR_Now();
}
@ -563,8 +563,8 @@ Event::SetEventType(const nsAString& aEventTypeArg)
if (mIsMainThreadEvent) {
mEvent->typeString.Truncate();
mEvent->userType =
nsContentUtils::GetEventIdAndAtom(aEventTypeArg, mEvent->mClass,
&(mEvent->mMessage));
nsContentUtils::GetEventMessageAndAtom(aEventTypeArg, mEvent->mClass,
&(mEvent->mMessage));
} else {
mEvent->userType = nullptr;
mEvent->mMessage = NS_USER_DEFINED_EVENT;
@ -726,6 +726,8 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
abuse = openControlled;
}
break;
default:
break;
}
}
break;
@ -740,6 +742,8 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
abuse = openControlled;
}
break;
default:
break;
}
}
break;
@ -757,6 +761,8 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
case NS_XUL_COMMAND:
abuse = openControlled;
break;
default:
break;
}
}
break;
@ -785,6 +791,8 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
abuse = openControlled;
}
break;
default:
break;
}
}
break;
@ -801,6 +809,8 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
abuse = openControlled;
}
break;
default:
break;
}
}
break;
@ -832,6 +842,8 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
abuse = openControlled;
}
break;
default:
break;
}
}
break;
@ -851,6 +863,8 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
abuse = openControlled;
}
break;
default:
break;
}
}
break;
@ -1026,13 +1040,13 @@ Event::GetOffsetCoords(nsPresContext* aPresContext,
// logic for handling user-defined events).
// static
const char*
Event::GetEventName(uint32_t aEventType)
Event::GetEventName(EventMessage aEventType)
{
switch(aEventType) {
#define ID_TO_EVENT(name_, _id, _type, _struct) \
case _id: return #name_;
#define MESSAGE_TO_EVENT(name_, _message, _type, _struct) \
case _message: return #name_;
#include "mozilla/EventNameList.h"
#undef ID_TO_EVENT
#undef MESSAGE_TO_EVENT
default:
break;
}

Просмотреть файл

@ -124,7 +124,7 @@ public:
static void Shutdown();
static const char* GetEventName(uint32_t aEventType);
static const char* GetEventName(EventMessage aEventType);
static CSSIntPoint GetClientCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,
LayoutDeviceIntPoint aPoint,

Просмотреть файл

@ -52,11 +52,11 @@ namespace mozilla {
using namespace dom;
using namespace hal;
#define EVENT_TYPE_EQUALS(ls, type, userType, typeString, allEvents) \
((ls->mEventType == type && \
(ls->mEventType != NS_USER_DEFINED_EVENT || \
(mIsMainThreadELM && ls->mTypeAtom == userType) || \
(!mIsMainThreadELM && ls->mTypeString.Equals(typeString)))) || \
#define EVENT_TYPE_EQUALS(ls, message, userType, typeString, allEvents) \
((ls->mEventMessage == message && \
(ls->mEventMessage != NS_USER_DEFINED_EVENT || \
(mIsMainThreadELM && ls->mTypeAtom == userType) || \
(!mIsMainThreadELM && ls->mTypeString.Equals(typeString)))) || \
(allEvents && ls->mAllEvents))
static const uint32_t kAllMutationBits =
@ -69,7 +69,7 @@ static const uint32_t kAllMutationBits =
NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED;
static uint32_t
MutationBitForEventType(uint32_t aEventType)
MutationBitForEventType(EventMessage aEventType)
{
switch (aEventType) {
case NS_MUTATION_SUBTREEMODIFIED:
@ -94,8 +94,9 @@ MutationBitForEventType(uint32_t aEventType)
uint32_t EventListenerManager::sMainThreadCreatedCount = 0;
EventListenerManager::EventListenerManager(EventTarget* aTarget)
: mMayHavePaintEventListener(false)
EventListenerManagerBase::EventListenerManagerBase()
: mNoListenerForEvent(NS_EVENT_NULL)
, mMayHavePaintEventListener(false)
, mMayHaveMutationListeners(false)
, mMayHaveCapturingListeners(false)
, mMayHaveSystemGroupListeners(false)
@ -106,7 +107,13 @@ EventListenerManager::EventListenerManager(EventTarget* aTarget)
, mMayHaveInputOrCompositionEventListener(false)
, mClearingListeners(false)
, mIsMainThreadELM(NS_IsMainThread())
, mNoListenerForEvent(0)
{
static_assert(sizeof(EventListenerManagerBase) == sizeof(uint32_t),
"Keep the size of EventListenerManagerBase size compact!");
}
EventListenerManager::EventListenerManager(EventTarget* aTarget)
: EventListenerManagerBase()
, mTarget(aTarget)
{
NS_ASSERTION(aTarget, "unexpected null pointer");
@ -215,15 +222,17 @@ EventListenerManager::GetTargetAsInnerWindow() const
void
EventListenerManager::AddEventListenerInternal(
const EventListenerHolder& aListenerHolder,
uint32_t aType,
EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aHandler,
bool aAllEvents)
{
MOZ_ASSERT((NS_IsMainThread() && aType && aTypeAtom) || // Main thread
(!NS_IsMainThread() && aType && !aTypeString.IsEmpty()) || // non-main-thread
MOZ_ASSERT(// Main thread
(NS_IsMainThread() && aEventMessage && aTypeAtom) ||
// non-main-thread
(!NS_IsMainThread() && aEventMessage && !aTypeString.IsEmpty()) ||
aAllEvents, "Missing type"); // all-events listener
if (!aListenerHolder || mClearingListeners) {
@ -241,7 +250,7 @@ EventListenerManager::AddEventListenerInternal(
// mListener == aListenerHolder is the last one, since it can be a bit slow.
if (listener->mListenerIsHandler == aHandler &&
listener->mFlags == aFlags &&
EVENT_TYPE_EQUALS(listener, aType, aTypeAtom, aTypeString,
EVENT_TYPE_EQUALS(listener, aEventMessage, aTypeAtom, aTypeString,
aAllEvents) &&
listener->mListener == aListenerHolder) {
return;
@ -254,8 +263,7 @@ EventListenerManager::AddEventListenerInternal(
listener = aAllEvents ? mListeners.InsertElementAt(0) :
mListeners.AppendElement();
listener->mListener = aListenerHolder;
MOZ_ASSERT(aType < PR_UINT16_MAX);
listener->mEventType = aType;
listener->mEventMessage = aEventMessage;
listener->mTypeString = aTypeString;
listener->mTypeAtom = aTypeAtom;
listener->mFlags = aFlags;
@ -284,13 +292,14 @@ EventListenerManager::AddEventListenerInternal(
mMayHaveCapturingListeners = true;
}
if (aType == NS_AFTERPAINT) {
if (aEventMessage == NS_AFTERPAINT) {
mMayHavePaintEventListener = true;
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window) {
window->SetHasPaintEventListeners();
}
} else if (aType >= NS_MUTATION_START && aType <= NS_MUTATION_END) {
} else if (aEventMessage >= NS_MUTATION_START &&
aEventMessage <= NS_MUTATION_END) {
// For mutation listeners, we need to update the global bit on the DOM window.
// Otherwise we won't actually fire the mutation event.
mMayHaveMutationListeners = true;
@ -301,11 +310,11 @@ EventListenerManager::AddEventListenerInternal(
if (doc) {
doc->WarnOnceAbout(nsIDocument::eMutationEvent);
}
// If aType is NS_MUTATION_SUBTREEMODIFIED, we need to listen all
// If aEventMessage is NS_MUTATION_SUBTREEMODIFIED, we need to listen all
// mutations. nsContentUtils::HasMutationListeners relies on this.
window->SetMutationListeners((aType == NS_MUTATION_SUBTREEMODIFIED) ?
kAllMutationBits :
MutationBitForEventType(aType));
window->SetMutationListeners(
(aEventMessage == NS_MUTATION_SUBTREEMODIFIED) ?
kAllMutationBits : MutationBitForEventType(aEventMessage));
}
} else if (aTypeAtom == nsGkAtoms::ondeviceorientation) {
EnableDevice(NS_DEVICE_ORIENTATION);
@ -343,7 +352,8 @@ EventListenerManager::AddEventListenerInternal(
if (window && !aFlags.mInSystemGroup) {
window->SetHasTouchEventListeners();
}
} else if (aType >= NS_POINTER_EVENT_START && aType <= NS_POINTER_LOST_CAPTURE) {
} else if (aEventMessage >= NS_POINTER_EVENT_START &&
aEventMessage <= NS_POINTER_LOST_CAPTURE) {
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (aTypeAtom == nsGkAtoms::onpointerenter ||
aTypeAtom == nsGkAtoms::onpointerleave) {
@ -372,8 +382,8 @@ EventListenerManager::AddEventListenerInternal(
window->SetHasMouseEnterLeaveEventListeners();
}
#ifdef MOZ_GAMEPAD
} else if (aType >= NS_GAMEPAD_START &&
aType <= NS_GAMEPAD_END) {
} else if (aEventMessage >= NS_GAMEPAD_START &&
aEventMessage <= NS_GAMEPAD_END) {
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window) {
window->SetHasGamepadEventListener();
@ -405,9 +415,9 @@ EventListenerManager::AddEventListenerInternal(
}
bool
EventListenerManager::IsDeviceType(uint32_t aType)
EventListenerManager::IsDeviceType(EventMessage aEventMessage)
{
switch (aType) {
switch (aEventMessage) {
case NS_DEVICE_ORIENTATION:
case NS_DEVICE_MOTION:
case NS_DEVICE_LIGHT:
@ -421,14 +431,14 @@ EventListenerManager::IsDeviceType(uint32_t aType)
}
void
EventListenerManager::EnableDevice(uint32_t aType)
EventListenerManager::EnableDevice(EventMessage aEventMessage)
{
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
if (!window) {
return;
}
switch (aType) {
switch (aEventMessage) {
case NS_DEVICE_ORIENTATION:
window->EnableDeviceSensor(SENSOR_ORIENTATION);
break;
@ -451,14 +461,14 @@ EventListenerManager::EnableDevice(uint32_t aType)
}
void
EventListenerManager::DisableDevice(uint32_t aType)
EventListenerManager::DisableDevice(EventMessage aEventMessage)
{
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
if (!window) {
return;
}
switch (aType) {
switch (aEventMessage) {
case NS_DEVICE_ORIENTATION:
window->DisableDeviceSensor(SENSOR_ORIENTATION);
break;
@ -483,13 +493,13 @@ EventListenerManager::DisableDevice(uint32_t aType)
void
EventListenerManager::RemoveEventListenerInternal(
const EventListenerHolder& aListenerHolder,
uint32_t aType,
EventMessage aEventMessage,
nsIAtom* aUserType,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aAllEvents)
{
if (!aListenerHolder || !aType || mClearingListeners) {
if (!aListenerHolder || !aEventMessage || mClearingListeners) {
return;
}
@ -497,16 +507,16 @@ EventListenerManager::RemoveEventListenerInternal(
uint32_t count = mListeners.Length();
uint32_t typeCount = 0;
bool deviceType = IsDeviceType(aType);
bool deviceType = IsDeviceType(aEventMessage);
#ifdef MOZ_B2G
bool timeChangeEvent = (aType == NS_MOZ_TIME_CHANGE_EVENT);
bool networkEvent = (aType == NS_NETWORK_UPLOAD_EVENT ||
aType == NS_NETWORK_DOWNLOAD_EVENT);
bool timeChangeEvent = (aEventMessage == NS_MOZ_TIME_CHANGE_EVENT);
bool networkEvent = (aEventMessage == NS_NETWORK_UPLOAD_EVENT ||
aEventMessage == NS_NETWORK_DOWNLOAD_EVENT);
#endif // MOZ_B2G
for (uint32_t i = 0; i < count; ++i) {
listener = &mListeners.ElementAt(i);
if (EVENT_TYPE_EQUALS(listener, aType, aUserType, aTypeString,
if (EVENT_TYPE_EQUALS(listener, aEventMessage, aUserType, aTypeString,
aAllEvents)) {
++typeCount;
if (listener->mListener == aListenerHolder &&
@ -537,7 +547,7 @@ EventListenerManager::RemoveEventListenerInternal(
}
if (!aAllEvents && deviceType && typeCount == 0) {
DisableDevice(aType);
DisableDevice(aEventMessage);
#ifdef MOZ_B2G
} else if (timeChangeEvent && typeCount == 0) {
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
@ -547,7 +557,7 @@ EventListenerManager::RemoveEventListenerInternal(
} else if (!aAllEvents && networkEvent && typeCount == 0) {
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
if (window) {
window->DisableNetworkEvent(aType);
window->DisableNetworkEvent(aEventMessage);
}
#endif // MOZ_B2G
}
@ -559,7 +569,7 @@ EventListenerManager::ListenerCanHandle(Listener* aListener,
{
// This is slightly different from EVENT_TYPE_EQUALS in that it returns
// true even when aEvent->mMessage == NS_USER_DEFINED_EVENT and
// aListener=>mEventType != NS_USER_DEFINED_EVENT as long as the atoms are
// aListener=>mEventMessage != NS_USER_DEFINED_EVENT as long as the atoms are
// the same
if (aListener->mAllEvents) {
return true;
@ -571,7 +581,7 @@ EventListenerManager::ListenerCanHandle(Listener* aListener,
return aListener->mTypeString.Equals(aEvent->typeString);
}
MOZ_ASSERT(mIsMainThreadELM);
return aListener->mEventType == aEvent->mMessage;
return aListener->mEventMessage == aEvent->mMessage;
}
void
@ -582,8 +592,8 @@ EventListenerManager::AddEventListenerByType(
{
nsCOMPtr<nsIAtom> atom =
mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
uint32_t type = nsContentUtils::GetEventId(atom);
AddEventListenerInternal(aListenerHolder, type, atom, aType, aFlags);
EventMessage message = nsContentUtils::GetEventMessage(atom);
AddEventListenerInternal(aListenerHolder, message, atom, aType, aFlags);
}
void
@ -594,12 +604,12 @@ EventListenerManager::RemoveEventListenerByType(
{
nsCOMPtr<nsIAtom> atom =
mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
uint32_t type = nsContentUtils::GetEventId(atom);
RemoveEventListenerInternal(aListenerHolder, type, atom, aType, aFlags);
EventMessage message = nsContentUtils::GetEventMessage(atom);
RemoveEventListenerInternal(aListenerHolder, message, atom, aType, aFlags);
}
EventListenerManager::Listener*
EventListenerManager::FindEventHandler(uint32_t aEventType,
EventListenerManager::FindEventHandler(EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString)
{
@ -610,7 +620,7 @@ EventListenerManager::FindEventHandler(uint32_t aEventType,
for (uint32_t i = 0; i < count; ++i) {
listener = &mListeners.ElementAt(i);
if (listener->mListenerIsHandler &&
EVENT_TYPE_EQUALS(listener, aEventType, aTypeAtom, aTypeString,
EVENT_TYPE_EQUALS(listener, aEventMessage, aTypeAtom, aTypeString,
false)) {
return listener;
}
@ -627,8 +637,8 @@ EventListenerManager::SetEventHandlerInternal(
{
MOZ_ASSERT(aName || !aTypeString.IsEmpty());
uint32_t eventType = nsContentUtils::GetEventId(aName);
Listener* listener = FindEventHandler(eventType, aName, aTypeString);
EventMessage eventMessage = nsContentUtils::GetEventMessage(aName);
Listener* listener = FindEventHandler(eventMessage, aName, aTypeString);
if (!listener) {
// If we didn't find a script listener or no listeners existed
@ -640,10 +650,10 @@ EventListenerManager::SetEventHandlerInternal(
NS_NewJSEventHandler(mTarget, aName,
aTypedHandler, getter_AddRefs(jsEventHandler));
EventListenerHolder listenerHolder(jsEventHandler);
AddEventListenerInternal(listenerHolder, eventType, aName, aTypeString,
AddEventListenerInternal(listenerHolder, eventMessage, aName, aTypeString,
flags, true);
listener = FindEventHandler(eventType, aName, aTypeString);
listener = FindEventHandler(eventMessage, aName, aTypeString);
} else {
JSEventHandler* jsEventHandler = listener->GetJSEventHandler();
MOZ_ASSERT(jsEventHandler,
@ -776,8 +786,8 @@ EventListenerManager::RemoveEventHandler(nsIAtom* aName,
return;
}
uint32_t eventType = nsContentUtils::GetEventId(aName);
Listener* listener = FindEventHandler(eventType, aName, aTypeString);
EventMessage eventMessage = nsContentUtils::GetEventMessage(aName);
Listener* listener = FindEventHandler(eventMessage, aName, aTypeString);
if (listener) {
mListeners.RemoveElementAt(uint32_t(listener - &mListeners.ElementAt(0)));
@ -1239,8 +1249,8 @@ EventListenerManager::HasMutationListeners()
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
Listener* listener = &mListeners.ElementAt(i);
if (listener->mEventType >= NS_MUTATION_START &&
listener->mEventType <= NS_MUTATION_END) {
if (listener->mEventMessage >= NS_MUTATION_START &&
listener->mEventMessage <= NS_MUTATION_END) {
return true;
}
}
@ -1257,12 +1267,12 @@ EventListenerManager::MutationListenerBits()
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
Listener* listener = &mListeners.ElementAt(i);
if (listener->mEventType >= NS_MUTATION_START &&
listener->mEventType <= NS_MUTATION_END) {
if (listener->mEventType == NS_MUTATION_SUBTREEMODIFIED) {
if (listener->mEventMessage >= NS_MUTATION_START &&
listener->mEventMessage <= NS_MUTATION_END) {
if (listener->mEventMessage == NS_MUTATION_SUBTREEMODIFIED) {
return kAllMutationBits;
}
bits |= MutationBitForEventType(listener->mEventType);
bits |= MutationBitForEventType(listener->mEventMessage);
}
}
}
@ -1352,8 +1362,8 @@ EventListenerManager::HasUnloadListeners()
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
Listener* listener = &mListeners.ElementAt(i);
if (listener->mEventType == NS_PAGE_UNLOAD ||
listener->mEventType == NS_BEFORE_PAGE_UNLOAD) {
if (listener->mEventMessage == NS_PAGE_UNLOAD ||
listener->mEventMessage == NS_BEFORE_PAGE_UNLOAD) {
return true;
}
}
@ -1424,8 +1434,8 @@ const TypedEventHandler*
EventListenerManager::GetTypedEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString)
{
uint32_t eventType = nsContentUtils::GetEventId(aEventName);
Listener* listener = FindEventHandler(eventType, aEventName, aTypeString);
EventMessage eventMessage = nsContentUtils::GetEventMessage(aEventName);
Listener* listener = FindEventHandler(eventMessage, aEventName, aTypeString);
if (!listener) {
return nullptr;

Просмотреть файл

@ -146,11 +146,31 @@ inline EventListenerFlags AllEventsAtSystemGroupCapture()
return flags;
}
class EventListenerManagerBase
{
protected:
EventListenerManagerBase();
EventMessage mNoListenerForEvent;
uint16_t mMayHavePaintEventListener : 1;
uint16_t mMayHaveMutationListeners : 1;
uint16_t mMayHaveCapturingListeners : 1;
uint16_t mMayHaveSystemGroupListeners : 1;
uint16_t mMayHaveTouchEventListener : 1;
uint16_t mMayHaveMouseEnterLeaveEventListener : 1;
uint16_t mMayHavePointerEnterLeaveEventListener : 1;
uint16_t mMayHaveKeyEventListener : 1;
uint16_t mMayHaveInputOrCompositionEventListener : 1;
uint16_t mClearingListeners : 1;
uint16_t mIsMainThreadELM : 1;
// uint16_t mUnused : 5;
};
/*
* Event listener manager
*/
class EventListenerManager final
class EventListenerManager final : public EventListenerManagerBase
{
~EventListenerManager();
@ -160,7 +180,7 @@ public:
EventListenerHolder mListener;
nsCOMPtr<nsIAtom> mTypeAtom; // for the main thread
nsString mTypeString; // for non-main-threads
uint16_t mEventType;
EventMessage mEventMessage;
enum ListenerType : uint8_t
{
@ -449,7 +469,7 @@ protected:
/**
* Find the Listener for the "inline" event listener for aTypeAtom.
*/
Listener* FindEventHandler(uint32_t aEventType,
Listener* FindEventHandler(EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString);
@ -465,9 +485,9 @@ protected:
const TypedEventHandler& aHandler,
bool aPermitUntrustedEvents);
bool IsDeviceType(uint32_t aType);
void EnableDevice(uint32_t aType);
void DisableDevice(uint32_t aType);
bool IsDeviceType(EventMessage aEventMessage);
void EnableDevice(EventMessage aEventMessage);
void DisableDevice(EventMessage aEventMessage);
public:
/**
@ -529,14 +549,14 @@ protected:
bool aUseCapture);
void AddEventListenerInternal(const EventListenerHolder& aListener,
uint32_t aType,
EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aHandler = false,
bool aAllEvents = false);
void RemoveEventListenerInternal(const EventListenerHolder& aListener,
uint32_t aType,
EventMessage aEventMessage,
nsIAtom* aUserType,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
@ -549,22 +569,14 @@ protected:
bool ListenerCanHandle(Listener* aListener, WidgetEvent* aEvent);
// BE AWARE, a lot of instances of EventListenerManager will be created.
// Therefor, we need to keep this class compact. When you add integer
// members, please add them to EventListemerManagerBase and check the size
// at build time.
already_AddRefed<nsIScriptGlobalObject>
GetScriptGlobalAndDocument(nsIDocument** aDoc);
uint32_t mMayHavePaintEventListener : 1;
uint32_t mMayHaveMutationListeners : 1;
uint32_t mMayHaveCapturingListeners : 1;
uint32_t mMayHaveSystemGroupListeners : 1;
uint32_t mMayHaveTouchEventListener : 1;
uint32_t mMayHaveMouseEnterLeaveEventListener : 1;
uint32_t mMayHavePointerEnterLeaveEventListener : 1;
uint32_t mMayHaveKeyEventListener : 1;
uint32_t mMayHaveInputOrCompositionEventListener : 1;
uint32_t mClearingListeners : 1;
uint32_t mIsMainThreadELM : 1;
uint32_t mNoListenerForEvent : 21;
nsAutoTObserverArray<Listener, 2> mListeners;
dom::EventTarget* MOZ_NON_OWNING_REF mTarget;
nsCOMPtr<nsIAtom> mNoListenerForEventAtom;

Просмотреть файл

@ -11,7 +11,7 @@
*
* Each entry consists of 4 pieces of information:
* 1) The name of the event
* 2) The event ID (see BasicEvents.h)
* 2) The event message
* 3) The event type (see the EventNameType enum in nsContentUtils.h)
* 4) The event struct type for this event.
* Items 2-4 might be empty strings for events for which they don't make sense.
@ -52,7 +52,7 @@
* update the tests for bug 689564 and bug 659350 as needed.
*/
#ifdef ID_TO_EVENT
#ifdef MESSAGE_TO_EVENT
#ifdef EVENT
#error "Don't define EVENT"
#endif /* EVENT */
@ -69,11 +69,11 @@
#error "Don't define NON_IDL_EVENT"
#endif /* NON_IDL_EVENT */
#define EVENT ID_TO_EVENT
#define WINDOW_ONLY_EVENT ID_TO_EVENT
#define TOUCH_EVENT ID_TO_EVENT
#define DOCUMENT_ONLY_EVENT ID_TO_EVENT
#define NON_IDL_EVENT ID_TO_EVENT
#define EVENT MESSAGE_TO_EVENT
#define WINDOW_ONLY_EVENT MESSAGE_TO_EVENT
#define TOUCH_EVENT MESSAGE_TO_EVENT
#define DOCUMENT_ONLY_EVENT MESSAGE_TO_EVENT
#define NON_IDL_EVENT MESSAGE_TO_EVENT
#endif
#ifdef DEFINED_FORWARDED_EVENT
@ -90,7 +90,7 @@
#endif /* DEFINED_WINDOW_ONLY_EVENT */
#ifndef WINDOW_ONLY_EVENT
#define WINDOW_ONLY_EVENT(_name, _id, _type, _struct)
#define WINDOW_ONLY_EVENT(_name, _message, _type, _struct)
#define DEFINED_WINDOW_ONLY_EVENT
#endif /* WINDOW_ONLY_EVENT */
@ -108,7 +108,7 @@
#endif /* DEFINED_TOUCH_EVENT */
#ifndef TOUCH_EVENT
#define TOUCH_EVENT(_name, _id, _type, _struct)
#define TOUCH_EVENT(_name, _message, _type, _struct)
#define DEFINED_TOUCH_EVENT
#endif /* TOUCH_EVENT */
@ -117,7 +117,7 @@
#endif /* DEFINED_DOCUMENT_ONLY_EVENT */
#ifndef DOCUMENT_ONLY_EVENT
#define DOCUMENT_ONLY_EVENT(_name, _id, _type, _struct)
#define DOCUMENT_ONLY_EVENT(_name, _message, _type, _struct)
#define DEFINED_DOCUMENT_ONLY_EVENT
#endif /* DOCUMENT_ONLY_EVENT */
@ -126,7 +126,7 @@
#endif /* DEFINED_NON_IDL_EVENT */
#ifndef NON_IDL_EVENT
#define NON_IDL_EVENT(_name, _id, _type, _struct)
#define NON_IDL_EVENT(_name, _message, _type, _struct)
#define DEFINED_NON_IDL_EVENT
#endif /* NON_IDL_EVENT */
@ -763,16 +763,16 @@ NON_IDL_EVENT(SVGZoom,
EventNameType_None,
eSVGZoomEventClass)
// Only map the ID to the real event name when ID_TO_EVENT is defined.
#ifndef ID_TO_EVENT
// Only map the ID to the real event name when MESSAGE_TO_EVENT is defined.
#ifndef MESSAGE_TO_EVENT
// This is a bit hackish, but SVG's event names are weird.
NON_IDL_EVENT(zoom,
NS_SVG_ZOOM,
EventNameType_SVGSVG,
eBasicEventClass)
#endif
// Only map the ID to the real event name when ID_TO_EVENT is defined.
#ifndef ID_TO_EVENT
// Only map the ID to the real event name when MESSAGE_TO_EVENT is defined.
#ifndef MESSAGE_TO_EVENT
NON_IDL_EVENT(begin,
NS_SMIL_BEGIN,
EventNameType_SMIL,
@ -782,8 +782,8 @@ NON_IDL_EVENT(beginEvent,
NS_SMIL_BEGIN,
EventNameType_None,
eSMILTimeEventClass)
// Only map the ID to the real event name when ID_TO_EVENT is defined.
#ifndef ID_TO_EVENT
// Only map the ID to the real event name when MESSAGE_TO_EVENT is defined.
#ifndef MESSAGE_TO_EVENT
NON_IDL_EVENT(end,
NS_SMIL_END,
EventNameType_SMIL,
@ -793,8 +793,8 @@ NON_IDL_EVENT(endEvent,
NS_SMIL_END,
EventNameType_None,
eSMILTimeEventClass)
// Only map the ID to the real event name when ID_TO_EVENT is defined.
#ifndef ID_TO_EVENT
// Only map the ID to the real event name when MESSAGE_TO_EVENT is defined.
#ifndef MESSAGE_TO_EVENT
NON_IDL_EVENT(repeat,
NS_SMIL_REPEAT,
EventNameType_SMIL,
@ -967,11 +967,11 @@ NON_IDL_EVENT(complete,
#undef BEFOREUNLOAD_EVENT
#endif /* BEFOREUNLOAD_EVENT */
#ifdef ID_TO_EVENT
#ifdef MESSAGE_TO_EVENT
#undef EVENT
#undef WINDOW_ONLY_EVENT
#undef TOUCH_EVENT
#undef DOCUMENT_ONLY_EVENT
#undef NON_IDL_EVENT
#endif /* ID_TO_EVENT */
#endif /* MESSAGE_TO_EVENT */

Просмотреть файл

@ -625,7 +625,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
}
GenerateMouseEnterExit(mouseEvent);
//This is a window level mouse exit event and should stop here
aEvent->mMessage = 0;
aEvent->mMessage = NS_EVENT_NULL;
break;
}
case NS_MOUSE_MOVE:
@ -836,6 +836,8 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
compositionEvent->mData = selectedText.mReply.mString;
}
break;
default:
break;
}
return NS_OK;
}
@ -1194,6 +1196,8 @@ CrossProcessSafeEvent(const WidgetEvent& aEvent)
case NS_DRAGDROP_EXIT:
case NS_DRAGDROP_DROP:
return true;
default:
break;
}
default:
return false;
@ -3332,6 +3336,9 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
break;
#endif
default:
break;
}
//Reset target frame to null to avoid mistargeting after reentrant event
@ -3685,7 +3692,7 @@ EventStateManager::IsHandlingUserInput()
static void
CreateMouseOrPointerWidgetEvent(WidgetMouseEvent* aMouseEvent,
uint32_t aMessage,
EventMessage aMessage,
nsIContent* aRelatedContent,
nsAutoPtr<WidgetMouseEvent>& aNewEvent)
{
@ -3725,7 +3732,7 @@ CreateMouseOrPointerWidgetEvent(WidgetMouseEvent* aMouseEvent,
nsIFrame*
EventStateManager::DispatchMouseOrPointerEvent(WidgetMouseEvent* aMouseEvent,
uint32_t aMessage,
EventMessage aMessage,
nsIContent* aTargetContent,
nsIContent* aRelatedContent)
{
@ -3814,10 +3821,11 @@ class EnterLeaveDispatcher
public:
EnterLeaveDispatcher(EventStateManager* aESM,
nsIContent* aTarget, nsIContent* aRelatedTarget,
WidgetMouseEvent* aMouseEvent, uint32_t aType)
WidgetMouseEvent* aMouseEvent,
EventMessage aEventMessage)
: mESM(aESM)
, mMouseEvent(aMouseEvent)
, mType(aType)
, mEventMessage(aEventMessage)
{
nsPIDOMWindow* win =
aTarget ? aTarget->OwnerDoc()->GetInnerWindow() : nullptr;
@ -3844,16 +3852,16 @@ public:
~EnterLeaveDispatcher()
{
if (mType == NS_MOUSEENTER ||
mType == NS_POINTER_ENTER) {
if (mEventMessage == NS_MOUSEENTER ||
mEventMessage == NS_POINTER_ENTER) {
for (int32_t i = mTargets.Count() - 1; i >= 0; --i) {
mESM->DispatchMouseOrPointerEvent(mMouseEvent, mType, mTargets[i],
mRelatedTarget);
mESM->DispatchMouseOrPointerEvent(mMouseEvent, mEventMessage,
mTargets[i], mRelatedTarget);
}
} else {
for (int32_t i = 0; i < mTargets.Count(); ++i) {
mESM->DispatchMouseOrPointerEvent(mMouseEvent, mType, mTargets[i],
mRelatedTarget);
mESM->DispatchMouseOrPointerEvent(mMouseEvent, mEventMessage,
mTargets[i], mRelatedTarget);
}
}
}
@ -3862,7 +3870,7 @@ public:
nsCOMArray<nsIContent> mTargets;
nsCOMPtr<nsIContent> mRelatedTarget;
WidgetMouseEvent* mMouseEvent;
uint32_t mType;
EventMessage mEventMessage;
};
void
@ -4055,7 +4063,8 @@ GetWindowInnerRectCenter(nsPIDOMWindow* aWindow,
}
void
EventStateManager::GeneratePointerEnterExit(uint32_t aMessage, WidgetMouseEvent* aEvent)
EventStateManager::GeneratePointerEnterExit(EventMessage aMessage,
WidgetMouseEvent* aEvent)
{
WidgetPointerEvent pointerEvent(*aEvent);
pointerEvent.mMessage = aMessage;
@ -4178,6 +4187,8 @@ EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent)
NotifyMouseOut(aMouseEvent, nullptr);
}
break;
default:
break;
}
// reset mCurretTargetContent to what it was
@ -4324,6 +4335,9 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
}
}
break;
default:
break;
}
//reset mCurretTargetContent to what it was
@ -4336,13 +4350,13 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
void
EventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
WidgetDragEvent* aDragEvent,
uint32_t aMsg,
EventMessage aMessage,
nsIContent* aRelatedTarget,
nsIContent* aTargetContent,
nsWeakFrame& aTargetFrame)
{
nsEventStatus status = nsEventStatus_eIgnore;
WidgetDragEvent event(aDragEvent->mFlags.mIsTrusted, aMsg,
WidgetDragEvent event(aDragEvent->mFlags.mIsTrusted, aMessage,
aDragEvent->widget);
event.refPoint = aDragEvent->refPoint;
event.modifiers = aDragEvent->modifiers;
@ -4360,15 +4374,19 @@ EventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
}
// adjust the drag hover if the dragenter event was cancelled or this is a drag exit
if (status == nsEventStatus_eConsumeNoDefault || aMsg == NS_DRAGDROP_EXIT)
SetContentState((aMsg == NS_DRAGDROP_ENTER) ? aTargetContent : nullptr,
if (status == nsEventStatus_eConsumeNoDefault ||
aMessage == NS_DRAGDROP_EXIT) {
SetContentState((aMessage == NS_DRAGDROP_ENTER) ?
aTargetContent : nullptr,
NS_EVENT_STATE_DRAGOVER);
}
// collect any changes to moz cursor settings stored in the event's
// data transfer.
if (aMsg == NS_DRAGDROP_LEAVE || aMsg == NS_DRAGDROP_EXIT ||
aMsg == NS_DRAGDROP_ENTER)
if (aMessage == NS_DRAGDROP_LEAVE || aMessage == NS_DRAGDROP_EXIT ||
aMessage == NS_DRAGDROP_ENTER) {
UpdateDragDataTransfer(&event);
}
}
// Finally dispatch the event to the frame

Просмотреть файл

@ -303,13 +303,14 @@ protected:
* if it goes away during the event).
*/
nsIFrame* DispatchMouseOrPointerEvent(WidgetMouseEvent* aMouseEvent,
uint32_t aMessage,
EventMessage aMessage,
nsIContent* aTargetContent,
nsIContent* aRelatedContent);
/**
* Synthesize DOM pointerover and pointerout events
*/
void GeneratePointerEnterExit(uint32_t aMessage, WidgetMouseEvent* aEvent);
void GeneratePointerEnterExit(EventMessage aMessage,
WidgetMouseEvent* aEvent);
/**
* Synthesize DOM and frame mouseover and mouseout events from this
* MOUSE_MOVE or MOUSE_EXIT event.
@ -351,7 +352,7 @@ protected:
*/
void FireDragEnterOrExit(nsPresContext* aPresContext,
WidgetDragEvent* aDragEvent,
uint32_t aMsg,
EventMessage aMessage,
nsIContent* aRelatedTarget,
nsIContent* aTargetContent,
nsWeakFrame& aTargetFrame);

Просмотреть файл

@ -262,8 +262,6 @@ private:
#define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(42)
// Element is rtl (for :dir pseudo-class)
#define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(43)
// Handler for play preview plugin
#define NS_EVENT_STATE_TYPE_PLAY_PREVIEW NS_DEFINE_EVENT_STATE_MACRO(44)
// Element is highlighted (devtools inspector)
#define NS_EVENT_STATE_DEVTOOLS_HIGHLIGHTED NS_DEFINE_EVENT_STATE_MACRO(45)
// Element is an unresolved custom element candidate

Просмотреть файл

@ -134,7 +134,7 @@ GetIMEStateSetOpenName(IMEState::Open aOpen)
}
static const char*
GetEventMessageName(uint32_t aMessage)
GetEventMessageName(EventMessage aMessage)
{
switch (aMessage) {
case NS_COMPOSITION_START:

Просмотреть файл

@ -15,7 +15,9 @@ InputEvent::InputEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalEditorInputEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new InternalEditorInputEvent(false, 0, nullptr))
aEvent ? aEvent :
new InternalEditorInputEvent(false, NS_EVENT_NULL,
nullptr))
{
NS_ASSERTION(mEvent->mClass == eEditorInputEventClass,
"event type mismatch");

Просмотреть файл

@ -19,7 +19,7 @@ class InternalMutationEvent : public WidgetEvent
public:
virtual InternalMutationEvent* AsMutationEvent() override { return this; }
InternalMutationEvent(bool aIsTrusted, uint32_t aMessage)
InternalMutationEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eMutationEventClass)
, mAttrChange(0)
{

Просмотреть файл

@ -15,7 +15,8 @@ KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetKeyboardEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetKeyboardEvent(false, 0, nullptr))
aEvent ? aEvent :
new WidgetKeyboardEvent(false, NS_EVENT_NULL, nullptr))
, mInitializedByCtor(false)
, mInitializedWhichValue(0)
{
@ -161,6 +162,8 @@ KeyboardEvent::CharCode()
return 0;
case NS_KEY_PRESS:
return mEvent->AsKeyboardEvent()->charCode;
default:
break;
}
return 0;
}
@ -213,6 +216,8 @@ KeyboardEvent::Which()
}
return CharCode();
}
default:
break;
}
return 0;

Просмотреть файл

@ -17,8 +17,9 @@ MouseEvent::MouseEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetMouseEventBase* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetMouseEvent(false, 0, nullptr,
WidgetMouseEvent::eReal))
aEvent ? aEvent :
new WidgetMouseEvent(false, NS_EVENT_NULL, nullptr,
WidgetMouseEvent::eReal))
{
// There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
// It's not that important, though, since a scroll event is not a real

Просмотреть файл

@ -15,7 +15,9 @@ MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetMouseScrollEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetMouseScrollEvent(false, 0, nullptr))
aEvent ? aEvent :
new WidgetMouseScrollEvent(false, NS_EVENT_NULL,
nullptr))
{
if (aEvent) {
mEventIsInternal = false;

Просмотреть файл

@ -17,7 +17,7 @@ MutationEvent::MutationEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalMutationEvent* aEvent)
: Event(aOwner, aPresContext,
aEvent ? aEvent : new InternalMutationEvent(false, 0))
aEvent ? aEvent : new InternalMutationEvent(false, NS_EVENT_NULL))
{
mEventIsInternal = (aEvent == nullptr);
}

Просмотреть файл

@ -18,12 +18,12 @@ namespace dom {
NotifyPaintEvent::NotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests)
: Event(aOwner, aPresContext, aEvent)
{
if (mEvent) {
mEvent->mMessage = aEventType;
mEvent->mMessage = aEventMessage;
}
if (aInvalidateRequests) {
mInvalidateRequests.AppendElements(Move(aInvalidateRequests->mRequests));
@ -166,11 +166,11 @@ already_AddRefed<NotifyPaintEvent>
NS_NewDOMNotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests)
{
nsRefPtr<NotifyPaintEvent> it =
new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventType,
new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventMessage,
aInvalidateRequests);
return it.forget();
}

Просмотреть файл

@ -28,7 +28,7 @@ public:
NotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests);
NS_DECL_ISUPPORTS_INHERITED
@ -72,7 +72,9 @@ already_AddRefed<mozilla::dom::NotifyPaintEvent>
NS_NewDOMNotifyPaintEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent,
uint32_t aEventType = 0,
nsInvalidateRequestList* aInvalidateRequests = nullptr);
mozilla::EventMessage aEventMessage =
mozilla::NS_EVENT_NULL,
nsInvalidateRequestList* aInvalidateRequests =
nullptr);
#endif // mozilla_dom_NotifyPaintEvent_h_

Просмотреть файл

@ -17,7 +17,8 @@ PointerEvent::PointerEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetPointerEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetPointerEvent(false, 0, nullptr))
aEvent ? aEvent :
new WidgetPointerEvent(false, NS_EVENT_NULL, nullptr))
{
NS_ASSERTION(mEvent->mClass == ePointerEventClass,
"event type mismatch ePointerEventClass");

Просмотреть файл

@ -16,7 +16,8 @@ SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
WidgetSimpleGestureEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
aEvent ? aEvent :
new WidgetSimpleGestureEvent(false, 0, nullptr))
new WidgetSimpleGestureEvent(false, NS_EVENT_NULL,
nullptr))
{
NS_ASSERTION(mEvent->mClass == eSimpleGestureEventClass,
"event type mismatch");

Просмотреть файл

@ -100,7 +100,7 @@ TextComposition::MaybeDispatchCompositionUpdate(
BaseEventFlags
TextComposition::CloneAndDispatchAs(
const WidgetCompositionEvent* aCompositionEvent,
uint32_t aMessage,
EventMessage aMessage,
nsEventStatus* aStatus,
EventDispatchingCallback* aCallBack)
{
@ -437,7 +437,7 @@ TextComposition::NotityUpdateComposition(
}
void
TextComposition::DispatchCompositionEventRunnable(uint32_t aEventMessage,
TextComposition::DispatchCompositionEventRunnable(EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizingCommit)
{
@ -585,13 +585,13 @@ TextComposition::HasEditor() const
TextComposition::CompositionEventDispatcher::CompositionEventDispatcher(
TextComposition* aComposition,
nsINode* aEventTarget,
uint32_t aEventMessage,
EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizedEvent)
: mTextComposition(aComposition)
, mEventTarget(aEventTarget)
, mEventMessage(aEventMessage)
, mData(aData)
, mEventMessage(aEventMessage)
, mIsSynthesizedEvent(aIsSynthesizedEvent)
{
}

Просмотреть файл

@ -319,7 +319,7 @@ private:
*/
BaseEventFlags CloneAndDispatchAs(
const WidgetCompositionEvent* aCompositionEvent,
uint32_t aMessage,
EventMessage aMessage,
nsEventStatus* aStatus = nullptr,
EventDispatchingCallback* aCallBack = nullptr);
@ -353,7 +353,7 @@ private:
public:
CompositionEventDispatcher(TextComposition* aTextComposition,
nsINode* aEventTarget,
uint32_t aEventMessage,
EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizedEvent = false);
NS_IMETHOD Run() override;
@ -361,8 +361,8 @@ private:
private:
nsRefPtr<TextComposition> mTextComposition;
nsCOMPtr<nsINode> mEventTarget;
uint32_t mEventMessage;
nsString mData;
EventMessage mEventMessage;
bool mIsSynthesizedEvent;
CompositionEventDispatcher() {};
@ -381,7 +381,7 @@ private:
* commit or cancel composition. Otherwise,
* false.
*/
void DispatchCompositionEventRunnable(uint32_t aEventMessage,
void DispatchCompositionEventRunnable(EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizingCommit = false);
};

Просмотреть файл

@ -63,7 +63,8 @@ TouchEvent::TouchEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetTouchEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetTouchEvent(false, 0, nullptr))
aEvent ? aEvent :
new WidgetTouchEvent(false, NS_EVENT_NULL, nullptr))
{
if (aEvent) {
mEventIsInternal = false;

Просмотреть файл

@ -15,7 +15,7 @@ TransitionEvent::TransitionEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalTransitionEvent* aEvent)
: Event(aOwner, aPresContext,
aEvent ? aEvent : new InternalTransitionEvent(false, 0))
aEvent ? aEvent : new InternalTransitionEvent(false, NS_EVENT_NULL))
{
if (aEvent) {
mEventIsInternal = false;

Просмотреть файл

@ -29,7 +29,7 @@ UIEvent::UIEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetGUIEvent* aEvent)
: Event(aOwner, aPresContext,
aEvent ? aEvent : new InternalUIEvent(false, 0, nullptr))
aEvent ? aEvent : new InternalUIEvent(false, NS_EVENT_NULL, nullptr))
, mClientPoint(0, 0)
, mLayerPoint(0, 0)
, mPagePoint(0, 0)

Просмотреть файл

@ -16,7 +16,8 @@ WheelEvent::WheelEvent(EventTarget* aOwner,
WidgetWheelEvent* aWheelEvent)
: MouseEvent(aOwner, aPresContext,
aWheelEvent ? aWheelEvent :
new WidgetWheelEvent(false, 0, nullptr))
new WidgetWheelEvent(false, NS_EVENT_NULL,
nullptr))
, mAppUnitsPerDevPixel(0)
{
if (aWheelEvent) {

Просмотреть файл

@ -218,6 +218,8 @@ WheelTransaction::OnEvent(WidgetEvent* aEvent)
case NS_DRAGDROP_DROP:
EndTransaction();
return;
default:
break;
}
}

Просмотреть файл

@ -14,7 +14,8 @@ XULCommandEvent::XULCommandEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetInputEvent(false, 0, nullptr))
aEvent ? aEvent :
new WidgetInputEvent(false, NS_EVENT_NULL, nullptr))
{
if (aEvent) {
mEventIsInternal = false;

Просмотреть файл

@ -16,6 +16,7 @@
#include "mozilla/dom/URL.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/workers/bindings/URL.h"
#include "mozilla/unused.h"
#include "WorkerPrivate.h"
@ -81,7 +82,17 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput,
nsCOMPtr<nsIURI> resolvedURI;
aRv = NS_NewURI(getter_AddRefs(resolvedURI), aInput, nullptr, baseURI);
if (NS_WARN_IF(aRv.Failed())) {
return;
aRv.ThrowTypeError(MSG_INVALID_URL, &aInput);
return;
}
// This fails with URIs with weird protocols, even when they are valid,
// so we ignore the failure
nsAutoCString credentials;
unused << resolvedURI->GetUserPass(credentials);
if (!credentials.IsEmpty()) {
aRv.ThrowTypeError(MSG_URL_HAS_CREDENTIALS, &aInput);
return;
}
nsCOMPtr<nsIURI> resolvedURIClone;
@ -110,6 +121,16 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL,
nsCOMPtr<nsIURI> uri;
aRv = NS_NewURI(getter_AddRefs(uri), aInput, nullptr, nullptr);
if (NS_WARN_IF(aRv.Failed())) {
aRv.ThrowTypeError(MSG_INVALID_URL, &aInput);
return;
}
// This fails with URIs with weird protocols, even when they are valid,
// so we ignore the failure
nsAutoCString credentials;
unused << uri->GetUserPass(credentials);
if (!credentials.IsEmpty()) {
aRv.ThrowTypeError(MSG_URL_HAS_CREDENTIALS, &aInput);
return;
}
@ -142,6 +163,24 @@ GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput,
nsRefPtr<workers::URL> url =
workers::URL::Constructor(aGlobal, aInput, baseURL, aRv);
if (NS_WARN_IF(aRv.Failed())) {
aRv.ThrowTypeError(MSG_INVALID_URL, &aInput);
return;
}
nsString username;
url->GetUsername(username, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
nsString password;
url->GetPassword(password, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
if (!username.IsEmpty() || !password.IsEmpty()) {
aRv.ThrowTypeError(MSG_URL_HAS_CREDENTIALS, &aInput);
return;
}

Просмотреть файл

@ -200,7 +200,7 @@ HTMLButtonElement::ParseAttribute(int32_t aNamespaceID,
}
bool
HTMLButtonElement::IsDisabledForEvents(uint32_t aMessage)
HTMLButtonElement::IsDisabledForEvents(EventMessage aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = do_QueryFrame(formControlFrame);

Просмотреть файл

@ -52,7 +52,7 @@ public:
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
NS_IMETHOD SaveState() override;
bool RestoreState(nsPresState* aState) override;
virtual bool IsDisabledForEvents(uint32_t aMessage) override;
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;

Просмотреть файл

@ -63,7 +63,7 @@ NS_IMPL_STRING_ATTR(HTMLFieldSetElement, Name, name)
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLFieldSetElement)
bool
HTMLFieldSetElement::IsDisabledForEvents(uint32_t aMessage)
HTMLFieldSetElement::IsDisabledForEvents(EventMessage aMessage)
{
return IsElementDisabledForEvents(aMessage, nullptr);
}

Просмотреть файл

@ -51,7 +51,7 @@ public:
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_FIELDSET; }
NS_IMETHOD Reset() override;
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
virtual bool IsDisabledForEvents(uint32_t aMessage) override;
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
const nsIContent* GetFirstLegend() const { return mFirstLegend; }

Просмотреть файл

@ -535,7 +535,7 @@ nsresult
HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this)) {
uint32_t msg = aVisitor.mEvent->mMessage;
EventMessage msg = aVisitor.mEvent->mMessage;
if (msg == NS_FORM_SUBMIT) {
// let the form know not to defer subsequent submissions
mDeferSubmission = false;
@ -555,8 +555,10 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
mPendingSubmission = nullptr;
}
DoSubmitOrReset(aVisitor.mEvent, msg);
break;
}
break;
default:
break;
}
} else {
if (msg == NS_FORM_SUBMIT) {

Просмотреть файл

@ -3040,7 +3040,7 @@ HTMLInputElement::NeedToInitializeEditorForEvent(
}
bool
HTMLInputElement::IsDisabledForEvents(uint32_t aMessage)
HTMLInputElement::IsDisabledForEvents(EventMessage aMessage)
{
return IsElementDisabledForEvents(aMessage, GetPrimaryFrame());
}
@ -3662,6 +3662,8 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
mForm->OnSubmitClickEnd();
}
break;
default:
break;
}
}
@ -4156,6 +4158,9 @@ HTMLInputElement::PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor)
CancelRangeThumbDrag();
}
break;
default:
break;
}
}

Просмотреть файл

@ -149,7 +149,7 @@ public:
NS_IMETHOD SaveState() override;
virtual bool RestoreState(nsPresState* aState) override;
virtual bool AllowDrop() override;
virtual bool IsDisabledForEvents(uint32_t aMessage) override;
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;

Просмотреть файл

@ -197,6 +197,9 @@ HTMLLabelElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
mouseEvent->mFlags.mMultipleActionsPrevented = true;
}
break;
default:
break;
}
mHandlingEvent = false;
}

Просмотреть файл

@ -2334,7 +2334,6 @@ HTMLMediaElement::WakeLockRelease()
if (mWakeLock) {
ErrorResult rv;
mWakeLock->Unlock(rv);
NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
mWakeLock = nullptr;
}
}

Просмотреть файл

@ -56,6 +56,13 @@ HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
if (aNameSpaceID == kNameSpaceID_None) {
if (aName == nsGkAtoms::content) {
nsIDocument *document = GetUncomposedDoc();
if (document && AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
nsGkAtoms::viewport, eIgnoreCase)) {
nsAutoString content;
nsresult rv = GetContent(content);
NS_ENSURE_SUCCESS(rv, rv);
nsContentUtils::ProcessViewportInfo(document, content);
}
CreateAndDispatchEvent(document, NS_LITERAL_STRING("DOMMetaChanged"));
}
}

Просмотреть файл

@ -224,6 +224,8 @@ HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
OnFocusBlurPlugin(aElement, false);
break;
}
default:
break;
}
}

Просмотреть файл

@ -1487,7 +1487,7 @@ HTMLSelectElement::GetAttributeMappingFunction() const
}
bool
HTMLSelectElement::IsDisabledForEvents(uint32_t aMessage)
HTMLSelectElement::IsDisabledForEvents(EventMessage aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = nullptr;

Просмотреть файл

@ -291,7 +291,7 @@ public:
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
NS_IMETHOD SaveState() override;
virtual bool RestoreState(nsPresState* aState) override;
virtual bool IsDisabledForEvents(uint32_t aMessage) override;
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;

Просмотреть файл

@ -469,7 +469,7 @@ HTMLTextAreaElement::GetAttributeMappingFunction() const
}
bool
HTMLTextAreaElement::IsDisabledForEvents(uint32_t aMessage)
HTMLTextAreaElement::IsDisabledForEvents(EventMessage aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = do_QueryFrame(formControlFrame);

Просмотреть файл

@ -75,7 +75,7 @@ public:
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
NS_IMETHOD SaveState() override;
virtual bool RestoreState(nsPresState* aState) override;
virtual bool IsDisabledForEvents(uint32_t aMessage) override;
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;

Просмотреть файл

@ -253,7 +253,6 @@ HTMLVideoElement::UpdateScreenWakeLock()
if (mScreenWakeLock && (mPaused || hidden)) {
ErrorResult rv;
mScreenWakeLock->Unlock(rv);
NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
mScreenWakeLock = nullptr;
return;
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше