mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge m-c to fx-team
This commit is contained in:
commit
4f7348bd2f
@ -970,17 +970,50 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible,
|
||||
}
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::alt ||
|
||||
aAttribute == nsGkAtoms::title ||
|
||||
aAttribute == nsGkAtoms::aria_label ||
|
||||
aAttribute == nsGkAtoms::aria_labelledby) {
|
||||
// Fire name change and description change events. XXX: it's not complete and
|
||||
// dupes the code logic of accessible name and description calculation, we do
|
||||
// that for performance reasons.
|
||||
if (aAttribute == nsGkAtoms::aria_label) {
|
||||
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::aria_describedby) {
|
||||
FireDelayedEvent(nsIAccessibleEvent::EVENT_DESCRIPTION_CHANGE, aAccessible);
|
||||
return;
|
||||
}
|
||||
|
||||
nsIContent* elm = aAccessible->GetContent();
|
||||
if (aAttribute == nsGkAtoms::aria_labelledby &&
|
||||
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_label)) {
|
||||
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::alt &&
|
||||
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_label) &&
|
||||
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_labelledby)) {
|
||||
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::title) {
|
||||
if (!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_label) &&
|
||||
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_labelledby) &&
|
||||
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::alt)) {
|
||||
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_describedby))
|
||||
FireDelayedEvent(nsIAccessibleEvent::EVENT_DESCRIPTION_CHANGE, aAccessible);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::aria_busy) {
|
||||
bool isOn = aAccessible->GetContent()->
|
||||
AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true, eCaseMatters);
|
||||
bool isOn = elm->AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true,
|
||||
eCaseMatters);
|
||||
nsRefPtr<AccEvent> event =
|
||||
new AccStateChangeEvent(aAccessible, states::BUSY, isOn);
|
||||
FireDelayedEvent(event);
|
||||
@ -993,7 +1026,6 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible,
|
||||
Accessible* widget =
|
||||
nsAccUtils::GetSelectableContainer(aAccessible, aAccessible->State());
|
||||
if (widget) {
|
||||
nsIContent* elm = aAccessible->GetContent();
|
||||
AccSelChangeEvent::SelChangeType selChangeType =
|
||||
elm->AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true, eCaseMatters) ?
|
||||
AccSelChangeEvent::eSelectionAdd : AccSelChangeEvent::eSelectionRemove;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Constants
|
||||
|
||||
const EVENT_ALERT = nsIAccessibleEvent.EVENT_ALERT;
|
||||
const EVENT_DESCRIPTION_CHANGE = nsIAccessibleEvent.EVENT_DESCRIPTION_CHANGE;
|
||||
const EVENT_DOCUMENT_LOAD_COMPLETE = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE;
|
||||
const EVENT_DOCUMENT_RELOAD = nsIAccessibleEvent.EVENT_DOCUMENT_RELOAD;
|
||||
const EVENT_DOCUMENT_LOAD_STOPPED = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_STOPPED;
|
||||
|
@ -13,6 +13,7 @@ support-files =
|
||||
[test_caretmove.xul]
|
||||
[test_coalescence.html]
|
||||
[test_contextmenu.html]
|
||||
[test_descrchange.html]
|
||||
[test_docload.html]
|
||||
[test_docload.xul]
|
||||
[test_docload_aria.html]
|
||||
@ -41,7 +42,8 @@ skip-if = os == 'win' || os == 'linux'
|
||||
[test_menu.xul]
|
||||
[test_mutation.html]
|
||||
[test_mutation.xhtml]
|
||||
[test_name.xul]
|
||||
[test_namechange.xul]
|
||||
[test_namechange.html]
|
||||
[test_scroll.xul]
|
||||
[test_selection.html]
|
||||
[test_selection.xul]
|
||||
|
85
accessible/tests/mochitest/events/test_descrchange.html
Normal file
85
accessible/tests/mochitest/events/test_descrchange.html
Normal file
@ -0,0 +1,85 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Accessible description change event testing</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../events.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../states.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Invokers
|
||||
|
||||
function setAttr(aID, aAttr, aValue, aChecker)
|
||||
{
|
||||
this.eventSeq = [ aChecker ];
|
||||
this.invoke = function setAttr_invoke()
|
||||
{
|
||||
getNode(aID).setAttribute(aAttr, aValue);
|
||||
}
|
||||
|
||||
this.getID = function setAttr_getID()
|
||||
{
|
||||
return "set attr '" + aAttr + "', value '" + aValue + "'";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Do tests
|
||||
|
||||
//gA11yEventDumpToConsole = true; // debuggin
|
||||
|
||||
var gQueue = null;
|
||||
function doTests()
|
||||
{
|
||||
gQueue = new eventQueue();
|
||||
|
||||
gQueue.push(new setAttr("tst1", "aria-describedby", "display",
|
||||
new invokerChecker(EVENT_DESCRIPTION_CHANGE, "tst1")));
|
||||
gQueue.push(new setAttr("tst1", "title", "title",
|
||||
new unexpectedInvokerChecker(EVENT_DESCRIPTION_CHANGE, "tst1")));
|
||||
|
||||
gQueue.push(new setAttr("tst2", "title", "title",
|
||||
new invokerChecker(EVENT_NAME_CHANGE, "tst2")));
|
||||
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTests);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=991969"
|
||||
title="Event not fired when description changes">
|
||||
Bug 991969
|
||||
</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<button id="tst1">btn1</button>
|
||||
<button id="tst2">btn2</button>
|
||||
|
||||
<div id="eventdump"></div>
|
||||
</body>
|
||||
</html>
|
103
accessible/tests/mochitest/events/test_namechange.html
Normal file
103
accessible/tests/mochitest/events/test_namechange.html
Normal file
@ -0,0 +1,103 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Accessible name change event testing</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../events.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../states.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Invokers
|
||||
|
||||
function setAttr(aID, aAttr, aValue, aChecker)
|
||||
{
|
||||
this.eventSeq = [ aChecker ];
|
||||
this.invoke = function setAttr_invoke()
|
||||
{
|
||||
getNode(aID).setAttribute(aAttr, aValue);
|
||||
}
|
||||
|
||||
this.getID = function setAttr_getID()
|
||||
{
|
||||
return "set attr '" + aAttr + "', value '" + aValue + "'";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Do tests
|
||||
|
||||
//gA11yEventDumpToConsole = true; // debuggin
|
||||
|
||||
var gQueue = null;
|
||||
function doTests()
|
||||
{
|
||||
gQueue = new eventQueue();
|
||||
|
||||
gQueue.push(new setAttr("tst1", "aria-label", "hi",
|
||||
new invokerChecker(EVENT_NAME_CHANGE, "tst1")));
|
||||
gQueue.push(new setAttr("tst1", "aria-labelledby", "display",
|
||||
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst1")));
|
||||
gQueue.push(new setAttr("tst1", "alt", "alt",
|
||||
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst1")));
|
||||
gQueue.push(new setAttr("tst1", "title", "title",
|
||||
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst1")));
|
||||
|
||||
gQueue.push(new setAttr("tst2", "aria-labelledby", "display",
|
||||
new invokerChecker(EVENT_NAME_CHANGE, "tst2")));
|
||||
gQueue.push(new setAttr("tst2", "alt", "alt",
|
||||
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst2")));
|
||||
gQueue.push(new setAttr("tst2", "title", "title",
|
||||
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst2")));
|
||||
|
||||
gQueue.push(new setAttr("tst3", "alt", "alt",
|
||||
new invokerChecker(EVENT_NAME_CHANGE, "tst3")));
|
||||
gQueue.push(new setAttr("tst3", "title", "title",
|
||||
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst3")));
|
||||
|
||||
gQueue.push(new setAttr("tst4", "title", "title",
|
||||
new invokerChecker(EVENT_NAME_CHANGE, "tst4")));
|
||||
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTests);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=991969"
|
||||
title="Event not fired when description changes">
|
||||
Bug 991969
|
||||
</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<img id="tst1">
|
||||
<img id="tst2">
|
||||
<img id="tst3">
|
||||
<img id="tst4">
|
||||
|
||||
<div id="eventdump"></div>
|
||||
</body>
|
||||
</html>
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="55bcc2d7e44dc805c24b57d1e783fc26e8a2ee86"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d6c36d74ba9aefbc8c3618fc93dd4907a0dbf5e"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="52c909ccead537f8f9dbf634f3e6639078a8b0bd">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="55bcc2d7e44dc805c24b57d1e783fc26e8a2ee86"/>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d6c36d74ba9aefbc8c3618fc93dd4907a0dbf5e"/>
|
||||
|
@ -4,6 +4,6 @@
|
||||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "a71af1a665a6596324db3487ba73a1d83bf695f2",
|
||||
"revision": "baa54fb0f2c415a4521259d7fa2f14db32f608a7",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d6c36d74ba9aefbc8c3618fc93dd4907a0dbf5e"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f3abbd2d0a60f1a1618db93f8b1957cae6de379c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e046133c79d13d2ad26814547a163ec1732d36e7"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
@ -112,6 +112,7 @@ class GlobalObject;
|
||||
class NodeFilter;
|
||||
class NodeIterator;
|
||||
class ProcessingInstruction;
|
||||
class StyleSheetList;
|
||||
class Touch;
|
||||
class TouchList;
|
||||
class TreeWalker;
|
||||
@ -126,8 +127,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0xa7679e4a, 0xa5ec, 0x45bf, \
|
||||
{ 0x8f, 0xe4, 0xad, 0x4a, 0xb8, 0xc7, 0x7f, 0xc7 } }
|
||||
{ 0x906d05e7, 0x39af, 0x4ff0, \
|
||||
{ 0xbc, 0xcd, 0x30, 0x0c, 0x7f, 0xeb, 0x86, 0x21 } }
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||
@ -1335,6 +1336,13 @@ public:
|
||||
*/
|
||||
virtual void UnblockOnload(bool aFireSync) = 0;
|
||||
|
||||
void BlockDOMContentLoaded()
|
||||
{
|
||||
++mBlockDOMContentLoaded;
|
||||
}
|
||||
|
||||
virtual void UnblockDOMContentLoaded() = 0;
|
||||
|
||||
/**
|
||||
* Notification that the page has been shown, for documents which are loaded
|
||||
* into a DOM window. This corresponds to the completion of document load,
|
||||
@ -2169,7 +2177,7 @@ public:
|
||||
WarnOnceAbout(ePrefixedVisibilityAPI);
|
||||
return VisibilityState();
|
||||
}
|
||||
virtual nsIDOMStyleSheetList* StyleSheets() = 0;
|
||||
virtual mozilla::dom::StyleSheetList* StyleSheets() = 0;
|
||||
void GetSelectedStyleSheetSet(nsAString& aSheetSet);
|
||||
virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0;
|
||||
virtual void GetLastStyleSheetSet(nsString& aSheetSet) = 0;
|
||||
@ -2553,6 +2561,9 @@ protected:
|
||||
uint32_t mInSyncOperationCount;
|
||||
|
||||
nsRefPtr<mozilla::dom::XPathEvaluator> mXPathEvaluator;
|
||||
|
||||
uint32_t mBlockDOMContentLoaded;
|
||||
bool mDidFireDOMContentLoaded:1;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID)
|
||||
|
@ -484,7 +484,7 @@ ShadowRoot::SetApplyAuthorStyles(bool aApplyAuthorStyles)
|
||||
}
|
||||
}
|
||||
|
||||
nsIDOMStyleSheetList*
|
||||
StyleSheetList*
|
||||
ShadowRoot::StyleSheets()
|
||||
{
|
||||
if (!mStyleSheetList) {
|
||||
@ -655,16 +655,14 @@ ShadowRoot::ContentRemoved(nsIDocument* aDocument,
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_1(ShadowRootStyleSheetList, mShadowRoot)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(ShadowRootStyleSheetList, StyleSheetList,
|
||||
mShadowRoot)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(ShadowRootStyleSheetList)
|
||||
NS_INTERFACE_TABLE1(ShadowRootStyleSheetList, nsIDOMStyleSheetList)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(ShadowRootStyleSheetList)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StyleSheetList)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ShadowRootStyleSheetList)
|
||||
NS_INTERFACE_MAP_END_INHERITING(StyleSheetList)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ShadowRootStyleSheetList)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(ShadowRootStyleSheetList)
|
||||
NS_IMPL_ADDREF_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
||||
NS_IMPL_RELEASE_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
||||
|
||||
ShadowRootStyleSheetList::ShadowRootStyleSheetList(ShadowRoot* aShadowRoot)
|
||||
: mShadowRoot(aShadowRoot)
|
||||
@ -677,33 +675,31 @@ ShadowRootStyleSheetList::~ShadowRootStyleSheetList()
|
||||
MOZ_COUNT_DTOR(ShadowRootStyleSheetList);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ShadowRootStyleSheetList::Item(uint32_t aIndex, nsIDOMStyleSheet** aReturn)
|
||||
nsCSSStyleSheet*
|
||||
ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
nsTArray<nsRefPtr<nsCSSStyleSheet>>* sheets =
|
||||
mShadowRoot->mProtoBinding->GetStyleSheets();
|
||||
|
||||
if (!sheets) {
|
||||
aFound = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aFound = aIndex < sheets->Length();
|
||||
return sheets->SafeElementAt(aIndex);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ShadowRootStyleSheetList::Length()
|
||||
{
|
||||
nsTArray<nsRefPtr<nsCSSStyleSheet> >* sheets =
|
||||
mShadowRoot->mProtoBinding->GetStyleSheets();
|
||||
|
||||
if (sheets) {
|
||||
NS_IF_ADDREF(*aReturn = sheets->SafeElementAt(aIndex));
|
||||
} else {
|
||||
*aReturn = nullptr;
|
||||
if (!sheets) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ShadowRootStyleSheetList::GetLength(uint32_t* aLength)
|
||||
{
|
||||
nsTArray<nsRefPtr<nsCSSStyleSheet> >* sheets =
|
||||
mShadowRoot->mProtoBinding->GetStyleSheets();
|
||||
|
||||
if (sheets) {
|
||||
*aLength = sheets->Length();
|
||||
} else {
|
||||
*aLength = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return sheets->Length();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define mozilla_dom_shadowroot_h__
|
||||
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsTHashtable.h"
|
||||
@ -52,7 +53,7 @@ public:
|
||||
void RemoveSheet(nsCSSStyleSheet* aSheet);
|
||||
bool ApplyAuthorStyles();
|
||||
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
|
||||
nsIDOMStyleSheetList* StyleSheets();
|
||||
StyleSheetList* StyleSheets();
|
||||
HTMLShadowElement* GetShadowElement() { return mShadowElement; }
|
||||
|
||||
/**
|
||||
@ -169,17 +170,22 @@ protected:
|
||||
bool mInsertionPointChanged;
|
||||
};
|
||||
|
||||
class ShadowRootStyleSheetList : public nsIDOMStyleSheetList
|
||||
class ShadowRootStyleSheetList : public StyleSheetList
|
||||
{
|
||||
public:
|
||||
ShadowRootStyleSheetList(ShadowRoot* aShadowRoot);
|
||||
virtual ~ShadowRootStyleSheetList();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(ShadowRootStyleSheetList)
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
||||
|
||||
// nsIDOMStyleSheetList
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
virtual nsINode* GetParentObject() const MOZ_OVERRIDE
|
||||
{
|
||||
return mShadowRoot;
|
||||
}
|
||||
|
||||
virtual uint32_t Length() MOZ_OVERRIDE;
|
||||
virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
nsRefPtr<ShadowRoot> mShadowRoot;
|
||||
|
46
content/base/src/StyleSheetList.cpp
Normal file
46
content/base/src/StyleSheetList.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
|
||||
#include "mozilla/dom/StyleSheetListBinding.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheetList)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheetList)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheetList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(StyleSheetList)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(StyleSheetList)
|
||||
|
||||
/* virtual */ JSObject*
|
||||
StyleSheetList::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return StyleSheetListBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StyleSheetList::GetLength(uint32_t* aLength)
|
||||
{
|
||||
*aLength = Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StyleSheetList::SlowItem(uint32_t aIndex, nsIDOMStyleSheet** aItem)
|
||||
{
|
||||
NS_IF_ADDREF(*aItem = Item(aIndex));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
48
content/base/src/StyleSheetList.h
Normal file
48
content/base/src/StyleSheetList.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_StyleSheetList_h
|
||||
#define mozilla_dom_StyleSheetList_h
|
||||
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsCSSStyleSheet;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class StyleSheetList : public nsIDOMStyleSheetList
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
StyleSheetList()
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
virtual ~StyleSheetList() {}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheetList)
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE MOZ_FINAL;
|
||||
|
||||
virtual nsINode* GetParentObject() const = 0;
|
||||
|
||||
virtual uint32_t Length() = 0;
|
||||
virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
|
||||
nsCSSStyleSheet* Item(uint32_t aIndex)
|
||||
{
|
||||
bool dummy = false;
|
||||
return IndexedGetter(aIndex, dummy);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_StyleSheetList_h
|
@ -72,6 +72,7 @@ EXPORTS.mozilla.dom += [
|
||||
'Link.h',
|
||||
'NodeIterator.h',
|
||||
'ShadowRoot.h',
|
||||
'StyleSheetList.h',
|
||||
'Text.h',
|
||||
'TreeWalker.h',
|
||||
]
|
||||
@ -161,6 +162,7 @@ UNIFIED_SOURCES += [
|
||||
'nsXMLHttpRequest.cpp',
|
||||
'nsXMLNameSpaceMap.cpp',
|
||||
'ShadowRoot.cpp',
|
||||
'StyleSheetList.cpp',
|
||||
'Text.cpp',
|
||||
'ThirdPartyUtil.cpp',
|
||||
'TreeWalker.cpp',
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define nsAttrValue_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsStringBuffer.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCaseTreatment.h"
|
||||
|
@ -723,76 +723,48 @@ nsDOMStyleSheetList::~nsDOMStyleSheetList()
|
||||
}
|
||||
}
|
||||
|
||||
DOMCI_DATA(StyleSheetList, nsDOMStyleSheetList)
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsDOMStyleSheetList, StyleSheetList,
|
||||
nsIDocumentObserver,
|
||||
nsIMutationObserver)
|
||||
|
||||
// XXX couldn't we use the GetIIDs method from CSSStyleSheetList here?
|
||||
// QueryInterface implementation for nsDOMStyleSheetList
|
||||
NS_INTERFACE_TABLE_HEAD(nsDOMStyleSheetList)
|
||||
NS_INTERFACE_TABLE3(nsDOMStyleSheetList,
|
||||
nsIDOMStyleSheetList,
|
||||
nsIDocumentObserver,
|
||||
nsIMutationObserver)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StyleSheetList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMStyleSheetList)
|
||||
NS_IMPL_RELEASE(nsDOMStyleSheetList)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetList::GetLength(uint32_t* aLength)
|
||||
uint32_t
|
||||
nsDOMStyleSheetList::Length()
|
||||
{
|
||||
if (mDocument) {
|
||||
// XXX Find the number and then cache it. We'll use the
|
||||
// observer notification to figure out if new ones have
|
||||
// been added or removed.
|
||||
if (-1 == mLength) {
|
||||
mLength = mDocument->GetNumberOfStyleSheets();
|
||||
if (!mDocument) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// XXX Find the number and then cache it. We'll use the
|
||||
// observer notification to figure out if new ones have
|
||||
// been added or removed.
|
||||
if (-1 == mLength) {
|
||||
mLength = mDocument->GetNumberOfStyleSheets();
|
||||
|
||||
#ifdef DEBUG
|
||||
int32_t i;
|
||||
for (i = 0; i < mLength; i++) {
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
|
||||
NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
|
||||
}
|
||||
#endif
|
||||
int32_t i;
|
||||
for (i = 0; i < mLength; i++) {
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
|
||||
NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
|
||||
}
|
||||
*aLength = mLength;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
*aLength = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return mLength;
|
||||
}
|
||||
|
||||
nsIStyleSheet*
|
||||
nsDOMStyleSheetList::GetItemAt(uint32_t aIndex)
|
||||
nsCSSStyleSheet*
|
||||
nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
if (!mDocument || aIndex >= (uint32_t)mDocument->GetNumberOfStyleSheets()) {
|
||||
aFound = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aFound = true;
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
NS_ASSERTION(sheet, "Must have a sheet");
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetList::Item(uint32_t aIndex, nsIDOMStyleSheet** aReturn)
|
||||
{
|
||||
nsIStyleSheet *sheet = GetItemAt(aIndex);
|
||||
if (!sheet) {
|
||||
*aReturn = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(sheet, aReturn);
|
||||
return static_cast<nsCSSStyleSheet*>(sheet);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1555,7 +1527,8 @@ nsIDocument::nsIDocument()
|
||||
mAllowDNSPrefetch(true),
|
||||
mIsBeingUsedAsImage(false),
|
||||
mHasLinksToUpdate(false),
|
||||
mPartID(0)
|
||||
mPartID(0),
|
||||
mDidFireDOMContentLoaded(true)
|
||||
{
|
||||
SetInDocument();
|
||||
}
|
||||
@ -4707,6 +4680,8 @@ nsDocument::BeginLoad()
|
||||
// Block onload here to prevent having to deal with blocking and
|
||||
// unblocking it while we know the document is loading.
|
||||
BlockOnload();
|
||||
mDidFireDOMContentLoaded = false;
|
||||
BlockDOMContentLoaded();
|
||||
|
||||
if (mScriptLoader) {
|
||||
mScriptLoader->BeginDeferringScripts();
|
||||
@ -4948,6 +4923,19 @@ nsDocument::EndLoad()
|
||||
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(EndLoad, (this));
|
||||
|
||||
UnblockDOMContentLoaded();
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::UnblockDOMContentLoaded()
|
||||
{
|
||||
MOZ_ASSERT(mBlockDOMContentLoaded);
|
||||
if (--mBlockDOMContentLoaded != 0 || mDidFireDOMContentLoaded) {
|
||||
return;
|
||||
}
|
||||
mDidFireDOMContentLoaded = true;
|
||||
|
||||
MOZ_ASSERT(mReadyState == READYSTATE_INTERACTIVE);
|
||||
if (!mSynchronousDOMContentLoaded) {
|
||||
nsRefPtr<nsIRunnable> ev =
|
||||
NS_NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents);
|
||||
@ -6092,7 +6080,7 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetList** aStyleSheets)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMStyleSheetList*
|
||||
StyleSheetList*
|
||||
nsDocument::StyleSheets()
|
||||
{
|
||||
if (!mDOMStyleSheets) {
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "nsIDOMXMLDocument.h"
|
||||
#include "nsIDOMDocumentXBL.h"
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPrincipal.h"
|
||||
@ -65,6 +64,7 @@
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/DOMImplementation.h"
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
#include "nsIDOMTouchEvent.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
@ -78,7 +78,6 @@
|
||||
#define XML_DECLARATION_BITS_STANDALONE_YES (1 << 3)
|
||||
|
||||
|
||||
class nsDOMStyleSheetList;
|
||||
class nsDOMStyleSheetSetList;
|
||||
class nsIOutputStream;
|
||||
class nsDocument;
|
||||
@ -436,16 +435,14 @@ public:
|
||||
nsDocHeaderData* mNext;
|
||||
};
|
||||
|
||||
class nsDOMStyleSheetList : public nsIDOMStyleSheetList,
|
||||
class nsDOMStyleSheetList : public mozilla::dom::StyleSheetList,
|
||||
public nsStubDocumentObserver
|
||||
{
|
||||
public:
|
||||
nsDOMStyleSheetList(nsIDocument *aDocument);
|
||||
virtual ~nsDOMStyleSheetList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED
|
||||
@ -454,7 +451,13 @@ public:
|
||||
// nsIMutationObserver
|
||||
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
||||
|
||||
nsIStyleSheet* GetItemAt(uint32_t aIndex);
|
||||
virtual nsINode* GetParentObject() const MOZ_OVERRIDE
|
||||
{
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
virtual uint32_t Length() MOZ_OVERRIDE;
|
||||
virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
int32_t mLength;
|
||||
@ -1225,7 +1228,7 @@ public:
|
||||
RegisterElement(JSContext* aCx, const nsAString& aName,
|
||||
const mozilla::dom::ElementRegistrationOptions& aOptions,
|
||||
mozilla::ErrorResult& rv) MOZ_OVERRIDE;
|
||||
virtual nsIDOMStyleSheetList* StyleSheets() MOZ_OVERRIDE;
|
||||
virtual mozilla::dom::StyleSheetList* StyleSheets() MOZ_OVERRIDE;
|
||||
virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
|
||||
virtual void GetLastStyleSheetSet(nsString& aSheetSet) MOZ_OVERRIDE;
|
||||
virtual mozilla::dom::DOMStringList* StyleSheetSets() MOZ_OVERRIDE;
|
||||
@ -1241,6 +1244,8 @@ public:
|
||||
mozilla::ErrorResult& rv) MOZ_OVERRIDE;
|
||||
virtual void UseRegistryFromDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
|
||||
|
||||
virtual void UnblockDOMContentLoaded() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
friend class nsNodeUtils;
|
||||
friend class nsDocumentOnStack;
|
||||
@ -1430,7 +1435,7 @@ public:
|
||||
nsRefPtr<mozilla::dom::Registry> mRegistry;
|
||||
|
||||
nsRefPtr<mozilla::EventListenerManager> mListenerManager;
|
||||
nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
|
||||
nsRefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
|
||||
nsRefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
|
||||
nsRefPtr<nsScriptLoader> mScriptLoader;
|
||||
nsDocHeaderData* mHeaderData;
|
||||
|
@ -94,13 +94,14 @@ class BlobURLsReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < maxFrames && frame; ++i) {
|
||||
nsCString fileName;
|
||||
nsString fileNameUTF16;
|
||||
int32_t lineNumber = 0;
|
||||
|
||||
frame->GetFilename(fileName);
|
||||
frame->GetFilename(fileNameUTF16);
|
||||
frame->GetLineNumber(&lineNumber);
|
||||
|
||||
if (!fileName.IsEmpty()) {
|
||||
if (!fileNameUTF16.IsEmpty()) {
|
||||
NS_ConvertUTF16toUTF8 fileName(fileNameUTF16);
|
||||
stack += "js(";
|
||||
if (!origin.IsEmpty()) {
|
||||
// Make the file name root-relative for conciseness if possible.
|
||||
|
@ -233,21 +233,6 @@ private:
|
||||
*/
|
||||
void UpdateImageState(bool aNotify);
|
||||
|
||||
/**
|
||||
* CancelImageRequests can be called when we want to cancel the
|
||||
* image requests, generally due to our src changing and us wanting
|
||||
* to start a new load. The "current" request will be canceled only
|
||||
* if it has not progressed far enough to know the image size yet
|
||||
* unless aEvenIfSizeAvailable is true.
|
||||
*
|
||||
* @param aReason the reason the requests are being canceled
|
||||
* @param aEvenIfSizeAvailable cancels the current load even if its size is
|
||||
* available
|
||||
* @param aNewImageStatus the nsIContentPolicy status of the new image load
|
||||
*/
|
||||
void CancelImageRequests(nsresult aReason, bool aEvenIfSizeAvailable,
|
||||
int16_t aNewImageStatus);
|
||||
|
||||
/**
|
||||
* Method to fire an event once we know what's going on with the image load.
|
||||
*
|
||||
|
@ -124,7 +124,8 @@ nsScriptLoader::nsScriptLoader(nsIDocument *aDocument)
|
||||
mBlockerCount(0),
|
||||
mEnabled(true),
|
||||
mDeferEnabled(false),
|
||||
mDocumentParsingDone(false)
|
||||
mDocumentParsingDone(false),
|
||||
mBlockingDOMContentLoaded(false)
|
||||
{
|
||||
// enable logging for CSP
|
||||
#ifdef PR_LOGGING
|
||||
@ -656,7 +657,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
||||
NS_ASSERTION(mDocument->GetCurrentContentSink() ||
|
||||
aElement->GetParserCreated() == FROM_PARSER_XSLT,
|
||||
"Non-XSLT Defer script on a document without an active parser; bug 592366.");
|
||||
mDeferRequests.AppendElement(request);
|
||||
AddDeferRequest(request);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1171,6 +1172,9 @@ nsScriptLoader::ProcessPendingRequests()
|
||||
!mParserBlockingRequest && mAsyncRequests.IsEmpty() &&
|
||||
mNonAsyncExternalScriptInsertedRequests.IsEmpty() &&
|
||||
mXSLTRequests.IsEmpty() && mDeferRequests.IsEmpty()) {
|
||||
if (MaybeRemovedDeferRequests()) {
|
||||
return ProcessPendingRequests();
|
||||
}
|
||||
// No more pending scripts; time to unblock onload.
|
||||
// OK to unblock onload synchronously here, since callers must be
|
||||
// prepared for the world changing anyway.
|
||||
@ -1488,3 +1492,27 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
|
||||
pi->mRequest = request;
|
||||
pi->mCharset = aCharset;
|
||||
}
|
||||
|
||||
void
|
||||
nsScriptLoader::AddDeferRequest(nsScriptLoadRequest* aRequest)
|
||||
{
|
||||
mDeferRequests.AppendElement(aRequest);
|
||||
if (mDeferEnabled && mDeferRequests.Length() == 1 && mDocument &&
|
||||
!mBlockingDOMContentLoaded) {
|
||||
MOZ_ASSERT(mDocument->GetReadyStateEnum() == nsIDocument::READYSTATE_LOADING);
|
||||
mBlockingDOMContentLoaded = true;
|
||||
mDocument->BlockDOMContentLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsScriptLoader::MaybeRemovedDeferRequests()
|
||||
{
|
||||
if (mDeferRequests.Length() == 0 && mDocument &&
|
||||
mBlockingDOMContentLoaded) {
|
||||
mBlockingDOMContentLoaded = false;
|
||||
mDocument->UnblockDOMContentLoaded();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -291,6 +291,9 @@ private:
|
||||
uint32_t aStringLen,
|
||||
const uint8_t* aString);
|
||||
|
||||
void AddDeferRequest(nsScriptLoadRequest* aRequest);
|
||||
bool MaybeRemovedDeferRequests();
|
||||
|
||||
nsIDocument* mDocument; // [WEAK]
|
||||
nsCOMArray<nsIScriptLoaderObserver> mObservers;
|
||||
nsTArray<nsRefPtr<nsScriptLoadRequest> > mNonAsyncExternalScriptInsertedRequests;
|
||||
@ -325,6 +328,7 @@ private:
|
||||
bool mEnabled;
|
||||
bool mDeferEnabled;
|
||||
bool mDocumentParsingDone;
|
||||
bool mBlockingDOMContentLoaded;
|
||||
};
|
||||
|
||||
class nsAutoScriptLoaderDisabler
|
||||
|
@ -496,7 +496,11 @@ public:
|
||||
|
||||
double MozFragmentEnd();
|
||||
|
||||
AudioChannel MozAudioChannelType() const;
|
||||
AudioChannel MozAudioChannelType() const
|
||||
{
|
||||
return mAudioChannel;
|
||||
}
|
||||
|
||||
void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
|
||||
|
||||
TextTrackList* TextTracks();
|
||||
@ -1122,8 +1126,8 @@ protected:
|
||||
// True if the media's channel's download has been suspended.
|
||||
bool mDownloadSuspendedByCache;
|
||||
|
||||
// Audio Channel Type.
|
||||
AudioChannelType mAudioChannelType;
|
||||
// Audio Channel.
|
||||
AudioChannel mAudioChannel;
|
||||
|
||||
// The audio channel has been faded.
|
||||
bool mAudioChannelFaded;
|
||||
|
@ -3919,7 +3919,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
||||
// the editor's handling of up/down keypress events. For that reason we
|
||||
// just ignore aVisitor.mEventStatus here and go ahead and handle the
|
||||
// event to increase/decrease the value of the number control.
|
||||
if (!aVisitor.mEvent->mFlags.mDefaultPreventedByContent) {
|
||||
if (!aVisitor.mEvent->mFlags.mDefaultPreventedByContent && IsMutable()) {
|
||||
StepNumberControlForUserEvent(keyEvent->keyCode == NS_VK_UP ? 1 : -1);
|
||||
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
@ -4145,7 +4145,8 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
||||
nsNumberControlFrame* numberControlFrame =
|
||||
do_QueryFrame(GetPrimaryFrame());
|
||||
if (numberControlFrame) {
|
||||
if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN) {
|
||||
if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN &&
|
||||
IsMutable()) {
|
||||
switch (numberControlFrame->GetSpinButtonForPointerEvent(
|
||||
aVisitor.mEvent->AsMouseEvent())) {
|
||||
case nsNumberControlFrame::eSpinButtonUp:
|
||||
|
@ -2004,7 +2004,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
|
||||
mCORSMode(CORS_NONE),
|
||||
mHasAudio(false),
|
||||
mDownloadSuspendedByCache(false),
|
||||
mAudioChannelType(AUDIO_CHANNEL_NORMAL),
|
||||
mAudioChannelFaded(false),
|
||||
mPlayingThroughTheAudioChannel(false)
|
||||
{
|
||||
@ -2017,6 +2016,8 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
|
||||
}
|
||||
#endif
|
||||
|
||||
mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
|
||||
|
||||
mPaused.SetOuter(this);
|
||||
|
||||
RegisterFreezableElement();
|
||||
@ -2282,18 +2283,6 @@ bool HTMLMediaElement::ParseAttribute(int32_t aNamespaceID,
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
// Mappings from 'mozaudiochannel' attribute strings to an enumeration.
|
||||
static const nsAttrValue::EnumTable kMozAudioChannelAttributeTable[] = {
|
||||
{ "normal", AUDIO_CHANNEL_NORMAL },
|
||||
{ "content", AUDIO_CHANNEL_CONTENT },
|
||||
{ "notification", AUDIO_CHANNEL_NOTIFICATION },
|
||||
{ "alarm", AUDIO_CHANNEL_ALARM },
|
||||
{ "telephony", AUDIO_CHANNEL_TELEPHONY },
|
||||
{ "ringer", AUDIO_CHANNEL_RINGER },
|
||||
{ "publicnotification", AUDIO_CHANNEL_PUBLICNOTIFICATION },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||
return true;
|
||||
@ -2307,18 +2296,21 @@ bool HTMLMediaElement::ParseAttribute(int32_t aNamespaceID,
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::mozaudiochannel) {
|
||||
bool parsed = aResult.ParseEnumValue(aValue, kMozAudioChannelAttributeTable, false,
|
||||
&kMozAudioChannelAttributeTable[0]);
|
||||
const nsAttrValue::EnumTable* table =
|
||||
AudioChannelService::GetAudioChannelTable();
|
||||
MOZ_ASSERT(table);
|
||||
|
||||
bool parsed = aResult.ParseEnumValue(aValue, table, false, &table[0]);
|
||||
if (!parsed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AudioChannelType audioChannelType = static_cast<AudioChannelType>(aResult.GetEnumValue());
|
||||
AudioChannel audioChannel = static_cast<AudioChannel>(aResult.GetEnumValue());
|
||||
|
||||
if (audioChannelType != mAudioChannelType &&
|
||||
if (audioChannel != mAudioChannel &&
|
||||
!mDecoder &&
|
||||
CheckAudioChannelPermissions(aValue)) {
|
||||
mAudioChannelType = audioChannelType;
|
||||
mAudioChannel = audioChannel;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -2604,7 +2596,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
|
||||
// Tell the decoder about its MediaResource now so things like principals are
|
||||
// available immediately.
|
||||
mDecoder->SetResource(aStream);
|
||||
mDecoder->SetAudioChannelType(mAudioChannelType);
|
||||
aDecoder->SetAudioChannel(mAudioChannel);
|
||||
mDecoder->SetAudioCaptured(mAudioCaptured);
|
||||
mDecoder->SetVolume(mMuted ? 0.0 : mVolume);
|
||||
mDecoder->SetPreservesPitch(mPreservesPitch);
|
||||
@ -3846,12 +3838,14 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState()
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLVideoElement> video = do_QueryObject(this);
|
||||
// Use a weak ref so the audio channel agent can't leak |this|.
|
||||
if (AUDIO_CHANNEL_NORMAL == mAudioChannelType && video) {
|
||||
if (AudioChannel::Normal == mAudioChannel && video) {
|
||||
mAudioChannelAgent->InitWithVideo(OwnerDoc()->GetWindow(),
|
||||
mAudioChannelType, this, true);
|
||||
static_cast<int32_t>(mAudioChannel),
|
||||
this, true);
|
||||
} else {
|
||||
mAudioChannelAgent->InitWithWeakCallback(OwnerDoc()->GetWindow(),
|
||||
mAudioChannelType, this);
|
||||
static_cast<int32_t>(mAudioChannel),
|
||||
this);
|
||||
}
|
||||
mAudioChannelAgent->SetVisibilityState(!OwnerDoc()->Hidden());
|
||||
}
|
||||
@ -3927,37 +3921,11 @@ HTMLMediaElement::GetOrCreateTextTrackManager()
|
||||
{
|
||||
if (!mTextTrackManager) {
|
||||
mTextTrackManager = new TextTrackManager(this);
|
||||
mTextTrackManager->AddListeners();
|
||||
}
|
||||
return mTextTrackManager;
|
||||
}
|
||||
|
||||
AudioChannel
|
||||
HTMLMediaElement::MozAudioChannelType() const
|
||||
{
|
||||
switch (mAudioChannelType) {
|
||||
case AUDIO_CHANNEL_CONTENT:
|
||||
return AudioChannel::Content;
|
||||
|
||||
case AUDIO_CHANNEL_NOTIFICATION:
|
||||
return AudioChannel::Notification;
|
||||
|
||||
case AUDIO_CHANNEL_ALARM:
|
||||
return AudioChannel::Alarm;
|
||||
|
||||
case AUDIO_CHANNEL_TELEPHONY:
|
||||
return AudioChannel::Telephony;
|
||||
|
||||
case AUDIO_CHANNEL_RINGER:
|
||||
return AudioChannel::Ringer;
|
||||
|
||||
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
|
||||
return AudioChannel::Publicnotification;
|
||||
|
||||
default:
|
||||
return AudioChannelService::GetDefaultAudioChannel();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv)
|
||||
{
|
||||
|
@ -8,8 +8,10 @@
|
||||
#include "mozilla/dom/TextTrackManager.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/HTMLTrackElement.h"
|
||||
#include "mozilla/dom/HTMLVideoElement.h"
|
||||
#include "mozilla/dom/TextTrack.h"
|
||||
#include "mozilla/dom/TextTrackCue.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsVideoFrame.h"
|
||||
@ -75,8 +77,13 @@ CompareTextTracks::LessThan(TextTrack* aOne, TextTrack* aTwo) const
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_4(TextTrackManager, mMediaElement, mTextTracks,
|
||||
mPendingTextTracks, mNewCues)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(TextTrackManager, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(TextTrackManager, Release)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextTrackManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(TextTrackManager)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(TextTrackManager)
|
||||
|
||||
StaticRefPtr<nsIWebVTTParserWrapper> TextTrackManager::sParserWrapper;
|
||||
|
||||
@ -84,8 +91,6 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
|
||||
: mMediaElement(aMediaElement)
|
||||
, performedTrackSelection(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TextTrackManager);
|
||||
|
||||
bool hasHadScriptObject = true;
|
||||
nsIScriptGlobalObject* scriptObject =
|
||||
mMediaElement->OwnerDoc()->GetScriptHandlingObject(hasHadScriptObject);
|
||||
@ -105,11 +110,6 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
|
||||
}
|
||||
}
|
||||
|
||||
TextTrackManager::~TextTrackManager()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TextTrackManager);
|
||||
}
|
||||
|
||||
TextTrackList*
|
||||
TextTrackManager::TextTracks() const
|
||||
{
|
||||
@ -255,6 +255,15 @@ TextTrackManager::PopulatePendingList()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackManager::AddListeners()
|
||||
{
|
||||
if (mMediaElement) {
|
||||
mMediaElement->AddEventListener(NS_LITERAL_STRING("resizevideocontrols"),
|
||||
this, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackManager::HonorUserPreferencesForTrackSelection()
|
||||
{
|
||||
@ -352,5 +361,22 @@ TextTrackManager::GetTextTracksOfKind(TextTrackKind aTextTrackKind,
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextTrackManager::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (!mTextTracks) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString type;
|
||||
aEvent->GetType(type);
|
||||
if (type.EqualsLiteral("resizevideocontrols")) {
|
||||
for (uint32_t i = 0; i< mTextTracks->Length(); i++) {
|
||||
((*mTextTracks)[i])->SetCuesDirty();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -33,14 +33,15 @@ public:
|
||||
class TextTrack;
|
||||
class TextTrackCue;
|
||||
|
||||
class TextTrackManager
|
||||
class TextTrackManager MOZ_FINAL : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(TextTrackManager)
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TextTrackManager);
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(TextTrackManager)
|
||||
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
|
||||
TextTrackManager(HTMLMediaElement *aMediaElement);
|
||||
~TextTrackManager();
|
||||
|
||||
TextTrackList* TextTracks() const;
|
||||
already_AddRefed<TextTrack> AddTextTrack(TextTrackKind aKind,
|
||||
@ -88,6 +89,8 @@ public:
|
||||
|
||||
void PopulatePendingList();
|
||||
|
||||
void AddListeners();
|
||||
|
||||
// The HTMLMediaElement that this TextTrackManager manages the TextTracks of.
|
||||
nsRefPtr<HTMLMediaElement> mMediaElement;
|
||||
private:
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/HTMLAllCollection.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
@ -2154,28 +2155,24 @@ NS_IMETHODIMP
|
||||
nsHTMLDocument::GetSelection(nsISelection** aReturn)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aReturn = GetSelection(rv).take();
|
||||
NS_IF_ADDREF(*aReturn = GetSelection(rv));
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<Selection>
|
||||
nsHTMLDocument::GetSelection(ErrorResult& rv)
|
||||
Selection*
|
||||
nsHTMLDocument::GetSelection(ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(GetScopeObject());
|
||||
nsCOMPtr<nsPIDOMWindow> pwin = do_QueryInterface(window);
|
||||
if (!pwin) {
|
||||
return nullptr;
|
||||
}
|
||||
NS_ASSERTION(pwin->IsInnerWindow(), "Should have inner window here!");
|
||||
if (!pwin->GetOuterWindow() ||
|
||||
pwin->GetOuterWindow()->GetCurrentInnerWindow() != pwin) {
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(GetScopeObject());
|
||||
if (!window) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISelection> sel;
|
||||
rv = window->GetSelection(getter_AddRefs(sel));
|
||||
nsRefPtr<Selection> selection = static_cast<Selection*>(sel.get());
|
||||
return selection.forget();
|
||||
NS_ASSERTION(window->IsInnerWindow(), "Should have inner window here!");
|
||||
if (!window->IsCurrentInnerWindow()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return static_cast<nsGlobalWindow*>(window.get())->GetSelection(aRv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -233,7 +233,7 @@ public:
|
||||
{
|
||||
// Deprecated
|
||||
}
|
||||
already_AddRefed<mozilla::Selection> GetSelection(mozilla::ErrorResult& rv);
|
||||
mozilla::Selection* GetSelection(mozilla::ErrorResult& aRv);
|
||||
// The XPCOM CaptureEvents works fine for us.
|
||||
// The XPCOM ReleaseEvents works fine for us.
|
||||
// We're picking up GetLocation from Document
|
||||
|
@ -24,6 +24,8 @@ enum AudioSampleFormat
|
||||
AUDIO_FORMAT_S16,
|
||||
// Signed 32-bit float samples
|
||||
AUDIO_FORMAT_FLOAT32,
|
||||
// Silence: format will be chosen later
|
||||
AUDIO_FORMAT_SILENCE,
|
||||
// The format used for output by AudioStream.
|
||||
#ifdef MOZ_SAMPLE_TYPE_S16
|
||||
AUDIO_OUTPUT_FORMAT = AUDIO_FORMAT_S16
|
||||
|
@ -52,6 +52,9 @@ InterleaveAndConvertBuffer(const void** aSourceChannels,
|
||||
aChannels,
|
||||
aOutput);
|
||||
break;
|
||||
case AUDIO_FORMAT_SILENCE:
|
||||
// nothing to do here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +124,18 @@ void AudioSegment::ResampleChunks(SpeexResamplerState* aResampler)
|
||||
|
||||
speex_resampler_get_rate(aResampler, &inRate, &outRate);
|
||||
|
||||
switch (mChunks[0].mBufferFormat) {
|
||||
AudioSampleFormat format = AUDIO_FORMAT_SILENCE;
|
||||
for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
|
||||
if (ci->mBufferFormat != AUDIO_FORMAT_SILENCE) {
|
||||
format = ci->mBufferFormat;
|
||||
}
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
// If the format is silence at this point, all the chunks are silent. The
|
||||
// actual function we use does not matter, it's just a matter of changing
|
||||
// the chunks duration.
|
||||
case AUDIO_FORMAT_SILENCE:
|
||||
case AUDIO_FORMAT_FLOAT32:
|
||||
Resample<float>(aResampler, inRate, outRate);
|
||||
break;
|
||||
|
@ -110,6 +110,7 @@ struct AudioChunk {
|
||||
mChannelData.Clear();
|
||||
mDuration = aDuration;
|
||||
mVolume = 1.0f;
|
||||
mBufferFormat = AUDIO_FORMAT_SILENCE;
|
||||
}
|
||||
int ChannelCount() const { return mChannelData.Length(); }
|
||||
|
||||
@ -144,6 +145,11 @@ public:
|
||||
nsAutoTArray<nsTArray<T>, GUESS_AUDIO_CHANNELS> output;
|
||||
nsAutoTArray<const T*, GUESS_AUDIO_CHANNELS> bufferPtrs;
|
||||
AudioChunk& c = *ci;
|
||||
// If this chunk is null, don't bother resampling, just alter its duration
|
||||
if (c.IsNull()) {
|
||||
c.mDuration *= aOutRate / aInRate;
|
||||
mDuration += c.mDuration;
|
||||
}
|
||||
uint32_t channels = c.mChannelData.Length();
|
||||
output.SetLength(channels);
|
||||
bufferPtrs.SetLength(channels);
|
||||
|
@ -110,25 +110,25 @@ bool AudioStream::sCubebLatencyPrefSet;
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__) && defined(MOZ_B2G)
|
||||
static cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannelType aType)
|
||||
static cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel)
|
||||
{
|
||||
switch(aType) {
|
||||
case dom::AUDIO_CHANNEL_NORMAL:
|
||||
switch(aChannel) {
|
||||
case dom::AudioChannel::Normal:
|
||||
return CUBEB_STREAM_TYPE_SYSTEM;
|
||||
case dom::AUDIO_CHANNEL_CONTENT:
|
||||
case dom::AudioChannel::Content:
|
||||
return CUBEB_STREAM_TYPE_MUSIC;
|
||||
case dom::AUDIO_CHANNEL_NOTIFICATION:
|
||||
case dom::AudioChannel::Notification:
|
||||
return CUBEB_STREAM_TYPE_NOTIFICATION;
|
||||
case dom::AUDIO_CHANNEL_ALARM:
|
||||
case dom::AudioChannel::Alarm:
|
||||
return CUBEB_STREAM_TYPE_ALARM;
|
||||
case dom::AUDIO_CHANNEL_TELEPHONY:
|
||||
case dom::AudioChannel::Telephony:
|
||||
return CUBEB_STREAM_TYPE_VOICE_CALL;
|
||||
case dom::AUDIO_CHANNEL_RINGER:
|
||||
case dom::AudioChannel::Ringer:
|
||||
return CUBEB_STREAM_TYPE_RING;
|
||||
// Currently Android openSLES library doesn't support FORCE_AUDIBLE yet.
|
||||
case dom::AUDIO_CHANNEL_PUBLICNOTIFICATION:
|
||||
case dom::AudioChannel::Publicnotification:
|
||||
default:
|
||||
NS_ERROR("The value of AudioChannelType is invalid");
|
||||
NS_ERROR("The value of AudioChannel is invalid");
|
||||
return CUBEB_STREAM_TYPE_MAX;
|
||||
}
|
||||
}
|
||||
@ -349,7 +349,7 @@ WriteDumpFile(FILE* aDumpFile, AudioStream* aStream, uint32_t aFrames,
|
||||
|
||||
nsresult
|
||||
AudioStream::Init(int32_t aNumChannels, int32_t aRate,
|
||||
const dom::AudioChannelType aAudioChannelType,
|
||||
const dom::AudioChannel aAudioChannel,
|
||||
LatencyRequest aLatencyRequest)
|
||||
{
|
||||
cubeb* cubebContext = GetCubebContext();
|
||||
@ -372,7 +372,7 @@ AudioStream::Init(int32_t aNumChannels, int32_t aRate,
|
||||
params.channels = mOutChannels;
|
||||
#if defined(__ANDROID__)
|
||||
#if defined(MOZ_B2G)
|
||||
params.stream_type = ConvertChannelToCubebType(aAudioChannelType);
|
||||
params.stream_type = ConvertChannelToCubebType(aAudioChannel);
|
||||
#else
|
||||
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
|
||||
#endif
|
||||
|
@ -7,11 +7,11 @@
|
||||
#define AudioStream_h_
|
||||
|
||||
#include "AudioSampleFormat.h"
|
||||
#include "AudioChannelCommon.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsAutoRef.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "Latency.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
|
||||
#include "cubeb/cubeb.h"
|
||||
@ -198,7 +198,7 @@ public:
|
||||
// channels (1 for mono, 2 for stereo, etc) and aRate is the sample rate
|
||||
// (22050Hz, 44100Hz, etc).
|
||||
nsresult Init(int32_t aNumChannels, int32_t aRate,
|
||||
const dom::AudioChannelType aAudioStreamType,
|
||||
const dom::AudioChannel aAudioStreamChannel,
|
||||
LatencyRequest aLatencyRequest);
|
||||
|
||||
// Closes the stream. All future use of the stream is an error.
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsITimer.h"
|
||||
#include <algorithm>
|
||||
#include "MediaShutdownManager.h"
|
||||
#include "AudioChannelService.h"
|
||||
|
||||
#ifdef MOZ_WMF
|
||||
#include "WMFDecoder.h"
|
||||
@ -427,7 +428,6 @@ MediaDecoder::MediaDecoder() :
|
||||
mPinnedForSeek(false),
|
||||
mShuttingDown(false),
|
||||
mPausedForPlaybackRateNull(false),
|
||||
mAudioChannelType(AUDIO_CHANNEL_NORMAL),
|
||||
mMinimizePreroll(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MediaDecoder);
|
||||
@ -438,6 +438,8 @@ MediaDecoder::MediaDecoder() :
|
||||
gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
|
||||
}
|
||||
#endif
|
||||
|
||||
mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
|
||||
}
|
||||
|
||||
bool MediaDecoder::Init(MediaDecoderOwner* aOwner)
|
||||
|
@ -183,11 +183,11 @@ destroying the MediaDecoder object.
|
||||
#include "nsIObserver.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "MediaResource.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "mozilla/ReentrantMonitor.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "AudioChannelCommon.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "necko-config.h"
|
||||
|
||||
@ -739,8 +739,8 @@ public:
|
||||
// held.
|
||||
void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
void SetAudioChannelType(dom::AudioChannelType aType) { mAudioChannelType = aType; }
|
||||
dom::AudioChannelType GetAudioChannelType() { return mAudioChannelType; }
|
||||
void SetAudioChannel(dom::AudioChannel aChannel) { mAudioChannel = aChannel; }
|
||||
dom::AudioChannel GetAudioChannel() { return mAudioChannel; }
|
||||
|
||||
// Send a new set of metadata to the state machine, to be dispatched to the
|
||||
// main thread to be presented when the |currentTime| of the media is greater
|
||||
@ -1205,7 +1205,7 @@ protected:
|
||||
|
||||
// Be assigned from media element during the initialization and pass to
|
||||
// AudioStream Class.
|
||||
dom::AudioChannelType mAudioChannelType;
|
||||
dom::AudioChannel mAudioChannel;
|
||||
|
||||
// True if the decoder has been directed to minimize its preroll before
|
||||
// playback starts. After the first time playback starts, we don't attempt
|
||||
|
@ -763,7 +763,7 @@ void MediaDecoderStateMachine::AudioLoop()
|
||||
bool setPlaybackRate;
|
||||
bool preservesPitch;
|
||||
bool setPreservesPitch;
|
||||
AudioChannelType audioChannelType;
|
||||
AudioChannel audioChannel;
|
||||
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
@ -773,7 +773,7 @@ void MediaDecoderStateMachine::AudioLoop()
|
||||
channels = mInfo.mAudio.mChannels;
|
||||
rate = mInfo.mAudio.mRate;
|
||||
|
||||
audioChannelType = mDecoder->GetAudioChannelType();
|
||||
audioChannel = mDecoder->GetAudioChannel();
|
||||
volume = mVolume;
|
||||
preservesPitch = mPreservesPitch;
|
||||
playbackRate = mPlaybackRate;
|
||||
@ -784,7 +784,7 @@ void MediaDecoderStateMachine::AudioLoop()
|
||||
// circumstances, so we take care to drop the decoder monitor while
|
||||
// initializing.
|
||||
nsAutoPtr<AudioStream> audioStream(new AudioStream());
|
||||
audioStream->Init(channels, rate, audioChannelType, AudioStream::HighLatency);
|
||||
audioStream->Init(channels, rate, audioChannel, AudioStream::HighLatency);
|
||||
audioStream->SetVolume(volume);
|
||||
if (audioStream->SetPreservesPitch(preservesPitch) != NS_OK) {
|
||||
NS_WARNING("Setting the pitch preservation failed at AudioLoop start.");
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "MediaStreamGraphImpl.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "AudioSegment.h"
|
||||
@ -18,7 +19,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "TrackUnionStream.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "AudioChannelCommon.h"
|
||||
#include "AudioChannelService.h"
|
||||
#include "AudioNodeEngine.h"
|
||||
#include "AudioNodeStream.h"
|
||||
#include "AudioNodeExternalInputStream.h"
|
||||
@ -841,7 +842,9 @@ MediaStreamGraphImpl::CreateOrDestroyAudioStreams(GraphTime aAudioOutputStartTim
|
||||
audioOutputStream->mStream = new AudioStream();
|
||||
// XXX for now, allocate stereo output. But we need to fix this to
|
||||
// match the system's ideal channel configuration.
|
||||
audioOutputStream->mStream->Init(2, IdealAudioRate(), AUDIO_CHANNEL_NORMAL, AudioStream::LowLatency);
|
||||
audioOutputStream->mStream->Init(2, IdealAudioRate(),
|
||||
AudioChannel::Normal,
|
||||
AudioStream::LowLatency);
|
||||
audioOutputStream->mTrackID = tracks->GetID();
|
||||
|
||||
LogLatency(AsyncLatencyLogger::AudioStreamCreate,
|
||||
@ -901,7 +904,7 @@ MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
|
||||
if (audioOutput.mLastTickWritten != offset) {
|
||||
// If there is a global underrun of the MSG, this property won't hold, and
|
||||
// we reset the sample count tracking.
|
||||
if (std::abs(audioOutput.mLastTickWritten - offset) != 1) {
|
||||
if (mozilla::Abs(audioOutput.mLastTickWritten - offset) != 1) {
|
||||
audioOutput.mLastTickWritten = offset;
|
||||
} else {
|
||||
offset = audioOutput.mLastTickWritten;
|
||||
|
@ -124,6 +124,14 @@ TextTrack::RemoveCue(TextTrackCue& aCue, ErrorResult& aRv)
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
void
|
||||
TextTrack::SetCuesDirty()
|
||||
{
|
||||
for (uint32_t i = 0; i < mCueList->Length(); i++) {
|
||||
((*mCueList)[i])->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrack::UpdateActiveCueList()
|
||||
{
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
void AddCue(TextTrackCue& aCue);
|
||||
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
||||
void SetDirty() { mDirty = true; }
|
||||
void SetCuesDirty();
|
||||
|
||||
TextTrackList* GetTextTrackList();
|
||||
void SetTextTrackList(TextTrackList* aTextTrackList);
|
||||
|
@ -295,6 +295,11 @@ public:
|
||||
mReset = false;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mReset = true;
|
||||
}
|
||||
|
||||
bool HasBeenReset()
|
||||
{
|
||||
return mReset;
|
||||
|
@ -80,7 +80,7 @@ VorbisTrackEncoder::Init(int aChannels, int aSamplingRate)
|
||||
|
||||
void VorbisTrackEncoder::WriteLacing(nsTArray<uint8_t> *aOutput, int32_t aLacing)
|
||||
{
|
||||
while (aLacing > 255) {
|
||||
while (aLacing >= 255) {
|
||||
aLacing -= 255;
|
||||
aOutput->AppendElement(255);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ MediaDecoder* MediaOmxDecoder::Clone()
|
||||
MediaDecoderStateMachine* MediaOmxDecoder::CreateStateMachine()
|
||||
{
|
||||
mReader = new MediaOmxReader(this);
|
||||
mReader->SetAudioChannelType(GetAudioChannelType());
|
||||
mReader->SetAudioChannel(GetAudioChannel());
|
||||
return new MediaDecoderStateMachine(this, mReader);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "VideoUtils.h"
|
||||
#include "MediaOmxDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "AudioChannelService.h"
|
||||
#include "OmxDecoder.h"
|
||||
#include "MPAPI.h"
|
||||
#include "gfx2DGlue.h"
|
||||
@ -45,14 +46,15 @@ MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder) :
|
||||
mHasAudio(false),
|
||||
mVideoSeekTimeUs(-1),
|
||||
mAudioSeekTimeUs(-1),
|
||||
mSkipCount(0),
|
||||
mAudioChannelType(dom::AUDIO_CHANNEL_DEFAULT)
|
||||
mSkipCount(0)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (!gMediaDecoderLog) {
|
||||
gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
|
||||
}
|
||||
#endif
|
||||
|
||||
mAudioChannel = dom::AudioChannelService::GetDefaultAudioChannel();
|
||||
}
|
||||
|
||||
MediaOmxReader::~MediaOmxReader()
|
||||
@ -437,11 +439,11 @@ void MediaOmxReader::CheckAudioOffload()
|
||||
|
||||
// Not much benefit in trying to offload other channel types. Most of them
|
||||
// aren't supported and also duration would be less than a minute
|
||||
bool isTypeMusic = mAudioChannelType == dom::AUDIO_CHANNEL_CONTENT;
|
||||
bool isTypeMusic = mAudioChannel == dom::AudioChannel::Content;
|
||||
|
||||
DECODER_LOG(PR_LOG_DEBUG, ("%s meta %p, no video %d, no streaming %d,"
|
||||
" channel type %d", __FUNCTION__, meta.get(), hasNoVideo,
|
||||
isNotStreaming, mAudioChannelType));
|
||||
isNotStreaming, mAudioChannel));
|
||||
|
||||
if ((meta.get()) && hasNoVideo && isNotStreaming && isTypeMusic &&
|
||||
canOffloadStream(meta, false, false, AUDIO_STREAM_MUSIC)) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "MediaResource.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "nsRect.h"
|
||||
#include "AudioChannelCommon.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include <ui/GraphicBuffer.h>
|
||||
#include <stagefright/MediaSource.h>
|
||||
|
||||
@ -36,7 +36,7 @@ class MediaOmxReader : public MediaDecoderReader
|
||||
int64_t mVideoSeekTimeUs;
|
||||
int64_t mAudioSeekTimeUs;
|
||||
int32_t mSkipCount;
|
||||
dom::AudioChannelType mAudioChannelType;
|
||||
dom::AudioChannel mAudioChannel;
|
||||
android::sp<android::MediaSource> mAudioOffloadTrack;
|
||||
|
||||
protected:
|
||||
@ -85,8 +85,8 @@ public:
|
||||
virtual void SetIdle() MOZ_OVERRIDE;
|
||||
virtual void SetActive() MOZ_OVERRIDE;
|
||||
|
||||
void SetAudioChannelType(dom::AudioChannelType aAudioChannelType) {
|
||||
mAudioChannelType = aAudioChannelType;
|
||||
void SetAudioChannel(dom::AudioChannel aAudioChannel) {
|
||||
mAudioChannel = aAudioChannel;
|
||||
}
|
||||
|
||||
android::sp<android::MediaSource> GetAudioOffloadTrack() {
|
||||
|
@ -477,40 +477,10 @@ AudioDestinationNode::CreateAudioChannelAgent()
|
||||
mAudioChannelAgent->StopPlaying();
|
||||
}
|
||||
|
||||
AudioChannelType type = AUDIO_CHANNEL_NORMAL;
|
||||
switch(mAudioChannel) {
|
||||
case AudioChannel::Normal:
|
||||
type = AUDIO_CHANNEL_NORMAL;
|
||||
break;
|
||||
|
||||
case AudioChannel::Content:
|
||||
type = AUDIO_CHANNEL_CONTENT;
|
||||
break;
|
||||
|
||||
case AudioChannel::Notification:
|
||||
type = AUDIO_CHANNEL_NOTIFICATION;
|
||||
break;
|
||||
|
||||
case AudioChannel::Alarm:
|
||||
type = AUDIO_CHANNEL_ALARM;
|
||||
break;
|
||||
|
||||
case AudioChannel::Telephony:
|
||||
type = AUDIO_CHANNEL_TELEPHONY;
|
||||
break;
|
||||
|
||||
case AudioChannel::Ringer:
|
||||
type = AUDIO_CHANNEL_RINGER;
|
||||
break;
|
||||
|
||||
case AudioChannel::Publicnotification:
|
||||
type = AUDIO_CHANNEL_PUBLICNOTIFICATION;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
mAudioChannelAgent = new AudioChannelAgent();
|
||||
mAudioChannelAgent->InitWithWeakCallback(GetOwner(), type, this);
|
||||
mAudioChannelAgent->InitWithWeakCallback(GetOwner(),
|
||||
static_cast<int32_t>(mAudioChannel),
|
||||
this);
|
||||
|
||||
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(GetOwner());
|
||||
if (docshell) {
|
||||
|
@ -34,8 +34,7 @@ LoadManager::LoadManager(int aLoadMeasurementInterval,
|
||||
int aAveragingMeasurements,
|
||||
float aHighLoadThreshold,
|
||||
float aLowLoadThreshold)
|
||||
: mLastSystemLoad(0),
|
||||
mLoadSum(0.0f),
|
||||
: mLoadSum(0.0f),
|
||||
mLoadSumMeasurements(0),
|
||||
mOveruseActive(false),
|
||||
mLoadMeasurementInterval(aLoadMeasurementInterval),
|
||||
|
@ -42,7 +42,6 @@ private:
|
||||
void LoadHasChanged();
|
||||
|
||||
nsRefPtr<LoadMonitor> mLoadMonitor;
|
||||
float mLastSystemLoad;
|
||||
float mLoadSum;
|
||||
int mLoadSumMeasurements;
|
||||
// Set when overuse was signaled to us, and hasn't been un-signaled yet.
|
||||
|
@ -53,7 +53,6 @@ private:
|
||||
mozilla::CondVar mCondVar;
|
||||
bool mShutdownPending;
|
||||
nsCOMPtr<nsIThread> mLoadInfoThread;
|
||||
uint64_t mTicksPerInterval;
|
||||
float mSystemLoad;
|
||||
float mProcessLoad;
|
||||
LoadNotificationCallback* mLoadNotificationCallback;
|
||||
|
@ -9,14 +9,21 @@
|
||||
#include "SVGLength.h"
|
||||
#include "SVGAnimatedLengthList.h"
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "nsIDOMSVGLength.h"
|
||||
#include "nsError.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "mozilla/dom/SVGLengthBinding.h"
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
|
||||
// See the architecture comment in DOMSVGAnimatedLengthList.h.
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static nsSVGAttrTearoffTable<nsSVGLength2, DOMSVGLength>
|
||||
sBaseSVGLengthTearOffTable,
|
||||
sAnimSVGLengthTearOffTable;
|
||||
|
||||
// We could use NS_IMPL_CYCLE_COLLECTION_1, except that in Unlink() we need to
|
||||
// clear our list's weak ref to us to be safe. (The other option would be to
|
||||
// not unlink and rely on the breaking of the other edges in the cycle, as
|
||||
@ -29,23 +36,28 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGLength)
|
||||
tmp->mList->mItems[tmp->mListIndex] = nullptr;
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mList)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSVGElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGLength)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSVGElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGLength)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGLength)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGLength)
|
||||
|
||||
}
|
||||
DOMCI_DATA(SVGLength, mozilla::DOMSVGLength)
|
||||
namespace mozilla {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGLength)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(mozilla::DOMSVGLength) // pseudo-interface
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLength)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLength)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -91,6 +103,7 @@ DOMSVGLength::DOMSVGLength(DOMSVGLengthList *aList,
|
||||
, mIsAnimValItem(aIsAnimValItem)
|
||||
, mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)
|
||||
, mValue(0.0f)
|
||||
, mVal(nullptr)
|
||||
{
|
||||
// These shifts are in sync with the members in the header.
|
||||
NS_ABORT_IF_FALSE(aList &&
|
||||
@ -98,6 +111,8 @@ DOMSVGLength::DOMSVGLength(DOMSVGLengthList *aList,
|
||||
aListIndex <= MaxListIndex(), "bad arg");
|
||||
|
||||
NS_ABORT_IF_FALSE(IndexIsValid(), "Bad index for DOMSVGNumber!");
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DOMSVGLength::DOMSVGLength()
|
||||
@ -107,49 +122,126 @@ DOMSVGLength::DOMSVGLength()
|
||||
, mIsAnimValItem(false)
|
||||
, mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)
|
||||
, mValue(0.0f)
|
||||
, mVal(nullptr)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DOMSVGLength::DOMSVGLength(nsSVGLength2* aVal, nsSVGElement* aSVGElement,
|
||||
bool aAnimVal)
|
||||
: mList(nullptr)
|
||||
, mListIndex(0)
|
||||
, mAttrEnum(0)
|
||||
, mIsAnimValItem(aAnimVal)
|
||||
, mUnit(nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)
|
||||
, mValue(0.0f)
|
||||
, mVal(aVal)
|
||||
, mSVGElement(aSVGElement)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DOMSVGLength::~DOMSVGLength()
|
||||
{
|
||||
// Our mList's weak ref to us must be nulled out when we die. If GC has
|
||||
// unlinked us using the cycle collector code, then that has already
|
||||
// happened, and mList is null.
|
||||
if (mList) {
|
||||
mList->mItems[mListIndex] = nullptr;
|
||||
}
|
||||
|
||||
if (mVal) {
|
||||
auto& table = mIsAnimValItem ? sAnimSVGLengthTearOffTable : sBaseSVGLengthTearOffTable;
|
||||
table.RemoveTearoff(mVal);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLength::GetTearOff(nsSVGLength2* aVal, nsSVGElement* aSVGElement,
|
||||
bool aAnimVal)
|
||||
{
|
||||
auto& table = aAnimVal ? sAnimSVGLengthTearOffTable : sBaseSVGLengthTearOffTable;
|
||||
nsRefPtr<DOMSVGLength> domLength = table.GetTearoff(aVal);
|
||||
if (!domLength) {
|
||||
domLength = new DOMSVGLength(aVal, aSVGElement, aAnimVal);
|
||||
table.AddTearoff(aVal, domLength);
|
||||
}
|
||||
|
||||
return domLength.forget();
|
||||
}
|
||||
|
||||
uint16_t
|
||||
DOMSVGLength::UnitType()
|
||||
{
|
||||
if (mVal) {
|
||||
if (mIsAnimValItem) {
|
||||
mSVGElement->FlushAnimations();
|
||||
}
|
||||
return mVal->mSpecifiedUnitType;
|
||||
}
|
||||
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
}
|
||||
return HasOwner() ? InternalItem().GetUnit() : mUnit;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::GetUnitType(uint16_t* aUnit)
|
||||
{
|
||||
*aUnit = UnitType();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
float
|
||||
DOMSVGLength::GetValue(ErrorResult& aRv)
|
||||
{
|
||||
if (mVal) {
|
||||
if (mIsAnimValItem) {
|
||||
mSVGElement->FlushAnimations();
|
||||
return mVal->GetAnimValue(mSVGElement);
|
||||
}
|
||||
return mVal->GetBaseValue(mSVGElement);
|
||||
}
|
||||
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
}
|
||||
*aUnit = HasOwner() ? InternalItem().GetUnit() : mUnit;
|
||||
return NS_OK;
|
||||
if (HasOwner()) {
|
||||
float value = InternalItem().GetValueInUserUnits(Element(), Axis());
|
||||
if (!NS_finite(value)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
return value;
|
||||
} else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER ||
|
||||
mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) {
|
||||
return mValue;
|
||||
}
|
||||
// else [SVGWG issue] Can't convert this length's value to user units
|
||||
// ReportToConsole
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::GetValue(float* aValue)
|
||||
{
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
}
|
||||
if (HasOwner()) {
|
||||
*aValue = InternalItem().GetValueInUserUnits(Element(), Axis());
|
||||
if (NS_finite(*aValue)) {
|
||||
return NS_OK;
|
||||
}
|
||||
} else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER ||
|
||||
mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) {
|
||||
*aValue = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
// else [SVGWG issue] Can't convert this length's value to user units
|
||||
// ReportToConsole
|
||||
return NS_ERROR_FAILURE;
|
||||
ErrorResult rv;
|
||||
*aValue = GetValue(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::SetValue(float aUserUnitValue)
|
||||
void
|
||||
DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NS_finite(aUserUnitValue)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
if (mVal) {
|
||||
mVal->SetBaseValue(aUserUnitValue, mSVGElement, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Although the value passed in is in user units, this method does not turn
|
||||
@ -160,7 +252,7 @@ DOMSVGLength::SetValue(float aUserUnitValue)
|
||||
if (HasOwner()) {
|
||||
if (InternalItem().GetValueInUserUnits(Element(), Axis()) ==
|
||||
aUserUnitValue) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
float uuPerUnit = InternalItem().GetUserUnitsPerUnit(Element(), Axis());
|
||||
if (uuPerUnit > 0) {
|
||||
@ -168,79 +260,142 @@ DOMSVGLength::SetValue(float aUserUnitValue)
|
||||
if (NS_finite(newValue)) {
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueAndUnit(newValue, InternalItem().GetUnit());
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER ||
|
||||
mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) {
|
||||
mValue = aUserUnitValue;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
// else [SVGWG issue] Can't convert user unit value to this length's unit
|
||||
// ReportToConsole
|
||||
return NS_ERROR_FAILURE;
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::SetValue(float aUserUnitValue)
|
||||
{
|
||||
if (!NS_finite(aUserUnitValue)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
SetValue(aUserUnitValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
float
|
||||
DOMSVGLength::ValueInSpecifiedUnits()
|
||||
{
|
||||
if (mVal) {
|
||||
if (mIsAnimValItem) {
|
||||
mSVGElement->FlushAnimations();
|
||||
return mVal->mAnimVal;
|
||||
}
|
||||
return mVal->mBaseVal;
|
||||
}
|
||||
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
}
|
||||
return HasOwner() ? InternalItem().GetValueInCurrentUnits() : mValue;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::GetValueInSpecifiedUnits(float* aValue)
|
||||
{
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
}
|
||||
*aValue = HasOwner() ? InternalItem().GetValueInCurrentUnits() : mValue;
|
||||
*aValue = ValueInSpecifiedUnits();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGLength::SetValueInSpecifiedUnits(float aValue, ErrorResult& aRv)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mVal) {
|
||||
mVal->SetBaseValueInSpecifiedUnits(aValue, mSVGElement, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasOwner()) {
|
||||
if (InternalItem().GetValueInCurrentUnits() == aValue) {
|
||||
return;
|
||||
}
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueInCurrentUnits(aValue);
|
||||
return;
|
||||
}
|
||||
mValue = aValue;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::SetValueInSpecifiedUnits(float aValue)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
if (!NS_finite(aValue)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
SetValueInSpecifiedUnits(aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGLength::SetValueAsString(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mVal) {
|
||||
mVal->SetBaseValueString(aValue, mSVGElement, true);
|
||||
return;
|
||||
}
|
||||
|
||||
SVGLength value;
|
||||
if (!value.SetValueFromString(aValue)) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return;
|
||||
}
|
||||
if (HasOwner()) {
|
||||
if (InternalItem().GetValueInCurrentUnits() == aValue) {
|
||||
return NS_OK;
|
||||
if (InternalItem() == value) {
|
||||
return;
|
||||
}
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueInCurrentUnits(aValue);
|
||||
return NS_OK;
|
||||
InternalItem() = value;
|
||||
return;
|
||||
}
|
||||
mValue = aValue;
|
||||
return NS_OK;
|
||||
mValue = value.GetValueInCurrentUnits();
|
||||
mUnit = value.GetUnit();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::SetValueAsString(const nsAString& aValue)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
SVGLength value;
|
||||
if (!value.SetValueFromString(aValue)) {
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
if (HasOwner()) {
|
||||
if (InternalItem() == value) {
|
||||
return NS_OK;
|
||||
}
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem() = value;
|
||||
return NS_OK;
|
||||
}
|
||||
mValue = value.GetValueInCurrentUnits();
|
||||
mUnit = value.GetUnit();
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
SetValueAsString(aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::GetValueAsString(nsAString& aValue)
|
||||
{
|
||||
if (mVal) {
|
||||
if (mIsAnimValItem) {
|
||||
mSVGElement->FlushAnimations();
|
||||
mVal->GetAnimValueString(aValue);
|
||||
} else {
|
||||
mVal->GetBaseValueString(aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
}
|
||||
@ -252,54 +407,76 @@ DOMSVGLength::GetValueAsString(nsAString& aValue)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue)
|
||||
void
|
||||
DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NS_finite(aValue)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
if (mVal) {
|
||||
mVal->NewValueSpecifiedUnits(aUnit, aValue, mSVGElement);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SVGLength::IsValidUnitType(aUnit)) {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
if (HasOwner()) {
|
||||
if (InternalItem().GetUnit() == aUnit &&
|
||||
InternalItem().GetValueInCurrentUnits() == aValue) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueAndUnit(aValue, uint8_t(aUnit));
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
mUnit = uint8_t(aUnit);
|
||||
mValue = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit)
|
||||
DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue)
|
||||
{
|
||||
if (!NS_finite(aValue)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
NewValueSpecifiedUnits(aUnit, aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mVal) {
|
||||
mVal->ConvertToSpecifiedUnits(aUnit, mSVGElement);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SVGLength::IsValidUnitType(aUnit)) {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
if (HasOwner()) {
|
||||
if (InternalItem().GetUnit() == aUnit) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
float val = InternalItem().GetValueInSpecifiedUnit(
|
||||
aUnit, Element(), Axis());
|
||||
if (NS_finite(val)) {
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueAndUnit(val, aUnit);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
SVGLength len(mValue, mUnit);
|
||||
@ -307,12 +484,26 @@ DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit)
|
||||
if (NS_finite(val)) {
|
||||
mValue = val;
|
||||
mUnit = aUnit;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// else [SVGWG issue] Can't convert unit
|
||||
// ReportToConsole
|
||||
return NS_ERROR_FAILURE;
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit)
|
||||
{
|
||||
ErrorResult rv;
|
||||
ConvertToSpecifiedUnits(aUnit, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMSVGLength::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return dom::SVGLengthBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsTArray.h"
|
||||
#include "SVGLength.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsSVGElement;
|
||||
|
||||
@ -29,6 +30,8 @@ class nsSVGElement;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
/**
|
||||
* Class DOMSVGLength
|
||||
*
|
||||
@ -66,14 +69,20 @@ namespace mozilla {
|
||||
* if-else as appropriate. The bug for doing that work is:
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=571734
|
||||
*/
|
||||
class DOMSVGLength MOZ_FINAL : public nsIDOMSVGLength
|
||||
class DOMSVGLength MOZ_FINAL : public nsIDOMSVGLength,
|
||||
public nsWrapperCache
|
||||
{
|
||||
friend class AutoChangeLengthNotifier;
|
||||
|
||||
/**
|
||||
* Ctor for creating the object returned by nsSVGLength2::ToDOMBaseVal/ToDOMAnimVal
|
||||
*/
|
||||
DOMSVGLength(nsSVGLength2* aVal, nsSVGElement* aSVGElement, bool aAnimVal);
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGLENGTH_IID)
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(DOMSVGLength)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGLength)
|
||||
NS_DECL_NSIDOMSVGLENGTH
|
||||
|
||||
/**
|
||||
@ -90,14 +99,11 @@ public:
|
||||
*/
|
||||
DOMSVGLength();
|
||||
|
||||
~DOMSVGLength() {
|
||||
// Our mList's weak ref to us must be nulled out when we die. If GC has
|
||||
// unlinked us using the cycle collector code, then that has already
|
||||
// happened, and mList is null.
|
||||
if (mList) {
|
||||
mList->mItems[mListIndex] = nullptr;
|
||||
}
|
||||
}
|
||||
~DOMSVGLength();
|
||||
|
||||
static already_AddRefed<DOMSVGLength> GetTearOff(nsSVGLength2* aVal,
|
||||
nsSVGElement* aSVGElement,
|
||||
bool aAnimVal);
|
||||
|
||||
/**
|
||||
* Create an unowned copy of an owned length. The caller is responsible for
|
||||
@ -156,9 +162,28 @@ public:
|
||||
|
||||
SVGLength ToSVGLength();
|
||||
|
||||
// WebIDL
|
||||
uint16_t UnitType();
|
||||
float GetValue(ErrorResult& aRv);
|
||||
void SetValue(float aValue, ErrorResult& aRv);
|
||||
float ValueInSpecifiedUnits();
|
||||
void SetValueInSpecifiedUnits(float aValue, ErrorResult& aRv);
|
||||
// The XPCOM GetValueAsString is good
|
||||
void SetValueAsString(const nsAString& aValue, ErrorResult& aRv);
|
||||
void NewValueSpecifiedUnits(uint16_t aUnit, float aValue,
|
||||
ErrorResult& aRv);
|
||||
void ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv);
|
||||
|
||||
nsISupports* GetParentObject() const {
|
||||
auto svgElement = mList ? Element() : mSVGElement.get();
|
||||
return static_cast<nsIDOMSVGElement*> (svgElement);
|
||||
}
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
nsSVGElement* Element() {
|
||||
nsSVGElement* Element() const {
|
||||
return mList->Element();
|
||||
}
|
||||
|
||||
@ -201,6 +226,10 @@ private:
|
||||
// The following members are only used when we're not in a list:
|
||||
uint32_t mUnit:5; // can handle 31 units (the 10 SVG 1.1 units + rem, vw, vh, wm, calc + future additions)
|
||||
float mValue;
|
||||
|
||||
// The following members are only used when we have an nsSVGLength2
|
||||
nsSVGLength2* mVal; // kept alive because it belongs to mSVGElement
|
||||
nsRefPtr<nsSVGElement> mSVGElement;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(DOMSVGLength, MOZILLA_DOMSVGLENGTH_IID)
|
||||
|
@ -172,8 +172,8 @@ DOMSVGLengthList::Clear(ErrorResult& aError)
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
DOMSVGLengthList::Initialize(nsIDOMSVGLength *newItem,
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLengthList::Initialize(DOMSVGLength& newItem,
|
||||
ErrorResult& error)
|
||||
{
|
||||
if (IsAnimValList()) {
|
||||
@ -189,33 +189,33 @@ DOMSVGLengthList::Initialize(nsIDOMSVGLength *newItem,
|
||||
// clone of newItem, it would actually insert newItem. To prevent that from
|
||||
// happening we have to do the clone here, if necessary.
|
||||
|
||||
nsCOMPtr<DOMSVGLength> domItem = do_QueryInterface(newItem);
|
||||
nsRefPtr<DOMSVGLength> domItem = &newItem;
|
||||
if (!domItem) {
|
||||
error.Throw(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
if (domItem->HasOwner()) {
|
||||
newItem = domItem->Copy();
|
||||
domItem = domItem->Copy();
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
Clear(rv);
|
||||
MOZ_ASSERT(!rv.Failed());
|
||||
return InsertItemBefore(newItem, 0, error);
|
||||
return InsertItemBefore(*domItem, 0, error);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLengthList::GetItem(uint32_t index, ErrorResult& error)
|
||||
{
|
||||
bool found;
|
||||
nsRefPtr<nsIDOMSVGLength> item = IndexedGetter(index, found, error);
|
||||
nsRefPtr<DOMSVGLength> item = IndexedGetter(index, found, error);
|
||||
if (!found) {
|
||||
error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
}
|
||||
return item.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLengthList::IndexedGetter(uint32_t index, bool& found, ErrorResult& error)
|
||||
{
|
||||
if (IsAnimValList()) {
|
||||
@ -228,8 +228,8 @@ DOMSVGLengthList::IndexedGetter(uint32_t index, bool& found, ErrorResult& error)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
DOMSVGLengthList::InsertItemBefore(nsIDOMSVGLength *newItem,
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLengthList::InsertItemBefore(DOMSVGLength& newItem,
|
||||
uint32_t index,
|
||||
ErrorResult& error)
|
||||
{
|
||||
@ -244,7 +244,7 @@ DOMSVGLengthList::InsertItemBefore(nsIDOMSVGLength *newItem,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<DOMSVGLength> domItem = do_QueryInterface(newItem);
|
||||
nsRefPtr<DOMSVGLength> domItem = &newItem;
|
||||
if (!domItem) {
|
||||
error.Throw(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR);
|
||||
return nullptr;
|
||||
@ -277,8 +277,8 @@ DOMSVGLengthList::InsertItemBefore(nsIDOMSVGLength *newItem,
|
||||
return domItem.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
DOMSVGLengthList::ReplaceItem(nsIDOMSVGLength *newItem,
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLengthList::ReplaceItem(DOMSVGLength& newItem,
|
||||
uint32_t index,
|
||||
ErrorResult& error)
|
||||
{
|
||||
@ -287,7 +287,7 @@ DOMSVGLengthList::ReplaceItem(nsIDOMSVGLength *newItem,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<DOMSVGLength> domItem = do_QueryInterface(newItem);
|
||||
nsRefPtr<DOMSVGLength> domItem = &newItem;
|
||||
if (!domItem) {
|
||||
error.Throw(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR);
|
||||
return nullptr;
|
||||
@ -317,7 +317,7 @@ DOMSVGLengthList::ReplaceItem(nsIDOMSVGLength *newItem,
|
||||
return domItem.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLengthList::RemoveItem(uint32_t index,
|
||||
ErrorResult& error)
|
||||
{
|
||||
@ -338,7 +338,7 @@ DOMSVGLengthList::RemoveItem(uint32_t index,
|
||||
MaybeRemoveItemFromAnimValListAt(index);
|
||||
|
||||
// We have to return the removed item, so get it, creating it if necessary:
|
||||
nsCOMPtr<nsIDOMSVGLength> result = GetItemAt(index);
|
||||
nsCOMPtr<DOMSVGLength> result = GetItemAt(index);
|
||||
|
||||
// Notify the DOM item of removal *before* modifying the lists so that the
|
||||
// DOM item can copy its *old* value:
|
||||
@ -352,7 +352,7 @@ DOMSVGLengthList::RemoveItem(uint32_t index,
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLengthList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
MOZ_ASSERT(aIndex < mItems.Length());
|
||||
@ -360,7 +360,7 @@ DOMSVGLengthList::GetItemAt(uint32_t aIndex)
|
||||
if (!mItems[aIndex]) {
|
||||
mItems[aIndex] = new DOMSVGLength(this, AttrEnum(), aIndex, IsAnimValList());
|
||||
}
|
||||
nsRefPtr<nsIDOMSVGLength> result = mItems[aIndex];
|
||||
nsRefPtr<DOMSVGLength> result = mItems[aIndex];
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
class nsIDOMSVGLength;
|
||||
class nsSVGElement;
|
||||
|
||||
namespace mozilla {
|
||||
@ -109,22 +108,22 @@ public:
|
||||
return LengthNoFlush();
|
||||
}
|
||||
void Clear(ErrorResult& aError);
|
||||
already_AddRefed<nsIDOMSVGLength> Initialize(nsIDOMSVGLength *newItem,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<nsIDOMSVGLength> GetItem(uint32_t index,
|
||||
already_AddRefed<DOMSVGLength> Initialize(DOMSVGLength& newItem,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<nsIDOMSVGLength> IndexedGetter(uint32_t index, bool& found,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<nsIDOMSVGLength> InsertItemBefore(nsIDOMSVGLength *newItem,
|
||||
uint32_t index,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<nsIDOMSVGLength> ReplaceItem(nsIDOMSVGLength *newItem,
|
||||
uint32_t index,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<nsIDOMSVGLength> RemoveItem(uint32_t index,
|
||||
already_AddRefed<DOMSVGLength> GetItem(uint32_t index,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<DOMSVGLength> IndexedGetter(uint32_t index, bool& found,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<nsIDOMSVGLength> AppendItem(nsIDOMSVGLength *newItem,
|
||||
ErrorResult& error)
|
||||
already_AddRefed<DOMSVGLength> InsertItemBefore(DOMSVGLength& newItem,
|
||||
uint32_t index,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<DOMSVGLength> ReplaceItem(DOMSVGLength& newItem,
|
||||
uint32_t index,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<DOMSVGLength> RemoveItem(uint32_t index,
|
||||
ErrorResult& error);
|
||||
already_AddRefed<DOMSVGLength> AppendItem(DOMSVGLength& newItem,
|
||||
ErrorResult& error)
|
||||
{
|
||||
return InsertItemBefore(newItem, LengthNoFlush(), error);
|
||||
}
|
||||
@ -164,8 +163,8 @@ private:
|
||||
*/
|
||||
SVGLengthList& InternalList() const;
|
||||
|
||||
/// Returns the nsIDOMSVGLength at aIndex, creating it if necessary.
|
||||
already_AddRefed<nsIDOMSVGLength> GetItemAt(uint32_t aIndex);
|
||||
/// Returns the DOMSVGLength at aIndex, creating it if necessary.
|
||||
already_AddRefed<DOMSVGLength> GetItemAt(uint32_t aIndex);
|
||||
|
||||
void MaybeInsertNullInAnimValListAt(uint32_t aIndex);
|
||||
void MaybeRemoveItemFromAnimValListAt(uint32_t aIndex);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "mozilla/dom/SVGAnimatedLength.h"
|
||||
#include "mozilla/dom/SVGAnimatedLengthBinding.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "DOMSVGLength.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -21,18 +22,18 @@ SVGAnimatedLength::WrapObject(JSContext* aCx)
|
||||
return SVGAnimatedLengthBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
already_AddRefed<DOMSVGLength>
|
||||
SVGAnimatedLength::BaseVal()
|
||||
{
|
||||
nsRefPtr<nsIDOMSVGLength> angle;
|
||||
nsRefPtr<DOMSVGLength> angle;
|
||||
mVal->ToDOMBaseVal(getter_AddRefs(angle), mSVGElement);
|
||||
return angle.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
already_AddRefed<DOMSVGLength>
|
||||
SVGAnimatedLength::AnimVal()
|
||||
{
|
||||
nsRefPtr<nsIDOMSVGLength> angle;
|
||||
nsRefPtr<DOMSVGLength> angle;
|
||||
mVal->ToDOMAnimVal(getter_AddRefs(angle), mSVGElement);
|
||||
return angle.forget();
|
||||
}
|
||||
|
@ -10,9 +10,11 @@
|
||||
#include "nsSVGElement.h"
|
||||
|
||||
class nsSVGLength2;
|
||||
class nsIDOMSVGLength;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DOMSVGLength;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class SVGAnimatedLength MOZ_FINAL : public nsWrapperCache
|
||||
@ -30,8 +32,8 @@ public:
|
||||
// WebIDL
|
||||
nsSVGElement* GetParentObject() { return mSVGElement; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
already_AddRefed<nsIDOMSVGLength> BaseVal();
|
||||
already_AddRefed<nsIDOMSVGLength> AnimVal();
|
||||
already_AddRefed<DOMSVGLength> BaseVal();
|
||||
already_AddRefed<DOMSVGLength> AnimVal();
|
||||
|
||||
protected:
|
||||
nsSVGLength2* mVal; // kept alive because it belongs to content
|
||||
|
@ -12,7 +12,7 @@
|
||||
* types don't need to be exported outside the SVG module.
|
||||
*/
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
class nsSVGAngle;
|
||||
class nsSVGIntegerPair;
|
||||
|
@ -98,8 +98,8 @@ SVGEllipseElement::ConstructPath(gfxContext *aCtx)
|
||||
if (!aCtx->IsCairo()) {
|
||||
RefPtr<Path> path = BuildPath();
|
||||
if (path) {
|
||||
gfxPath gfxpath(path);
|
||||
aCtx->SetPath(&gfxpath);
|
||||
nsRefPtr<gfxPath> gfxpath = new gfxPath(path);
|
||||
aCtx->SetPath(gfxpath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -387,10 +387,10 @@ SVGSVGElement::CreateSVGNumber()
|
||||
return number.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGLength>
|
||||
already_AddRefed<DOMSVGLength>
|
||||
SVGSVGElement::CreateSVGLength()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length = new DOMSVGLength();
|
||||
nsCOMPtr<DOMSVGLength> length = new DOMSVGLength();
|
||||
return length.forget();
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ class nsSVGImageFrame;
|
||||
namespace mozilla {
|
||||
class AutoSVGRenderingState;
|
||||
class DOMSVGAnimatedPreserveAspectRatio;
|
||||
class DOMSVGLength;
|
||||
class EventChainPreVisitor;
|
||||
class SVGFragmentIdentifier;
|
||||
|
||||
@ -239,7 +240,7 @@ public:
|
||||
void SetCurrentTime(float seconds);
|
||||
void DeselectAll();
|
||||
already_AddRefed<nsIDOMSVGNumber> CreateSVGNumber();
|
||||
already_AddRefed<nsIDOMSVGLength> CreateSVGLength();
|
||||
already_AddRefed<DOMSVGLength> CreateSVGLength();
|
||||
already_AddRefed<SVGAngle> CreateSVGAngle();
|
||||
already_AddRefed<nsISVGPoint> CreateSVGPoint();
|
||||
already_AddRefed<SVGMatrix> CreateSVGMatrix();
|
||||
|
@ -15,32 +15,11 @@
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
#include "nsSVGIntegrationUtils.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "DOMSVGLength.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGLength2::DOMBaseVal, mSVGElement)
|
||||
|
||||
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGLength2::DOMAnimVal, mSVGElement)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGLength2::DOMBaseVal)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGLength2::DOMBaseVal)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGLength2::DOMAnimVal)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGLength2::DOMAnimVal)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGLength2::DOMBaseVal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLength)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLength)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGLength2::DOMAnimVal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLength)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLength)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
static nsIAtom** const unitMap[] =
|
||||
{
|
||||
nullptr, /* SVG_LENGTHTYPE_UNKNOWN */
|
||||
@ -58,10 +37,6 @@ static nsIAtom** const unitMap[] =
|
||||
|
||||
static nsSVGAttrTearoffTable<nsSVGLength2, SVGAnimatedLength>
|
||||
sSVGAnimatedLengthTearoffTable;
|
||||
static nsSVGAttrTearoffTable<nsSVGLength2, nsSVGLength2::DOMBaseVal>
|
||||
sBaseSVGLengthTearoffTable;
|
||||
static nsSVGAttrTearoffTable<nsSVGLength2, nsSVGLength2::DOMAnimVal>
|
||||
sAnimSVGLengthTearoffTable;
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
@ -345,43 +320,25 @@ nsSVGLength2::NewValueSpecifiedUnits(uint16_t unitType,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGLength2::ToDOMBaseVal(nsIDOMSVGLength **aResult, nsSVGElement *aSVGElement)
|
||||
nsSVGLength2::ToDOMBaseVal(DOMSVGLength **aResult, nsSVGElement *aSVGElement)
|
||||
{
|
||||
nsRefPtr<DOMBaseVal> domBaseVal =
|
||||
sBaseSVGLengthTearoffTable.GetTearoff(this);
|
||||
if (!domBaseVal) {
|
||||
domBaseVal = new DOMBaseVal(this, aSVGElement);
|
||||
sBaseSVGLengthTearoffTable.AddTearoff(this, domBaseVal);
|
||||
}
|
||||
nsRefPtr<DOMSVGLength> domBaseVal =
|
||||
DOMSVGLength::GetTearOff(this, aSVGElement, false);
|
||||
|
||||
domBaseVal.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGLength2::DOMBaseVal::~DOMBaseVal()
|
||||
{
|
||||
sBaseSVGLengthTearoffTable.RemoveTearoff(mVal);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGLength2::ToDOMAnimVal(nsIDOMSVGLength **aResult, nsSVGElement *aSVGElement)
|
||||
nsSVGLength2::ToDOMAnimVal(DOMSVGLength **aResult, nsSVGElement *aSVGElement)
|
||||
{
|
||||
nsRefPtr<DOMAnimVal> domAnimVal =
|
||||
sAnimSVGLengthTearoffTable.GetTearoff(this);
|
||||
if (!domAnimVal) {
|
||||
domAnimVal = new DOMAnimVal(this, aSVGElement);
|
||||
sAnimSVGLengthTearoffTable.AddTearoff(this, domAnimVal);
|
||||
}
|
||||
nsRefPtr<DOMSVGLength> domAnimVal =
|
||||
DOMSVGLength::GetTearOff(this, aSVGElement, true);
|
||||
|
||||
domAnimVal.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGLength2::DOMAnimVal::~DOMAnimVal()
|
||||
{
|
||||
sAnimSVGLengthTearoffTable.RemoveTearoff(mVal);
|
||||
}
|
||||
|
||||
/* Implementation */
|
||||
|
||||
nsresult
|
||||
|
@ -21,6 +21,7 @@ class nsIFrame;
|
||||
class nsSMILValue;
|
||||
|
||||
namespace mozilla {
|
||||
class DOMSVGLength;
|
||||
namespace dom {
|
||||
class SVGAnimatedLength;
|
||||
class SVGAnimationElement;
|
||||
@ -31,6 +32,7 @@ class SVGSVGElement;
|
||||
class nsSVGLength2
|
||||
{
|
||||
friend class mozilla::dom::SVGAnimatedLength;
|
||||
friend class mozilla::DOMSVGLength;
|
||||
public:
|
||||
void Init(uint8_t aCtxType = SVGContentUtils::XY,
|
||||
uint8_t aAttrEnum = 0xff,
|
||||
@ -131,118 +133,10 @@ private:
|
||||
nsresult NewValueSpecifiedUnits(uint16_t aUnitType, float aValue,
|
||||
nsSVGElement *aSVGElement);
|
||||
nsresult ConvertToSpecifiedUnits(uint16_t aUnitType, nsSVGElement *aSVGElement);
|
||||
nsresult ToDOMBaseVal(nsIDOMSVGLength **aResult, nsSVGElement* aSVGElement);
|
||||
nsresult ToDOMAnimVal(nsIDOMSVGLength **aResult, nsSVGElement* aSVGElement);
|
||||
nsresult ToDOMBaseVal(mozilla::DOMSVGLength **aResult, nsSVGElement* aSVGElement);
|
||||
nsresult ToDOMAnimVal(mozilla::DOMSVGLength **aResult, nsSVGElement* aSVGElement);
|
||||
|
||||
public:
|
||||
struct DOMBaseVal : public nsIDOMSVGLength
|
||||
{
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(DOMBaseVal)
|
||||
|
||||
DOMBaseVal(nsSVGLength2* aVal, nsSVGElement *aSVGElement)
|
||||
: mVal(aVal), mSVGElement(aSVGElement) {}
|
||||
virtual ~DOMBaseVal();
|
||||
|
||||
nsSVGLength2* mVal; // kept alive because it belongs to mSVGElement
|
||||
nsRefPtr<nsSVGElement> mSVGElement;
|
||||
|
||||
NS_IMETHOD GetUnitType(uint16_t* aResult) MOZ_OVERRIDE
|
||||
{ *aResult = mVal->mSpecifiedUnitType; return NS_OK; }
|
||||
|
||||
NS_IMETHOD GetValue(float* aResult) MOZ_OVERRIDE
|
||||
{ *aResult = mVal->GetBaseValue(mSVGElement); return NS_OK; }
|
||||
NS_IMETHOD SetValue(float aValue) MOZ_OVERRIDE
|
||||
{
|
||||
if (!NS_finite(aValue)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
mVal->SetBaseValue(aValue, mSVGElement, true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValueInSpecifiedUnits(float* aResult) MOZ_OVERRIDE
|
||||
{ *aResult = mVal->mBaseVal; return NS_OK; }
|
||||
NS_IMETHOD SetValueInSpecifiedUnits(float aValue) MOZ_OVERRIDE
|
||||
{
|
||||
if (!NS_finite(aValue)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
mVal->SetBaseValueInSpecifiedUnits(aValue, mSVGElement, true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD SetValueAsString(const nsAString& aValue) MOZ_OVERRIDE
|
||||
{ return mVal->SetBaseValueString(aValue, mSVGElement, true); }
|
||||
NS_IMETHOD GetValueAsString(nsAString& aValue) MOZ_OVERRIDE
|
||||
{ mVal->GetBaseValueString(aValue); return NS_OK; }
|
||||
|
||||
NS_IMETHOD NewValueSpecifiedUnits(uint16_t unitType,
|
||||
float valueInSpecifiedUnits) MOZ_OVERRIDE
|
||||
{
|
||||
return mVal->NewValueSpecifiedUnits(unitType, valueInSpecifiedUnits,
|
||||
mSVGElement); }
|
||||
|
||||
NS_IMETHOD ConvertToSpecifiedUnits(uint16_t unitType) MOZ_OVERRIDE
|
||||
{ return mVal->ConvertToSpecifiedUnits(unitType, mSVGElement); }
|
||||
};
|
||||
|
||||
struct DOMAnimVal : public nsIDOMSVGLength
|
||||
{
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimVal)
|
||||
|
||||
DOMAnimVal(nsSVGLength2* aVal, nsSVGElement *aSVGElement)
|
||||
: mVal(aVal), mSVGElement(aSVGElement) {}
|
||||
virtual ~DOMAnimVal();
|
||||
|
||||
nsSVGLength2* mVal; // kept alive because it belongs to mSVGElement
|
||||
nsRefPtr<nsSVGElement> mSVGElement;
|
||||
|
||||
// Script may have modified animation parameters or timeline -- DOM getters
|
||||
// need to flush any resample requests to reflect these modifications.
|
||||
NS_IMETHOD GetUnitType(uint16_t* aResult) MOZ_OVERRIDE
|
||||
{
|
||||
mSVGElement->FlushAnimations();
|
||||
*aResult = mVal->mSpecifiedUnitType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(float* aResult) MOZ_OVERRIDE
|
||||
{
|
||||
mSVGElement->FlushAnimations();
|
||||
*aResult = mVal->GetAnimValue(mSVGElement);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD SetValue(float aValue) MOZ_OVERRIDE
|
||||
{ return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
|
||||
|
||||
NS_IMETHOD GetValueInSpecifiedUnits(float* aResult) MOZ_OVERRIDE
|
||||
{
|
||||
mSVGElement->FlushAnimations();
|
||||
*aResult = mVal->mAnimVal;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD SetValueInSpecifiedUnits(float aValue) MOZ_OVERRIDE
|
||||
{ return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
|
||||
|
||||
NS_IMETHOD SetValueAsString(const nsAString& aValue) MOZ_OVERRIDE
|
||||
{ return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
|
||||
NS_IMETHOD GetValueAsString(nsAString& aValue) MOZ_OVERRIDE
|
||||
{
|
||||
mSVGElement->FlushAnimations();
|
||||
mVal->GetAnimValueString(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD NewValueSpecifiedUnits(uint16_t unitType,
|
||||
float valueInSpecifiedUnits) MOZ_OVERRIDE
|
||||
{ return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
|
||||
|
||||
NS_IMETHOD ConvertToSpecifiedUnits(uint16_t unitType) MOZ_OVERRIDE
|
||||
{ return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
|
||||
};
|
||||
|
||||
struct SMILLength : public nsISMILAttr
|
||||
{
|
||||
public:
|
||||
|
15
content/xml/document/crashtests/994740-1.xhtml
Normal file
15
content/xml/document/crashtests/994740-1.xhtml
Normal file
@ -0,0 +1,15 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
function boom()
|
||||
{
|
||||
document.createElement("head").innerHTML = "<";
|
||||
}
|
||||
|
||||
]]>
|
||||
</script></head>
|
||||
|
||||
<body onload="boom();"></body>
|
||||
</html>
|
@ -5,3 +5,4 @@ load 382636-2.svg
|
||||
load 382636-3.xhtml
|
||||
load 382636-4.xul # Throws (bug 455856)
|
||||
load 431703-1.xhtml
|
||||
load 994740-1.xhtml
|
||||
|
@ -362,6 +362,8 @@ nsXMLFragmentContentSink::FinishFragmentParsing(nsIDOMDocumentFragment** aFragme
|
||||
mContentStack.Clear();
|
||||
mDocumentURI = nullptr;
|
||||
mDocShell = nullptr;
|
||||
mDocElement = nullptr;
|
||||
mCurrentHead = nullptr;
|
||||
if (mParseError) {
|
||||
//XXX PARSE_ERR from DOM3 Load and Save would be more appropriate
|
||||
mRoot = nullptr;
|
||||
|
@ -2336,6 +2336,76 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
|
||||
this._writeFile(manFile, JSON.stringify(aJsonManifest));
|
||||
},
|
||||
|
||||
// Add an app that is already installed to the registry.
|
||||
addInstalledApp: Task.async(function*(aApp, aManifest, aUpdateManifest) {
|
||||
if (this.getAppLocalIdByManifestURL(aApp.manifestURL) !=
|
||||
Ci.nsIScriptSecurityManager.NO_APP_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
let app = AppsUtils.cloneAppObject(aApp);
|
||||
|
||||
if (!AppsUtils.checkManifest(aManifest, app) ||
|
||||
(aUpdateManifest && !AppsUtils.checkManifest(aUpdateManifest, app))) {
|
||||
return;
|
||||
}
|
||||
|
||||
app.name = aManifest.name;
|
||||
|
||||
app.csp = aManifest.csp || "";
|
||||
|
||||
app.appStatus = AppsUtils.getAppManifestStatus(aManifest);
|
||||
|
||||
app.removable = true;
|
||||
|
||||
// Reuse the app ID if the scheme is "app".
|
||||
let uri = Services.io.newURI(app.origin, null, null);
|
||||
if (uri.scheme == "app") {
|
||||
app.id = uri.host;
|
||||
} else {
|
||||
app.id = this.makeAppId();
|
||||
}
|
||||
|
||||
app.localId = this._nextLocalId();
|
||||
|
||||
app.basePath = OS.Path.dirname(this.appsFile);
|
||||
|
||||
app.progress = 0.0;
|
||||
app.installState = "installed";
|
||||
app.downloadAvailable = false;
|
||||
app.downloading = false;
|
||||
app.readyToApplyDownload = false;
|
||||
|
||||
if (aUpdateManifest && aUpdateManifest.size) {
|
||||
app.downloadSize = aUpdateManifest.size;
|
||||
}
|
||||
|
||||
app.manifestHash = AppsUtils.computeHash(JSON.stringify(aUpdateManifest ||
|
||||
aManifest));
|
||||
|
||||
let zipFile = WebappOSUtils.getPackagePath(app);
|
||||
app.packageHash = yield this._computeFileHash(zipFile);
|
||||
|
||||
app.role = aManifest.role || "";
|
||||
|
||||
app.redirects = this.sanitizeRedirects(aManifest.redirects);
|
||||
|
||||
this.webapps[app.id] = app;
|
||||
|
||||
// Store the manifest in the manifest cache, so we don't need to re-read it
|
||||
this._manifestCache[app.id] = app.manifest;
|
||||
|
||||
// Store the manifest and the updateManifest.
|
||||
this._writeManifestFile(app.id, false, aManifest);
|
||||
if (aUpdateManifest) {
|
||||
this._writeManifestFile(app.id, true, aUpdateManifest);
|
||||
}
|
||||
|
||||
this._saveApps().then(() => {
|
||||
this.broadcastMessage("Webapps:AddApp", { id: app.id, app: app });
|
||||
});
|
||||
}),
|
||||
|
||||
confirmInstall: function(aData, aProfileDir, aInstallSuccessCallback) {
|
||||
debug("confirmInstall");
|
||||
|
||||
|
@ -84,22 +84,22 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
|
||||
MOZ_ASSERT(aWindow || XRE_GetProcessType() == GeckoProcessType_Default);
|
||||
|
||||
// We syncd the enum of channel type between nsIAudioChannelAgent.idl and
|
||||
// AudioChannelCommon.h the same.
|
||||
static_assert(static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NORMAL) ==
|
||||
AUDIO_CHANNEL_NORMAL &&
|
||||
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_CONTENT) ==
|
||||
AUDIO_CHANNEL_CONTENT &&
|
||||
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NOTIFICATION) ==
|
||||
AUDIO_CHANNEL_NOTIFICATION &&
|
||||
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_ALARM) ==
|
||||
AUDIO_CHANNEL_ALARM &&
|
||||
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_TELEPHONY) ==
|
||||
AUDIO_CHANNEL_TELEPHONY &&
|
||||
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_RINGER) ==
|
||||
AUDIO_CHANNEL_RINGER &&
|
||||
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) ==
|
||||
AUDIO_CHANNEL_PUBLICNOTIFICATION,
|
||||
"Enum of channel on nsIAudioChannelAgent.idl should be the same with AudioChannelCommon.h");
|
||||
// AudioChannelBinding.h the same.
|
||||
MOZ_ASSERT(static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_NORMAL) ==
|
||||
AudioChannel::Normal &&
|
||||
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_CONTENT) ==
|
||||
AudioChannel::Content &&
|
||||
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_NOTIFICATION) ==
|
||||
AudioChannel::Notification &&
|
||||
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_ALARM) ==
|
||||
AudioChannel::Alarm &&
|
||||
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_TELEPHONY) ==
|
||||
AudioChannel::Telephony &&
|
||||
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_RINGER) ==
|
||||
AudioChannel::Ringer &&
|
||||
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) ==
|
||||
AudioChannel::Publicnotification,
|
||||
"Enum of channel on nsIAudioChannelAgent.idl should be the same with AudioChannelBinding.h");
|
||||
|
||||
if (mAudioChannelType != AUDIO_AGENT_CHANNEL_ERROR ||
|
||||
aChannelType > AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION ||
|
||||
@ -131,7 +131,7 @@ NS_IMETHODIMP AudioChannelAgent::StartPlaying(int32_t *_retval)
|
||||
}
|
||||
|
||||
service->RegisterAudioChannelAgent(this,
|
||||
static_cast<AudioChannelType>(mAudioChannelType), mWithVideo);
|
||||
static_cast<AudioChannel>(mAudioChannelType), mWithVideo);
|
||||
*_retval = service->GetState(this, !mVisible);
|
||||
mIsRegToService = true;
|
||||
return NS_OK;
|
||||
|
@ -10,20 +10,6 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// The audio channel. Read the nsIHTMLMediaElement.idl for a description
|
||||
// about this attribute.
|
||||
enum AudioChannelType {
|
||||
AUDIO_CHANNEL_DEFAULT = -1,
|
||||
AUDIO_CHANNEL_NORMAL = 0,
|
||||
AUDIO_CHANNEL_CONTENT,
|
||||
AUDIO_CHANNEL_NOTIFICATION,
|
||||
AUDIO_CHANNEL_ALARM,
|
||||
AUDIO_CHANNEL_TELEPHONY,
|
||||
AUDIO_CHANNEL_RINGER,
|
||||
AUDIO_CHANNEL_PUBLICNOTIFICATION,
|
||||
AUDIO_CHANNEL_LAST
|
||||
};
|
||||
|
||||
enum AudioChannelState {
|
||||
AUDIO_CHANNEL_STATE_NORMAL = 0,
|
||||
AUDIO_CHANNEL_STATE_MUTED,
|
||||
|
@ -37,6 +37,18 @@ using namespace mozilla::hal;
|
||||
|
||||
StaticRefPtr<AudioChannelService> gAudioChannelService;
|
||||
|
||||
// Mappings from 'mozaudiochannel' attribute strings to an enumeration.
|
||||
static const nsAttrValue::EnumTable kMozAudioChannelAttributeTable[] = {
|
||||
{ "normal", (int16_t)AudioChannel::Normal },
|
||||
{ "content", (int16_t)AudioChannel::Content },
|
||||
{ "notification", (int16_t)AudioChannel::Notification },
|
||||
{ "alarm", (int16_t)AudioChannel::Alarm },
|
||||
{ "telephony", (int16_t)AudioChannel::Telephony },
|
||||
{ "ringer", (int16_t)AudioChannel::Ringer },
|
||||
{ "publicnotification", (int16_t)AudioChannel::Publicnotification },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
// static
|
||||
AudioChannelService*
|
||||
AudioChannelService::GetAudioChannelService()
|
||||
@ -75,8 +87,8 @@ AudioChannelService::Shutdown()
|
||||
NS_IMPL_ISUPPORTS2(AudioChannelService, nsIObserver, nsITimerCallback)
|
||||
|
||||
AudioChannelService::AudioChannelService()
|
||||
: mCurrentHigherChannel(AUDIO_CHANNEL_LAST)
|
||||
, mCurrentVisibleHigherChannel(AUDIO_CHANNEL_LAST)
|
||||
: mCurrentHigherChannel(INT32_MAX)
|
||||
, mCurrentVisibleHigherChannel(INT32_MAX)
|
||||
, mPlayableHiddenContentChildID(CONTENT_PROCESS_ID_UNKNOWN)
|
||||
, mDisabled(false)
|
||||
, mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN)
|
||||
@ -100,21 +112,19 @@ AudioChannelService::~AudioChannelService()
|
||||
|
||||
void
|
||||
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
||||
AudioChannelType aType,
|
||||
AudioChannel aChannel,
|
||||
bool aWithVideo)
|
||||
{
|
||||
if (mDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aType != AUDIO_CHANNEL_DEFAULT);
|
||||
|
||||
AudioChannelAgentData* data = new AudioChannelAgentData(aType,
|
||||
AudioChannelAgentData* data = new AudioChannelAgentData(aChannel,
|
||||
true /* aElementHidden */,
|
||||
AUDIO_CHANNEL_STATE_MUTED /* aState */,
|
||||
aWithVideo);
|
||||
mAgents.Put(aAgent, data);
|
||||
RegisterType(aType, CONTENT_PROCESS_ID_MAIN, aWithVideo);
|
||||
RegisterType(aChannel, CONTENT_PROCESS_ID_MAIN, aWithVideo);
|
||||
|
||||
// If this is the first agent for this window, we must notify the observers.
|
||||
uint32_t count = CountWindow(aAgent->Window());
|
||||
@ -130,22 +140,24 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelService::RegisterType(AudioChannelType aType, uint64_t aChildID, bool aWithVideo)
|
||||
AudioChannelService::RegisterType(AudioChannel aChannel, uint64_t aChildID,
|
||||
bool aWithVideo)
|
||||
{
|
||||
if (mDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
AudioChannelInternalType type = GetInternalType(aType, true);
|
||||
AudioChannelInternalType type = GetInternalType(aChannel, true);
|
||||
mChannelCounters[type].AppendElement(aChildID);
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
// Since there is another telephony registered, we can unregister old one
|
||||
// immediately.
|
||||
if (mDeferTelChannelTimer && aType == AUDIO_CHANNEL_TELEPHONY) {
|
||||
if (mDeferTelChannelTimer && aChannel == AudioChannel::Telephony) {
|
||||
mDeferTelChannelTimer->Cancel();
|
||||
mDeferTelChannelTimer = nullptr;
|
||||
UnregisterTypeInternal(aType, mTimerElementHidden, mTimerChildID, false);
|
||||
UnregisterTypeInternal(aChannel, mTimerElementHidden, mTimerChildID,
|
||||
false);
|
||||
}
|
||||
|
||||
if (aWithVideo) {
|
||||
@ -186,7 +198,7 @@ AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
|
||||
mAgents.RemoveAndForget(aAgent, data);
|
||||
|
||||
if (data) {
|
||||
UnregisterType(data->mType, data->mElementHidden,
|
||||
UnregisterType(data->mChannel, data->mElementHidden,
|
||||
CONTENT_PROCESS_ID_MAIN, data->mWithVideo);
|
||||
}
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@ -210,7 +222,7 @@ AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelService::UnregisterType(AudioChannelType aType,
|
||||
AudioChannelService::UnregisterType(AudioChannel aChannel,
|
||||
bool aElementHidden,
|
||||
uint64_t aChildID,
|
||||
bool aWithVideo)
|
||||
@ -223,7 +235,7 @@ AudioChannelService::UnregisterType(AudioChannelType aType,
|
||||
// 1. User can have time to remove device from his ear before music resuming.
|
||||
// 2. Give BT SCO to be disconnected before starting to connect A2DP.
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default &&
|
||||
aType == AUDIO_CHANNEL_TELEPHONY &&
|
||||
aChannel == AudioChannel::Telephony &&
|
||||
(mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].Length() +
|
||||
mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY].Length()) == 1) {
|
||||
mTimerElementHidden = aElementHidden;
|
||||
@ -233,18 +245,18 @@ AudioChannelService::UnregisterType(AudioChannelType aType,
|
||||
return;
|
||||
}
|
||||
|
||||
UnregisterTypeInternal(aType, aElementHidden, aChildID, aWithVideo);
|
||||
UnregisterTypeInternal(aChannel, aElementHidden, aChildID, aWithVideo);
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelService::UnregisterTypeInternal(AudioChannelType aType,
|
||||
AudioChannelService::UnregisterTypeInternal(AudioChannel aChannel,
|
||||
bool aElementHidden,
|
||||
uint64_t aChildID,
|
||||
bool aWithVideo)
|
||||
{
|
||||
// The array may contain multiple occurrence of this appId but
|
||||
// this should remove only the first one.
|
||||
AudioChannelInternalType type = GetInternalType(aType, aElementHidden);
|
||||
AudioChannelInternalType type = GetInternalType(aChannel, aElementHidden);
|
||||
MOZ_ASSERT(mChannelCounters[type].Contains(aChildID));
|
||||
mChannelCounters[type].RemoveElement(aChildID);
|
||||
|
||||
@ -253,7 +265,7 @@ AudioChannelService::UnregisterTypeInternal(AudioChannelType aType,
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
// No hidden content channel is playable if the original playable hidden
|
||||
// process does not need to play audio from background anymore.
|
||||
if (aType == AUDIO_CHANNEL_CONTENT &&
|
||||
if (aChannel == AudioChannel::Content &&
|
||||
mPlayableHiddenContentChildID == aChildID &&
|
||||
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].Contains(aChildID)) {
|
||||
mPlayableHiddenContentChildID = CONTENT_PROCESS_ID_UNKNOWN;
|
||||
@ -270,14 +282,14 @@ AudioChannelService::UnregisterTypeInternal(AudioChannelType aType,
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelService::UpdateChannelType(AudioChannelType aType,
|
||||
AudioChannelService::UpdateChannelType(AudioChannel aChannel,
|
||||
uint64_t aChildID,
|
||||
bool aElementHidden,
|
||||
bool aElementWasHidden)
|
||||
{
|
||||
// Calculate the new and old internal type and update the hashtable if needed.
|
||||
AudioChannelInternalType newType = GetInternalType(aType, aElementHidden);
|
||||
AudioChannelInternalType oldType = GetInternalType(aType, aElementWasHidden);
|
||||
AudioChannelInternalType newType = GetInternalType(aChannel, aElementHidden);
|
||||
AudioChannelInternalType oldType = GetInternalType(aChannel, aElementWasHidden);
|
||||
|
||||
if (newType != oldType) {
|
||||
mChannelCounters[newType].AppendElement(aChildID);
|
||||
@ -315,24 +327,26 @@ AudioChannelService::GetState(AudioChannelAgent* aAgent, bool aElementHidden)
|
||||
// Update visibility.
|
||||
data->mElementHidden = aElementHidden;
|
||||
|
||||
data->mState = GetStateInternal(data->mType, CONTENT_PROCESS_ID_MAIN,
|
||||
data->mState = GetStateInternal(data->mChannel, CONTENT_PROCESS_ID_MAIN,
|
||||
aElementHidden, oldElementHidden);
|
||||
return data->mState;
|
||||
}
|
||||
|
||||
AudioChannelState
|
||||
AudioChannelService::GetStateInternal(AudioChannelType aType, uint64_t aChildID,
|
||||
bool aElementHidden, bool aElementWasHidden)
|
||||
AudioChannelService::GetStateInternal(AudioChannel aChannel, uint64_t aChildID,
|
||||
bool aElementHidden,
|
||||
bool aElementWasHidden)
|
||||
{
|
||||
UpdateChannelType(aType, aChildID, aElementHidden, aElementWasHidden);
|
||||
UpdateChannelType(aChannel, aChildID, aElementHidden, aElementWasHidden);
|
||||
|
||||
// Calculating the new and old type and update the hashtable if needed.
|
||||
AudioChannelInternalType newType = GetInternalType(aType, aElementHidden);
|
||||
AudioChannelInternalType oldType = GetInternalType(aType, aElementWasHidden);
|
||||
AudioChannelInternalType newType = GetInternalType(aChannel, aElementHidden);
|
||||
AudioChannelInternalType oldType = GetInternalType(aChannel,
|
||||
aElementWasHidden);
|
||||
|
||||
if (newType != oldType &&
|
||||
(aType == AUDIO_CHANNEL_CONTENT ||
|
||||
(aType == AUDIO_CHANNEL_NORMAL &&
|
||||
(aChannel == AudioChannel::Content ||
|
||||
(aChannel == AudioChannel::Normal &&
|
||||
mWithVideoChildIDs.Contains(aChildID)))) {
|
||||
Notify();
|
||||
}
|
||||
@ -427,15 +441,17 @@ AudioChannelService::ProcessContentOrNormalChannelIsActive(uint64_t aChildID)
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelService::SetDefaultVolumeControlChannel(AudioChannelType aType,
|
||||
AudioChannelService::SetDefaultVolumeControlChannel(int32_t aChannel,
|
||||
bool aHidden)
|
||||
{
|
||||
SetDefaultVolumeControlChannelInternal(aType, aHidden, CONTENT_PROCESS_ID_MAIN);
|
||||
SetDefaultVolumeControlChannelInternal(aChannel, aHidden,
|
||||
CONTENT_PROCESS_ID_MAIN);
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelService::SetDefaultVolumeControlChannelInternal(
|
||||
AudioChannelType aType, bool aHidden, uint64_t aChildID)
|
||||
AudioChannelService::SetDefaultVolumeControlChannelInternal(int32_t aChannel,
|
||||
bool aHidden,
|
||||
uint64_t aChildID)
|
||||
{
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
return;
|
||||
@ -450,7 +466,13 @@ AudioChannelService::SetDefaultVolumeControlChannelInternal(
|
||||
|
||||
mDefChannelChildID = aChildID;
|
||||
nsString channelName;
|
||||
channelName.AssignASCII(ChannelName(aType));
|
||||
|
||||
if (aChannel == -1) {
|
||||
channelName.AssignASCII("unknown");
|
||||
} else {
|
||||
GetAudioChannelString(static_cast<AudioChannel>(aChannel), channelName);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(nullptr, "default-volume-channel-changed",
|
||||
@ -475,52 +497,57 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
|
||||
}
|
||||
|
||||
// Calculating the most important active channel.
|
||||
AudioChannelType higher = AUDIO_CHANNEL_DEFAULT;
|
||||
int32_t higher = -1;
|
||||
|
||||
// Top-Down in the hierarchy for visible elements
|
||||
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION;
|
||||
higher = static_cast<int32_t>(AudioChannel::Publicnotification);
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_RINGER].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_RINGER;
|
||||
higher = static_cast<int32_t>(AudioChannel::Ringer);
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_TELEPHONY;
|
||||
higher = static_cast<int32_t>(AudioChannel::Telephony);
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_ALARM].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_ALARM;
|
||||
higher = static_cast<int32_t>(AudioChannel::Alarm);
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NOTIFICATION].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_NOTIFICATION;
|
||||
higher = static_cast<int32_t>(AudioChannel::Notification);
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_CONTENT;
|
||||
higher = static_cast<int32_t>(AudioChannel::Content);
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NORMAL].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_NORMAL;
|
||||
higher = static_cast<int32_t>(AudioChannel::Normal);
|
||||
}
|
||||
|
||||
AudioChannelType visibleHigher = higher;
|
||||
int32_t visibleHigher = higher;
|
||||
|
||||
// Top-Down in the hierarchy for non-visible elements
|
||||
// And we can ignore normal channel because it can't play in the background.
|
||||
for (int i = AUDIO_CHANNEL_LAST - 1;
|
||||
i > higher && i > AUDIO_CHANNEL_NORMAL; i--) {
|
||||
if (i == AUDIO_CHANNEL_CONTENT &&
|
||||
int32_t index;
|
||||
for (index = 0; kMozAudioChannelAttributeTable[index].tag; ++index);
|
||||
|
||||
for (--index;
|
||||
kMozAudioChannelAttributeTable[index].value > higher &&
|
||||
kMozAudioChannelAttributeTable[index].value > (int16_t)AudioChannel::Normal;
|
||||
--index) {
|
||||
if (kMozAudioChannelAttributeTable[index].value == (int16_t)AudioChannel::Content &&
|
||||
mPlayableHiddenContentChildID != CONTENT_PROCESS_ID_UNKNOWN) {
|
||||
higher = static_cast<AudioChannelType>(i);
|
||||
higher = kMozAudioChannelAttributeTable[index].value;
|
||||
}
|
||||
|
||||
// Each channel type will be split to fg and bg for recording the state,
|
||||
// so here need to do a translation.
|
||||
if (!mChannelCounters[i * 2 + 1].IsEmpty()) {
|
||||
higher = static_cast<AudioChannelType>(i);
|
||||
if (!mChannelCounters[index * 2 + 1].IsEmpty()) {
|
||||
higher = kMozAudioChannelAttributeTable[index].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -529,8 +556,9 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
|
||||
mCurrentHigherChannel = higher;
|
||||
|
||||
nsString channelName;
|
||||
if (mCurrentHigherChannel != AUDIO_CHANNEL_DEFAULT) {
|
||||
channelName.AssignASCII(ChannelName(mCurrentHigherChannel));
|
||||
if (mCurrentHigherChannel != -1) {
|
||||
GetAudioChannelString(static_cast<AudioChannel>(mCurrentHigherChannel),
|
||||
channelName);
|
||||
} else {
|
||||
channelName.AssignLiteral("none");
|
||||
}
|
||||
@ -544,8 +572,9 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
|
||||
mCurrentVisibleHigherChannel = visibleHigher;
|
||||
|
||||
nsString channelName;
|
||||
if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_DEFAULT) {
|
||||
channelName.AssignASCII(ChannelName(mCurrentVisibleHigherChannel));
|
||||
if (mCurrentVisibleHigherChannel != -1) {
|
||||
GetAudioChannelString(static_cast<AudioChannel>(mCurrentVisibleHigherChannel),
|
||||
channelName);
|
||||
} else {
|
||||
channelName.AssignLiteral("none");
|
||||
}
|
||||
@ -584,7 +613,8 @@ AudioChannelService::Notify()
|
||||
NS_IMETHODIMP
|
||||
AudioChannelService::Notify(nsITimer* aTimer)
|
||||
{
|
||||
UnregisterTypeInternal(AUDIO_CHANNEL_TELEPHONY, mTimerElementHidden, mTimerChildID, false);
|
||||
UnregisterTypeInternal(AudioChannel::Telephony, mTimerElementHidden,
|
||||
mTimerChildID, false);
|
||||
mDeferTelChannelTimer = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -620,34 +650,6 @@ AudioChannelService::ChannelsActiveWithHigherPriorityThan(
|
||||
return false;
|
||||
}
|
||||
|
||||
const char*
|
||||
AudioChannelService::ChannelName(AudioChannelType aType)
|
||||
{
|
||||
static struct {
|
||||
int32_t type;
|
||||
const char* value;
|
||||
} ChannelNameTable[] = {
|
||||
{ AUDIO_CHANNEL_NORMAL, "normal" },
|
||||
{ AUDIO_CHANNEL_CONTENT, "content" },
|
||||
{ AUDIO_CHANNEL_NOTIFICATION, "notification" },
|
||||
{ AUDIO_CHANNEL_ALARM, "alarm" },
|
||||
{ AUDIO_CHANNEL_TELEPHONY, "telephony" },
|
||||
{ AUDIO_CHANNEL_RINGER, "ringer" },
|
||||
{ AUDIO_CHANNEL_PUBLICNOTIFICATION, "publicnotification" },
|
||||
{ -1, "unknown" }
|
||||
};
|
||||
|
||||
for (int i = AUDIO_CHANNEL_NORMAL; ; ++i) {
|
||||
if (ChannelNameTable[i].type == aType ||
|
||||
ChannelNameTable[i].type == -1) {
|
||||
return ChannelNameTable[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
NS_NOTREACHED("Execution should not reach here!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
|
||||
{
|
||||
@ -693,8 +695,7 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
|
||||
Notify();
|
||||
|
||||
if (mDefChannelChildID == childID) {
|
||||
SetDefaultVolumeControlChannelInternal(AUDIO_CHANNEL_DEFAULT,
|
||||
false, childID);
|
||||
SetDefaultVolumeControlChannelInternal(-1, false, childID);
|
||||
mDefChannelChildID = CONTENT_PROCESS_ID_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
@ -739,13 +740,13 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
|
||||
|
||||
int32_t index = value.toInt32();
|
||||
if (keyStr.EqualsLiteral("audio.volume.content")) {
|
||||
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_CONTENT, index);
|
||||
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Content, index);
|
||||
} else if (keyStr.EqualsLiteral("audio.volume.notification")) {
|
||||
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_NOTIFICATION, index);
|
||||
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Notification, index);
|
||||
} else if (keyStr.EqualsLiteral("audio.volume.alarm")) {
|
||||
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_ALARM, index);
|
||||
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Alarm, index);
|
||||
} else if (keyStr.EqualsLiteral("audio.volume.telephony")) {
|
||||
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_TELEPHONY, index);
|
||||
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Telephony, index);
|
||||
} else if (!keyStr.EqualsLiteral("audio.volume.bt_sco")) {
|
||||
// bt_sco is not a valid audio channel so we manipulate it in
|
||||
// AudioManager.cpp. And the others should not be used.
|
||||
@ -761,51 +762,50 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
|
||||
}
|
||||
|
||||
AudioChannelService::AudioChannelInternalType
|
||||
AudioChannelService::GetInternalType(AudioChannelType aType,
|
||||
AudioChannelService::GetInternalType(AudioChannel aChannel,
|
||||
bool aElementHidden)
|
||||
{
|
||||
switch (aType) {
|
||||
case AUDIO_CHANNEL_NORMAL:
|
||||
switch (aChannel) {
|
||||
case AudioChannel::Normal:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_NORMAL_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_NORMAL;
|
||||
|
||||
case AUDIO_CHANNEL_CONTENT:
|
||||
case AudioChannel::Content:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_CONTENT_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_CONTENT;
|
||||
|
||||
case AUDIO_CHANNEL_NOTIFICATION:
|
||||
case AudioChannel::Notification:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_NOTIFICATION;
|
||||
|
||||
case AUDIO_CHANNEL_ALARM:
|
||||
case AudioChannel::Alarm:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_ALARM_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_ALARM;
|
||||
|
||||
case AUDIO_CHANNEL_TELEPHONY:
|
||||
case AudioChannel::Telephony:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_TELEPHONY;
|
||||
|
||||
case AUDIO_CHANNEL_RINGER:
|
||||
case AudioChannel::Ringer:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_RINGER_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_RINGER;
|
||||
|
||||
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
|
||||
case AudioChannel::Publicnotification:
|
||||
return aElementHidden
|
||||
? AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN
|
||||
: AUDIO_CHANNEL_INT_PUBLICNOTIFICATION;
|
||||
|
||||
case AUDIO_CHANNEL_LAST:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
MOZ_CRASH("unexpected audio channel type");
|
||||
MOZ_CRASH("unexpected audio channel");
|
||||
}
|
||||
|
||||
struct RefreshAgentsVolumeData
|
||||
@ -883,21 +883,23 @@ AudioChannelService::CountWindow(nsIDOMWindow* aWindow)
|
||||
return data.mCount;
|
||||
}
|
||||
|
||||
// Mappings from 'mozaudiochannel' attribute strings to an enumeration.
|
||||
static const struct AudioChannelTable
|
||||
/* static */ const nsAttrValue::EnumTable*
|
||||
AudioChannelService::GetAudioChannelTable()
|
||||
{
|
||||
const char* string;
|
||||
AudioChannel value;
|
||||
} kMozAudioChannelAttributeTable[] = {
|
||||
{ "normal", AudioChannel::Normal },
|
||||
{ "content", AudioChannel::Content },
|
||||
{ "notification", AudioChannel::Notification },
|
||||
{ "alarm", AudioChannel::Alarm },
|
||||
{ "telephony", AudioChannel::Telephony },
|
||||
{ "ringer", AudioChannel::Ringer },
|
||||
{ "publicnotification", AudioChannel::Publicnotification },
|
||||
{ nullptr }
|
||||
};
|
||||
return kMozAudioChannelAttributeTable;
|
||||
}
|
||||
|
||||
/* static */ AudioChannel
|
||||
AudioChannelService::GetAudioChannel(const nsAString& aChannel)
|
||||
{
|
||||
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
|
||||
if (aChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
|
||||
return static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
return AudioChannel::Normal;
|
||||
}
|
||||
|
||||
/* static */ AudioChannel
|
||||
AudioChannelService::GetDefaultAudioChannel()
|
||||
@ -907,9 +909,9 @@ AudioChannelService::GetDefaultAudioChannel()
|
||||
return AudioChannel::Normal;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].string; ++i) {
|
||||
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].string)) {
|
||||
return kMozAudioChannelAttributeTable[i].value;
|
||||
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
|
||||
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
|
||||
return static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -917,14 +919,29 @@ AudioChannelService::GetDefaultAudioChannel()
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AudioChannelService::GetDefaultAudioChannelString(nsString& aString)
|
||||
AudioChannelService::GetAudioChannelString(AudioChannel aChannel,
|
||||
nsAString& aString)
|
||||
{
|
||||
aString.AssignASCII("normal");
|
||||
|
||||
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
|
||||
if (aChannel ==
|
||||
static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value)) {
|
||||
aString.AssignASCII(kMozAudioChannelAttributeTable[i].tag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AudioChannelService::GetDefaultAudioChannelString(nsAString& aString)
|
||||
{
|
||||
aString.AssignASCII("normal");
|
||||
|
||||
nsString audioChannel = Preferences::GetString("media.defaultAudioChannel");
|
||||
if (!audioChannel.IsEmpty()) {
|
||||
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].string; ++i) {
|
||||
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].string)) {
|
||||
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
|
||||
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
|
||||
aString = audioChannel;
|
||||
break;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "AudioChannelCommon.h"
|
||||
#include "AudioChannelAgent.h"
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
|
||||
@ -48,10 +49,10 @@ public:
|
||||
|
||||
/**
|
||||
* Any audio channel agent that starts playing should register itself to
|
||||
* this service, sharing the AudioChannelType.
|
||||
* this service, sharing the AudioChannel.
|
||||
*/
|
||||
virtual void RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
||||
AudioChannelType aType,
|
||||
AudioChannel aChannel,
|
||||
bool aWithVideo);
|
||||
|
||||
/**
|
||||
@ -81,9 +82,11 @@ public:
|
||||
|
||||
/***
|
||||
* AudioChannelManager calls this function to notify the default channel used
|
||||
* to adjust volume when there is no any active channel.
|
||||
* to adjust volume when there is no any active channel. if aChannel is -1,
|
||||
* the default audio channel will be used. Otherwise aChannel is casted to
|
||||
* AudioChannel enum.
|
||||
*/
|
||||
virtual void SetDefaultVolumeControlChannel(AudioChannelType aType,
|
||||
virtual void SetDefaultVolumeControlChannel(int32_t aChannel,
|
||||
bool aHidden);
|
||||
|
||||
bool AnyAudioChannelIsActive();
|
||||
@ -104,8 +107,11 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
static const nsAttrValue::EnumTable* GetAudioChannelTable();
|
||||
static AudioChannel GetAudioChannel(const nsAString& aString);
|
||||
static AudioChannel GetDefaultAudioChannel();
|
||||
static void GetDefaultAudioChannelString(nsString& aString);
|
||||
static void GetAudioChannelString(AudioChannel aChannel, nsAString& aString);
|
||||
static void GetDefaultAudioChannelString(nsAString& aString);
|
||||
|
||||
protected:
|
||||
void Notify();
|
||||
@ -117,22 +123,22 @@ protected:
|
||||
void SendAudioChannelChangedNotification(uint64_t aChildID);
|
||||
|
||||
/* Register/Unregister IPC types: */
|
||||
void RegisterType(AudioChannelType aType, uint64_t aChildID, bool aWithVideo);
|
||||
void UnregisterType(AudioChannelType aType, bool aElementHidden,
|
||||
void RegisterType(AudioChannel aChannel, uint64_t aChildID, bool aWithVideo);
|
||||
void UnregisterType(AudioChannel aChannel, bool aElementHidden,
|
||||
uint64_t aChildID, bool aWithVideo);
|
||||
void UnregisterTypeInternal(AudioChannelType aType, bool aElementHidden,
|
||||
void UnregisterTypeInternal(AudioChannel aChannel, bool aElementHidden,
|
||||
uint64_t aChildID, bool aWithVideo);
|
||||
|
||||
AudioChannelState GetStateInternal(AudioChannelType aType, uint64_t aChildID,
|
||||
AudioChannelState GetStateInternal(AudioChannel aChannel, uint64_t aChildID,
|
||||
bool aElementHidden,
|
||||
bool aElementWasHidden);
|
||||
|
||||
/* Update the internal type value following the visibility changes */
|
||||
void UpdateChannelType(AudioChannelType aType, uint64_t aChildID,
|
||||
void UpdateChannelType(AudioChannel aChannel, uint64_t aChildID,
|
||||
bool aElementHidden, bool aElementWasHidden);
|
||||
|
||||
/* Send the default-volume-channel-changed notification */
|
||||
void SetDefaultVolumeControlChannelInternal(AudioChannelType aType,
|
||||
void SetDefaultVolumeControlChannelInternal(int32_t aChannel,
|
||||
bool aHidden, uint64_t aChildID);
|
||||
|
||||
AudioChannelService();
|
||||
@ -161,24 +167,22 @@ protected:
|
||||
bool CheckVolumeFadedCondition(AudioChannelInternalType aType,
|
||||
bool aElementHidden);
|
||||
|
||||
const char* ChannelName(AudioChannelType aType);
|
||||
|
||||
AudioChannelInternalType GetInternalType(AudioChannelType aType,
|
||||
AudioChannelInternalType GetInternalType(AudioChannel aChannel,
|
||||
bool aElementHidden);
|
||||
|
||||
class AudioChannelAgentData {
|
||||
public:
|
||||
AudioChannelAgentData(AudioChannelType aType,
|
||||
AudioChannelAgentData(AudioChannel aChannel,
|
||||
bool aElementHidden,
|
||||
AudioChannelState aState,
|
||||
bool aWithVideo)
|
||||
: mType(aType)
|
||||
: mChannel(aChannel)
|
||||
, mElementHidden(aElementHidden)
|
||||
, mState(aState)
|
||||
, mWithVideo(aWithVideo)
|
||||
{}
|
||||
|
||||
AudioChannelType mType;
|
||||
AudioChannel mChannel;
|
||||
bool mElementHidden;
|
||||
AudioChannelState mState;
|
||||
const bool mWithVideo;
|
||||
@ -207,8 +211,8 @@ protected:
|
||||
#endif
|
||||
nsTArray<uint64_t> mChannelCounters[AUDIO_CHANNEL_INT_LAST];
|
||||
|
||||
AudioChannelType mCurrentHigherChannel;
|
||||
AudioChannelType mCurrentVisibleHigherChannel;
|
||||
int32_t mCurrentHigherChannel;
|
||||
int32_t mCurrentVisibleHigherChannel;
|
||||
|
||||
nsTArray<uint64_t> mWithVideoChildIDs;
|
||||
|
||||
|
@ -72,13 +72,15 @@ AudioChannelServiceChild::GetState(AudioChannelAgent* aAgent, bool aElementHidde
|
||||
AudioChannelState state = AUDIO_CHANNEL_STATE_MUTED;
|
||||
bool oldElementHidden = data->mElementHidden;
|
||||
|
||||
UpdateChannelType(data->mType, CONTENT_PROCESS_ID_MAIN, aElementHidden, oldElementHidden);
|
||||
UpdateChannelType(data->mChannel, CONTENT_PROCESS_ID_MAIN, aElementHidden,
|
||||
oldElementHidden);
|
||||
|
||||
// Update visibility.
|
||||
data->mElementHidden = aElementHidden;
|
||||
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
cc->SendAudioChannelGetState(data->mType, aElementHidden, oldElementHidden, &state);
|
||||
cc->SendAudioChannelGetState(data->mChannel, aElementHidden, oldElementHidden,
|
||||
&state);
|
||||
data->mState = state;
|
||||
cc->SendAudioChannelChangedNotification();
|
||||
|
||||
@ -87,14 +89,12 @@ AudioChannelServiceChild::GetState(AudioChannelAgent* aAgent, bool aElementHidde
|
||||
|
||||
void
|
||||
AudioChannelServiceChild::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
||||
AudioChannelType aType,
|
||||
AudioChannel aChannel,
|
||||
bool aWithVideo)
|
||||
{
|
||||
MOZ_ASSERT(aType != AUDIO_CHANNEL_DEFAULT);
|
||||
AudioChannelService::RegisterAudioChannelAgent(aAgent, aChannel, aWithVideo);
|
||||
|
||||
AudioChannelService::RegisterAudioChannelAgent(aAgent, aType, aWithVideo);
|
||||
|
||||
ContentChild::GetSingleton()->SendAudioChannelRegisterType(aType, aWithVideo);
|
||||
ContentChild::GetSingleton()->SendAudioChannelRegisterType(aChannel, aWithVideo);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
@ -117,7 +117,7 @@ AudioChannelServiceChild::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
|
||||
AudioChannelService::UnregisterAudioChannelAgent(aAgent);
|
||||
|
||||
ContentChild::GetSingleton()->SendAudioChannelUnregisterType(
|
||||
data.mType, data.mElementHidden, data.mWithVideo);
|
||||
data.mChannel, data.mElementHidden, data.mWithVideo);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
@ -132,11 +132,11 @@ AudioChannelServiceChild::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelServiceChild::SetDefaultVolumeControlChannel(
|
||||
AudioChannelType aType, bool aHidden)
|
||||
AudioChannelServiceChild::SetDefaultVolumeControlChannel(int32_t aChannel,
|
||||
bool aHidden)
|
||||
{
|
||||
ContentChild *cc = ContentChild::GetSingleton();
|
||||
if (cc) {
|
||||
cc->SendAudioChannelChangeDefVolChannel(aType, aHidden);
|
||||
cc->SendAudioChannelChangeDefVolChannel(aChannel, aHidden);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
static void Shutdown();
|
||||
|
||||
virtual void RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
||||
AudioChannelType aType,
|
||||
AudioChannel aChannel,
|
||||
bool aWithVideo);
|
||||
virtual void UnregisterAudioChannelAgent(AudioChannelAgent* aAgent);
|
||||
|
||||
@ -42,7 +42,8 @@ public:
|
||||
virtual AudioChannelState GetState(AudioChannelAgent* aAgent,
|
||||
bool aElementHidden);
|
||||
|
||||
virtual void SetDefaultVolumeControlChannel(AudioChannelType aType, bool aHidden);
|
||||
virtual void SetDefaultVolumeControlChannel(int32_t aChannel,
|
||||
bool aHidden);
|
||||
|
||||
protected:
|
||||
AudioChannelServiceChild();
|
||||
|
@ -31,8 +31,8 @@ class Agent : public nsIAudioChannelAgentCallback,
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
Agent(AudioChannelType aType)
|
||||
: mType(aType)
|
||||
Agent(AudioChannel aChannel)
|
||||
: mChannel(aChannel)
|
||||
, mWaitCallback(false)
|
||||
, mRegistered(false)
|
||||
, mCanPlay(AUDIO_CHANNEL_STATE_MUTED)
|
||||
@ -51,10 +51,12 @@ public:
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (video) {
|
||||
rv = mAgent->InitWithVideo(nullptr, mType, this, true);
|
||||
rv = mAgent->InitWithVideo(nullptr, static_cast<int32_t>(mChannel),
|
||||
this, true);
|
||||
}
|
||||
else {
|
||||
rv = mAgent->InitWithWeakCallback(nullptr, mType, this);
|
||||
rv = mAgent->InitWithWeakCallback(nullptr, static_cast<int32_t>(mChannel),
|
||||
this);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -127,7 +129,7 @@ public:
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAudioChannelAgent> mAgent;
|
||||
AudioChannelType mType;
|
||||
AudioChannel mChannel;
|
||||
bool mWaitCallback;
|
||||
bool mRegistered;
|
||||
AudioChannelState mCanPlay;
|
||||
@ -139,7 +141,7 @@ NS_IMPL_ISUPPORTS2(Agent, nsIAudioChannelAgentCallback,
|
||||
nsresult
|
||||
TestDoubleStartPlaying()
|
||||
{
|
||||
nsRefPtr<Agent> agent = new Agent(AUDIO_CHANNEL_NORMAL);
|
||||
nsRefPtr<Agent> agent = new Agent(AudioChannel::Normal);
|
||||
|
||||
nsresult rv = agent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -158,7 +160,7 @@ TestDoubleStartPlaying()
|
||||
nsresult
|
||||
TestOneNormalChannel()
|
||||
{
|
||||
nsRefPtr<Agent> agent = new Agent(AUDIO_CHANNEL_NORMAL);
|
||||
nsRefPtr<Agent> agent = new Agent(AudioChannel::Normal);
|
||||
nsresult rv = agent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -182,11 +184,11 @@ TestOneNormalChannel()
|
||||
nsresult
|
||||
TestTwoNormalChannels()
|
||||
{
|
||||
nsRefPtr<Agent> agent1 = new Agent(AUDIO_CHANNEL_NORMAL);
|
||||
nsRefPtr<Agent> agent1 = new Agent(AudioChannel::Normal);
|
||||
nsresult rv = agent1->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> agent2 = new Agent(AUDIO_CHANNEL_NORMAL);
|
||||
nsRefPtr<Agent> agent2 = new Agent(AudioChannel::Normal);
|
||||
rv = agent2->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -223,11 +225,11 @@ TestTwoNormalChannels()
|
||||
nsresult
|
||||
TestContentChannels()
|
||||
{
|
||||
nsRefPtr<Agent> agent1 = new Agent(AUDIO_CHANNEL_CONTENT);
|
||||
nsRefPtr<Agent> agent1 = new Agent(AudioChannel::Content);
|
||||
nsresult rv = agent1->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> agent2 = new Agent(AUDIO_CHANNEL_CONTENT);
|
||||
nsRefPtr<Agent> agent2 = new Agent(AudioChannel::Content);
|
||||
rv = agent2->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -308,15 +310,15 @@ TestContentChannels()
|
||||
nsresult
|
||||
TestFadedState()
|
||||
{
|
||||
nsRefPtr<Agent> normalAgent = new Agent(AUDIO_CHANNEL_NORMAL);
|
||||
nsRefPtr<Agent> normalAgent = new Agent(AudioChannel::Normal);
|
||||
nsresult rv = normalAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> contentAgent = new Agent(AUDIO_CHANNEL_CONTENT);
|
||||
nsRefPtr<Agent> contentAgent = new Agent(AudioChannel::Content);
|
||||
rv = contentAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> notificationAgent = new Agent(AUDIO_CHANNEL_NOTIFICATION);
|
||||
nsRefPtr<Agent> notificationAgent = new Agent(AudioChannel::Notification);
|
||||
rv = notificationAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -387,32 +389,32 @@ TestFadedState()
|
||||
nsresult
|
||||
TestPriorities()
|
||||
{
|
||||
nsRefPtr<Agent> normalAgent = new Agent(AUDIO_CHANNEL_NORMAL);
|
||||
nsRefPtr<Agent> normalAgent = new Agent(AudioChannel::Normal);
|
||||
nsresult rv = normalAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> contentAgent = new Agent(AUDIO_CHANNEL_CONTENT);
|
||||
nsRefPtr<Agent> contentAgent = new Agent(AudioChannel::Content);
|
||||
rv = contentAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> notificationAgent = new Agent(AUDIO_CHANNEL_NOTIFICATION);
|
||||
nsRefPtr<Agent> notificationAgent = new Agent(AudioChannel::Notification);
|
||||
rv = notificationAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> alarmAgent = new Agent(AUDIO_CHANNEL_ALARM);
|
||||
nsRefPtr<Agent> alarmAgent = new Agent(AudioChannel::Alarm);
|
||||
rv = alarmAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> telephonyAgent = new Agent(AUDIO_CHANNEL_TELEPHONY);
|
||||
nsRefPtr<Agent> telephonyAgent = new Agent(AudioChannel::Telephony);
|
||||
rv = telephonyAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> ringerAgent = new Agent(AUDIO_CHANNEL_RINGER);
|
||||
nsRefPtr<Agent> ringerAgent = new Agent(AudioChannel::Ringer);
|
||||
rv = ringerAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> pNotificationAgent =
|
||||
new Agent(AUDIO_CHANNEL_PUBLICNOTIFICATION);
|
||||
new Agent(AudioChannel::Publicnotification);
|
||||
rv = pNotificationAgent->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -544,11 +546,11 @@ TestPriorities()
|
||||
nsresult
|
||||
TestOneVideoNormalChannel()
|
||||
{
|
||||
nsRefPtr<Agent> agent1 = new Agent(AUDIO_CHANNEL_NORMAL);
|
||||
nsRefPtr<Agent> agent1 = new Agent(AudioChannel::Normal);
|
||||
nsresult rv = agent1->Init(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<Agent> agent2 = new Agent(AUDIO_CHANNEL_CONTENT);
|
||||
nsRefPtr<Agent> agent2 = new Agent(AudioChannel::Content);
|
||||
rv = agent2->Init(false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -649,11 +651,11 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Channel type with AUDIO_CHANNEL_TELEPHONY cannot be unregistered until the
|
||||
// Channel type with AudioChannel::Telephony cannot be unregistered until the
|
||||
// main thread has chances to process 1500 millisecond timer. In order to
|
||||
// skip ambiguous return value of ChannelsActiveWithHigherPriorityThan(), new
|
||||
// test cases are added before any test case that registers the channel type
|
||||
// with AUDIO_CHANNEL_TELEPHONY channel.
|
||||
// with AudioChannel::Telephony channel.
|
||||
if (NS_FAILED(TestOneVideoNormalChannel())) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -8,5 +8,8 @@ CPP_UNIT_TESTS += [
|
||||
'TestAudioChannelService.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
DEFINES['NOMINMAX'] = True
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
|
||||
|
@ -814,15 +814,12 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
|
||||
language == nsIProgrammingLanguage::JAVASCRIPT2) {
|
||||
ConsoleStackEntry& data = *callData->mStack.AppendElement();
|
||||
|
||||
nsCString string;
|
||||
rv = stack->GetFilename(string);
|
||||
rv = stack->GetFilename(data.mFilename);
|
||||
if (NS_FAILED(rv)) {
|
||||
Throw(aCx, rv);
|
||||
return;
|
||||
}
|
||||
|
||||
CopyUTF8toUTF16(string, data.mFilename);
|
||||
|
||||
int32_t lineNumber;
|
||||
rv = stack->GetLineNumber(&lineNumber);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -832,14 +829,12 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
|
||||
|
||||
data.mLineNumber = lineNumber;
|
||||
|
||||
rv = stack->GetName(string);
|
||||
rv = stack->GetName(data.mFunctionName);
|
||||
if (NS_FAILED(rv)) {
|
||||
Throw(aCx, rv);
|
||||
return;
|
||||
}
|
||||
|
||||
CopyUTF8toUTF16(string, data.mFunctionName);
|
||||
|
||||
data.mLanguage = language;
|
||||
}
|
||||
|
||||
|
@ -320,9 +320,9 @@ Exception::GetName(nsACString& aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AUTF8String filename; */
|
||||
/* readonly attribute AString filename; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetFilename(nsACString& aFilename)
|
||||
Exception::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@ -509,18 +509,6 @@ Exception::GetName(nsString& retval)
|
||||
CopyUTF8toUTF16(str, retval);
|
||||
}
|
||||
|
||||
void
|
||||
Exception::GetFilename(nsString& retval)
|
||||
{
|
||||
nsCString str;
|
||||
#ifdef DEBUG
|
||||
DebugOnly<nsresult> rv =
|
||||
#endif
|
||||
GetFilename(str);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
CopyUTF8toUTF16(str, retval);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Exception::LineNumber() const
|
||||
{
|
||||
@ -622,7 +610,7 @@ DOMException::ToString(nsACString& aReturn)
|
||||
nsAutoCString location;
|
||||
|
||||
if (mInner) {
|
||||
nsCString filename;
|
||||
nsString filename;
|
||||
mInner->GetFilename(filename);
|
||||
|
||||
if (!filename.IsEmpty()) {
|
||||
@ -630,7 +618,9 @@ DOMException::ToString(nsACString& aReturn)
|
||||
|
||||
mInner->GetLineNumber(&line_nr);
|
||||
|
||||
char *temp = PR_smprintf("%s Line: %d", filename.get(), line_nr);
|
||||
char *temp = PR_smprintf("%s Line: %d",
|
||||
NS_ConvertUTF16toUTF8(filename).get(),
|
||||
line_nr);
|
||||
if (temp) {
|
||||
location.Assign(temp);
|
||||
PR_smprintf_free(temp);
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
void GetName(nsString& retval);
|
||||
|
||||
void GetFilename(nsString& retval);
|
||||
// The XPCOM GetFilename does the right thing.
|
||||
|
||||
uint32_t LineNumber() const;
|
||||
|
||||
@ -100,7 +100,7 @@ protected:
|
||||
nsCString mName;
|
||||
nsCOMPtr<nsIStackFrame> mLocation;
|
||||
nsCOMPtr<nsISupports> mData;
|
||||
nsCString mFilename;
|
||||
nsString mFilename;
|
||||
int mLineNumber;
|
||||
nsCOMPtr<nsIException> mInner;
|
||||
bool mInitialized;
|
||||
|
@ -21,7 +21,7 @@ load 473284.xul
|
||||
load 499006-1.html
|
||||
load 499006-2.html
|
||||
load 502617.html
|
||||
asserts(1-2) load 504224.html # bug 564098
|
||||
load 504224.html
|
||||
load 603531.html
|
||||
load 601247.html
|
||||
load 609560-1.xhtml
|
||||
|
@ -85,7 +85,6 @@
|
||||
|
||||
// CSS related includes
|
||||
#include "nsCSSRules.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMCSSRule.h"
|
||||
#include "nsICSSRuleList.h"
|
||||
#include "nsAutoPtr.h"
|
||||
@ -122,7 +121,6 @@
|
||||
#include "nsIDOMXPathNSResolver.h"
|
||||
#include "nsIDOMXPathResult.h"
|
||||
|
||||
#include "nsIDOMSVGLength.h"
|
||||
#include "nsIDOMSVGNumber.h"
|
||||
|
||||
// Storage includes
|
||||
@ -319,8 +317,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSRuleList, nsCSSRuleListSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(StyleSheetList, nsStyleSheetListSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSStyleSheet, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -365,8 +361,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
// other SVG classes
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -948,10 +942,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(StyleSheetList, nsIDOMStyleSheetList)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSStyleSheet, nsIDOMCSSStyleSheet)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleSheet)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
@ -1018,10 +1008,6 @@ nsDOMClassInfo::Init()
|
||||
// The SVG document
|
||||
|
||||
// other SVG classes
|
||||
DOM_CLASSINFO_MAP_BEGIN(SVGLength, nsIDOMSVGLength)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLength)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(SVGNumber, nsIDOMSVGNumber)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumber)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
@ -3680,19 +3666,6 @@ nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
}
|
||||
|
||||
|
||||
// StyleSheetList helper
|
||||
|
||||
nsISupports*
|
||||
nsStyleSheetListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
|
||||
nsWrapperCache **aCache, nsresult *rv)
|
||||
{
|
||||
nsIDOMStyleSheetList* list = static_cast<nsIDOMStyleSheetList*>(aNative);
|
||||
nsCOMPtr<nsIDOMStyleSheet> sheet;
|
||||
list->Item(aIndex, getter_AddRefs(sheet));
|
||||
return sheet;
|
||||
}
|
||||
|
||||
|
||||
// CSSRuleList scriptable helper
|
||||
|
||||
nsISupports*
|
||||
|
@ -368,30 +368,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// StyleSheetList helper
|
||||
|
||||
class nsStyleSheetListSH : public nsArraySH
|
||||
{
|
||||
protected:
|
||||
nsStyleSheetListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsStyleSheetListSH()
|
||||
{
|
||||
}
|
||||
|
||||
virtual nsISupports* GetItemAt(nsISupports *aNative, uint32_t aIndex,
|
||||
nsWrapperCache **aCache, nsresult *aResult) MOZ_OVERRIDE;
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsStyleSheetListSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// CSSRuleList helper
|
||||
|
||||
class nsCSSRuleListSH : public nsArraySH
|
||||
|
@ -16,7 +16,6 @@ DOMCI_CLASS(CSSImportRule)
|
||||
DOMCI_CLASS(CSSMediaRule)
|
||||
DOMCI_CLASS(CSSNameSpaceRule)
|
||||
DOMCI_CLASS(CSSRuleList)
|
||||
DOMCI_CLASS(StyleSheetList)
|
||||
DOMCI_CLASS(CSSStyleSheet)
|
||||
|
||||
// XUL classes
|
||||
@ -46,7 +45,6 @@ DOMCI_CLASS(CSSMozDocumentRule)
|
||||
DOMCI_CLASS(CSSSupportsRule)
|
||||
|
||||
// other SVG classes
|
||||
DOMCI_CLASS(SVGLength)
|
||||
DOMCI_CLASS(SVGNumber)
|
||||
|
||||
// WindowUtils
|
||||
|
@ -434,12 +434,6 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
DisplayPortMarginsPropertyData* currentData =
|
||||
static_cast<DisplayPortMarginsPropertyData*>(content->GetProperty(nsGkAtoms::DisplayPortMargins));
|
||||
if (currentData && currentData->mPriority > aPriority) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Note order change of arguments between our function signature and
|
||||
// LayerMargin constructor.
|
||||
LayerMargin displayportMargins(aTopMargin,
|
||||
@ -447,21 +441,8 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
|
||||
aBottomMargin,
|
||||
aLeftMargin);
|
||||
|
||||
content->SetProperty(nsGkAtoms::DisplayPortMargins,
|
||||
new DisplayPortMarginsPropertyData(displayportMargins, aAlignmentX, aAlignmentY, aPriority),
|
||||
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
|
||||
|
||||
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
|
||||
if (rootScrollFrame && content == rootScrollFrame->GetContent()) {
|
||||
// We are setting a root displayport for a document.
|
||||
// The pres shell needs a special flag set.
|
||||
presShell->SetIgnoreViewportScrolling(true);
|
||||
}
|
||||
|
||||
nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
rootFrame->SchedulePaint();
|
||||
}
|
||||
nsLayoutUtils::SetDisplayPortMargins(content, presShell, displayportMargins,
|
||||
aAlignmentX, aAlignmentY, aPriority);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -497,8 +478,7 @@ nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
content->SetProperty(nsGkAtoms::DisplayPortBase, new nsRect(aX, aY, aWidth, aHeight),
|
||||
nsINode::DeleteProperty<nsRect>);
|
||||
nsLayoutUtils::SetDisplayPortBase(content, nsRect(aX, aY, aWidth, aHeight));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -111,21 +111,25 @@ public:
|
||||
return !mImpl.empty();
|
||||
}
|
||||
|
||||
void Construct()
|
||||
// Return InternalType here so we can work with it usefully.
|
||||
InternalType& Construct()
|
||||
{
|
||||
mImpl.construct();
|
||||
return mImpl.ref();
|
||||
}
|
||||
|
||||
template <class T1>
|
||||
void Construct(const T1 &t1)
|
||||
InternalType& Construct(const T1 &t1)
|
||||
{
|
||||
mImpl.construct(t1);
|
||||
return mImpl.ref();
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
void Construct(const T1 &t1, const T2 &t2)
|
||||
InternalType& Construct(const T1 &t1, const T2 &t2)
|
||||
{
|
||||
mImpl.construct(t1, t2);
|
||||
return mImpl.ref();
|
||||
}
|
||||
|
||||
void Reset()
|
||||
@ -228,18 +232,18 @@ public:
|
||||
{}
|
||||
|
||||
// Don't allow us to have an uninitialized JSObject*
|
||||
void Construct()
|
||||
JSObject*& Construct()
|
||||
{
|
||||
// The Android compiler sucks and thinks we're trying to construct
|
||||
// a JSObject* from an int if we don't cast here. :(
|
||||
Optional_base<JSObject*, JSObject*>::Construct(
|
||||
return Optional_base<JSObject*, JSObject*>::Construct(
|
||||
static_cast<JSObject*>(nullptr));
|
||||
}
|
||||
|
||||
template <class T1>
|
||||
void Construct(const T1& t1)
|
||||
JSObject*& Construct(const T1& t1)
|
||||
{
|
||||
Optional_base<JSObject*, JSObject*>::Construct(t1);
|
||||
return Optional_base<JSObject*, JSObject*>::Construct(t1);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1055,6 +1055,11 @@ DOMInterfaces = {
|
||||
'concrete': False,
|
||||
},
|
||||
|
||||
'SVGLength': {
|
||||
'nativeType': 'mozilla::DOMSVGLength',
|
||||
'headerFile': 'DOMSVGLength.h'
|
||||
},
|
||||
|
||||
'SVGLengthList': {
|
||||
'nativeType': 'mozilla::DOMSVGLengthList',
|
||||
'headerFile': 'DOMSVGLengthList.h'
|
||||
@ -1915,8 +1920,6 @@ addExternalIface('Principal', nativeType='nsIPrincipal',
|
||||
headerFile='nsIPrincipal.h', notflattened=True)
|
||||
addExternalIface('StackFrame', nativeType='nsIStackFrame',
|
||||
headerFile='nsIException.h', notflattened=True)
|
||||
addExternalIface('StyleSheetList')
|
||||
addExternalIface('SVGLength')
|
||||
addExternalIface('SVGNumber')
|
||||
addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
|
||||
notflattened=True)
|
||||
|
@ -302,8 +302,8 @@ private:
|
||||
nsCOMPtr<nsIStackFrame> mCaller;
|
||||
|
||||
// Cached values
|
||||
nsCString mFilename;
|
||||
nsCString mFunname;
|
||||
nsString mFilename;
|
||||
nsString mFunname;
|
||||
int32_t mLineno;
|
||||
uint32_t mLanguage;
|
||||
|
||||
@ -374,13 +374,13 @@ NS_IMETHODIMP JSStackFrame::GetLanguageName(nsACString& aLanguageName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string filename; */
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(nsACString& aFilename)
|
||||
/* readonly attribute AString filename; */
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
if (!mFilenameInitialized) {
|
||||
JS::FrameDescription& desc = mStackDescription->FrameAt(mIndex);
|
||||
if (const char *filename = desc.filename()) {
|
||||
mFilename.Assign(filename);
|
||||
CopyUTF8toUTF16(filename, mFilename);
|
||||
}
|
||||
mFilenameInitialized = true;
|
||||
}
|
||||
@ -395,13 +395,15 @@ NS_IMETHODIMP JSStackFrame::GetFilename(nsACString& aFilename)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP JSStackFrame::GetName(nsACString& aFunction)
|
||||
/* readonly attribute AString name; */
|
||||
NS_IMETHODIMP JSStackFrame::GetName(nsAString& aFunction)
|
||||
{
|
||||
if (!mFunnameInitialized) {
|
||||
JS::FrameDescription& desc = mStackDescription->FrameAt(mIndex);
|
||||
if (JSFlatString *name = desc.funDisplayName()) {
|
||||
CopyUTF16toUTF8(JS_GetFlatStringChars(name), mFunname);
|
||||
mFunname.Assign(JS_GetFlatStringChars(name),
|
||||
// XXXbz Can't JS_GetStringLength on JSFlatString!
|
||||
JS_GetStringLength(JS_FORGET_STRING_FLATNESS(name)));
|
||||
}
|
||||
mFunnameInitialized = true;
|
||||
}
|
||||
@ -460,24 +462,26 @@ NS_IMETHODIMP JSStackFrame::ToString(nsACString& _retval)
|
||||
|
||||
const char* frametype = IsJSFrame() ? "JS" : "native";
|
||||
|
||||
nsCString filename;
|
||||
nsString filename;
|
||||
nsresult rv = GetFilename(filename);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (filename.IsEmpty()) {
|
||||
filename.AssignASCII("<unknown filename>");
|
||||
filename.AssignLiteral("<unknown filename>");
|
||||
}
|
||||
|
||||
nsCString funname;
|
||||
nsString funname;
|
||||
rv = GetName(funname);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (funname.IsEmpty()) {
|
||||
funname.AssignASCII("<TOP_LEVEL>");
|
||||
funname.AssignLiteral("<TOP_LEVEL>");
|
||||
}
|
||||
static const char format[] = "%s frame :: %s :: %s :: line %d";
|
||||
_retval.AppendPrintf(format, frametype, filename.get(),
|
||||
funname.get(), GetLineno());
|
||||
_retval.AppendPrintf(format, frametype,
|
||||
NS_ConvertUTF16toUTF8(filename).get(),
|
||||
NS_ConvertUTF16toUTF8(funname).get(),
|
||||
GetLineno());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -511,8 +515,8 @@ JSStackFrame::CreateStackFrameLocation(uint32_t aLanguage,
|
||||
|
||||
self->mLanguage = aLanguage;
|
||||
self->mLineno = aLineNumber;
|
||||
self->mFilename = aFilename;
|
||||
self->mFunname = aFunctionName;
|
||||
CopyUTF8toUTF16(aFilename, self->mFilename);
|
||||
CopyUTF8toUTF16(aFunctionName, self->mFunname);
|
||||
|
||||
self->mCaller = aCaller;
|
||||
|
||||
|
@ -193,6 +193,16 @@ ToJSValue(JSContext* aCx,
|
||||
return ToJSValue(aCx, *aArgument.get(), aValue);
|
||||
}
|
||||
|
||||
// Accept WebIDL dictionaries
|
||||
template <class T>
|
||||
typename EnableIf<IsBaseOf<DictionaryBase, T>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
const T& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
return aArgument.ToObject(aCx, aValue);
|
||||
}
|
||||
|
||||
// Accept arrays of other things we accept
|
||||
template <typename T>
|
||||
bool
|
||||
|
@ -205,7 +205,22 @@ ClassToIcon(uint32_t aClass, nsAString& aRetIcon)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (aRetIcon.IsEmpty()) {
|
||||
if (HAS_AUDIO(aClass)) {
|
||||
/**
|
||||
* Property 'Icon' may be missed due to CoD of major class is TOY(0x08).
|
||||
* But we need to assign Icon as audio-card if service class is 'Audio'.
|
||||
* This is for PTS test case TC_AG_COD_BV_02_I. As HFP specification
|
||||
* defines that service class is 'Audio' can be considered as HFP HF.
|
||||
*/
|
||||
aRetIcon.AssignLiteral("audio-card");
|
||||
} else {
|
||||
BT_LOGR("No icon to match class: %x", aClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ControlPlayStatus
|
||||
PlayStatusStringToControlPlayStatus(const nsAString& aPlayStatus)
|
||||
{
|
||||
|
@ -643,19 +643,17 @@ void BluetoothHfpManager::ProcessDialCall(char *aNumber)
|
||||
void
|
||||
BluetoothHfpManager::ProcessAtCnum()
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(!mMsisdn.IsEmpty());
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
if (!mMsisdn.IsEmpty()) {
|
||||
nsAutoCString message("+CNUM: ,\"");
|
||||
message.Append(NS_ConvertUTF16toUTF8(mMsisdn).get());
|
||||
message.AppendLiteral("\",");
|
||||
message.AppendInt(BTHF_CALL_ADDRTYPE_UNKNOWN);
|
||||
message.AppendLiteral(",,4");
|
||||
|
||||
nsAutoCString message("+CNUM: ,\"");
|
||||
message.Append(NS_ConvertUTF16toUTF8(mMsisdn).get());
|
||||
message.AppendLiteral("\",");
|
||||
message.AppendInt(BTHF_CALL_ADDRTYPE_UNKNOWN);
|
||||
message.AppendLiteral(",,4");
|
||||
SendLine(message.get());
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->formatted_at_response(message.get()));
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->at_response(BTHF_AT_RESPONSE_OK, 0));
|
||||
SendResponse(BTHF_AT_RESPONSE_OK);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -727,7 +727,7 @@ nsDOMCameraControl::StartRecording(const CameraStartRecordingOptions& aOptions,
|
||||
mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
|
||||
if (mAudioChannelAgent) {
|
||||
// Camera app will stop recording when it falls to the background, so no callback is necessary.
|
||||
mAudioChannelAgent->Init(mWindow, AUDIO_CHANNEL_CONTENT, nullptr);
|
||||
mAudioChannelAgent->Init(mWindow, (int32_t)AudioChannel::Content, nullptr);
|
||||
// Video recording doesn't output any sound, so it's not necessary to check canPlay.
|
||||
int32_t canPlay;
|
||||
mAudioChannelAgent->StartPlaying(&canPlay);
|
||||
|
@ -13,7 +13,6 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMHTMLBodyElement.idl',
|
||||
'nsIDOMHTMLBRElement.idl',
|
||||
'nsIDOMHTMLButtonElement.idl',
|
||||
'nsIDOMHTMLByteRanges.idl',
|
||||
'nsIDOMHTMLCanvasElement.idl',
|
||||
'nsIDOMHTMLCollection.idl',
|
||||
'nsIDOMHTMLDirectoryElement.idl',
|
||||
|
@ -1,27 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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 "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(992c540c-4d81-42df-80a6-f71ede2b59d8)]
|
||||
interface nsIDOMHTMLByteRanges : nsISupports
|
||||
{
|
||||
/* The number of ranges represented by the object */
|
||||
readonly attribute unsigned long length;
|
||||
|
||||
/* The start(index) method must return the position of the first
|
||||
byte of the indexth range represented by the object. */
|
||||
unsigned long start(in unsigned long index);
|
||||
|
||||
/* The end(index) method must return the position of the byte
|
||||
immediately after the last byte of the indexth range represented
|
||||
by the object. (The byte position returned by this method is not
|
||||
in the range itself. If the first byte of the range is the byte
|
||||
at position 0, and the entire stream of bytes is in the range,
|
||||
then the value of the position of the byte returned by this
|
||||
method for that range will be the same as the number of bytes in
|
||||
the stream.) */
|
||||
unsigned long end(in unsigned long index);
|
||||
};
|
@ -8,7 +8,6 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMStorage.idl',
|
||||
'nsIDOMStorageEvent.idl',
|
||||
'nsIDOMStorageManager.idl',
|
||||
'nsIDOMToString.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_storage'
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user