Merge from mozilla-central.

This commit is contained in:
David Anderson 2012-08-13 13:40:42 -07:00
commit 5c045998a5
559 changed files with 31049 additions and 6074 deletions

View File

@ -7,11 +7,12 @@
#include "nsARIAMap.h"
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
#include "Role.h"
#include "States.h"
#include "nsIContent.h"
#include "nsAttrName.h"
#include "nsWhitespaceTokenizer.h"
using namespace mozilla;
@ -684,3 +685,39 @@ aria::UniversalStatesFor(mozilla::dom::Element* aElement)
return state;
}
////////////////////////////////////////////////////////////////////////////////
// AttrIterator class
bool
AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
{
while (mAttrIdx < mAttrCount) {
const nsAttrName* attr = mContent->GetAttrNameAt(mAttrIdx);
mAttrIdx++;
if (attr->NamespaceEquals(kNameSpaceID_None)) {
nsIAtom* attrAtom = attr->Atom();
nsDependentAtomString attrStr(attrAtom);
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
continue; // Not ARIA
PRUint8 attrFlags = nsAccUtils::GetAttributeCharacteristics(attrAtom);
if (attrFlags & ATTR_BYPASSOBJ)
continue; // No need to handle exposing as obj attribute here
if ((attrFlags & ATTR_VALTOKEN) &&
!nsAccUtils::HasDefinedARIAToken(mContent, attrAtom))
continue; // only expose token based attributes if they are defined
nsAutoString value;
if (mContent->GetAttr(kNameSpaceID_None, attrAtom, value)) {
aAttrName.Assign(Substring(attrStr, 5));
aAttrValue.Assign(value);
return true;
}
}
}
return false;
}

View File

@ -12,8 +12,8 @@
#include "mozilla/a11y/Role.h"
#include "nsIAtom.h"
#include "nsIContent.h"
class nsIContent;
class nsINode;
////////////////////////////////////////////////////////////////////////////////
@ -226,6 +226,31 @@ nsRoleMapEntry* GetRoleMap(nsINode* aNode);
*/
PRUint64 UniversalStatesFor(mozilla::dom::Element* aElement);
/**
* Represents a simple enumerator for iterating through ARIA attributes
* exposed as object attributes on a given accessible.
*/
class AttrIterator
{
public:
AttrIterator(nsIContent* aContent) :
mContent(aContent), mAttrIdx(0)
{
mAttrCount = mContent->GetAttrCount();
}
bool Next(nsAString& aAttrName, nsAString& aAttrValue);
private:
AttrIterator() MOZ_DELETE;
AttrIterator(const AttrIterator&) MOZ_DELETE;
AttrIterator& operator= (const AttrIterator&) MOZ_DELETE;
nsIContent* mContent;
PRUint32 mAttrIdx;
PRUint32 mAttrCount;
};
} // namespace aria
} // namespace a11y
} // namespace mozilla

View File

@ -1225,25 +1225,11 @@ Accessible::GetAttributes(nsIPersistentProperties **aAttributes)
groupPos.setSize, groupPos.posInSet);
// Expose object attributes from ARIA attributes.
PRUint32 numAttrs = mContent->GetAttrCount();
for (PRUint32 count = 0; count < numAttrs; count ++) {
const nsAttrName *attr = mContent->GetAttrNameAt(count);
if (attr && attr->NamespaceEquals(kNameSpaceID_None)) {
nsIAtom *attrAtom = attr->Atom();
nsDependentAtomString attrStr(attrAtom);
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
continue; // Not ARIA
PRUint8 attrFlags = nsAccUtils::GetAttributeCharacteristics(attrAtom);
if (attrFlags & ATTR_BYPASSOBJ)
continue; // No need to handle exposing as obj attribute here
if ((attrFlags & ATTR_VALTOKEN) &&
!nsAccUtils::HasDefinedARIAToken(mContent, attrAtom))
continue; // only expose token based attributes if they are defined
nsAutoString value;
if (mContent->GetAttr(kNameSpaceID_None, attrAtom, value)) {
attributes->SetStringProperty(NS_ConvertUTF16toUTF8(Substring(attrStr, 5)), value, oldValueUnused);
}
}
aria::AttrIterator attribIter(mContent);
nsAutoString name, value;
while(attribIter.Next(name, value)) {
attributes->SetStringProperty(NS_ConvertUTF16toUTF8(name), value,
oldValueUnused);
}
// If there is no aria-live attribute then expose default value of 'live'
@ -3258,3 +3244,4 @@ KeyBinding::ToAtkFormat(nsAString& aValue) const
aValue.Append(mKey);
}

View File

@ -8,6 +8,7 @@
#include "AccessibleWrap.h"
#include "nsIPersistentProperties2.h"
#include "nsARIAMap.h"
using namespace mozilla;
using namespace mozilla::a11y;
@ -199,6 +200,30 @@ uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
break;
}
//ARIA Properties
case UIA_AriaPropertiesPropertyId: {
nsAutoString ariaProperties;
aria::AttrIterator attribIter(mAcc->GetContent());
nsAutoString attribName, attribValue;
while (attribIter.Next(attribName, attribValue)) {
ariaProperties.Append(attribName);
ariaProperties.Append('=');
ariaProperties.Append(attribValue);
ariaProperties.Append(';');
}
if (!ariaProperties.IsEmpty()) {
//remove last delimiter:
ariaProperties.Truncate(ariaProperties.Length()-1);
aPropertyValue->vt = VT_BSTR;
aPropertyValue->bstrVal = ::SysAllocString(ariaProperties.get());
return S_OK;
}
break;
}
}
return S_OK;

View File

@ -472,6 +472,9 @@ pref("dom.disable_window_print", true);
// Disable window.showModalDialog
pref("dom.disable_window_showModalDialog", true);
// Enable new experimental html forms
pref("dom.experimental_forms", true);
// Turns on gralloc-based direct texturing for Gonk
pref("gfx.gralloc.enabled", false);

View File

@ -180,15 +180,15 @@ FormAssistant.init();
function getJSON(element) {
let type = element.type || "";
// FIXME/bug 344616 is input type="number"
// Until then, let's return 'number' even if the platform returns 'text'
// Until the input type=date/datetime/time have been implemented
// let's return their real type even if the platform returns 'text'
// Related to Bug 769352 - Implement <input type=date>
// Related to Bug 777279 - Implement <input type=time>
let attributeType = element.getAttribute("type") || "";
if (attributeType) {
var typeLowerCase = attributeType.toLowerCase();
switch (typeLowerCase) {
case "number":
case "date":
case "time":
case "datetime":

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1343854380000">
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1344613852000">
<emItems>
<emItem blockID="i58" id="webmaster@buzzzzvideos.info">
<versionRange minVersion="0" maxVersion="*">
@ -120,6 +120,10 @@
</emItem>
<emItem blockID="i13" id="{E8E88AB0-7182-11DF-904E-6045E0D72085}">
</emItem>
<emItem blockID="i117" id="{ce7e73df-6a44-4028-8079-5927a588c948}">
<versionRange minVersion="0" maxVersion="1.0.8" severity="1">
</versionRange>
</emItem>
<emItem blockID="i24" id="{6E19037A-12E3-4295-8915-ED48BC341614}">
<versionRange minVersion="0.1" maxVersion="1.3.328.4" severity="1">
<targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">

View File

@ -510,34 +510,23 @@ pref("browser.gesture.twist.right", "");
pref("browser.gesture.twist.left", "");
pref("browser.gesture.tap", "cmd_fullZoomReset");
// 0=lines, 1=pages, 2=history , 3=text size
// 0: Nothing happens
// 1: Scrolling contents
// 2: Go back or go forward, in your history
// 3: Zoom in or out.
#ifdef XP_MACOSX
// On OS X, if the wheel has one axis only, shift+wheel comes through as a
// horizontal scroll event. Thus, we can't assign anything other than normal
// scrolling to shift+wheel.
pref("mousewheel.withshiftkey.action",0);
pref("mousewheel.withshiftkey.sysnumlines",true);
pref("mousewheel.withshiftkey.numlines",1);
pref("mousewheel.withaltkey.action",2);
pref("mousewheel.withaltkey.sysnumlines",false);
pref("mousewheel.withaltkey.numlines",1);
pref("mousewheel.withmetakey.action",0);
pref("mousewheel.withmetakey.sysnumlines",false);
pref("mousewheel.withmetakey.numlines",1);
pref("mousewheel.with_alt.action", 2);
pref("mousewheel.with_shift.action", 1);
#else
pref("mousewheel.withshiftkey.action",2);
pref("mousewheel.withshiftkey.sysnumlines",false);
pref("mousewheel.withshiftkey.numlines",1);
pref("mousewheel.withaltkey.action",0);
pref("mousewheel.withaltkey.sysnumlines",false);
pref("mousewheel.withaltkey.numlines",1);
pref("mousewheel.withmetakey.action",0);
pref("mousewheel.withmetakey.sysnumlines",true);
pref("mousewheel.withmetakey.numlines",1);
pref("mousewheel.with_alt.action", 1);
pref("mousewheel.with_shift.action", 2);
#endif
pref("mousewheel.withcontrolkey.action",3);
pref("mousewheel.withcontrolkey.sysnumlines",false);
pref("mousewheel.withcontrolkey.numlines",1);
pref("mousewheel.with_control.action",3);
pref("mousewheel.with_meta.action", 1); // command key on Mac
pref("mousewheel.with_win.action", 1);
// pref to control the alert notification
pref("alerts.slideIncrement", 1);

View File

@ -232,6 +232,7 @@ _BROWSER_FILES = \
plugin_clickToPlayAllow.html \
plugin_clickToPlayDeny.html \
plugin_bug749455.html \
plugin_hidden_to_visible.html \
alltabslistener.html \
zoom_test.html \
dummy_page.html \

View File

@ -72,11 +72,11 @@ function runOverflowTests(aEvent) {
"(" + left(scrollbox) + " <= " + firstScrollableLeft + ")");
for (var i = 2; i; i--)
EventUtils.synthesizeMouseScroll(scrollbox, 1, 1, {axis: "horizontal", delta: -1});
EventUtils.synthesizeWheel(scrollbox, 1, 1, { deltaX: -1.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
is(left(firstScrollable()), firstScrollableLeft, "Remained at the start with the mouse wheel");
element = nextRightElement();
EventUtils.synthesizeMouseScroll(scrollbox, 1, 1, {axis: "horizontal", delta: 1});
EventUtils.synthesizeWheel(scrollbox, 1, 1, { deltaX: 1.0, deltaMode: WheelEvent.DOM_DELTA_LINE});
isRight(element, "Scrolled one tab to the right with the mouse wheel");
while (tabs.length > 1)

View File

@ -689,5 +689,56 @@ function test19f() {
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 19f, Plugin should be activated");
prepareTest(test20a, gTestRoot + "plugin_hidden_to_visible.html");
}
// Tests that a plugin in a div that goes from style="display: none" to
// "display: block" can be clicked to activate.
function test20a() {
var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(clickToPlayNotification, "Test 20a, Should have a click-to-play notification");
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("plugin");
var mainBox = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
ok(mainBox, "Test 20a, plugin overlay should not be null");
var pluginRect = mainBox.getBoundingClientRect();
ok(pluginRect.width == 0, "Test 20a, plugin should have an overlay with 0px width");
ok(pluginRect.height == 0, "Test 20a, plugin should have an overlay with 0px height");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 20a, plugin should not be activated");
var div = doc.getElementById("container");
ok(div.style.display == "none", "Test 20a, container div should be display: none");
div.style.display = "block";
var condition = function() {
var pluginRect = mainBox.getBoundingClientRect();
return (pluginRect.width == 200);
}
waitForCondition(condition, test20b, "Test 20a, Waited too long for plugin to become visible");
}
function test20b() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("plugin");
var pluginRect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect();
ok(pluginRect.width == 200, "Test 20b, plugin should have an overlay with 200px width");
ok(pluginRect.height == 200, "Test 20b, plugin should have an overlay with 200px height");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 20b, plugin should not be activated");
EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow);
var condition = function() objLoadingContent.activated;
waitForCondition(condition, test20c, "Test 20b, Waited too long for plugin to activate");
}
function test20c() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("plugin");
var pluginRect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect();
ok(pluginRect.width == 0, "Test 20c, plugin should have click-to-play overlay with zero width");
ok(pluginRect.height == 0, "Test 20c, plugin should have click-to-play overlay with zero height");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 20c, plugin should be activated");
finishTest();
}

View File

@ -20,6 +20,7 @@ function test() {
}, true);
registerCleanupFunction(function() {
Services.prefs.clearUserPref(prefName);
gBrowser.removeTab(tab);
});
}

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="container" style="display: none">
<object id="plugin" type="application/x-test" style="width: 200px; height: 200px;"></object>
</div>
</body>
</html>

View File

@ -51,8 +51,8 @@ function performScrollingTest()
InspectorUI.highlighter.removeListener("nodeselected", performScrollingTest);
executeSoon(function() {
EventUtils.synthesizeMouseScroll(div, 10, 10,
{axis:"vertical", delta:50, type:"MozMousePixelScroll"},
EventUtils.synthesizeWheel(div, 10, 10,
{ deltaY: 50.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL },
iframe.contentWindow);
});

View File

@ -40,9 +40,6 @@ SUBMAKEFILES += \
# This makefile uses variable overrides from the libs-% target to
# build non-default locales to non-default dist/ locations. Be aware!
# XXXCallek Unused?
APP_VERSION := $(shell cat $(srcdir)/../config/version.txt)
PWD := $(CURDIR)
# These are defaulted to be compatible with the files the wget-en-US target

View File

@ -35,16 +35,19 @@ class B2GRemoteAutomation(Automation):
_devicemanager = None
def __init__(self, deviceManager, appName='', remoteLog=None,
marionette=None):
marionette=None, context_chrome=True):
self._devicemanager = deviceManager
self._appName = appName
self._remoteProfile = None
self._remoteLog = remoteLog
self.marionette = marionette
self.context_chrome = context_chrome
self._is_emulator = False
# Default our product to b2g
self._product = "b2g"
# Default log finish to mochitest standard
self.logFinish = 'INFO SimpleTest FINISHED'
Automation.__init__(self)
def setEmulator(self, is_emulator):
@ -121,7 +124,7 @@ class B2GRemoteAutomation(Automation):
def waitForFinish(self, proc, utilityPath, timeout, maxTime, startTime,
debuggerInfo, symbolsPath):
""" Wait for mochitest to finish (as evidenced by a signature string
""" Wait for tests to finish (as evidenced by a signature string
in logcat), or for a given amount of time to elapse with no
output.
"""
@ -135,7 +138,7 @@ class B2GRemoteAutomation(Automation):
if currentlog:
done = time.time() + timeout
print currentlog
if 'INFO SimpleTest FINISHED' in currentlog:
if hasattr(self, 'logFinish') and self.logFinish in currentlog:
return 0
else:
if time.time() > done:
@ -162,6 +165,8 @@ class B2GRemoteAutomation(Automation):
return (serial, status)
def restartB2G(self):
# TODO hangs in subprocess.Popen without this delay
time.sleep(5)
self._devicemanager.checkCmd(['shell', 'stop', 'b2g'])
# Wait for a bit to make sure B2G has completely shut down.
time.sleep(10)
@ -194,7 +199,7 @@ class B2GRemoteAutomation(Automation):
def Process(self, cmd, stdout=None, stderr=None, env=None, cwd=None):
# On a desktop or fennec run, the Process method invokes a gecko
# process in which to run mochitests. For B2G, we simply
# process in which to the tests. For B2G, we simply
# reboot the device (which was configured with a test profile
# already), wait for B2G to start up, and then navigate to the
# test url using Marionette. There doesn't seem to be any way
@ -239,11 +244,27 @@ class B2GRemoteAutomation(Automation):
if 'b2g' not in session:
raise Exception("bad session value %s returned by start_session" % session)
# Start the tests by navigating to the mochitest url, by setting it
# as the 'src' attribute to the homescreen mozbrowser element
# provided by B2G's shell.js.
self.marionette.set_context("chrome")
self.marionette.execute_script("document.getElementById('homescreen').src='%s';" % self.testURL)
if self.context_chrome:
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
# start the tests
if hasattr(self, 'testURL'):
# Start the tests by navigating to the mochitest url, by setting it
# as the 'src' attribute to the homescreen mozbrowser element
# provided by B2G's shell.js.
self.marionette.execute_script("document.getElementById('homescreen').src='%s';" % self.testURL)
# run the script that starts the tests
elif hasattr(self, 'testScript'):
if os.path.isfile(self.testScript):
script = open(self.testScript, 'r')
self.marionette.execute_script(script.read())
script.close()
else:
# assume testScript is a string
self.marionette.execute_script(self.testScript)
else:
# assumes the tests are started on startup automatically
pass
return instance

View File

@ -43,7 +43,7 @@ public interface Actions {
*
* @param geckoEvent The geckoEvent JSONObject's type
*/
EventExpecter expectGeckoEvent(String geckoEvent);
RepeatedEventExpecter expectGeckoEvent(String geckoEvent);
/**
* Listens for a paint event. Note that calling expectPaint() will

View File

@ -65,8 +65,8 @@ public class FennecNativeActions implements Actions {
Class [] parameters = new Class[2];
parameters[0] = String.class;
parameters[1] = mGel;
mRegisterGEL = mGas.getMethod("registerGeckoEventListener", parameters);
mUnregisterGEL = mGas.getMethod("unregisterGeckoEventListener", parameters);
mRegisterGEL = mGas.getMethod("registerEventListener", parameters);
mUnregisterGEL = mGas.getMethod("unregisterEventListener", parameters);
parameters = new Class[1];
parameters[0] = mGe;
mSendGE = mGas.getMethod("sendEventToGecko", parameters);
@ -115,7 +115,7 @@ public class FennecNativeActions implements Actions {
}
}
class GeckoEventExpecter implements EventExpecter {
class GeckoEventExpecter implements RepeatedEventExpecter {
private final String mGeckoEvent;
private final Object[] mRegistrationParams;
private boolean mEventReceived;
@ -143,6 +143,61 @@ public class FennecNativeActions implements Actions {
return;
}
}
try {
mUnregisterGEL.invoke(null, mRegistrationParams);
} catch (IllegalAccessException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
}
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
"unblocked on expecter for " + mGeckoEvent);
}
public synchronized void blockUntilClear(long millis) {
if (millis <= 0) {
throw new IllegalArgumentException("millis must be > 0");
}
// wait for at least one event
long startTime = SystemClock.uptimeMillis();
long endTime = 0;
while (!mEventReceived) {
try {
this.wait(MAX_WAIT_MS);
} catch (InterruptedException ie) {
FennecNativeDriver.log(LogLevel.ERROR, ie);
break;
}
endTime = SystemClock.uptimeMillis();
if (!mEventReceived && (endTime - startTime >= MAX_WAIT_MS)) {
mAsserter.ok(false, "GeckoEventExpecter", "blockUtilClear timeout");
return;
}
}
// now wait for a period of millis where we don't get an event
startTime = SystemClock.uptimeMillis();
while (true) {
try {
this.wait(millis);
} catch (InterruptedException ie) {
FennecNativeDriver.log(LogLevel.ERROR, ie);
break;
}
endTime = SystemClock.uptimeMillis();
if (endTime - startTime >= millis) {
// success
break;
}
// we got a notify() before we could wait long enough, so we need to start over
startTime = endTime;
}
try {
mUnregisterGEL.invoke(null, mRegistrationParams);
} catch (IllegalAccessException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
}
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
"unblocked on expecter for " + mGeckoEvent);
}
@ -152,13 +207,6 @@ public class FennecNativeActions implements Actions {
}
void notifyOfEvent() {
try {
mUnregisterGEL.invoke(null, mRegistrationParams);
} catch (IllegalAccessException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
}
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
"received event " + mGeckoEvent);
synchronized (this) {
@ -168,7 +216,7 @@ public class FennecNativeActions implements Actions {
}
}
public EventExpecter expectGeckoEvent(String geckoEvent) {
public RepeatedEventExpecter expectGeckoEvent(String geckoEvent) {
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
"waiting for "+geckoEvent);
try {

View File

@ -94,8 +94,8 @@ public class FennecNativeDriver implements Driver {
Class [] parameters = new Class[2];
parameters[0] = String.class;
parameters[1] = mGel;
mRegisterGEL = mGas.getMethod("registerGeckoEventListener", parameters);
mUnregisterGEL = mGas.getMethod("unregisterGeckoEventListener", parameters);
mRegisterGEL = mGas.getMethod("registerEventListener", parameters);
mUnregisterGEL = mGas.getMethod("unregisterEventListener", parameters);
parameters = new Class[1];
parameters[0] = mGe;
mSendGE = mGas.getMethod("sendEventToGecko", parameters);

View File

@ -790,7 +790,10 @@ public class SUTAgentAndroid extends Activity
}
finally
{
pw.close();
if (pw != null)
{
pw.close();
}
}
}

View File

@ -87,20 +87,12 @@ endif
CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
AUTOCONF_TOOLS = $(topsrcdir)/build/autoconf
ifeq ($(OS_ARCH),QNX)
ifeq ($(OS_TARGET),NTO)
LD := qcc -Vgcc_ntox86 -nostdlib
else
LD := $(CC)
endif
endif
#
# Strip off the excessively long version numbers on these platforms,
# but save the version to allow multiple versions of the same base
# platform to be built in the same tree.
#
ifneq (,$(filter FreeBSD HP-UX Linux NetBSD OpenBSD OSF1 SunOS,$(OS_ARCH)))
ifneq (,$(filter FreeBSD HP-UX Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
OS_RELEASE := $(basename $(OS_RELEASE))
# Allow the user to ignore the OS_VERSION, which is usually irrelevant.

View File

@ -500,17 +500,6 @@ endif # HAS_EXTRAEXPORTS
endif # IS_COMPONENT
endif # AIX
#
# OSF1: add -B symbolic flag for components
#
ifeq ($(OS_ARCH),OSF1)
ifdef IS_COMPONENT
ifeq ($(GNU_CC)$(GNU_CXX),)
EXTRA_DSO_LDOPTS += -B symbolic
endif
endif
endif
#
# Linux: add -Bsymbolic flag for components
#

View File

@ -4150,7 +4150,6 @@ MOZ_SPEEX_RESAMPLER=1
MOZ_CUBEB=
MOZ_VORBIS=
MOZ_TREMOR=
MOZ_FLOATING_POINT_AUDIO=
MOZ_WAVE=1
MOZ_MEDIA=
MOZ_OPUS=1
@ -5200,24 +5199,6 @@ fi
AC_SUBST(MOZ_WEBRTC)
dnl ========================================================
dnl = Disable floating point audio.
dnl ========================================================
MOZ_ARG_DISABLE_BOOL(floating-point,
[ --disable-floating-point Disable floating point audio],
MOZ_FLOATING_POINT_AUDIO=,
MOZ_FLOATING_POINT_AUDIO=1)
case "$target_cpu" in
arm*)
;;
*)
AC_DEFINE(MOZ_FLOATING_POINT_AUDIO)
MOZ_FLOATING_POINT_AUDIO=1
;;
esac
dnl ========================================================
dnl = Enable Raw Codecs
dnl ========================================================
@ -5246,6 +5227,14 @@ if test -n "$MOZ_OGG"; then
MOZ_SYDNEYAUDIO=1
MOZ_CUBEB=1
MOZ_MEDIA=1
case "$target_cpu" in
arm*)
MOZ_TREMOR=1
;;
*)
MOZ_VORBIS=1
;;
esac
dnl Checks for __attribute__(aligned()) directive
AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
@ -5315,7 +5304,7 @@ if test -n "$MOZ_MEDIA_NAVIGATOR"; then
fi
dnl ========================================================
dnl = Enable building OMX media plugin (B2G)
dnl = Enable building OMX media plugin (B2G or Android)
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(omx-plugin,
[ --enable-omx-plugin Enable building OMX plugin (B2G)],
@ -5323,12 +5312,12 @@ MOZ_ARG_ENABLE_BOOL(omx-plugin,
MOZ_OMX_PLUGIN=)
if test -n "$MOZ_OMX_PLUGIN"; then
if test "$OS_TARGET" = "Android" -a -n "$gonkdir"; then
dnl Only allow building OMX plugin on Gonk (B2G)
if test "$OS_TARGET" = "Android"; then
dnl Only allow building OMX plugin on Gonk (B2G) or Android
AC_DEFINE(MOZ_OMX_PLUGIN)
else
dnl fail if we're not building on Gonk
AC_MSG_ERROR([OMX media plugin can only be built on B2G])
dnl fail if we're not building on Gonk or Android
AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
fi
fi
@ -5375,11 +5364,14 @@ if test "$MOZ_WEBM"; then
MOZ_SYDNEYAUDIO=1
MOZ_CUBEB=1
MOZ_MEDIA=1
if test -n "$MOZ_FLOATING_POINT_AUDIO"; then
MOZ_VORBIS=1
else
case "$target_cpu" in
arm*)
MOZ_TREMOR=1
fi
;;
*)
MOZ_VORBIS=1
;;
esac
fi
if test -n "$MOZ_VP8" -a -z "$MOZ_NATIVE_LIBVPX"; then

View File

@ -15,7 +15,6 @@ LIBRARY_NAME = gkconbase_s
LIBXUL_LIBRARY = 1
EXPORTS = \
nsAtomListUtils.h \
nsAttrName.h \

View File

@ -1199,8 +1199,8 @@ nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
PRInt32 endOffset = mRange->EndOffset();
MOZ_ASSERT(mCommonParent && startParent && endParent);
// Bug 767169
MOZ_ASSERT(startOffset <= startParent->Length() &&
endOffset <= endParent->Length());
MOZ_ASSERT(PRUint32(startOffset) <= startParent->Length() &&
PRUint32(endOffset) <= endParent->Length());
// short circuit when start node == end node
if (startParent == endParent) {

View File

@ -57,7 +57,6 @@ private:
nsCOMPtr<nsIURI> mBaseURI;
nsWeakPtr mScriptHandlingObject;
bool mLoopingForSyncLoad;
bool mAttemptedInit;
};

View File

@ -808,9 +808,13 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
nsCOMPtr<nsIInputStream> input;
channel->Open(getter_AddRefs(input));
nsString dataString;
PRUint32 avail = 0;
if (input && NS_SUCCEEDED(input->Available(&avail)) && avail) {
PRUint64 avail64 = 0;
if (input && NS_SUCCEEDED(input->Available(&avail64)) && avail64) {
if (avail64 > PR_UINT32_MAX) {
return;
}
nsCString buffer;
PRUint32 avail = (PRUint32)NS_MIN(avail64, (PRUint64)PR_UINT32_MAX);
if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) {
return;
}

View File

@ -607,10 +607,7 @@ PRInt32
nsGenericElement::GetScrollTop()
{
nsIScrollableFrame* sf = GetScrollFrame();
return sf ?
nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollPosition().y) :
0;
return sf ? sf->GetScrollPositionCSSPixels().y : 0;
}
NS_IMETHODIMP
@ -626,9 +623,7 @@ nsGenericElement::SetScrollTop(PRInt32 aScrollTop)
{
nsIScrollableFrame* sf = GetScrollFrame();
if (sf) {
nsPoint pt = sf->GetScrollPosition();
sf->ScrollToCSSPixels(nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
aScrollTop));
sf->ScrollToCSSPixels(nsIntPoint(sf->GetScrollPositionCSSPixels().x, aScrollTop));
}
return NS_OK;
}
@ -637,10 +632,7 @@ PRInt32
nsGenericElement::GetScrollLeft()
{
nsIScrollableFrame* sf = GetScrollFrame();
return sf ?
nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollPosition().x) :
0;
return sf ? sf->GetScrollPositionCSSPixels().x : 0;
}
NS_IMETHODIMP
@ -656,9 +648,7 @@ nsGenericElement::SetScrollLeft(PRInt32 aScrollLeft)
{
nsIScrollableFrame* sf = GetScrollFrame();
if (sf) {
nsPoint pt = sf->GetScrollPosition();
sf->ScrollToCSSPixels(nsIntPoint(aScrollLeft,
nsPresContext::AppUnitsToIntCSSPixels(pt.y)));
sf->ScrollToCSSPixels(nsIntPoint(aScrollLeft, sf->GetScrollPositionCSSPixels().y));
}
return NS_OK;
}

View File

@ -720,6 +720,7 @@ GK_ATOM(ontransitionend, "ontransitionend")
GK_ATOM(onunderflow, "onunderflow")
GK_ATOM(onunload, "onunload")
GK_ATOM(onupgradeneeded, "onupgradeneeded")
GK_ATOM(onwheel, "onwheel")
GK_ATOM(open, "open")
GK_ATOM(optgroup, "optgroup")
GK_ATOM(optimum, "optimum")

View File

@ -352,9 +352,9 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
// Load
rv = aListener->OnStartRequest(aChannel, nullptr);
if (NS_SUCCEEDED(rv)) {
PRUint32 sourceOffset = 0;
PRUint64 sourceOffset = 0;
while (1) {
PRUint32 readCount = 0;
PRUint64 readCount = 0;
rv = aIn->Available(&readCount);
if (NS_FAILED(rv) || !readCount) {
if (rv == NS_BASE_STREAM_CLOSED) {
@ -364,8 +364,12 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
break;
}
if (readCount > PR_UINT32_MAX)
readCount = PR_UINT32_MAX;
rv = aListener->OnDataAvailable(aChannel, nullptr, aIn,
sourceOffset, readCount);
(PRUint32)NS_MIN(sourceOffset, (PRUint64)PR_UINT32_MAX),
(PRUint32)readCount);
if (NS_FAILED(rv)) {
break;
}

View File

@ -2962,7 +2962,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
}
mUploadComplete = false;
PRUint32 uploadTotal = 0;
PRUint64 uploadTotal = 0;
postDataStream->Available(&uploadTotal);
mUploadTotal = uploadTotal;

View File

@ -4316,8 +4316,11 @@ nsCanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer *aOldLayer,
LayerManager *aManager)
{
if (!EnsureSurface())
// If we don't have anything to draw, don't bother.
if (!mValid || !mSurface || mSurface->CairoStatus() || !mThebes ||
!mSurfaceCreated) {
return nullptr;
}
if (!mResetLayer && aOldLayer) {
CanvasRenderingContext2DUserData* userData =

View File

@ -4645,23 +4645,20 @@ nsCanvasRenderingContext2DAzure::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
return nullptr;
}
CanvasRenderingContext2DUserDataAzure *userData = nullptr;
if (aBuilder->IsPaintingToWindow()) {
// Make the layer tell us whenever a transaction finishes (including
// the current transaction), so we can clear our invalidation state and
// start invalidating again. We need to do this for the layer that is
// being painted to a window (there shouldn't be more than one at a time,
// and if there is, flushing the invalidation state more often than
// necessary is harmless).
// Make the layer tell us whenever a transaction finishes (including
// the current transaction), so we can clear our invalidation state and
// start invalidating again. We need to do this for all layers since
// callers of DrawWindow may be expecting to receive normal invalidation
// notifications after this paint.
// The layer will be destroyed when we tear down the presentation
// (at the latest), at which time this userData will be destroyed,
// releasing the reference to the element.
// The userData will receive DidTransactionCallbacks, which flush the
// the invalidation state to indicate that the canvas is up to date.
userData = new CanvasRenderingContext2DUserDataAzure(this);
canvasLayer->SetDidTransactionCallback(
CanvasRenderingContext2DUserDataAzure::DidTransactionCallback, userData);
}
// The layer will be destroyed when we tear down the presentation
// (at the latest), at which time this userData will be destroyed,
// releasing the reference to the element.
// The userData will receive DidTransactionCallbacks, which flush the
// the invalidation state to indicate that the canvas is up to date.
userData = new CanvasRenderingContext2DUserDataAzure(this);
canvasLayer->SetDidTransactionCallback(
CanvasRenderingContext2DUserDataAzure::DidTransactionCallback, userData);
canvasLayer->SetUserData(&g2DContextLayerUserData, userData);
CanvasLayer::Data data;

View File

@ -600,6 +600,10 @@ NON_IDL_EVENT(underflow,
NS_SCROLLPORT_UNDERFLOW,
EventNameType_XUL,
NS_EVENT_NULL)
NON_IDL_EVENT(wheel,
NS_WHEEL_WHEEL,
EventNameType_XUL,
NS_WHEEL_EVENT)
// Various SVG events
NON_IDL_EVENT(SVGLoad,

View File

@ -0,0 +1,176 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DOMWheelEvent.h"
#include "nsGUIEvent.h"
#include "nsIContent.h"
#include "nsContentUtils.h"
#include "DictionaryHelpers.h"
#include "nsDOMClassInfoID.h"
DOMCI_DATA(WheelEvent, mozilla::dom::DOMWheelEvent)
namespace mozilla {
namespace dom {
DOMWheelEvent::DOMWheelEvent(nsPresContext* aPresContext,
widget::WheelEvent* aWheelEvent)
: nsDOMMouseEvent(aPresContext, aWheelEvent ? aWheelEvent :
new widget::WheelEvent(false, 0, nullptr))
{
if (aWheelEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = 0;
static_cast<widget::WheelEvent*>(mEvent)->inputSource =
nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
}
}
DOMWheelEvent::~DOMWheelEvent()
{
if (mEventIsInternal && mEvent) {
MOZ_ASSERT(mEvent->eventStructType == NS_WHEEL_EVENT,
"The mEvent must be WheelEvent");
delete static_cast<widget::WheelEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_IMPL_ADDREF_INHERITED(DOMWheelEvent, nsDOMMouseEvent)
NS_IMPL_RELEASE_INHERITED(DOMWheelEvent, nsDOMMouseEvent)
NS_INTERFACE_MAP_BEGIN(DOMWheelEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMWheelEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WheelEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
NS_IMETHODIMP
DOMWheelEvent::InitWheelEvent(const nsAString & aType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow *aView,
PRInt32 aDetail,
PRInt32 aScreenX,
PRInt32 aScreenY,
PRInt32 aClientX,
PRInt32 aClientY,
PRUint16 aButton,
nsIDOMEventTarget *aRelatedTarget,
const nsAString& aModifiersList,
double aDeltaX,
double aDeltaY,
double aDeltaZ,
PRUint32 aDeltaMode)
{
nsresult rv =
nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView,
aDetail, aScreenX, aScreenY,
aClientX, aClientY, aButton,
aRelatedTarget, aModifiersList);
NS_ENSURE_SUCCESS(rv, rv);
widget::WheelEvent* wheelEvent = static_cast<widget::WheelEvent*>(mEvent);
wheelEvent->deltaX = aDeltaX;
wheelEvent->deltaY = aDeltaY;
wheelEvent->deltaZ = aDeltaZ;
wheelEvent->deltaMode = aDeltaMode;
return NS_OK;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaX(double* aDeltaX)
{
NS_ENSURE_ARG_POINTER(aDeltaX);
*aDeltaX = static_cast<widget::WheelEvent*>(mEvent)->deltaX;
return NS_OK;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaY(double* aDeltaY)
{
NS_ENSURE_ARG_POINTER(aDeltaY);
*aDeltaY = static_cast<widget::WheelEvent*>(mEvent)->deltaY;
return NS_OK;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaZ(double* aDeltaZ)
{
NS_ENSURE_ARG_POINTER(aDeltaZ);
*aDeltaZ = static_cast<widget::WheelEvent*>(mEvent)->deltaZ;
return NS_OK;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaMode(PRUint32* aDeltaMode)
{
NS_ENSURE_ARG_POINTER(aDeltaMode);
*aDeltaMode = static_cast<widget::WheelEvent*>(mEvent)->deltaMode;
return NS_OK;
}
nsresult
DOMWheelEvent::InitFromCtor(const nsAString& aType,
JSContext* aCx, jsval* aVal)
{
WheelEventInit d;
nsresult rv = d.Init(aCx, aVal);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString modifierList;
if (d.ctrlKey) {
modifierList.AppendLiteral(NS_DOM_KEYNAME_CONTROL);
}
if (d.shiftKey) {
if (!modifierList.IsEmpty()) {
modifierList.AppendLiteral(" ");
}
modifierList.AppendLiteral(NS_DOM_KEYNAME_SHIFT);
}
if (d.altKey) {
if (!modifierList.IsEmpty()) {
modifierList.AppendLiteral(" ");
}
modifierList.AppendLiteral(NS_DOM_KEYNAME_ALT);
}
if (d.metaKey) {
if (!modifierList.IsEmpty()) {
modifierList.AppendLiteral(" ");
}
modifierList.AppendLiteral(NS_DOM_KEYNAME_META);
}
rv = InitWheelEvent(aType, d.bubbles, d.cancelable,
d.view, d.detail, d.screenX, d.screenY,
d.clientX, d.clientY, d.button, d.relatedTarget,
modifierList, d.deltaX, d.deltaY, d.deltaZ, d.deltaMode);
NS_ENSURE_SUCCESS(rv, rv);
static_cast<widget::WheelEvent*>(mEvent)->buttons = d.buttons;
return NS_OK;
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
nsresult NS_NewDOMWheelEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
widget::WheelEvent *aEvent)
{
dom::DOMWheelEvent* it = new dom::DOMWheelEvent(aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_DOMWheelEvent_h__
#define mozilla_dom_DOMWheelEvent_h__
#include "nsIDOMWheelEvent.h"
#include "nsDOMMouseEvent.h"
namespace mozilla {
namespace dom {
class DOMWheelEvent : public nsDOMMouseEvent,
public nsIDOMWheelEvent
{
public:
DOMWheelEvent(nsPresContext* aPresContext,
widget::WheelEvent* aWheelEvent);
virtual ~DOMWheelEvent();
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMWheelEvent Interface
NS_DECL_NSIDOMWHEELEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMMOUSEEVENT
virtual nsresult InitFromCtor(const nsAString& aType,
JSContext* aCx, jsval* aVal);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_DOMWheelEvent_h__

View File

@ -13,6 +13,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = content
LIBRARY_NAME = gkconevents_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS = 1
EXPORTS = \
nsEventStateManager.h \
@ -62,6 +63,7 @@ CPPSRCS = \
nsDOMAnimationEvent.cpp \
nsDOMTouchEvent.cpp \
nsDOMCompositionEvent.cpp \
DOMWheelEvent.cpp \
$(NULL)
ifdef MOZ_B2G_RIL

View File

@ -52,7 +52,7 @@ static const char* const sEventNames[] = {
"DOMNodeRemovedFromDocument", "DOMNodeInsertedIntoDocument",
"DOMAttrModified", "DOMCharacterDataModified",
"DOMActivate", "DOMFocusIn", "DOMFocusOut",
"pageshow", "pagehide", "DOMMouseScroll", "MozMousePixelScroll",
"pageshow", "pagehide", "DOMMouseScroll", "MozMousePixelScroll", "wheel",
"offline", "online", "copy", "cut", "paste", "open", "message", "show",
"SVGLoad", "SVGUnload", "SVGAbort", "SVGError", "SVGResize", "SVGScroll",
"SVGZoom",
@ -191,6 +191,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
switch (tmp->mEvent->eventStructType) {
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget = nullptr;
@ -218,6 +219,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
switch (tmp->mEvent->eventStructType) {
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
@ -718,11 +720,10 @@ nsDOMEvent::DuplicatePrivateData()
{
nsMouseScrollEvent* mouseScrollEvent =
new nsMouseScrollEvent(false, msg, nullptr);
NS_ENSURE_TRUE(mouseScrollEvent, NS_ERROR_OUT_OF_MEMORY);
isInputEvent = true;
nsMouseScrollEvent* oldMouseScrollEvent =
static_cast<nsMouseScrollEvent*>(mEvent);
mouseScrollEvent->scrollFlags = oldMouseScrollEvent->scrollFlags;
mouseScrollEvent->isHorizontal = oldMouseScrollEvent->isHorizontal;
mouseScrollEvent->delta = oldMouseScrollEvent->delta;
mouseScrollEvent->relatedTarget = oldMouseScrollEvent->relatedTarget;
mouseScrollEvent->button = oldMouseScrollEvent->button;
@ -732,6 +733,33 @@ nsDOMEvent::DuplicatePrivateData()
newEvent = mouseScrollEvent;
break;
}
case NS_WHEEL_EVENT:
{
widget::WheelEvent* wheelEvent =
new widget::WheelEvent(false, msg, nullptr);
isInputEvent = true;
widget::WheelEvent* oldWheelEvent =
static_cast<widget::WheelEvent*>(mEvent);
wheelEvent->deltaX = oldWheelEvent->deltaX;
wheelEvent->deltaY = oldWheelEvent->deltaY;
wheelEvent->deltaZ = oldWheelEvent->deltaZ;
wheelEvent->deltaMode = oldWheelEvent->deltaMode;
wheelEvent->relatedTarget = oldWheelEvent->relatedTarget;
wheelEvent->button = oldWheelEvent->button;
wheelEvent->buttons = oldWheelEvent->buttons;
wheelEvent->modifiers = oldWheelEvent->modifiers;
wheelEvent->inputSource = oldWheelEvent->inputSource;
wheelEvent->customizedByUserPrefs = oldWheelEvent->customizedByUserPrefs;
wheelEvent->isMomentum = oldWheelEvent->isMomentum;
wheelEvent->isPixelOnlyDevice = oldWheelEvent->isPixelOnlyDevice;
wheelEvent->lineOrPageDeltaX = oldWheelEvent->lineOrPageDeltaX;
wheelEvent->lineOrPageDeltaY = oldWheelEvent->lineOrPageDeltaY;
wheelEvent->scrollType = oldWheelEvent->scrollType;
wheelEvent->overflowDeltaX = oldWheelEvent->overflowDeltaX;
wheelEvent->overflowDeltaY = oldWheelEvent->overflowDeltaY;
newEvent = wheelEvent;
break;
}
case NS_SCROLLPORT_EVENT:
{
newEvent = new nsScrollPortEvent(false, msg, nullptr);
@ -1157,6 +1185,7 @@ nsDOMEvent::GetScreenCoords(nsPresContext* aPresContext,
(aEvent->eventStructType != NS_MOUSE_EVENT &&
aEvent->eventStructType != NS_POPUP_EVENT &&
aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_MOZTOUCH_EVENT &&
aEvent->eventStructType != NS_TOUCH_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
@ -1216,6 +1245,7 @@ nsDOMEvent::GetClientCoords(nsPresContext* aPresContext,
(aEvent->eventStructType != NS_MOUSE_EVENT &&
aEvent->eventStructType != NS_POPUP_EVENT &&
aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_MOZTOUCH_EVENT &&
aEvent->eventStructType != NS_TOUCH_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
@ -1390,6 +1420,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return sEventNames[eDOMEvents_DOMMouseScroll];
case NS_MOUSE_PIXEL_SCROLL:
return sEventNames[eDOMEvents_MozMousePixelScroll];
case NS_WHEEL_WHEEL:
return sEventNames[eDOMEvents_wheel];
case NS_OFFLINE:
return sEventNames[eDOMEvents_offline];
case NS_ONLINE:

View File

@ -102,6 +102,7 @@ public:
eDOMEvents_pagehide,
eDOMEvents_DOMMouseScroll,
eDOMEvents_MozMousePixelScroll,
eDOMEvents_wheel,
eDOMEvents_offline,
eDOMEvents_online,
eDOMEvents_copy,

View File

@ -85,6 +85,7 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, bool aCanBubble, bool a
{
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
@ -139,6 +140,7 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString& aType,
switch(mEvent->eventStructType) {
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
@ -167,6 +169,7 @@ nsDOMMouseEvent::InitFromCtor(const nsAString& aType,
switch(mEvent->eventStructType) {
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
@ -206,6 +209,7 @@ nsDOMMouseEvent::GetButton(PRUint16* aButton)
{
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
@ -227,6 +231,7 @@ nsDOMMouseEvent::GetButtons(PRUint16* aButtons)
{
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
@ -250,6 +255,7 @@ nsDOMMouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
{
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:

View File

@ -21,8 +21,7 @@ nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(nsPresContext* aPresContext,
}
if(mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
nsMouseScrollEvent* mouseEvent = static_cast<nsMouseScrollEvent*>(mEvent);
mDetail = mouseEvent->delta;
mDetail = static_cast<nsMouseScrollEvent*>(mEvent)->delta;
}
}
@ -66,9 +65,8 @@ nsDOMMouseScrollEvent::InitMouseScrollEvent(const nsAString & aType, bool aCanBu
NS_ENSURE_SUCCESS(rv, rv);
if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
static_cast<nsMouseScrollEvent*>(mEvent)->scrollFlags =
(aAxis == HORIZONTAL_AXIS) ? nsMouseScrollEvent::kIsHorizontal
: nsMouseScrollEvent::kIsVertical;
static_cast<nsMouseScrollEvent*>(mEvent)->isHorizontal =
(aAxis == HORIZONTAL_AXIS);
}
return NS_OK;
@ -81,9 +79,9 @@ nsDOMMouseScrollEvent::GetAxis(PRInt32* aResult)
NS_ENSURE_ARG_POINTER(aResult);
if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
PRUint32 flags = static_cast<nsMouseScrollEvent*>(mEvent)->scrollFlags;
*aResult = (flags & nsMouseScrollEvent::kIsHorizontal)
? PRInt32(HORIZONTAL_AXIS) : PRInt32(VERTICAL_AXIS);
*aResult = static_cast<nsMouseScrollEvent*>(mEvent)->isHorizontal ?
static_cast<PRInt32>(HORIZONTAL_AXIS) :
static_cast<PRInt32>(VERTICAL_AXIS);
} else {
*aResult = 0;
}

View File

@ -97,7 +97,7 @@ protected:
bool mPointsInitialized;
};
class nsDOMTouchList : public nsIDOMTouchList
class nsDOMTouchList MOZ_FINAL : public nsIDOMTouchList
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS

View File

@ -114,6 +114,7 @@ nsDOMUIEvent::GetMovementPoint()
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_POPUP_EVENT &&
mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
mEvent->eventStructType != NS_WHEEL_EVENT &&
mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
mEvent->eventStructType != NS_DRAG_EVENT &&
mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT)) {
@ -312,6 +313,7 @@ nsDOMUIEvent::GetLayerPoint()
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_POPUP_EVENT &&
mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
mEvent->eventStructType != NS_WHEEL_EVENT &&
mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
mEvent->eventStructType != NS_TOUCH_EVENT &&
mEvent->eventStructType != NS_DRAG_EVENT &&

View File

@ -39,6 +39,7 @@ public:
(aEvent->eventStructType != NS_MOUSE_EVENT &&
aEvent->eventStructType != NS_POPUP_EVENT &&
aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_MOZTOUCH_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT)) {
@ -64,6 +65,7 @@ public:
(aEvent->eventStructType != NS_MOUSE_EVENT &&
aEvent->eventStructType != NS_POPUP_EVENT &&
aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_MOZTOUCH_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||

View File

@ -22,6 +22,8 @@
#include "sampler.h"
#include "GeneratedEvents.h"
using namespace mozilla;
#define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH (1 << 0)
#define NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT (1 << 1)
#define NS_TARGET_CHAIN_MAY_HAVE_MANAGER (1 << 2)
@ -734,6 +736,9 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
case NS_MOUSE_SCROLL_EVENT:
return NS_NewDOMMouseScrollEvent(aDOMEvent, aPresContext,
static_cast<nsInputEvent*>(aEvent));
case NS_WHEEL_EVENT:
return NS_NewDOMWheelEvent(aDOMEvent, aPresContext,
static_cast<widget::WheelEvent*>(aEvent));
case NS_DRAG_EVENT:
return NS_NewDOMDragEvent(aDOMEvent, aPresContext,
static_cast<nsDragEvent*>(aEvent));

File diff suppressed because it is too large Load Diff

View File

@ -86,6 +86,14 @@ public:
nsIFrame* aTargetFrame,
nsEventStatus* aStatus);
/**
* DispatchLegacyMouseScrollEvents() dispatches NS_MOUSE_SCROLL event and
* NS_MOUSE_PIXEL_SCROLL event for compatiblity with old Gecko.
*/
void DispatchLegacyMouseScrollEvents(nsIFrame* aTargetFrame,
mozilla::widget::WheelEvent* aEvent,
nsEventStatus* aStatus);
void NotifyDestroyPresContext(nsPresContext* aPresContext);
void SetPresContext(nsPresContext* aPresContext);
void ClearFrameRefs(nsIFrame* aFrame);
@ -317,67 +325,241 @@ protected:
bool IsShellVisible(nsIDocShell* aShell);
// These functions are for mousewheel and pixel scrolling
void SendLineScrollEvent(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aEvent,
nsPresContext* aPresContext,
nsEventStatus* aStatus,
PRInt32 aNumLines);
void SendPixelScrollEvent(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aEvent,
nsPresContext* aPresContext,
nsEventStatus* aStatus);
class WheelPrefs
{
public:
static WheelPrefs* GetInstance();
static void Shutdown();
/**
* ApplyUserPrefsToDelta() overrides the wheel event's delta values with
* user prefs.
*/
void ApplyUserPrefsToDelta(mozilla::widget::WheelEvent* aEvent);
/**
* If ApplyUserPrefsToDelta() changed the delta values with customized
* prefs, the overflowDelta values would be inflated.
* CancelApplyingUserPrefsFromOverflowDelta() cancels the inflation.
*/
void CancelApplyingUserPrefsFromOverflowDelta(
mozilla::widget::WheelEvent* aEvent);
/**
* Computes the default action for the aEvent with the prefs.
*/
enum Action
{
ACTION_NONE = 0,
ACTION_SCROLL,
ACTION_HISTORY,
ACTION_ZOOM,
ACTION_LAST = ACTION_ZOOM
};
Action ComputeActionFor(mozilla::widget::WheelEvent* aEvent);
/**
* NeedToComputeLineOrPageDelta() returns if the aEvent needs to be
* computed the lineOrPageDelta values.
*/
bool NeedToComputeLineOrPageDelta(mozilla::widget::WheelEvent* aEvent);
private:
WheelPrefs();
~WheelPrefs();
static int OnPrefChanged(const char* aPrefName, void* aClosure);
enum Index
{
INDEX_DEFAULT = 0,
INDEX_ALT,
INDEX_CONTROL,
INDEX_META,
INDEX_SHIFT,
INDEX_OS,
COUNT_OF_MULTIPLIERS
};
/**
* GetIndexFor() returns the index of the members which should be used for
* the aEvent. When only one modifier key of MODIFIER_ALT,
* MODIFIER_CONTROL, MODIFIER_META, MODIFIER_SHIFT or MODIFIER_OS is
* pressed, returns the index for the modifier. Otherwise, this return the
* default index which is used at either no modifier key is pressed or
* two or modifier keys are pressed.
*/
Index GetIndexFor(mozilla::widget::WheelEvent* aEvent);
/**
* GetPrefNameBase() returns the base pref name for aEvent.
* It's decided by GetModifierForPref() which modifier should be used for
* the aEvent.
*
* @param aBasePrefName The result, must be "mousewheel.with_*." or
* "mousewheel.default.".
*/
void GetBasePrefName(Index aIndex, nsACString& aBasePrefName);
void Init(Index aIndex);
void Reset();
bool mInit[COUNT_OF_MULTIPLIERS];
double mMultiplierX[COUNT_OF_MULTIPLIERS];
double mMultiplierY[COUNT_OF_MULTIPLIERS];
double mMultiplierZ[COUNT_OF_MULTIPLIERS];
Action mActions[COUNT_OF_MULTIPLIERS];
static WheelPrefs* sInstance;
};
/**
* @param aQueryEvent If you set vailid pointer for this, DoScrollText()
* computes the line-height and page size of current
* mouse wheel scroll target and sets it to the event.
* And then, this method does NOT scroll any scrollable
* elements. I.e., you can just query the scroll target
* information.
* DeltaDirection is used for specifying whether the called method should
* handle vertical delta or horizontal delta.
* This is clearer than using bool.
*/
nsresult DoScrollText(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aMouseEvent,
nsIScrollableFrame::ScrollUnit aScrollQuantity,
bool aAllowScrollSpeedOverride,
nsQueryContentEvent* aQueryEvent = nullptr,
nsIAtom *aOrigin = nullptr);
enum DeltaDirection
{
DELTA_DIRECTION_X = 0,
DELTA_DIRECTION_Y
};
/**
* SendLineScrollEvent() dispatches a DOMMouseScroll event for the
* widget::WheelEvent. This method shouldn't be called for non-trusted
* wheel event because it's not necessary for compatiblity.
*
* @param aTargetFrame The event target of wheel event.
* @param aEvent The original Wheel event.
* @param aStatus The event status, must not be
* nsEventStatus_eConsumeNoDefault.
* @param aDelta The delta value of the event.
* @param aDeltaDirection The X/Y direction of dispatching event.
*/
void SendLineScrollEvent(nsIFrame* aTargetFrame,
mozilla::widget::WheelEvent* aEvent,
nsEventStatus* aStatus,
PRInt32 aDelta,
DeltaDirection aDeltaDirection);
/**
* SendPixelScrollEvent() dispatches a MozMousePixelScroll event for the
* widget::WheelEvent. This method shouldn't be called for non-trusted
* wheel event because it's not necessary for compatiblity.
*
* @param aTargetFrame The event target of wheel event.
* @param aEvent The original Wheel event.
* @param aStatus The event status, must not be
* nsEventStatus_eConsumeNoDefault.
* @param aPixelDelta The delta value of the event.
* @param aDeltaDirection The X/Y direction of dispatching event.
*/
void SendPixelScrollEvent(nsIFrame* aTargetFrame,
mozilla::widget::WheelEvent* aEvent,
nsEventStatus* aStatus,
PRInt32 aPixelDelta,
DeltaDirection aDeltaDirection);
/**
* ComputeScrollTarget() returns the scrollable frame which should be
* scrolled.
*
* @param aTargetFrame The event target of the wheel event.
* @param aEvent The handling mouse wheel event.
* @param aForDefaultAction Whether this uses wheel transaction or not.
* If true, returns the latest scrolled frame if
* there is it. Otherwise, the nearest ancestor
* scrollable frame from aTargetFrame.
* @return The scrollable frame which should be scrolled.
*/
nsIScrollableFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
mozilla::widget::WheelEvent* aEvent,
bool aForDefaultAction);
/**
* GetScrollAmount() returns the scroll amount in app uints of one line or
* one page. If the wheel event scrolls a page, returns the page width and
* height. Otherwise, returns line height for both its width and height.
*
* @param aScrollableFrame A frame which will be scrolled by the event.
* The result of ComputeScrollTarget() is
* expected for this value.
* This can be NULL if there is no scrollable
* frame. Then, this method uses root frame's
* line height or visible area's width and height.
*/
nsSize GetScrollAmount(nsPresContext* aPresContext,
mozilla::widget::WheelEvent* aEvent,
nsIScrollableFrame* aScrollableFrame);
/**
* DoScrollText() scrolls the scrollable frame for aEvent.
*/
void DoScrollText(nsIScrollableFrame* aScrollableFrame,
mozilla::widget::WheelEvent* aEvent);
void DoScrollHistory(PRInt32 direction);
void DoScrollZoom(nsIFrame *aTargetFrame, PRInt32 adjustment);
nsresult GetMarkupDocumentViewer(nsIMarkupDocumentViewer** aMv);
nsresult ChangeTextSize(PRInt32 change);
nsresult ChangeFullZoom(PRInt32 change);
/**
* Computes actual delta value used for scrolling. If user customized the
* scrolling speed and/or direction, this would return the customized value.
* Otherwise, it would return the original delta value of aMouseEvent.
* DeltaAccumulator class manages delta values for dispatching DOMMouseScroll
* event. If wheel events are caused by pixel scroll only devices or
* the delta values are customized by prefs, this class stores the delta
* values and set lineOrPageDelta values.
*/
PRInt32 ComputeWheelDeltaFor(nsMouseScrollEvent* aMouseEvent);
/**
* Computes the action for the aMouseEvent with prefs. The result is
* MOUSE_SCROLL_N_LINES, MOUSE_SCROLL_PAGE, MOUSE_SCROLL_HISTORY,
* MOUSE_SCROLL_ZOOM, MOUSE_SCROLL_PIXELS or -1.
* When the result is -1, nothing happens for the event.
*
* @param aUseSystemSettings Set the result of UseSystemScrollSettingFor().
*/
PRInt32 ComputeWheelActionFor(nsMouseScrollEvent* aMouseEvent,
bool aUseSystemSettings);
/**
* Gets the wheel action for the aMouseEvent ONLY with the pref.
* When you actually do something for the event, probably you should use
* ComputeWheelActionFor().
*/
PRInt32 GetWheelActionFor(nsMouseScrollEvent* aMouseEvent);
/**
* Gets the pref value for line scroll amount for the aMouseEvent.
* Note that this method doesn't check whether the aMouseEvent is line scroll
* event and doesn't use system settings.
*/
PRInt32 GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent);
/**
* Whether use system scroll settings or settings in our prefs for the event.
* TRUE, if use system scroll settings. Otherwise, FALSE.
*/
bool UseSystemScrollSettingFor(nsMouseScrollEvent* aMouseEvent);
class DeltaAccumulator
{
public:
static DeltaAccumulator* GetInstance()
{
if (!sInstance) {
sInstance = new DeltaAccumulator;
}
return sInstance;
}
static void Shutdown()
{
delete sInstance;
sInstance = nullptr;
}
/**
* InitLineOrPageDelta() stores pixel delta values of WheelEvents which are
* caused if it's needed. And if the accumulated delta becomes a
* line height, sets lineOrPageDeltaX and lineOrPageDeltaY automatically.
*/
void InitLineOrPageDelta(nsIFrame* aTargetFrame,
nsEventStateManager* aESM,
mozilla::widget::WheelEvent* aEvent);
/**
* Reset() resets both delta values.
*/
void Reset();
private:
DeltaAccumulator() :
mX(0.0), mY(0.0), mHandlingDeltaMode(PR_UINT32_MAX),
mHandlingPixelOnlyDevice(false)
{
}
double mX;
double mY;
TimeStamp mLastTime;
PRUint32 mHandlingDeltaMode;
bool mHandlingPixelOnlyDevice;
static DeltaAccumulator* sInstance;
};
// end mousewheel functions
/*
@ -440,8 +622,6 @@ protected:
nsresult DoContentCommandEvent(nsContentCommandEvent* aEvent);
nsresult DoContentCommandScrollEvent(nsContentCommandEvent* aEvent);
void DoQueryScrollTargetInfo(nsQueryContentEvent* aEvent,
nsIFrame* aTargetFrame);
void DoQuerySelectedText(nsQueryContentEvent* aEvent);
bool RemoteQueryContentEvent(nsEvent *aEvent);
@ -530,10 +710,6 @@ public:
// Array for accesskey support
nsCOMArray<nsIContent> mAccessKeys;
// Unlocks pixel scrolling
bool mLastLineScrollConsumedX;
bool mLastLineScrollConsumedY;
static PRInt32 sUserInputEventDepth;
static bool sNormalLMouseEventInProcess;

View File

@ -84,6 +84,11 @@ MOCHITEST_FILES = \
test_bug741666.html \
test_dom_keyboard_event.html \
test_dom_mouse_event.html \
test_dom_wheel_event.html \
test_continuous_wheel_events.html \
test_moz_mouse_pixel_scroll_event.html \
test_wheel_default_action.html \
window_wheel_default_action.html \
test_bug603008.html \
test_bug716822.html \
test_bug742376.html \
@ -106,7 +111,6 @@ endif
MOCHITEST_CHROME_FILES = \
test_bug336682_2.xul \
test_bug336682.js \
test_bug350471.xul \
test_bug586961.xul \
test_bug415498.xul \
bug415498-doc1.html \

View File

@ -1,264 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=350471
-->
<window title="Mozilla Bug 350471"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<title>Test for Bug 350471</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=350471">Mozilla Bug 350471</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
</body>
<script class="testbody" type="application/javascript;version=1.7"><![CDATA[
/** Test for Bug 350471 **/
const minLineHeight = 10, maxLineHeight = 20;
function between(x, min, max) (min <= max) ? (min <= x && x <= max) : (max <= x && x <= min);
function isbetween(x, min, max, msg) ok(between(x, min, max), msg + " - Expected " + min + " to " + max + ", got " + x);
function testEventDispatching(aWin) {
function helper(aAxis, aDelta, aKind, aShiftKey, aCtrlKey, aAltKey, aMetaKey) {
let expectedEvents = [];
let deltaUnit = "";
function listener(e) {
if (!expectedEvents.length) {
ok(false, "Received an event that I didn't expect. type: " + e.type +
", axis: " + e.axis + ", delta: " + e.delta);
return;
}
let expected = expectedEvents.shift();
["type", "shiftKey", "ctrlKey", "altKey", "metaKey"].forEach(function(field) {
is(e[field], expected[field],
"e." + field + " (" + e[field] + ") does not match expected value (" + expected[field] + ")");
});
let expectedAxis = expected.axis == "horizontal" ? e.HORIZONTAL_AXIS : e.VERTICAL_AXIS;
is(e.axis, expectedAxis,
"e.axis (" + e.axis + ") does not match expected value (" + expectedAxis + ")");
// When modifier keys are pressed, cancel the event.
// We don't want to zoom or navigate back / forward (history scroll).
if (aShiftKey || aCtrlKey || aAltKey || aMetaKey) {
e.preventDefault();
// Note: If this is a DOMMouseScroll event without hasPixels, we still
// expect a follow-up MozMousePixelScroll event.
} else {
// Only check the delta if no modifiers are pressed.
// History scroll and zoom change the deltas in nsESM::PreHandleEvent.
if (deltaUnit == (e.type == "DOMMouseScroll" ? "lines" : "pixels")) {
// no unit conversion necessary
is(e.detail, expected.delta,
"e.detail (" + e.detail + ") does not match expected value (" + expected.delta + ")");
} else if (e.type == "MozMousePixelScroll") {
// We sent a line scroll event but are receiving a pixel scroll event,
// so we need to convert the delta.
let minDelta = expected.delta * minLineHeight;
let maxDelta = expected.delta * maxLineHeight;
isbetween(e.detail, minDelta, maxDelta, "wrong pixel scroll event delta");
}
}
e.stopPropagation();
}
// Set up the expected values.
if (aKind == 0 || aKind == 1) {
expectedEvents.push({
type: "DOMMouseScroll",
axis: aAxis,
delta: aDelta,
hasPixels: (aKind == 1),
shiftKey: aShiftKey,
ctrlKey: aCtrlKey,
altKey: aAltKey,
metaKey: aMetaKey
});
}
if (aKind == 0 || aKind == 2) {
expectedEvents.push({
type: "MozMousePixelScroll",
axis: aAxis,
delta: aDelta,
shiftKey: aShiftKey,
ctrlKey: aCtrlKey,
altKey: aAltKey,
metaKey: aMetaKey
});
}
deltaUnit = aKind == 2 ? "pixels" : "lines";
aWin.document.addEventListener("DOMMouseScroll", listener, true);
aWin.document.addEventListener("MozMousePixelScroll", listener, true);
// Send the event to the documentElement.
synthesizeMouseScroll(aWin.document.documentElement, 10, 10, expectedEvents[0], aWin);
aWin.document.removeEventListener("DOMMouseScroll", listener, true);
aWin.document.removeEventListener("MozMousePixelScroll", listener, true);
// expectedEvents should be empty now. If it's not, print errors.
expectedEvents.forEach(function(e) {
ok(false, "Didn't receive expected event: " + JSON.stringify(e));
});
};
let i = 0;
[0, 1, 2].forEach(function(aKind) {
["horizontal", "vertical"].forEach(function(aAxis) {
[false, true].forEach(function(aShift) {
[false, true].forEach(function(aCtrl) {
[false, true].forEach(function(aAlt) {
[false, true].forEach(function(aMeta) {
helper(aAxis, [-5, -1, 0, 1, 5][i++ % 5], aKind, aShift, aCtrl, aAlt, aMeta);
});
});
});
});
});
});
}
function testDefaultHandling(aWin, andThen) {
let scrollbox = aWin.document.getElementById("scrollbox");
function scrollWithPreventDefault(aEvent, aDoConsume) {
function listener(e) {
if (aDoConsume[e.type])
e.preventDefault();
}
scrollbox.addEventListener("DOMMouseScroll", listener, true);
scrollbox.addEventListener("MozMousePixelScroll", listener, true);
synthesizeMouseScroll(scrollbox, 10, 10, aEvent, aWin);
scrollbox.removeEventListener("DOMMouseScroll", listener, true);
scrollbox.removeEventListener("MozMousePixelScroll", listener, true);
}
let tests = [];
function helper(aType, aHasPixels, aAxis, aStart, aDelta, aConsumeLine, aConsumePixel, aPositionShouldChange, aCurrentTest) {
tests.push([aType, aHasPixels, aAxis, aStart, aDelta, aConsumeLine, aConsumePixel, aPositionShouldChange, aCurrentTest]);
}
function exec() {
let [aType, aHasPixels, aAxis, aStart, aDelta, aConsumeLine, aConsumePixel, aPositionShouldChange, currentTest] = tests[0];
tests.shift();
scrollbox.scrollLeft = aStart;
scrollbox.scrollTop = aStart;
scrollWithPreventDefault({
type: aType,
axis: aAxis,
hasPixels: aHasPixels,
delta: aDelta
}, {
"DOMMouseScroll": aConsumeLine,
"MozMousePixelScroll": aConsumePixel
});
setTimeout(function() {
let newPos = scrollbox[aAxis == "horizontal" ? "scrollLeft" : "scrollTop"];
let newPosWrongAxis = scrollbox[aAxis == "horizontal" ? "scrollTop" : "scrollLeft"];
is(newPosWrongAxis, aStart, currentTest + " wrong axis scrolled - type: " + aType);
if (aPositionShouldChange) {
if (aType == "MozMousePixelScroll") {
// aDelta is in pixels, no conversion necessary
is(newPos, aStart + aDelta, currentTest + " wrong scroll position - type: " + aType);
} else {
// Use minLineHeight and maxLineHeight as an estimate for the conversion factor.
isbetween(newPos, aStart + aDelta * minLineHeight, aStart + aDelta * maxLineHeight,
currentTest + " wrong scroll position - type: " + aType);
}
} else {
is(newPos, aStart, currentTest + " The scroll position shouldn't have changed. - type: " + aType);
}
if (tests.length)
exec();
else
andThen();
}, 20);
}
["horizontal", "vertical"].forEach(function(aAxis) {
[-5, 5].forEach(function(aDelta) {
[false, true].forEach(function(aConsumeLine) {
[false, true].forEach(function(aConsumePixel) {
let shouldScroll = !aConsumeLine && !aConsumePixel;
let currentTest = "";
currentTest = "normal DOMMouseScroll: only scroll if neither line nor pixel scroll are consumed.";
helper("DOMMouseScroll", false, aAxis, 4000, aDelta, aConsumeLine, aConsumePixel, shouldScroll, currentTest);
currentTest = "DOMMouseScroll with hasPixels: never scroll.";
helper("DOMMouseScroll", true, aAxis, 4000, aDelta, aConsumeLine, aConsumePixel, false, currentTest);
currentTest = "MozMousePixelScroll (consumed: " + aConsumePixel +
") with preceding DOMMouseScroll (consumed: " + aConsumeLine +
"): " + (shouldScroll ? "scroll." : "don't scroll.");
// It shouldn't matter:
// 1. whether hasPixels is set on the preceding DOMMouseScroll event or
// 2. whether the preceding DOMMouseScroll event's MozMousePixelScroll event is consumed.
helper("DOMMouseScroll", true, aAxis, 4000, aDelta, aConsumeLine, false, false, currentTest);
helper("MozMousePixelScroll", false, aAxis, 4000, aDelta, false, aConsumePixel, shouldScroll, currentTest);
helper("DOMMouseScroll", false, aAxis, 4000, aDelta, aConsumeLine, false, !aConsumeLine, currentTest);
helper("MozMousePixelScroll", false, aAxis, 4000, aDelta, false, aConsumePixel, shouldScroll, currentTest);
helper("DOMMouseScroll", false, aAxis, 4000, aDelta, aConsumeLine, true, false, currentTest);
helper("MozMousePixelScroll", false, aAxis, 4000, aDelta, false, aConsumePixel, shouldScroll, currentTest);
});
});
});
});
exec();
}
function initPrefs()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
// Disables the app level scroll acceleration
prefSvc.setIntPref("mousewheel.acceleration.start", -1);
prefSvc.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false);
prefSvc.setBoolPref("general.smoothScroll", false);
}
function clearPrefs()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
prefSvc.clearUserPref("mousewheel.acceleration.start");
prefSvc.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled");
prefSvc.clearUserPref("general.smoothScroll");
}
window.onload = function () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
let win = window.open('data:application/vnd.mozilla.xul+xml,<?xml version="1.0"?><?xml-stylesheet href="chrome://global/skin" type="text/css"?><window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><vbox style="height: 150px; background: cyan; overflow: auto;" id="scrollbox"><hbox style="height: 8000px;"><vbox style="width: 8000px;"/></hbox></vbox></window>', '_blank', 'chrome,width=400,height=200');
win.onload = function() {
setTimeout(function() {
initPrefs();
testEventDispatching(win);
testDefaultHandling(win, function() {
clearPrefs();
win.close();
SimpleTest.finish();
});
}, 20);
}
}
SimpleTest.waitForExplicitFinish();
]]></script>
</window>

View File

@ -23,25 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=574663
function sendTouchpadScrollMotion(scrollbox, direction, ctrl, momentum) {
var win = scrollbox.ownerDocument.defaultView;
let event = {
'type': "DOMMouseScroll",
'axis': "vertical",
'delta': direction,
'hasPixels': true,
'ctrlKey': ctrl,
'isMomentum': momentum,
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaY: direction * 3,
lineOrPageDeltaY: direction,
ctrlKey: ctrl,
isMomentum: momentum
};
// first a line scroll
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// Then a line scroll with hasPixels set to false
event.hasPixels = false;
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// then 5 pixel scrolls
event.hasPixels = true;
event.delta *= 3;
event.type = "MozMousePixelScroll";
event.hasPixels = false;
synthesizeWheel(scrollbox, 10, 10, event, win);
// then 5 additional pixel scrolls
event.lineOrPageDeltaY = 0;
for (let i = 0; i < 5; ++i) {
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
synthesizeWheel(scrollbox, 10, 10, event, win);
}
}
@ -110,7 +102,7 @@ function initPrefs()
prefSvc.setIntPref("mousewheel.acceleration.start", -1);
prefSvc.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false);
// Enable zooming for ctrl-scrolling
prefSvc.setIntPref("mousewheel.withcontrolkey.action", 3);
prefSvc.setIntPref("mousewheel.with_control.action", 3);
}
function clearPrefs()
@ -122,7 +114,7 @@ function clearPrefs()
prefSvc.clearUserPref("general.smoothScroll");
prefSvc.clearUserPref("mousewheel.acceleration.start");
prefSvc.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled");
prefSvc.clearUserPref("mousewheel.withcontrolkey.action");
prefSvc.clearUserPref("mousewheel.with_control.action");
}
window.onload = function () {

View File

@ -26,19 +26,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607464
function scrollDown15PxWithPixelScrolling(scrollbox) {
var win = scrollbox.ownerDocument.defaultView;
let event = {
'type': "DOMMouseScroll",
'axis': "vertical",
'delta': 1,
'hasPixels': true,
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaY: 3.0,
lineOrPageDeltaY: 1
};
// first a line scroll
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// then 5 pixel scrolls with 3px each
event.delta *= 3;
event.type = "MozMousePixelScroll";
event.hasPixels = false;
for (let i = 0; i < 5; ++i) {
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// A pixel scroll with lineOrPageDeltaY.
synthesizeWheel(scrollbox, 10, 10, event, win);
// then 4 pixel scrolls without lineOrPageDeltaY.
event.lineOrPageDeltaY = 0;
for (let i = 0; i < 4; ++i) {
synthesizeWheel(scrollbox, 10, 10, event, win);
}
// Note: the line scroll shouldn't have any effect because it has

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,707 @@
<!DOCTYPE HTML>
<html style="font-size: 32px;">
<head>
<title>Test for D3E WheelEvent</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="scrollable" style="font-size: 16px; line-height: 1; overflow: auto; width: 200px; height: 200px;">
<div id="scrolled" style="font-size: 64px; width: 5000px; height: 5000px;">
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
</div>
</div>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests, window);
var gScrollableElement = document.getElementById("scrollable");
var gScrolledElement = document.getElementById("scrolled");
var gLineHeight = 0;
var gPageHeight = 0;
var gPageWidth = 0;
function prepareScrollUnits()
{
var result = -1;
function handler(aEvent)
{
result = aEvent.detail;
aEvent.preventDefault();
}
window.addEventListener("MozMousePixelScroll", handler, true);
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaY: 1.0, lineOrPageDeltaY: 1 });
gLineHeight = result;
ok(gLineHeight > 10 && gLineHeight < 25, "prepareScrollUnits: gLineHeight may be illegal value, got " + gLineHeight);
result = -1;
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_PAGE,
deltaY: 1.0, lineOrPageDeltaY: 1 });
gPageHeight = result;
// XXX Cannot we know the actual scroll port size?
ok(gPageHeight >= 150 && gPageHeight <= 200,
"prepareScrollUnits: gPageHeight is strange value, got " + gPageHeight);
result = -1;
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_PAGE,
deltaX: 1.0, lineOrPageDeltaX: 1 });
gPageWidth = result;
ok(gPageWidth >= 150 && gPageWidth <= 200,
"prepareScrollUnits: gPageWidth is strange value, got " + gPageWidth);
window.removeEventListener("MozMousePixelScroll", handler, true);
}
function testMakingUntrustedEvent()
{
const kCreateEventArgs = [
"WheelEvent", "wheelevent", "wheelEvent", "Wheelevent"
];
for (var i = 0; i < kCreateEventArgs.length; i++) {
try {
// We never support WheelEvent construction with document.createEvent().
var event = document.createEvent(kCreateEventArgs[i]);
ok(false, "document.createEvent(" + kCreateEventArgs[i] + ") should throw an error");
} catch (e) {
ok(true, "document.createEvent(" + kCreateEventArgs[i] + ") threw an error");
}
}
var wheelEvent = new WheelEvent("wheel");
ok(wheelEvent instanceof WheelEvent,
"new WheelEvent() should create an instance of WheelEvent");
ok(typeof(wheelEvent.initWheelEvent) != "function",
"WheelEvent must not have initWheelEvent()");
}
// delta_multiplier prefs should cause changing delta values of trusted events only.
// And also legacy events' detail value should be changed too.
function testDeltaMultiplierPrefs()
{
const kModifierAlt = 0x01;
const kModifierControl = 0x02;
const kModifierMeta = 0x04;
const kModifierShift = 0x08;
const kModifierWin = 0x10;
const kTests = [
{ name: "default",
expected: [ 0, kModifierShift | kModifierAlt, kModifierShift | kModifierControl,
kModifierShift | kModifierMeta, kModifierShift | kModifierWin,
kModifierControl | kModifierAlt, kModifierMeta | kModifierAlt ],
unexpected: [ kModifierAlt, kModifierControl, kModifierMeta, kModifierShift, kModifierWin ] },
{ name: "with_alt",
expected: [ kModifierAlt ],
unexpected: [0, kModifierControl, kModifierMeta, kModifierShift, kModifierWin,
kModifierShift | kModifierAlt, kModifierControl | kModifierAlt,
kModifierMeta | kModifierAlt ] },
{ name: "with_control",
expected: [ kModifierControl ],
unexpected: [0, kModifierAlt, kModifierMeta, kModifierShift, kModifierWin,
kModifierShift | kModifierControl, kModifierControl | kModifierAlt,
kModifierMeta | kModifierControl ] },
{ name: "with_meta",
expected: [ kModifierMeta ],
unexpected: [0, kModifierAlt, kModifierControl, kModifierShift, kModifierWin,
kModifierShift | kModifierMeta, kModifierControl | kModifierMeta,
kModifierMeta | kModifierAlt ] },
{ name: "with_shift",
expected: [ kModifierShift ],
unexpected: [0, kModifierAlt, kModifierControl, kModifierMeta, kModifierWin,
kModifierShift | kModifierAlt, kModifierControl | kModifierShift,
kModifierMeta | kModifierShift ] },
{ name: "with_win",
expected: [ kModifierWin ],
unexpected: [0, kModifierAlt, kModifierControl, kModifierMeta, kModifierShift,
kModifierShift | kModifierWin ] },
];
// Note that this test doesn't support complicated lineOrPageDelta values which are computed with
// accumulated delta values by the prefs. If you need to test the lineOrPageDelta accumulation,
// use test_continuous_dom_wheel_event.html.
const kEvents = [
{ deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaX: gLineHeight, deltaY: gLineHeight, deltaZ: gLineHeight, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
{ deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaX: 1.0, deltaY: 1.0, deltaZ: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
{ deltaMode: WheelEvent.DOM_DELTA_PAGE,
deltaX: 1.0, deltaY: 1.0, deltaZ: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
{ deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaX: -gLineHeight, deltaY: -gLineHeight, deltaZ: -gLineHeight, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
{ deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaX: -1.0, deltaY: -1.0, deltaZ: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
{ deltaMode: WheelEvent.DOM_DELTA_PAGE,
deltaX: -1.0, deltaY: -1.0, deltaZ: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
];
const kDeltaMultiplierPrefs = [
"delta_multiplier_x", "delta_multiplier_y", "delta_multiplier_z"
];
const kPrefValues = [
200, 50, 0, -50, -150
];
var currentTest, currentModifiers, currentEvent, currentPref, currentMultiplier, testingExpected;
var description;
var calledHandlers = { wheel: false,
DOMMouseScroll: { horizontal: false, vertical: false },
MozMousePixelScroll: { horizontal: false, vertical: false } };
function wheelEventHandler(aEvent) {
calledHandlers.wheel = true;
var expectedDeltaX = currentEvent.deltaX;
var expectedDeltaY = currentEvent.deltaY;
var expectedDeltaZ = currentEvent.deltaZ;
if (testingExpected) {
switch (currentPref.charAt(currentPref.length - 1)) {
case "x":
expectedDeltaX *= currentMultiplier;
break;
case "y":
expectedDeltaY *= currentMultiplier;
break;
case "z":
expectedDeltaZ *= currentMultiplier;
break;
}
}
is(aEvent.deltaX, expectedDeltaX, description + "deltaX (" + currentEvent.deltaX + ") was invaild");
is(aEvent.deltaY, expectedDeltaY, description + "deltaY (" + currentEvent.deltaY + ") was invaild");
is(aEvent.deltaZ, expectedDeltaZ, description + "deltaZ (" + currentEvent.deltaZ + ") was invaild");
}
function legacyEventHandler(aEvent) {
var isHorizontal = (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS);
var isScrollEvent = (aEvent.type == "DOMMouseScroll");
if (isScrollEvent) {
if (isHorizontal) {
calledHandlers.DOMMouseScroll.horizontal = true;
} else {
calledHandlers.DOMMouseScroll.vertical = true;
}
} else {
if (isHorizontal) {
calledHandlers.MozMousePixelScroll.horizontal = true;
} else {
calledHandlers.MozMousePixelScroll.vertical = true;
}
}
var eventName = (isHorizontal ? "Horizontal " : "Vertical ") + aEvent.type + " ";
var expectedDetail;
if (isScrollEvent) {
expectedDetail = isHorizontal ? currentEvent.lineOrPageDeltaX : currentEvent.lineOrPageDeltaY;
if (currentEvent.deltaMode == WheelEvent.DOM_DELTA_PAGE && expectedDetail) {
expectedDetail = ((expectedDetail > 0) ? UIEvent.SCROLL_PAGE_DOWN : UIEvent.SCROLL_PAGE_UP);
}
} else {
expectedDetail = isHorizontal ? currentEvent.deltaX : currentEvent.deltaY;
if (expectedDetail) {
if (currentEvent.deltaMode == WheelEvent.DOM_DELTA_LINE) {
expectedDetail *= gLineHeight;
} else if (currentEvent.deltaMode == WheelEvent.DOM_DELTA_PAGE) {
if (expectedDetail > 0) {
expectedDetail = (isHorizontal ? gPageWidth : gPageHeight);
} else {
expectedDetail = (isHorizontal ? -gPageWidth : -gPageHeight);
}
}
}
}
if (testingExpected) {
if ((isHorizontal && currentPref.charAt(currentPref.length - 1) == "x") ||
(!isHorizontal && currentPref.charAt(currentPref.length - 1) == "y")) {
// If it's a page scroll event, the detail value is UIEvent.SCROLL_PAGE_DOWN or
// UIEvent.SCROLL_PAGE_UP. If the delta value sign is reverted, we need to
// revert the expected detail value too. Otherwise, don't touch it.
if (isScrollEvent && currentEvent.deltaMode == WheelEvent.DOM_DELTA_PAGE) {
if (currentMultiplier < 0) {
expectedDetail = ((expectedDetail == UIEvent.SCROLL_PAGE_UP) ? UIEvent.SCROLL_PAGE_DOWN : UIEvent.SCROLL_PAGE_UP);
}
} else {
expectedDetail *= currentMultiplier;
expectedDetail = expectedDetail < 0 ? Math.ceil(expectedDetail) : Math.floor(expectedDetail);
}
}
}
is(aEvent.detail, expectedDetail, description + eventName + "detail was invalid");
aEvent.preventDefault();
}
window.addEventListener("wheel", wheelEventHandler, true);
window.addEventListener("DOMMouseScroll", legacyEventHandler, true);
window.addEventListener("MozMousePixelScroll", legacyEventHandler, true);
function dispatchEvent(aIsExpected) {
for (var i = 0; i < kEvents.length; i++) {
currentEvent = kEvents[i];
currentEvent.shiftKey = (currentModifiers & kModifierShift) != 0;
currentEvent.ctrlKey = (currentModifiers & kModifierControl) != 0;
currentEvent.altKey = (currentModifiers & kModifierAlt) != 0;
currentEvent.metaKey = (currentModifiers & kModifierMeta) != 0;
currentEvent.osKey = (currentModifiers & kModifierWin) != 0;
var modifierList = "";
if (currentEvent.shiftKey) {
modifierList += "Shift ";
}
if (currentEvent.ctrlKey) {
modifierList += "Control ";
}
if (currentEvent.altKey) {
modifierList += "Alt ";
}
if (currentEvent.metaKey) {
modifierList += "Meta ";
}
if (currentEvent.osKey) {
modifierList += "Win ";
}
for (var j = 0; j < kPrefValues.length; j++) {
currentMultiplier = kPrefValues[j] / 100;
if (currentMultiplier > -1.0 && currentMultiplier < 1.0) {
currentMultiplier = currentMultiplier < 0 ? -1.0 : 1.0;
}
for (var k = 0; k < kDeltaMultiplierPrefs.length; k++) {
currentPref = "mousewheel." + currentTest.name + "." + kDeltaMultiplierPrefs[k];
SpecialPowers.setIntPref(currentPref, kPrefValues[j]);
gScrollableElement.scrollTop = gScrollableElement.scrollBottom = 1000;
// trusted event's delta valuses should be reverted by the pref.
testingExpected = aIsExpected;
description = "testDeltaMultiplierPrefs, pref: " + currentPref + "=" + kPrefValues[j] +
", deltaMode: " + currentEvent.deltaMode + ", modifiers: \"" + modifierList + "\", (trusted event): ";
synthesizeWheel(gScrollableElement, 10, 10, currentEvent);
ok(calledHandlers.wheel, description + "wheel event was not fired");
ok(calledHandlers.DOMMouseScroll.horizontal,
description + "Horizontal DOMMouseScroll event was not fired");
ok(calledHandlers.DOMMouseScroll.vertical,
description + "Vertical DOMMouseScroll event was not fired");
ok(calledHandlers.MozMousePixelScroll.horizontal,
description + "Horizontal MozMousePixelScroll event was not fired");
ok(calledHandlers.MozMousePixelScroll.vertical,
description + "Vertical MozMousePixelScroll event was not fired");
calledHandlers = { wheel: false,
DOMMouseScroll: { horizontal: false, vertical: false },
MozMousePixelScroll: { horizontal: false, vertical: false } };
// untrusted event's delta values shouldn't be reverted by the pref.
testingExpected = false;
var props = {
bubbles: true,
cancelable: true,
shiftKey: currentEvent.shiftKey,
ctrlKey: currentEvent.ctrlKey,
altKey: currentEvent.altKey,
metaKey: currentEvent.metaKey,
deltaX: currentEvent.deltaX,
deltaY: currentEvent.deltaY,
deltaZ: currentEvent.deltaZ,
deltaMode: currentEvent.deltaMode,
};
var untrustedEvent = new WheelEvent("wheel", props);
description = "testDeltaMultiplierPrefs, pref: " + currentPref + "=" + kPrefValues[j] +
", deltaMode: " + currentEvent.deltaMode + ", modifiers: \"" + modifierList + "\", (untrusted event): ";
gScrollableElement.dispatchEvent(untrustedEvent);
ok(calledHandlers.wheel, description + "wheel event was not fired for untrusted event");
ok(!calledHandlers.DOMMouseScroll.horizontal,
description + "Horizontal DOMMouseScroll event was fired for untrusted event");
ok(!calledHandlers.DOMMouseScroll.vertical,
description + "Vertical DOMMouseScroll event was fired for untrusted event");
ok(!calledHandlers.MozMousePixelScroll.horizontal,
description + "Horizontal MozMousePixelScroll event was fired for untrusted event");
ok(!calledHandlers.MozMousePixelScroll.vertical,
description + "Vertical MozMousePixelScroll event was fired for untrusted event");
SpecialPowers.setIntPref(currentPref, 100);
calledHandlers = { wheel: false,
DOMMouseScroll: { horizontal: false, vertical: false },
MozMousePixelScroll: { horizontal: false, vertical: false } };
}
// We should skip other value tests if testing with modifier key.
// If we didn't do so, it would test too many times, but we don't need to do so.
if (kTests.name != "default") {
break;
}
}
}
}
for (var i = 0; i < kTests.length; i++) {
currentTest = kTests[i];
for (var j = 0; j < currentTest.expected.length; j++) {
currentModifiers = currentTest.expected[j];
dispatchEvent(true);
}
for (var k = 0; k < currentTest.unexpected.length; k++) {
currentModifiers = currentTest.unexpected[k];
dispatchEvent(false);
}
}
window.removeEventListener("wheel", wheelEventHandler, true);
window.removeEventListener("DOMMouseScroll", legacyEventHandler, true);
window.removeEventListener("MozMousePixelScroll", legacyEventHandler, true);
}
// Untrusted wheel events shouldn't cause legacy mouse scroll events.
function testDispatchingUntrustEvent()
{
var descriptionBase = "testDispatchingUntrustEvent, ";
var description, wheelEventFired;
function wheelEventHandler(aEvent)
{
wheelEventFired = true;
}
function legacyEventHandler(aEvent)
{
ok(false, aEvent.type + " must not be fired");
}
window.addEventListener("wheel", wheelEventHandler, true);
window.addEventListener("DOMMouseScroll", legacyEventHandler, true);
window.addEventListener("MozMousePixelScroll", legacyEventHandler, true);
description = descriptionBase + "dispatching a pixel wheel event: ";
wheelEventFired = false;
var untrustedPixelEvent = new WheelEvent("wheel", {
bubbles: true, cancelable: true,
deltaX: 24.0, deltaY: 24.0,
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
});
gScrolledElement.dispatchEvent(untrustedPixelEvent);
ok(wheelEventFired, description + "wheel event wasn't fired");
description = descriptionBase + "dispatching a line wheel event: ";
wheelEventFired = false;
var untrustedLineEvent = new WheelEvent("wheel", {
bubbles: true, cancelable: true,
deltaX: 3.0, deltaY: 3.0,
deltaMode: WheelEvent.DOM_DELTA_LINE,
});
gScrolledElement.dispatchEvent(untrustedLineEvent);
ok(wheelEventFired, description + "wheel event wasn't fired");
description = descriptionBase + "dispatching a page wheel event: ";
wheelEventFired = false;
var untrustedPageEvent = new WheelEvent("wheel", {
bubbles: true, cancelable: true,
deltaX: 1.0, deltaY: 1.0,
deltaMode: WheelEvent.DOM_DELTA_PAGE,
});
gScrolledElement.dispatchEvent(untrustedPageEvent);
ok(wheelEventFired, description + "wheel event wasn't fired");
window.removeEventListener("wheel", wheelEventHandler, true);
window.removeEventListener("DOMMouseScroll", legacyEventHandler, true);
window.removeEventListener("MozMousePixelScroll", legacyEventHandler, true);
}
function testEventOrder()
{
const kWheelEvent = 0x0001;
const kDOMMouseScrollEvent = 0x0002;
const kMozMousePixelScrollEvent = 0x0004;
const kVerticalScrollEvent = 0x0010;
const kHorizontalScrollEvent = 0x0020;
const kInSystemGroup = 0x0100;
const kDefaultPrevented = 0x1000;
var currentTest;
const kTests = [
{
description: "Testing the order of the events without preventDefault()",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup],
resultEvents: [],
doPreventDefaultAt: 0,
},
{
description: "Testing the order of the events, calling preventDefault() at default group wheel event",
expectedEvents: [ kWheelEvent,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kWheelEvent,
},
{
description: "Testing the order of the events, calling preventDefault() at default group DOMMouseScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kDefaultPrevented,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kDOMMouseScrollEvent | kVerticalScrollEvent,
},
{
description: "Testing the order of the events, calling preventDefault() at default group MozMousePixelScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kMozMousePixelScrollEvent | kVerticalScrollEvent,
},
{
description: "Testing the order of the events, calling preventDefault() at system group DOMMouseScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kDefaultPrevented,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
},
{
description: "Testing the order of the events, calling preventDefault() at system group MozMousePixelScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup,
},
];
function getEventDescription(aEvent)
{
var result = "";
if (aEvent & kWheelEvent) {
result = "wheel"
} else {
if (aEvent & kDOMMouseScrollEvent) {
result = "DOMMouseScroll";
} else if (aEvent & kMozMousePixelScrollEvent) {
result = "MozMousePixelScroll";
}
if (aEvent & kVerticalScrollEvent) {
result += ", vertical";
} else {
result += ", horizontal";
}
}
if (aEvent & kInSystemGroup) {
result += ", system group";
}
if (aEvent & kDefaultPrevented) {
result += ", defaultPrevented";
}
return result;
}
function pushEvent(aEvent, aIsSystemGroup)
{
var event = 0;
if (aEvent.type == "wheel") {
event = kWheelEvent;
} else {
if (aEvent.type == "DOMMouseScroll") {
event = kDOMMouseScrollEvent;
} else if (aEvent.type == "MozMousePixelScroll") {
event = kMozMousePixelScrollEvent;
}
if (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS) {
event |= kHorizontalScrollEvent;
} else {
event |= kVerticalScrollEvent;
}
}
if (aIsSystemGroup) {
event |= kInSystemGroup;
}
if (aEvent.defaultPrevented) {
event |= kDefaultPrevented;
}
currentTest.resultEvents.push(event);
return event;
}
function handler(aEvent)
{
if (pushEvent(aEvent, false) == currentTest.doPreventDefaultAt) {
aEvent.preventDefault();
}
}
function systemHandler(aEvent)
{
if (pushEvent(aEvent, true) == currentTest.doPreventDefaultAt) {
aEvent.preventDefault();
}
}
window.addEventListener("wheel", handler, true);
window.addEventListener("DOMMouseScroll", handler, true);
window.addEventListener("MozMousePixelScroll", handler, true);
SpecialPowers.addSystemEventListener(window, "wheel", systemHandler, true);
SpecialPowers.addSystemEventListener(window, "DOMMouseScroll", systemHandler, true);
SpecialPowers.addSystemEventListener(window, "MozMousePixelScroll", systemHandler, true);
for (var i = 0; i < kTests.length; i++) {
currentTest = kTests[i];
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_LINE, deltaX: 1.0, deltaY: 1.0 });
for (var j = 0; j < currentTest.expectedEvents.length; j++) {
if (currentTest.resultEvents.length == j) {
ok(false, currentTest.description + ": " +
getEventDescription(currentTest.expectedEvents[j]) + " wasn't fired");
break;
}
is(getEventDescription(currentTest.resultEvents[j]),
getEventDescription(currentTest.expectedEvents[j]),
currentTest.description + ": " + (j + 1) + "th event is mismatched");
}
if (currentTest.expectedEvents.length < currentTest.resultEvents.length) {
ok(false, currentTest.description + ": " +
getEventDescription(currentTest.resultEvents[currentTest.expectedEvents.length]) +
" was fired unexpectedly");
}
}
window.removeEventListener("wheel", handler, true);
window.removeEventListener("DOMMouseScroll", handler, true);
window.removeEventListener("MozMousePixelScroll", handler, true);
SpecialPowers.removeSystemEventListener(window, "wheel", systemHandler, true);
SpecialPowers.removeSystemEventListener(window, "DOMMouseScroll", systemHandler, true);
SpecialPowers.removeSystemEventListener(window, "MozMousePixelScroll", systemHandler, true);
}
function runTests()
{
SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_z", 100);
SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_x", 100);
SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_y", 100);
SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_z", 100);
SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_x", 100);
SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_y", 100);
SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_z", 100);
SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_x", 100);
SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_y", 100);
SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_z", 100);
SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_x", 100);
SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_y", 100);
SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_z", 100);
SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_x", 100);
SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_y", 100);
SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_z", 100);
prepareScrollUnits();
testMakingUntrustedEvent();
testDeltaMultiplierPrefs();
testDispatchingUntrustEvent();
testEventOrder();
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_z");
SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_y");
SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_z");
SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_y");
SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_z");
SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_y");
SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_z");
SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_y");
SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_z");
SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_y");
SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_z");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View File

@ -451,16 +451,16 @@ try {
} catch(exp) {
ex = true;
}
ok(ex, "First parameter is required!");
ok(ex, "MouseEvent: First parameter is required!");
ex = false;
e = new MouseEvent("hello");
ok(e.type, "hello", "Wrong event type!");
ok(!e.isTrusted, "Event shouldn't be trusted!");
ok(!e.bubbles, "Event shouldn't bubble!");
ok(!e.cancelable, "Event shouldn't be cancelable!");
ok(e.type, "hello", "MouseEvent: Wrong event type!");
ok(!e.isTrusted, "MouseEvent: Event shouldn't be trusted!");
ok(!e.bubbles, "MouseEvent: Event shouldn't bubble!");
ok(!e.cancelable, "MouseEvent: Event shouldn't be cancelable!");
document.dispatchEvent(e);
is(receivedEvent, e, "Wrong event!");
is(receivedEvent, e, "MouseEvent: Wrong event!");
var mouseEventProps =
[ { screenX: 0 },
@ -494,7 +494,7 @@ var testProps =
var defaultMouseEventValues = {};
for (var i = 0; i < mouseEventProps.length; ++i) {
for (prop in mouseEventProps[i]) {
ok(prop in e, "MouseEvent doesn't have property " + prop + "!");
ok(prop in e, "MouseEvent: MouseEvent doesn't have property " + prop + "!");
defaultMouseEventValues[prop] = mouseEventProps[i][prop];
}
}
@ -504,9 +504,86 @@ while (testProps.length) {
e = new MouseEvent("foo", p);
for (var def in defaultMouseEventValues) {
if (!(def in p)) {
is(e[def], defaultMouseEventValues[def], "Wrong default value for " + def + "!");
is(e[def], defaultMouseEventValues[def],
"MouseEvent: Wrong default value for " + def + "!");
} else {
is(e[def], p[def], "Wrong event init value for " + def + "!");
is(e[def], p[def], "MouseEvent: Wrong event init value for " + def + "!");
}
}
}
// WheelEvent
try {
e = new WheelEvent();
} catch(exp) {
ex = true;
}
ok(ex, "WheelEvent: First parameter is required!");
ex = false;
e = new WheelEvent("hello");
ok(e.type, "hello", "WheelEvent: Wrong event type!");
ok(!e.isTrusted, "WheelEvent: Event shouldn't be trusted!");
ok(!e.bubbles, "WheelEvent: Event shouldn't bubble!");
ok(!e.cancelable, "WheelEvent: Event shouldn't be cancelable!");
document.dispatchEvent(e);
is(receivedEvent, e, "WheelEvent: Wrong event!");
var wheelEventProps =
[ { screenX: 0 },
{ screenY: 0 },
{ clientX: 0 },
{ clientY: 0 },
{ ctrlKey: false },
{ shiftKey: false },
{ altKey: false },
{ metaKey: false },
{ button: 0 },
{ buttons: 0 },
{ relatedTarget: null },
{ deltaX: 0.0 },
{ deltaY: 0.0 },
{ deltaZ: 0.0 },
{ deltaMode: 0 }
];
var testWheelProps =
[
{ screenX: 1 },
{ screenY: 2 },
{ clientX: 3 },
{ clientY: 4 },
{ ctrlKey: true },
{ shiftKey: true },
{ altKey: true },
{ metaKey: true },
{ button: 5 },
{ buttons: 6 },
{ relatedTarget: window },
{ deltaX: 7.8 },
{ deltaY: 9.1 },
{ deltaZ: 2.3 },
{ deltaMode: 4 }
];
var defaultWheelEventValues = {};
for (var i = 0; i < wheelEventProps.length; ++i) {
for (prop in wheelEventProps[i]) {
ok(prop in e, "WheelEvent: WheelEvent doesn't have property " + prop + "!");
defaultWheelEventValues[prop] = wheelEventProps[i][prop];
}
}
while (testWheelProps.length) {
var p = testWheelProps.shift();
e = new WheelEvent("foo", p);
for (var def in defaultWheelEventValues) {
if (!(def in p)) {
is(e[def], defaultWheelEventValues[def],
"WheelEvent: Wrong default value for " + def + "!");
} else {
is(e[def], p[def], "WheelEvent: Wrong event init value for " + def + "!");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for default action of WheelEvent</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var subWin = window.open("window_wheel_default_action.html", "_blank",
"width=500,height=500,scrollbars=yes");
function finish()
{
subWin.close();
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -116,7 +116,8 @@ nsHTMLAudioElement::MozSetup(PRUint32 aChannels, PRUint32 aRate)
}
mAudioStream = nsAudioStream::AllocateStream();
nsresult rv = mAudioStream->Init(aChannels, aRate);
nsresult rv = mAudioStream->Init(aChannels, aRate,
nsAudioStream::FORMAT_FLOAT32);
if (NS_FAILED(rv)) {
mAudioStream->Shutdown();
mAudioStream = nullptr;

View File

@ -359,11 +359,12 @@ nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType,
aDataURL = NS_LITERAL_STRING("data:") + type +
NS_LITERAL_STRING(";base64,");
PRUint32 count;
PRUint64 count;
rv = stream->Available(&count);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(count <= PR_UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
return Base64EncodeInputStream(stream, aDataURL, count, aDataURL.Length());
return Base64EncodeInputStream(stream, aDataURL, (PRUint32)count, aDataURL.Length());
}
NS_IMETHODIMP
@ -398,17 +399,18 @@ nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
type.AssignLiteral("image/png");
}
PRUint32 imgSize;
PRUint64 imgSize;
rv = stream->Available(&imgSize);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(imgSize <= PR_UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
void* imgData = nullptr;
rv = NS_ReadInputStreamToBuffer(stream, &imgData, imgSize);
rv = NS_ReadInputStreamToBuffer(stream, &imgData, (PRUint32)imgSize);
NS_ENSURE_SUCCESS(rv, rv);
// The DOMFile takes ownership of the buffer
nsRefPtr<nsDOMMemoryFile> file =
new nsDOMMemoryFile(imgData, imgSize, aName, type);
new nsDOMMemoryFile(imgData, (PRUint32)imgSize, aName, type);
file.forget(aResult);
return NS_OK;

View File

@ -2204,7 +2204,7 @@ nsHTMLMediaElement::CanHandleMediaType(const char* aMIMEType,
}
#endif
#ifdef MOZ_MEDIA_PLUGINS
if (GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), aCodecList))
if (IsMediaPluginsEnabled() && GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), aCodecList))
return CANPLAY_MAYBE;
#endif
return CANPLAY_NO;
@ -2230,7 +2230,7 @@ bool nsHTMLMediaElement::ShouldHandleMediaType(const char* aMIMEType)
return true;
#endif
#ifdef MOZ_MEDIA_PLUGINS
if (GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), NULL))
if (IsMediaPluginsEnabled() && GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), NULL))
return true;
#endif
// We should not return true for Wave types, since there are some
@ -2346,7 +2346,7 @@ nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
}
#endif
#ifdef MOZ_MEDIA_PLUGINS
if (GetMediaPluginHost()->FindDecoder(aType, NULL)) {
if (IsMediaPluginsEnabled() && GetMediaPluginHost()->FindDecoder(aType, NULL)) {
nsRefPtr<nsMediaPluginDecoder> decoder = new nsMediaPluginDecoder(aType);
if (decoder->Init(this)) {
return decoder.forget();

View File

@ -61,7 +61,6 @@ var observers = os.enumerateObservers("invalidformsubmit");
*/
if (observers.hasMoreElements()) {
document.getElementById('av').addEventListener("invalid", function(aEvent) {
aEvent.target.removeAttribute("invalid", arguments.callee, false);
ok(true, "formnovalidate should not apply on if not set on the submit " +
@ -133,6 +132,8 @@ if (observers.hasMoreElements()) {
SimpleTest.waitForFocus(function() {
document.getElementById('a').click();
});
} else {
todo(false, "No 'invalidformsubmit' observers. Skip test.");
}
</script>

View File

@ -98,6 +98,8 @@ if (observers.hasMoreElements()) {
checkPseudoClass(textarea, false);
checkPseudoClass(input, false);
checkPseudoClass(select, false);
} else {
todo(false, "No 'invalidformsubmit' observers. Skip test.");
}
</script>

View File

@ -104,6 +104,8 @@ if (observers.hasMoreElements()) {
checkPseudoClass(textarea, false);
checkPseudoClass(input, false);
checkPseudoClass(select, false);
} else {
todo(false, "No 'invalidformsubmit' observers. Skip test.");
}
</script>

View File

@ -13,7 +13,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = content
LIBRARY_NAME = gkconhtmldoc_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS = 1
CPPSRCS = \
nsHTMLContentSink.cpp \

View File

@ -13,6 +13,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = content
LIBRARY_NAME = gkcontentmathml_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS = 1
CPPSRCS = \
nsMathMLElement.cpp \

View File

@ -1053,13 +1053,13 @@ nsresult FileMediaResource::Open(nsIStreamListener** aStreamListener)
return NS_ERROR_FAILURE;
}
// Get the file size and inform the decoder. Only files up to 4GB are
// supported here.
PRUint32 size;
// Get the file size and inform the decoder.
PRUint64 size;
rv = mInput->Available(&size);
if (NS_SUCCEEDED(rv)) {
mSize = size;
}
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(size <= PR_INT64_MAX, NS_ERROR_FILE_TOO_BIG);
mSize = (PRInt64)size;
nsCOMPtr<nsIRunnable> event = new LoadedEvent(mDecoder);
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);

View File

@ -1028,7 +1028,8 @@ MediaStreamGraphImpl::CreateOrDestroyAudioStream(GraphTime aAudioOutputStartTime
aStream->mAudioPlaybackStartTime = aAudioOutputStartTime;
aStream->mAudioOutput = nsAudioStream::AllocateStream();
aStream->mAudioOutput->Init(audio->GetChannels(),
track->GetRate());
track->GetRate(),
audio->GetFirstFrameFormat());
}
void

View File

@ -49,6 +49,14 @@ double VideoFrameContainer::GetFrameDelay()
void VideoFrameContainer::Invalidate()
{
NS_ASSERTION(NS_IsMainThread(), "Must call on main thread");
if (!mNeedInvalidation) {
return;
}
if (mImageContainer && mImageContainer->IsAsync()) {
mNeedInvalidation = false;
}
if (!mElement) {
// Element has been destroyed
return;

View File

@ -37,11 +37,13 @@ public:
already_AddRefed<ImageContainer> aContainer)
: mElement(aElement),
mImageContainer(aContainer), mMutex("nsVideoFrameContainer"),
mIntrinsicSizeChanged(false), mImageSizeChanged(false)
mIntrinsicSizeChanged(false), mImageSizeChanged(false),
mNeedInvalidation(true)
{
NS_ASSERTION(aElement, "aElement must not be null");
NS_ASSERTION(mImageContainer, "aContainer must not be null");
}
// Call on any thread
void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage,
TimeStamp aTargetTime);
@ -86,6 +88,8 @@ protected:
// frame is fully invalidated instead of just invalidating for the image change
// in the ImageLayer.
bool mImageSizeChanged;
bool mNeedInvalidation;
};
}

View File

@ -60,7 +60,7 @@ class nsNativeAudioStream : public nsAudioStream
~nsNativeAudioStream();
nsNativeAudioStream();
nsresult Init(PRInt32 aNumChannels, PRInt32 aRate);
nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat);
void Shutdown();
nsresult Write(const void* aBuf, PRUint32 aFrames);
PRUint32 Available();
@ -95,7 +95,7 @@ class nsRemotedAudioStream : public nsAudioStream
nsRemotedAudioStream();
~nsRemotedAudioStream();
nsresult Init(PRInt32 aNumChannels, PRInt32 aRate);
nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat);
void Shutdown();
nsresult Write(const void* aBuf, PRUint32 aFrames);
PRUint32 Available();
@ -422,11 +422,11 @@ nsNativeAudioStream::~nsNativeAudioStream()
NS_IMPL_THREADSAFE_ISUPPORTS0(nsNativeAudioStream)
nsresult nsNativeAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate)
nsresult nsNativeAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat)
{
mRate = aRate;
mChannels = aNumChannels;
mFormat = MOZ_AUDIO_DATA_FORMAT;
mFormat = aFormat;
if (sa_stream_create_pcm(reinterpret_cast<sa_stream_t**>(&mAudioHandle),
NULL,
@ -474,28 +474,53 @@ nsresult nsNativeAudioStream::Write(const void* aBuf, PRUint32 aFrames)
if (s_data) {
double scaled_volume = GetVolumeScale() * mVolume;
const SampleType* buf = static_cast<const SampleType*>(aBuf);
for (PRUint32 i = 0; i < samples; ++i) {
float scaled_value = floorf(0.5 + 32768 * buf[i] * scaled_volume);
if (buf[i] < 0.0) {
s_data[i] = (scaled_value < -32768.0) ?
-32768 :
short(scaled_value);
} else {
s_data[i] = (scaled_value > 32767.0) ?
32767 :
short(scaled_value);
switch (mFormat) {
case FORMAT_U8: {
const PRUint8* buf = static_cast<const PRUint8*>(aBuf);
PRInt32 volume = PRInt32((1 << 16) * scaled_volume);
for (PRUint32 i = 0; i < samples; ++i) {
s_data[i] = short(((PRInt32(buf[i]) - 128) * volume) >> 8);
}
break;
}
case FORMAT_S16_LE: {
const short* buf = static_cast<const short*>(aBuf);
PRInt32 volume = PRInt32((1 << 16) * scaled_volume);
for (PRUint32 i = 0; i < samples; ++i) {
short s = buf[i];
#if defined(IS_BIG_ENDIAN)
s = ((s & 0x00ff) << 8) | ((s & 0xff00) >> 8);
#endif
s_data[i] = short((PRInt32(s) * volume) >> 16);
}
break;
}
case FORMAT_FLOAT32: {
const float* buf = static_cast<const float*>(aBuf);
for (PRUint32 i = 0; i < samples; ++i) {
float scaled_value = floorf(0.5 + 32768 * buf[i] * scaled_volume);
if (buf[i] < 0.0) {
s_data[i] = (scaled_value < -32768.0) ?
-32768 :
short(scaled_value);
} else {
s_data[i] = (scaled_value > 32767.0) ?
32767 :
short(scaled_value);
}
}
break;
}
}
}
if (sa_stream_write(static_cast<sa_stream_t*>(mAudioHandle),
s_data.get(),
samples * sizeof(short)) != SA_SUCCESS)
{
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_write error"));
mInError = true;
return NS_ERROR_FAILURE;
if (sa_stream_write(static_cast<sa_stream_t*>(mAudioHandle),
s_data.get(),
samples * sizeof(short)) != SA_SUCCESS)
{
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_write error"));
mInError = true;
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
@ -619,12 +644,26 @@ NS_IMPL_THREADSAFE_ISUPPORTS0(nsRemotedAudioStream)
nsresult
nsRemotedAudioStream::Init(PRInt32 aNumChannels,
PRInt32 aRate)
PRInt32 aRate,
SampleFormat aFormat)
{
mRate = aRate;
mChannels = aNumChannels;
mFormat = MOZ_AUDIO_DATA_FORMAT;
mBytesPerFrame = sizeof(SampleType) * mChannels;
mFormat = aFormat;
switch (mFormat) {
case FORMAT_U8: {
mBytesPerFrame = sizeof(PRUint8) * mChannels;
break;
}
case FORMAT_S16_LE: {
mBytesPerFrame = sizeof(short) * mChannels;
break;
}
case FORMAT_FLOAT32: {
mBytesPerFrame = sizeof(float) * mChannels;
}
}
nsCOMPtr<nsIRunnable> event = new AudioInitEvent(this);
NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
@ -822,7 +861,7 @@ class nsBufferedAudioStream : public nsAudioStream
nsBufferedAudioStream();
~nsBufferedAudioStream();
nsresult Init(PRInt32 aNumChannels, PRInt32 aRate);
nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat);
void Shutdown();
nsresult Write(const void* aBuf, PRUint32 aFrames);
PRUint32 Available();
@ -924,7 +963,7 @@ nsBufferedAudioStream::~nsBufferedAudioStream()
NS_IMPL_THREADSAFE_ISUPPORTS0(nsBufferedAudioStream)
nsresult
nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate)
nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat)
{
cubeb* cubebContext = GetCubebContext();
@ -934,13 +973,23 @@ nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate)
mRate = aRate;
mChannels = aNumChannels;
mFormat = MOZ_AUDIO_DATA_FORMAT;
mFormat = aFormat;
cubeb_stream_params params;
params.rate = aRate;
params.channels = aNumChannels;
params.format = CUBEB_SAMPLE_FLOAT32NE;
mBytesPerFrame = sizeof(float) * aNumChannels;
switch (aFormat) {
case FORMAT_S16_LE:
params.format = CUBEB_SAMPLE_S16LE;
mBytesPerFrame = sizeof(short) * aNumChannels;
break;
case FORMAT_FLOAT32:
params.format = CUBEB_SAMPLE_FLOAT32NE;
mBytesPerFrame = sizeof(float) * aNumChannels;
break;
default:
return NS_ERROR_FAILURE;
}
{
cubeb_stream* stream;
@ -1172,10 +1221,29 @@ nsBufferedAudioStream::DataCallback(void* aBuffer, long aFrames)
output += input_size[i];
} else {
// Adjust volume as each sample is copied out.
const float* src = static_cast<const float*>(input[i]);
float* dst = reinterpret_cast<float*>(output);
for (PRUint32 j = 0; j < input_size[i] / (mBytesPerFrame / mChannels); ++j) {
dst[j] = src[j] * scaled_volume;
switch (mFormat) {
case FORMAT_S16_LE: {
PRInt32 volume = PRInt32(1 << 16) * scaled_volume;
const short* src = static_cast<const short*>(input[i]);
short* dst = reinterpret_cast<short*>(output);
for (PRUint32 j = 0; j < input_size[i] / (mBytesPerFrame / mChannels); ++j) {
dst[j] = short((PRInt32(src[j]) * volume) >> 16);
}
output += input_size[i];
break;
}
case FORMAT_FLOAT32: {
const float* src = static_cast<const float*>(input[i]);
float* dst = reinterpret_cast<float*>(output);
for (PRUint32 j = 0; j < input_size[i] / (mBytesPerFrame / mChannels); ++j) {
dst[j] = src[j] * scaled_volume;
}
output += input_size[i];
break;
}
default:
return -1;
}
}
}

View File

@ -11,14 +11,6 @@
#include "nsIThread.h"
#include "nsAutoPtr.h"
#ifndef MOZ_FLOATING_POINT_AUDIO
#define MOZ_AUDIO_DATA_FORMAT (nsAudioStream::FORMAT_S16_LE)
typedef short SampleType;
#else
#define MOZ_AUDIO_DATA_FORMAT (nsAudioStream::FORMAT_FLOAT32)
typedef float SampleType;
#endif
// Access to a single instance of this class must be synchronized by
// callers, or made from a single thread. One exception is that access to
// GetPosition, GetPositionInFrames, SetVolume, and Get{Rate,Channels,Format}
@ -36,7 +28,8 @@ public:
nsAudioStream()
: mRate(0),
mChannels(0)
mChannels(0),
mFormat(FORMAT_S16_LE)
{}
virtual ~nsAudioStream();
@ -63,7 +56,7 @@ public:
// (22050Hz, 44100Hz, etc).
// Unsafe to call with a monitor held due to synchronous event execution
// on the main thread, which may attempt to acquire any held monitor.
virtual nsresult Init(PRInt32 aNumChannels, PRInt32 aRate) = 0;
virtual nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat) = 0;
// Closes the stream. All future use of the stream is an error.
// Unsafe to call with a monitor held due to synchronous event execution
@ -113,7 +106,7 @@ public:
int GetRate() { return mRate; }
int GetChannels() { return mChannels; }
SampleFormat GetFormat() { return MOZ_AUDIO_DATA_FORMAT; }
SampleFormat GetFormat() { return mFormat; }
protected:
nsCOMPtr<nsIThread> mAudioPlaybackThread;

View File

@ -52,11 +52,12 @@ public:
bool mHasVideo;
};
#ifndef MOZ_FLOATING_POINT_AUDIO
#ifdef MOZ_TREMOR
#include <ogg/os_types.h>
typedef ogg_int32_t VorbisPCMValue;
typedef short AudioDataValue;
#define MOZ_AUDIO_DATA_FORMAT (nsAudioStream::FORMAT_S16_LE)
#define MOZ_CLIP_TO_15(x) ((x)<-32768?-32768:(x)<=32767?(x):32767)
// Convert the output of vorbis_synthesis_pcmout to a AudioDataValue
#define MOZ_CONVERT_VORBIS_SAMPLE(x) \
@ -65,11 +66,12 @@ typedef short AudioDataValue;
#define MOZ_CONVERT_AUDIO_SAMPLE(x) ((x)*(1.F/32768))
#define MOZ_SAMPLE_TYPE_S16LE 1
#else /* MOZ_FLOATING_POINT_AUDIO == 1*/
#else /*MOZ_VORBIS*/
typedef float VorbisPCMValue;
typedef float AudioDataValue;
#define MOZ_AUDIO_DATA_FORMAT (nsAudioStream::FORMAT_FLOAT32)
#define MOZ_CONVERT_VORBIS_SAMPLE(x) (x)
#define MOZ_CONVERT_AUDIO_SAMPLE(x) (x)
#define MOZ_SAMPLE_TYPE_FLOAT32 1

View File

@ -1008,7 +1008,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
// are unsafe to call with the decoder monitor held are documented as such
// in nsAudioStream.h.
nsRefPtr<nsAudioStream> audioStream = nsAudioStream::AllocateStream();
audioStream->Init(channels, rate);
audioStream->Init(channels, rate, MOZ_AUDIO_DATA_FORMAT);
{
// We must hold the monitor while setting mAudioStream or whenever we query

View File

@ -770,6 +770,7 @@ nsOpusState::nsOpusState(ogg_page* aBosPage) :
#endif
mChannelMapping(0),
mStreams(0),
mCoupledStreams(0),
mDecoder(NULL),
mSkip(0),
mPrevPacketGranulepos(0),
@ -783,7 +784,7 @@ nsOpusState::~nsOpusState() {
Reset();
if (mDecoder) {
opus_decoder_destroy(mDecoder);
opus_multistream_decoder_destroy(mDecoder);
mDecoder = NULL;
}
}
@ -799,7 +800,7 @@ nsresult nsOpusState::Reset(bool aStart)
if (mActive && mDecoder) {
// Reset the decoder.
opus_decoder_ctl(mDecoder, OPUS_RESET_STATE);
opus_multistream_decoder_ctl(mDecoder, OPUS_RESET_STATE);
// Let the seek logic handle pre-roll if we're not seeking to the start.
mSkip = aStart ? mPreSkip : 0;
// This lets us distinguish the first page being the last page vs. just
@ -827,7 +828,13 @@ bool nsOpusState::Init(void)
NS_ASSERTION(mDecoder == NULL, "leaking OpusDecoder");
mDecoder = opus_decoder_create(mRate, mChannels, &error);
mDecoder = opus_multistream_decoder_create(mRate,
mChannels,
mStreams,
mCoupledStreams,
mMappingTable,
&error);
mSkip = mPreSkip;
LOG(PR_LOG_DEBUG, ("Opus decoder init, to skip %d", mSkip));
@ -855,7 +862,17 @@ bool nsOpusState::DecodeHeader(ogg_packet* aPacket)
return false;
}
mChannels= aPacket->packet[9];
mChannels = aPacket->packet[9];
if (mChannels<1) {
LOG(PR_LOG_DEBUG, ("Invalid Opus file: Number of channels %d", mChannels));
return false;
}
#ifndef MOZ_SAMPLE_TYPE_FLOAT32
// Downmixing more than 2 channels it is not supported for integer
// output samples. It is only supported for float output.
if (mChannels>2)
return false;
#endif
mPreSkip = LEUint16(aPacket->packet + 10);
mNominalRate = LEUint32(aPacket->packet + 12);
double gain_dB = LEInt16(aPacket->packet + 16) / 256.0;
@ -869,8 +886,15 @@ bool nsOpusState::DecodeHeader(ogg_packet* aPacket)
if (mChannelMapping == 0) {
mStreams = 1;
} else if (aPacket->bytes > 19) {
mCoupledStreams = mChannels - 1;
mMappingTable[0] = 0;
mMappingTable[1] = 1;
} else if (aPacket->bytes>20+mChannels) {
mStreams = aPacket->packet[19];
mCoupledStreams = aPacket->packet[20];
int i;
for (i=0; i<mChannels; i++)
mMappingTable[i] = aPacket->packet[21+i];
} else {
LOG(PR_LOG_DEBUG, ("Invalid Opus file: channel mapping %d,"
" but no channel mapping table", mChannelMapping));

View File

@ -15,6 +15,9 @@
#endif
#ifdef MOZ_OPUS
#include <opus/opus.h>
extern "C" {
#include "opus/opus_multistream.h"
}
// For MOZ_SAMPLE_TYPE_*
#include "nsBuiltinDecoderStateMachine.h"
#include "nsBuiltinDecoderReader.h"
@ -326,8 +329,11 @@ public:
#endif
int mChannelMapping; // Channel mapping family.
int mStreams; // Number of packed streams in each packet.
int mCoupledStreams; // Number of packed coupled streams in each packet.
unsigned char mMappingTable[255]; // Channel mapping table.
OpusMSDecoder *mDecoder;
OpusDecoder *mDecoder;
int mSkip; // Number of samples left to trim before playback.
// Granule position (end sample) of the last decoded Opus packet. This is
// used to calculate the amount we should trim from the last packet.

View File

@ -11,6 +11,9 @@
#include "theora/theoradec.h"
#ifdef MOZ_OPUS
#include "opus/opus.h"
extern "C" {
#include "opus/opus_multistream.h"
}
#endif
#include "nsTimeRanges.h"
#include "mozilla/TimeStamp.h"
@ -321,7 +324,7 @@ nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo,
if (mOpusState && ReadHeaders(mOpusState)) {
mInfo.mHasAudio = true;
mInfo.mAudioRate = mOpusState->mRate;
mInfo.mAudioChannels = mOpusState->mChannels;
mInfo.mAudioChannels = mOpusState->mChannels > 2 ? 2 : mOpusState->mChannels;
mOpusSerial = mOpusState->mSerial;
mOpusPreSkip = mOpusState->mPreSkip;
}
@ -423,9 +426,12 @@ nsresult nsOggReader::DecodeOpus(ogg_packet* aPacket) {
NS_ASSERTION(aPacket->granulepos != -1, "Must know opus granulepos!");
// Maximum value is 63*2880.
PRInt32 frames = opus_decoder_get_nb_samples(mOpusState->mDecoder,
aPacket->packet,
aPacket->bytes);
PRInt32 frames_number = opus_packet_get_nb_frames(aPacket->packet,
aPacket->bytes);
PRInt32 samples = opus_packet_get_samples_per_frame(aPacket->packet,
(opus_int32) mOpusState->mRate);
PRInt32 frames = frames_number*samples;
if (frames <= 0)
return NS_ERROR_FAILURE;
PRUint32 channels = mOpusState->mChannels;
@ -433,13 +439,13 @@ nsresult nsOggReader::DecodeOpus(ogg_packet* aPacket) {
// Decode to the appropriate sample type.
#ifdef MOZ_SAMPLE_TYPE_FLOAT32
int ret = opus_decode_float(mOpusState->mDecoder,
aPacket->packet, aPacket->bytes,
buffer, frames, false);
int ret = opus_multistream_decode_float(mOpusState->mDecoder,
aPacket->packet, aPacket->bytes,
buffer, frames, false);
#else
int ret = opus_decode(mOpusState->mDecoder,
aPacket->packet, aPacket->bytes,
buffer, frames, false);
int ret = opus_multistream_decode(mOpusState->mDecoder,
aPacket->packet, aPacket->bytes,
buffer, frames, false);
#endif
if (ret < 0)
return NS_ERROR_FAILURE;
@ -504,6 +510,45 @@ nsresult nsOggReader::DecodeOpus(ogg_packet* aPacket) {
}
#endif
// More than 2 decoded channels must be downmixed to stereo.
if (channels > 2) {
// Opus doesn't provide a channel mapping for more than 8 channels,
// so we can't downmix more than that.
if (channels > 8)
return NS_ERROR_FAILURE;
#ifdef MOZ_SAMPLE_TYPE_FLOAT32
PRUint32 out_channels;
out_channels = 2;
// dBuffer stores the downmixed sample data.
nsAutoArrayPtr<AudioDataValue> dBuffer(new AudioDataValue[frames * out_channels]);
// Downmix matrix for channels up to 8, normalized to 2.0.
static const float dmatrix[6][8][2]= {
/*3*/{ {0.5858f,0}, {0.4142f,0.4142f}, {0,0.5858f}},
/*4*/{ {0.4226f,0}, {0,0.4226f}, {0.366f,0.2114f}, {0.2114f,0.366f}},
/*5*/{ {0.651f,0}, {0.46f,0.46f}, {0,0.651f}, {0.5636f,0.3254f}, {0.3254f,0.5636f}},
/*6*/{ {0.529f,0}, {0.3741f,0.3741f}, {0,0.529f}, {0.4582f,0.2645f}, {0.2645f,0.4582f}, {0.3741f,0.3741f}},
/*7*/{ {0.4553f,0}, {0.322f,0.322f}, {0,4553}, {0.3943f,0.2277f}, {0.2277f,0.3943f}, {0.2788f,0.2788f}, {0.322f,0.322f}},
/*8*/{ {0.3886f,0}, {0.2748f,0.2748f}, {0,0.3886f}, {0.3366f,0.1943f}, {0.1943f,0.3366f}, {0.3366f,0.1943f}, {0.1943f,0.3366f}, {0.2748f,0.2748f}},
};
for (PRInt32 i = 0; i < frames; i++) {
float sampL = 0.0;
float sampR = 0.0;
for (PRUint32 j = 0; j < channels; j++) {
sampL+=buffer[i*channels+j]*dmatrix[channels-3][j][0];
sampR+=buffer[i*channels+j]*dmatrix[channels-3][j][1];
}
dBuffer[i*out_channels]=sampL;
dBuffer[i*out_channels+1]=sampR;
}
channels = out_channels;
buffer = dBuffer;
#else
return NS_ERROR_FAILURE;
#endif
}
LOG(PR_LOG_DEBUG, ("Opus decoder pushing %d frames", frames));
PRInt64 startTime = mOpusState->Time(startFrame);
PRInt64 endTime = mOpusState->Time(endFrame);

View File

@ -73,7 +73,9 @@ void nsMediaPluginHost::TryLoad(const char *name)
nsMediaPluginHost::nsMediaPluginHost() {
MOZ_COUNT_CTOR(nsMediaPluginHost);
#ifdef ANDROID
#if defined(ANDROID) && !defined(MOZ_WIDGET_GONK)
TryLoad("lib/libomxplugin.so");
#elif defined(ANDROID) && defined(MOZ_WIDGET_GONK)
TryLoad("libomxplugin.so");
#endif
}

View File

@ -30,8 +30,6 @@ nsMediaPluginReader::~nsMediaPluginReader()
nsresult nsMediaPluginReader::Init(nsBuiltinDecoderReader* aCloneDonor)
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
return NS_OK;
}
@ -145,10 +143,15 @@ bool nsMediaPluginReader::DecodeVideoFrame(bool &aKeyframeSkip,
mVideoSeekTimeUs = -1;
if (aKeyframeSkip) {
// Disable keyframe skipping for now as
// stagefright doesn't seem to be telling us
// when a frame is a keyframe.
#if 0
if (!frame.mKeyFrame) {
++parsed;
continue;
}
#endif
aKeyframeSkip = false;
}

View File

@ -230,6 +230,11 @@ MOCHITEST_FILES += \
audio.wav \
$(NULL)
# Media plugin sample files
MOCHITEST_FILES += \
gizmo.mp4 \
$(NULL)
# Other files
MOCHITEST_FILES += \
bogus.duh \

Binary file not shown.

View File

@ -10,6 +10,7 @@ var gSmallTests = [
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 },
{ name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },
{ name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
{ name:"gizmo.mp4", type:"video/mp4", duration:5.0 },
{ name:"bogus.duh", type:"bogus/duh" }
];
@ -21,6 +22,7 @@ var gProgressTests = [
{ name:"seek.ogv", type:"video/ogg", duration:3.966, size:285310 },
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266, size:28942 },
{ name:"seek.webm", type:"video/webm", duration:3.966, size:215529 },
{ name:"gizmo.mp4", type:"video/mp4", duration:5.0, size:383631 },
{ name:"bogus.duh", type:"bogus/duh" }
];
@ -30,6 +32,7 @@ var gPlayedTests = [
{ name:"sound.ogg", type:"audio/ogg", duration:4.0 },
{ name:"seek.ogv", type:"video/ogg", duration:3.966 },
{ name:"seek.webm", type:"video/webm", duration:3.966 },
{ name:"gizmo.mp4", type:"video/mp4", duration:5.0 },
];
// Used by test_mozLoadFrom. Need one test file per decoder backend, plus
@ -147,6 +150,8 @@ var gPlayTests = [
// Opus data in an ogg container
{ name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
{ name:"gizmo.mp4", type:"video/mp4", duration:5.0 },
// Invalid file
{ name:"bogus.duh", type:"bogus/duh", duration:Number.NaN }
];

View File

@ -13,6 +13,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = content
LIBRARY_NAME = gkcontentsvg_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS = 1
CPPSRCS = \
DOMSVGAnimatedLengthList.cpp \

View File

@ -14,7 +14,6 @@ MODULE = content
LIBRARY_NAME = gkconxbl_s
LIBXUL_LIBRARY = 1
CPPSRCS = \
nsXBLBinding.cpp \
nsXBLPrototypeBinding.cpp \

View File

@ -151,6 +151,7 @@ NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
case NS_DRAG_EVENT:
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
*aResult = new nsXBLMouseEventHandler(aHandler);
break;

View File

@ -13,7 +13,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = content
LIBRARY_NAME = gkconxmlcon_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS = 1
CPPSRCS = \
nsXMLElement.cpp \

View File

@ -13,7 +13,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = content
LIBRARY_NAME = gkconxmldoc_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS = 1
CPPSRCS = \
nsXMLContentSink.cpp \

View File

@ -29,7 +29,6 @@ NS_IMPL_ISUPPORTS2(nsXMLPrettyPrinter,
nsIMutationObserver)
nsXMLPrettyPrinter::nsXMLPrettyPrinter() : mDocument(nullptr),
mUpdateDepth(0),
mUnhookPending(false)
{
}

View File

@ -49,7 +49,6 @@ private:
void MaybeUnhook(nsIContent* aContent);
nsIDocument* mDocument; //weak. Set as long as we're observing the document
PRUint32 mUpdateDepth;
bool mUnhookPending;
};

View File

@ -26,14 +26,12 @@
class nsXPathEvaluatorParseContext : public txIParseContext
{
public:
nsXPathEvaluatorParseContext(nsXPathEvaluator &aEvaluator,
nsIDOMXPathNSResolver* aResolver,
nsXPathEvaluatorParseContext(nsIDOMXPathNSResolver* aResolver,
nsTArray<PRInt32> *aNamespaceIDs,
nsTArray<nsCString> *aContractIDs,
nsCOMArray<nsISupports> *aState,
bool aIsCaseSensitive)
: mEvaluator(aEvaluator),
mResolver(aResolver),
: mResolver(aResolver),
mNamespaceIDs(aNamespaceIDs),
mContractIDs(aContractIDs),
mState(aState),
@ -57,7 +55,6 @@ public:
void SetErrorOffset(PRUint32 aOffset);
private:
nsXPathEvaluator &mEvaluator;
nsIDOMXPathNSResolver* mResolver;
nsTArray<PRInt32> *mNamespaceIDs;
nsTArray<nsCString> *mContractIDs;
@ -191,7 +188,7 @@ nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
}
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
nsXPathEvaluatorParseContext pContext(*this, aResolver, aNamespaceIDs,
nsXPathEvaluatorParseContext pContext(aResolver, aNamespaceIDs,
aContractIDs, aState,
!(doc && doc->IsHTML()));

View File

@ -99,9 +99,9 @@ public:
txXPCOMExtensionFunctionCall(nsISupports *aHelper, const nsIID &aIID,
PRUint16 aMethodIndex,
#ifdef TX_TO_STRING
PRInt32 aNamespaceID, nsIAtom *aName,
nsIAtom *aName,
#endif
nsISupports *aState);
nsISupports *aState);
TX_DECL_FUNCTION
@ -113,7 +113,6 @@ private:
nsIID mIID;
PRUint16 mMethodIndex;
#ifdef TX_TO_STRING
PRInt32 mNamespaceID;
nsCOMPtr<nsIAtom> mName;
#endif
nsCOMPtr<nsISupports> mState;
@ -123,7 +122,6 @@ txXPCOMExtensionFunctionCall::txXPCOMExtensionFunctionCall(nsISupports *aHelper,
const nsIID &aIID,
PRUint16 aMethodIndex,
#ifdef TX_TO_STRING
PRInt32 aNamespaceID,
nsIAtom *aName,
#endif
nsISupports *aState)
@ -131,7 +129,6 @@ txXPCOMExtensionFunctionCall::txXPCOMExtensionFunctionCall(nsISupports *aHelper,
mIID(aIID),
mMethodIndex(aMethodIndex),
#ifdef TX_TO_STRING
mNamespaceID(aNamespaceID),
mName(aName),
#endif
mState(aState)
@ -248,7 +245,7 @@ TX_ResolveFunctionCallXPCOM(const nsCString &aContractID, PRInt32 aNamespaceID,
*aFunction = new txXPCOMExtensionFunctionCall(helper, iid, methodIndex,
#ifdef TX_TO_STRING
aNamespaceID, aName,
aName,
#endif
aState);

View File

@ -859,9 +859,8 @@ txStylesheetCompilerState::resolveNamespacePrefix(nsIAtom* aPrefix,
class txErrorFunctionCall : public FunctionCall
{
public:
txErrorFunctionCall(nsIAtom* aName, const PRInt32 aID)
: mName(aName),
mID(aID)
txErrorFunctionCall(nsIAtom* aName)
: mName(aName)
{
}
@ -869,7 +868,6 @@ public:
private:
nsCOMPtr<nsIAtom> mName;
PRInt32 mID;
};
nsresult
@ -1092,7 +1090,7 @@ txStylesheetCompilerState::resolveFunctionCall(nsIAtom* aName, PRInt32 aID,
nsresult rv = findFunction(aName, aID, this, aFunction);
if (rv == NS_ERROR_XPATH_UNKNOWN_FUNCTION &&
(aID != kNameSpaceID_None || fcp())) {
*aFunction = new txErrorFunctionCall(aName, aID);
*aFunction = new txErrorFunctionCall(aName);
rv = *aFunction ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -12,6 +12,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = content
LIBRARY_NAME = gkcontentxtf_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS = 1
CPPSRCS = \
nsXMLContentBuilder.cpp \

View File

@ -7,6 +7,7 @@ DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FAIL_ON_WARNINGS = 1
include $(DEPTH)/config/autoconf.mk

View File

@ -646,8 +646,17 @@ nsXULPrototypeCache::BeginCaching(nsIURI* aURI)
rv = tmp;
}
}
if (NS_SUCCEEDED(rv))
rv = inputStream->Available(&len);
if (NS_SUCCEEDED(rv)) {
PRUint64 len64;
rv = inputStream->Available(&len64);
if (NS_SUCCEEDED(rv)) {
if (len64 <= PR_UINT32_MAX)
len = (PRUint32)len64;
else
rv = NS_ERROR_FILE_TOO_BIG;
}
}
if (NS_SUCCEEDED(rv)) {
buf = new char[len];

View File

@ -35,7 +35,7 @@
#
# ***** END LICENSE BLOCK *****
DEPTH = @DEPTH@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

View File

@ -35,7 +35,7 @@
#
# ***** END LICENSE BLOCK *****
DEPTH = @DEPTH@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

View File

@ -35,7 +35,7 @@
#
# ***** END LICENSE BLOCK *****
DEPTH = @DEPTH@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

View File

@ -8,6 +8,7 @@
#define LoadContext_h
#include "SerializedLoadContext.h"
#include "mozilla/Attributes.h"
namespace mozilla {
@ -21,7 +22,7 @@ namespace mozilla {
* it.
*/
class LoadContext : public nsILoadContext
class LoadContext MOZ_FINAL : public nsILoadContext
{
public:
NS_DECL_ISUPPORTS

View File

@ -54,6 +54,8 @@
#include "nsIDOMGlobalPropertyInitializer.h"
using namespace mozilla::dom::power;
// This should not be in the namespace.
DOMCI_DATA(Navigator, mozilla::dom::Navigator)
@ -1029,11 +1031,11 @@ Navigator::GetMozPower(nsIDOMMozPowerManager** aPower)
*aPower = nullptr;
if (!mPowerManager) {
nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(win, NS_OK);
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, NS_OK);
mPowerManager = new power::PowerManager();
mPowerManager->Init(win);
mPowerManager = PowerManager::CheckPermissionAndCreateInstance(window);
NS_ENSURE_TRUE(mPowerManager, NS_OK);
}
nsCOMPtr<nsIDOMMozPowerManager> power(mPowerManager);

View File

@ -199,6 +199,7 @@
#include "nsIDOMCompositionEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMMouseScrollEvent.h"
#include "nsIDOMWheelEvent.h"
#include "nsIDOMDragEvent.h"
#include "nsIDOMCommandEvent.h"
#include "nsIDOMPopupBlockedEvent.h"
@ -539,6 +540,7 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
#include "LockedFile.h"
#include "GeneratedEvents.h"
#include "mozilla/Likely.h"
#include "nsDebug.h"
#undef None // something included above defines this preprocessor symbol, maybe Xlib headers
#include "WebGLContext.h"
@ -814,6 +816,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MouseScrollEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(WheelEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DragEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(KeyboardEvent, nsDOMGenericSH,
@ -1749,6 +1753,7 @@ NS_DEFINE_CONTRACT_CTOR(MozActivity, NS_DOMACTIVITY_CONTRACTID)
NS_DEFINE_EVENT_CTOR(Event)
NS_DEFINE_EVENT_CTOR(UIEvent)
NS_DEFINE_EVENT_CTOR(MouseEvent)
NS_DEFINE_EVENT_CTOR(WheelEvent)
#ifdef MOZ_B2G_RIL
NS_DEFINE_EVENT_CTOR(MozWifiStatusChangeEvent)
NS_DEFINE_EVENT_CTOR(MozWifiConnectionInfoEvent)
@ -1787,6 +1792,7 @@ static const nsConstructorFuncMapData kConstructorFuncMap[] =
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(Event)
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(UIEvent)
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MouseEvent)
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(WheelEvent)
#ifdef MOZ_B2G_RIL
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MozWifiStatusChangeEvent)
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MozWifiConnectionInfoEvent)
@ -1821,6 +1827,7 @@ jsid nsDOMClassInfo::sParent_id = JSID_VOID;
jsid nsDOMClassInfo::sScrollbars_id = JSID_VOID;
jsid nsDOMClassInfo::sLocation_id = JSID_VOID;
jsid nsDOMClassInfo::sConstructor_id = JSID_VOID;
jsid nsDOMClassInfo::s_content_id = JSID_VOID;
jsid nsDOMClassInfo::sContent_id = JSID_VOID;
jsid nsDOMClassInfo::sMenubar_id = JSID_VOID;
jsid nsDOMClassInfo::sToolbar_id = JSID_VOID;
@ -2067,8 +2074,10 @@ SetParentToWindow(nsGlobalWindow *win, JSObject **parent)
if (MOZ_UNLIKELY(!*parent)) {
// The only known case where this can happen is when the inner window has
// been torn down. See bug 691178 comment 11.
MOZ_ASSERT(win->IsClosedOrClosing());
// been torn down. See bug 691178 comment 11. Should be a fatal MOZ_ASSERT,
// but we've found a way to hit it too often in mochitests. See bugs 777875
// 778424, 781078.
NS_ASSERTION(win->IsClosedOrClosing(), "win should be closed or closing");
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -2097,6 +2106,7 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars");
SET_JSID_TO_STRING(sLocation_id, cx, "location");
SET_JSID_TO_STRING(sConstructor_id, cx, "constructor");
SET_JSID_TO_STRING(s_content_id, cx, "_content");
SET_JSID_TO_STRING(sContent_id, cx, "content");
SET_JSID_TO_STRING(sMenubar_id, cx, "menubar");
SET_JSID_TO_STRING(sToolbar_id, cx, "toolbar");
@ -2657,6 +2667,12 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(WheelEvent, nsIDOMWheelEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWheelEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(DragEvent, nsIDOMDragEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDragEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
@ -5212,6 +5228,7 @@ nsDOMClassInfo::ShutDown()
sScrollbars_id = JSID_VOID;
sLocation_id = JSID_VOID;
sConstructor_id = JSID_VOID;
s_content_id = JSID_VOID;
sContent_id = JSID_VOID;
sMenubar_id = JSID_VOID;
sToolbar_id = JSID_VOID;
@ -6949,6 +6966,18 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
return rv;
}
// Native code for window._content getter, this simply maps
// window._content to window.content for backwards compatibility only.
static JSBool
ContentWindowGetter(JSContext *cx, unsigned argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
if (!obj)
return JS_FALSE;
return ::JS_GetProperty(cx, obj, "content", vp);
}
static JSNewResolveOp sOtherResolveFuncs[] = {
mozilla::dom::workers::ResolveWorkerClasses
};
@ -7280,6 +7309,36 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
}
}
if (s_content_id == id) {
// Map window._content to window.content for backwards
// compatibility, this should spit out an message on the JS
// console.
JSObject *windowObj = win->GetGlobalJSObject();
JSAutoRequest ar(cx);
JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
windowObj, "_content");
if (!fun) {
return NS_ERROR_OUT_OF_MEMORY;
}
JSObject *funObj = ::JS_GetFunctionObject(fun);
if (!::JS_DefinePropertyById(cx, windowObj, id, JSVAL_VOID,
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj),
nullptr,
JSPROP_ENUMERATE | JSPROP_GETTER |
JSPROP_SHARED)) {
return NS_ERROR_FAILURE;
}
*objp = obj;
return NS_OK;
}
if (flags & JSRESOLVE_ASSIGNING) {
if (IsReadonlyReplaceable(id) ||
(!(flags & JSRESOLVE_QUALIFIED) && IsWritableReplaceable(id))) {
@ -7936,9 +7995,14 @@ GetBindingURL(Element *aElement, nsIDocument *aDocument,
{
// If we have a frame the frame has already loaded the binding. And
// otherwise, don't do anything else here unless we're dealing with
// XUL.
// XUL or an HTML element that may have a plugin-related overlay
// (i.e. object, embed, or applet).
bool isXULorPluginElement = (aElement->IsXUL() ||
aElement->IsHTML(nsGkAtoms::object) ||
aElement->IsHTML(nsGkAtoms::embed) ||
aElement->IsHTML(nsGkAtoms::applet));
nsIPresShell *shell = aDocument->GetShell();
if (!shell || aElement->GetPrimaryFrame() || !aElement->IsXUL()) {
if (!shell || aElement->GetPrimaryFrame() || !isXULorPluginElement) {
*aResult = nullptr;
return true;
@ -9768,18 +9832,18 @@ nsHTMLPluginObjElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper,
// that can result from such a situation. We'll return NS_OK for the time
// being and hope for the best.
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "SetupProtoChain failed!");
return NS_OK;
}
else {
// This may be null if the JS context is not a DOM context. That's ok, we'll
// use the safe context from XPConnect in the runnable.
nsCOMPtr<nsIScriptContext> scriptContext = GetScriptContextFromJSContext(cx);
nsRefPtr<nsPluginProtoChainInstallRunner> runner =
new nsPluginProtoChainInstallRunner(wrapper, scriptContext);
nsContentUtils::AddScriptRunner(runner);
}
// This may be null if the JS context is not a DOM context. That's ok, we'll
// use the safe context from XPConnect in the runnable.
nsCOMPtr<nsIScriptContext> scriptContext = GetScriptContextFromJSContext(cx);
nsRefPtr<nsPluginProtoChainInstallRunner> runner =
new nsPluginProtoChainInstallRunner(wrapper, scriptContext);
nsContentUtils::AddScriptRunner(runner);
return NS_OK;
return nsElementSH::PostCreate(wrapper, cx, obj);
}
NS_IMETHODIMP

Some files were not shown because too many files have changed in this diff Show More