Merge m-c to fx-team a=merge

This commit is contained in:
Wes Kocher 2014-10-20 18:34:45 -07:00
commit ade010d0a2
100 changed files with 1273 additions and 643 deletions

View File

@ -8,8 +8,6 @@
// This file is only loaded on Gonk to manage ADB state
const { utils: Cu } = Components;
const DEBUG = false;
var debug = function(str) {
dump("AdbController: " + str + "\n");

View File

@ -9,6 +9,8 @@
* 'capture-logs-success' event with detail.logFilenames representing each log
* file's filename in the directory. If an error occurs it will instead produce
* a 'capture-logs-error' event.
* We send a capture-logs-start events to notify the system app and the user,
* since dumping can be a bit long sometimes.
*/
/* enable Mozilla javascript extensions and global strictness declaration,
@ -54,6 +56,7 @@ function debug(msg) {
const EXCITEMENT_THRESHOLD = 500;
const DEVICE_MOTION_EVENT = 'devicemotion';
const SCREEN_CHANGE_EVENT = 'screenchange';
const CAPTURE_LOGS_START_EVENT = 'capture-logs-start';
const CAPTURE_LOGS_ERROR_EVENT = 'capture-logs-error';
const CAPTURE_LOGS_SUCCESS_EVENT = 'capture-logs-success';
@ -165,6 +168,7 @@ let LogShake = {
if (excitement > EXCITEMENT_THRESHOLD) {
if (!this.captureRequested) {
this.captureRequested = true;
SystemAppProxy._sendCustomEvent(CAPTURE_LOGS_START_EVENT, {});
captureLogs().then(logResults => {
// On resolution send the success event to the requester
SystemAppProxy._sendCustomEvent(CAPTURE_LOGS_SUCCESS_EVENT, {
@ -218,7 +222,7 @@ function getLogDirectory() {
d = new Date(d.getTime() - d.getTimezoneOffset() * 60000);
let timestamp = d.toISOString().slice(0, -5).replace(/[:T]/g, '-');
// return directory name of format 'logs/timestamp/'
return OS.Path.join('logs', timestamp, '');
return OS.Path.join('logs', timestamp);
}
/**
@ -281,7 +285,7 @@ function saveLogs(logArrays) {
// The filename represents the relative path within the SD card, not the
// absolute path because Gaia will refer to it using the DeviceStorage
// API
let filename = dirName + getLogFilename(logLocation);
let filename = OS.Path.join(dirName, getLogFilename(logLocation));
logFilenames.push(filename);
let saveRequest = OS.File.writeAtomic(OS.Path.join(sdcardPrefix, filename), logArray);
saveRequests.push(saveRequest);

View File

@ -15,9 +15,9 @@
<project name="platform_build" path="build" remote="b2g" revision="3a2947df41a480de1457a6dcdbf46ad0af70d8e0">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>

View File

@ -19,8 +19,8 @@
<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="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="c058843242068d0df7c107e09da31b53d2e08fa6"/>

View File

@ -17,8 +17,8 @@
</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="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="9f6b7471c881ee689183d681658cf2ba3dfc5610"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
@ -134,7 +134,7 @@
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="d259117b4976decbe2f76eeed85218bf0109190f"/>
<project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="0e56e450367cd802241b27164a2979188242b95f"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="9f28c4faea3b2f01db227b2467b08aeba96d9bec"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="7047fcaa8bb55888ec7b84997e1bab41185ba3a3"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="a6cfdff6e9198a0f0aec5be024d26ecf2d36c614"/>
<project name="android-sdk" path="sdk" remote="b2g" revision="8b1365af38c9a653df97349ee53a3f5d64fd590a"/>
<project name="darwinstreamingserver" path="system/darwinstreamingserver" remote="b2g" revision="cf85968c7f85e0ec36e72c87ceb4837a943b8af6"/>
</manifest>

View File

@ -15,9 +15,9 @@
<project name="platform_build" path="build" remote="b2g" revision="3a2947df41a480de1457a6dcdbf46ad0af70d8e0">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>

View File

@ -19,8 +19,8 @@
<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="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="c058843242068d0df7c107e09da31b53d2e08fa6"/>

View File

@ -15,9 +15,9 @@
<project name="platform_build" path="build" remote="b2g" revision="3a2947df41a480de1457a6dcdbf46ad0af70d8e0">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
@ -151,7 +151,7 @@
<project name="platform/hardware/ril" path="hardware/ril" revision="12b1977cc704b35f2e9db2bb423fa405348bc2f3"/>
<project name="platform/system/bluetooth" path="system/bluetooth" revision="985bf15264d865fe7b9c5b45f61c451cbaafa43d"/>
<project name="platform/system/core" path="system/core" revision="350eac5403124dacb2a5fd9e28ac290a59fc3b8e"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="7047fcaa8bb55888ec7b84997e1bab41185ba3a3"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="a6cfdff6e9198a0f0aec5be024d26ecf2d36c614"/>
<project name="platform/system/qcom" path="system/qcom" revision="63e3f6f176caad587d42bba4c16b66d953fb23c2"/>
<project name="platform/vendor/qcom-opensource/wlan/prima" path="vendor/qcom/opensource/wlan/prima" revision="d8952a42771045fca73ec600e2b42a4c7129d723"/>
<project name="platform/vendor/qcom/msm8610" path="device/qcom/msm8610" revision="7704e16da545f4207812e593743d6743e1afb9c5"/>

View File

@ -17,8 +17,8 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="9f6b7471c881ee689183d681658cf2ba3dfc5610"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
@ -145,7 +145,7 @@
<project name="platform/hardware/ril" path="hardware/ril" revision="c4e2ac95907a5519a0e09f01a0d8e27fec101af0"/>
<project name="platform/system/bluetooth" path="system/bluetooth" revision="e1eb226fa3ad3874ea7b63c56a9dc7012d7ff3c2"/>
<project name="platform/system/core" path="system/core" revision="adc485d8755af6a61641d197de7cfef667722580"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="7047fcaa8bb55888ec7b84997e1bab41185ba3a3"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="a6cfdff6e9198a0f0aec5be024d26ecf2d36c614"/>
<project name="platform/system/qcom" path="system/qcom" revision="1cdab258b15258b7f9657da70e6f06ebd5a2fc25"/>
<project name="platform/vendor/qcom/msm8610" path="device/qcom/msm8610" revision="4ae5df252123591d5b941191790e7abed1bce5a4"/>
<project name="platform/vendor/qcom-opensource/wlan/prima" path="vendor/qcom/opensource/wlan/prima" revision="ce18b47b4a4f93a581d672bbd5cb6d12fe796ca9"/>

View File

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "f486771c1a2a76bfea1a5c7eac8debe14f29927b",
"revision": "162be54d45ece9196921eb2b342490ec2ab9e1a6",
"repo_path": "/integration/gaia-central"
}

View File

@ -17,8 +17,8 @@
<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="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>

View File

@ -15,8 +15,8 @@
<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="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>

View File

@ -17,8 +17,8 @@
</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="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="9f6b7471c881ee689183d681658cf2ba3dfc5610"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
@ -129,7 +129,7 @@
<project name="device-mako" path="device/lge/mako" remote="b2g" revision="78d17f0c117f0c66dd55ee8d5c5dde8ccc93ecba"/>
<project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="3a9a17613cc685aa232432566ad6cc607eab4ec1"/>
<project name="device/lge/mako-kernel" path="device/lge/mako-kernel" revision="d1729e53d71d711c8fde25eab8728ff2b9b4df0e"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="7047fcaa8bb55888ec7b84997e1bab41185ba3a3"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="a6cfdff6e9198a0f0aec5be024d26ecf2d36c614"/>
<project name="platform/external/libnfc-nci" path="external/libnfc-nci" revision="7d33aaf740bbf6c7c6e9c34a92b371eda311b66b"/>
<project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="0e56e450367cd802241b27164a2979188242b95f"/>
<project name="platform/hardware/broadcom/wlan" path="hardware/broadcom/wlan" revision="0e1929fa3aa38bf9d40e9e953d619fab8164c82e"/>

View File

@ -17,8 +17,8 @@
<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="dc496d04907dd314f9736ff78bab3bd27156f79a"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cc1f362ce43dce92ac786187ff4abf39060094bd"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="457a54fc3200b80e4f5e1cd3acaa062309230732"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="73d68c9c91bc568ce7c888ac057b3f44bd1b2e79"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>

View File

@ -2184,6 +2184,12 @@ public:
*/
static uint64_t GetInnerWindowID(nsIRequest* aRequest);
/**
* If the hostname for aURI is an IPv6 it encloses it in brackets,
* otherwise it just outputs the hostname in aHost.
*/
static void GetHostOrIPv6WithBrackets(nsIURI* aURI, nsAString& aHost);
private:
static bool InitializeEventTable();

View File

@ -361,13 +361,7 @@ Link::GetHostname(nsAString &_hostname, ErrorResult& aError)
return;
}
nsAutoCString host;
nsresult rv = uri->GetHost(host);
// Note that failure to get the host from the URI is not necessarily a bad
// thing. Some URIs do not have a host.
if (NS_SUCCEEDED(rv)) {
CopyUTF8toUTF16(host, _hostname);
}
nsContentUtils::GetHostOrIPv6WithBrackets(uri, _hostname);
}
void

View File

@ -6998,3 +6998,23 @@ nsContentUtils::GetInnerWindowID(nsIRequest* aRequest)
return inner ? inner->WindowID() : 0;
}
void
nsContentUtils::GetHostOrIPv6WithBrackets(nsIURI* aURI, nsAString& aHost)
{
aHost.Truncate();
nsAutoCString hostname;
nsresult rv = aURI->GetHost(hostname);
if (NS_FAILED(rv)) { // Some URIs do not have a host
return;
}
if (hostname.FindChar(':') != -1) { // Escape IPv6 address
MOZ_ASSERT(!hostname.Length() ||
(hostname[0] !='[' && hostname[hostname.Length() - 1] != ']'));
hostname.Insert('[', 0);
hostname.Append(']');
}
CopyUTF8toUTF16(hostname, aHost);
}

View File

@ -2707,7 +2707,8 @@ void MediaDecoderStateMachine::AdvanceFrame()
// Filter out invalid frames by checking the frame time. FrameTime could be
// zero if it's a initial frame.
int64_t frameTime = currentFrame->mTime - mStartTime;
if (frameTime > 0 || (frameTime == 0 && mPlayDuration == 0)) {
if (frameTime > 0 || (frameTime == 0 && mPlayDuration == 0) ||
mScheduler->IsRealTime()) {
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
// If we have video, we want to increment the clock in steps of the frame
// duration.

View File

@ -382,17 +382,7 @@ void
URL::GetHostname(nsString& aHostname, ErrorResult& aRv) const
{
aHostname.Truncate();
nsAutoCString tmp;
nsresult rv = mURI->GetHost(tmp);
if (NS_SUCCEEDED(rv)) {
if (tmp.FindChar(':') != -1) { // Escape IPv6 address
MOZ_ASSERT(!tmp.Length() ||
(tmp[0] !='[' && tmp[tmp.Length() - 1] != ']'));
tmp.Insert('[', 0);
tmp.Append(']');
}
CopyUTF8toUTF16(tmp, aHostname);
}
nsContentUtils::GetHostOrIPv6WithBrackets(mURI, aHostname);
}
void

View File

@ -407,18 +407,9 @@ nsLocation::GetHostname(nsAString& aHostname)
aHostname.Truncate();
nsCOMPtr<nsIURI> uri;
nsresult result;
result = GetURI(getter_AddRefs(uri), true);
GetURI(getter_AddRefs(uri), true);
if (uri) {
nsAutoCString host;
result = uri->GetHost(host);
if (NS_SUCCEEDED(result)) {
AppendUTF8toUTF16(host, aHostname);
}
nsContentUtils::GetHostOrIPv6WithBrackets(uri, aHostname);
}
return NS_OK;

View File

@ -363,6 +363,8 @@ public:
{
MOZ_ASSERT(NS_IsMainThread());
mozilla::ScopedClose fd(aFd); // Close received socket fd on error
if (mImpl->IsShutdownOnMainThread()) {
BT_LOGD("mConsumer is null, aborting receive!");
return;
@ -374,7 +376,8 @@ public:
}
mImpl->mConsumer->SetAddress(aBdAddress);
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd));
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new AcceptTask(mImpl, fd.forget()));
}
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE

View File

@ -9,6 +9,7 @@
#include <unistd.h>
#include <sys/socket.h>
#include "BluetoothHALHelpers.h"
#include "mozilla/FileUtils.h"
#include "nsClassHashtable.h"
#include "nsXULAppAPI.h"
@ -485,6 +486,10 @@ public:
void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE
{
if ((aStatus != STATUS_SUCCESS) && (GetClientFd() != -1)) {
mozilla::ScopedClose(GetClientFd()); // Close received socket fd on error
}
DispatchBluetoothSocketHALResult(
GetResultHandler(), &BluetoothSocketResultHandler::Accept,
GetClientFd(), GetBdAddress(), GetConnectionStatus(), aStatus);

View File

@ -363,6 +363,8 @@ public:
{
MOZ_ASSERT(NS_IsMainThread());
mozilla::ScopedClose fd(aFd); // Close received socket fd on error
if (mImpl->IsShutdownOnMainThread()) {
BT_LOGD("mConsumer is null, aborting receive!");
return;
@ -374,7 +376,8 @@ public:
}
mImpl->mConsumer->SetAddress(aBdAddress);
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd));
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new AcceptTask(mImpl, fd.forget()));
}
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE

View File

@ -9,6 +9,7 @@
#include <sys/socket.h>
#include <unistd.h>
#include "BluetoothHALHelpers.h"
#include "mozilla/FileUtils.h"
#include "nsClassHashtable.h"
#include "nsXULAppAPI.h"
@ -485,6 +486,10 @@ public:
void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE
{
if ((aStatus != STATUS_SUCCESS) && (GetClientFd() != -1)) {
mozilla::ScopedClose(GetClientFd()); // Close received socket fd on error
}
DispatchBluetoothSocketHALResult(
GetResultHandler(), &BluetoothSocketResultHandler::Accept,
GetClientFd(), GetBdAddress(), GetConnectionStatus(), aStatus);

View File

@ -248,6 +248,7 @@ ContactManager.prototype = {
let type = "contacts-" + access;
let permValue =
Services.perms.testExactPermissionFromPrincipal(principal, type);
DEBUG && debug("Existing permission " + permValue);
if (permValue == Ci.nsIPermissionManager.ALLOW_ACTION) {
if (aAllowCallback) {
aAllowCallback();
@ -256,7 +257,7 @@ ContactManager.prototype = {
} else if (permValue == Ci.nsIPermissionManager.DENY_ACTION ||
permValue == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
if (aCancelCallback) {
aCancelCallback();
aCancelCallback("PERMISSION_DENIED");
}
return;
}
@ -276,16 +277,14 @@ ContactManager.prototype = {
types: typeArray,
principal: principal,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionRequest]),
allow: aAllowCallback ||
function() {
if (DEBUG)
debug("Default allow contacts callback. " + access +"\n");
},
cancel: aCancelCallback ||
function() {
if (DEBUG)
debug("Default cancel contacts callback. " + access +"\n");
},
allow: function() {
aAllowCallback && aAllowCallback();
DEBUG && debug("Permission granted. Access " + access +"\n");
},
cancel: function() {
aCancelCallback && aCancelCallback("PERMISSION_DENIED");
DEBUG && debug("Permission denied. Access " + access +"\n");
},
window: this._window
};
@ -336,9 +335,17 @@ ContactManager.prototype = {
let options = { contact: newContact, reason: reason };
let allowCallback = function() {
cpmm.sendAsyncMessage("Contact:Save", {requestID: requestID, options: options});
}.bind(this)
this.askPermission(reason, request, allowCallback);
cpmm.sendAsyncMessage("Contact:Save", {
requestID: requestID,
options: options
});
}.bind(this);
let cancelCallback = function(reason) {
Services.DOMRequest.fireErrorAsync(request, reason);
};
this.askPermission(reason, request, allowCallback, cancelCallback);
return request;
},
@ -346,10 +353,19 @@ ContactManager.prototype = {
if (DEBUG) debug("find! " + JSON.stringify(aOptions));
let request = this.createRequest();
let options = { findOptions: aOptions };
let allowCallback = function() {
cpmm.sendAsyncMessage("Contacts:Find", {requestID: this.getRequestId({request: request, reason: "find"}), options: options});
}.bind(this)
this.askPermission("find", request, allowCallback);
cpmm.sendAsyncMessage("Contacts:Find", {
requestID: this.getRequestId({request: request, reason: "find"}),
options: options
});
}.bind(this);
let cancelCallback = function(reason) {
Services.DOMRequest.fireErrorAsync(request, reason);
};
this.askPermission("find", request, allowCallback, cancelCallback);
return request;
},
@ -369,11 +385,19 @@ ContactManager.prototype = {
getAll: function CM_getAll(aOptions) {
if (DEBUG) debug("getAll: " + JSON.stringify(aOptions));
let [cursorId, cursor] = this.createCursor();
let allowCallback = function() {
cpmm.sendAsyncMessage("Contacts:GetAll", {
cursorId: cursorId, findOptions: aOptions});
cursorId: cursorId,
findOptions: aOptions
});
}.bind(this);
this.askPermission("find", cursor, allowCallback);
let cancelCallback = function(reason) {
Services.DOMRequest.fireErrorAsync(cursor, reason);
};
this.askPermission("find", cursor, allowCallback, cancelCallback);
return cursor;
},
@ -412,10 +436,19 @@ ContactManager.prototype = {
}
let options = { id: id };
let allowCallback = function() {
cpmm.sendAsyncMessage("Contact:Remove", {requestID: this.getRequestId({request: request, reason: "remove"}), options: options});
cpmm.sendAsyncMessage("Contact:Remove", {
requestID: this.getRequestId({request: request, reason: "remove"}),
options: options
});
}.bind(this);
this.askPermission("remove", request, allowCallback);
let cancelCallback = function(reason) {
Services.DOMRequest.fireErrorAsync(request, reason);
};
this.askPermission("remove", request, allowCallback, cancelCallback);
return request;
},
@ -423,10 +456,19 @@ ContactManager.prototype = {
if (DEBUG) debug("clear");
let request = this.createRequest();
let options = {};
let allowCallback = function() {
cpmm.sendAsyncMessage("Contacts:Clear", {requestID: this.getRequestId({request: request, reason: "remove"}), options: options});
cpmm.sendAsyncMessage("Contacts:Clear", {
requestID: this.getRequestId({request: request, reason: "remove"}),
options: options
});
}.bind(this);
this.askPermission("remove", request, allowCallback);
let cancelCallback = function(reason) {
Services.DOMRequest.fireErrorAsync(request, reason);
};
this.askPermission("remove", request, allowCallback, cancelCallback);
return request;
},
@ -439,8 +481,8 @@ ContactManager.prototype = {
});
}.bind(this);
let cancelCallback = function() {
Services.DOMRequest.fireError(request, "");
let cancelCallback = function(reason) {
Services.DOMRequest.fireErrorAsync(request, reason);
};
this.askPermission("revision", request, allowCallback, cancelCallback);
@ -456,8 +498,8 @@ ContactManager.prototype = {
});
}.bind(this);
let cancelCallback = function() {
Services.DOMRequest.fireError(request, "");
let cancelCallback = function(reason) {
Services.DOMRequest.fireErrorAsync(request, reason);
};
this.askPermission("count", request, allowCallback, cancelCallback);

View File

@ -21,4 +21,4 @@ skip-if = (toolkit == 'gonk' && debug) #debug-only failure
support-files =
test_migration_chrome.js
skip-if = os == "android"
[test_permission_denied.html]

View File

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1081873
-->
<head>
<title>Test for Bug 1081873</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1081873">Mozilla Bug 1081873</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
"use strict";
SpecialPowers.addPermission("contacts-write", false, document);
SpecialPowers.addPermission("contacts-read", false, document);
SpecialPowers.addPermission("contacts-create", false, document);
function onUnexpectedSuccess() {
ok(false, "Unexpected success");
next();
}
function onExpectedError(event) {
is(event.target.error.name, PERMISSION_DENIED, "Expected PERMISSION_DENIED");
next();
}
const PERMISSION_DENIED = "PERMISSION_DENIED";
var index = 0;
function next() {
info("Step " + index);
if (index >= steps.length) {
ok(false, "Shouldn't get here!");
return;
}
try {
var i = index++;
steps[i]();
} catch(ex) {
ok(false, "Caught exception", ex);
}
}
var steps = [
function() {
ok(true, "Add contact without permission");
var req = navigator.mozContacts.save(new mozContact({}));
req.onsuccess = onUnexpectedSuccess;
req.onerror = onExpectedError;
},
function() {
ok(true, "Find contact without permission");
var req = navigator.mozContacts.find({});
req.onsuccess = onUnexpectedSuccess;
req.onerror = onExpectedError;
},
function() {
ok(true, "Get all contacts without permission");
var req = navigator.mozContacts.getAll();
req.onsuccess = onUnexpectedSuccess;
req.onerror = onExpectedError;
},
function() {
ok(true, "Remove contact without permission");
var req = navigator.mozContacts.remove("aId");
req.onsuccess = onUnexpectedSuccess;
req.onerror = onExpectedError;
},
function() {
ok(true, "Clear contacts without permission");
var req = navigator.mozContacts.clear();
req.onsuccess = onUnexpectedSuccess;
req.onerror = onExpectedError;
},
function() {
ok(true, "Get revision without permission");
var req = navigator.mozContacts.getRevision();
req.onsuccess = onUnexpectedSuccess;
req.onerror = onExpectedError;
},
function() {
ok(true, "Get count without permission");
var req = navigator.mozContacts.getCount();
req.onsuccess = onUnexpectedSuccess;
req.onerror = function() {
is(req.error.name, PERMISSION_DENIED, "Expected PERMISSION_DENIED");
SimpleTest.finish();
};
}
];
SimpleTest.waitForExplicitFinish();
const DENY = SpecialPowers.Ci.nsIPermissionManager.DENY_ACTION;
var interval = setInterval(function() {
if (!SpecialPowers.testPermission("contacts-read", DENY, document) ||
!SpecialPowers.testPermission("contacts-write", DENY, document) ||
!SpecialPowers.testPermission("contacts-create", DENY, document)) {
return;
}
clearInterval(interval);
next();
}, 1000);
</script>
</pre>
</body>
</html>

View File

@ -28,6 +28,8 @@ dictionary WifiWPSInfo {
dictionary NetworkProperties {
DOMString ssid;
long mode;
long frequency;
sequence<DOMString>? security;
sequence<DOMString>? capabilities;
boolean known;
@ -63,6 +65,8 @@ dictionary NetworkProperties {
Func="Navigator::HasWifiManagerSupport"]
interface MozWifiNetwork {
readonly attribute DOMString ssid;
readonly attribute long mode;
readonly attribute long frequency;
[Constant, Cached] readonly attribute sequence<DOMString>? security;
[Constant, Cached] readonly attribute sequence<DOMString>? capabilities;
readonly attribute boolean known;

View File

@ -149,7 +149,7 @@ MozWifiP2pManager.prototype = {
case "WifiP2pManager:getPeerList:Return:OK":
request = this.takeRequest(msg.rid);
Services.DOMRequest.fireSuccess(request, msg.data);
Services.DOMRequest.fireSuccess(request, Cu.cloneInto(msg.data, this._window));
break;
case "WifiP2pManager:getPeerList:Return:NO":

View File

@ -25,6 +25,13 @@ this.WifiCommand = function(aControlMessage, aInterface, aSdkVersion) {
var command = {};
//-------------------------------------------------
// Utilities.
//-------------------------------------------------
command.getSdkVersion = function() {
return aSdkVersion;
};
//-------------------------------------------------
// General commands.
//-------------------------------------------------

View File

@ -608,18 +608,28 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
_sm.pause();
// Step 1: Connect to p2p0.
aP2pCommand.connectToSupplicant(function (status) {
let detail;
if (0 !== status) {
debug('Failed to connect to p2p0');
onFailure();
// This function will only call back on success.
function connectToSupplicantIfNeeded(callback) {
if (aP2pCommand.getSdkVersion() >= 19) {
// No need to connect to supplicant on KK. Call back directly.
callback();
return;
}
aP2pCommand.connectToSupplicant(function (status) {
if (0 !== status) {
debug('Failed to connect to p2p0');
onFailure();
return;
}
debug('wpa_supplicant p2p0 connected!');
_onSupplicantConnected();
callback();
});
}
debug('wpa_supplicant p2p0 connected!');
_onSupplicantConnected();
// Step 1: Connect to p2p0 if needed.
connectToSupplicantIfNeeded(function callback () {
let detail;
// Step 2: Get MAC address.
if (!_localDevice.address) {

View File

@ -174,6 +174,14 @@ WifiProxyService::Start(nsIWifiEventListener* aListener,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aListener);
#if ANDROID_VERSION >= 19
// KK changes the way mux'ing/demux'ing different supplicant interfaces
// (e.g. wlan0/p2p0) from multi-sockets to single socket embedded with
// prefixed interface name (e.g. IFNAME=wlan0 xxxxxx). Therefore, we use
// the first given interface as the global interface for KK.
aNumOfInterfaces = 1;
#endif
nsresult rv;
// Since EventRunnable runs in the manner of blocking, we have to
@ -250,6 +258,14 @@ WifiProxyService::WaitForEvent(const nsACString& aInterface)
{
MOZ_ASSERT(NS_IsMainThread());
#if ANDROID_VERSION >= 19
// We will only have one global interface for KK.
if (!mEventThreadList.IsEmpty()) {
nsCOMPtr<nsIRunnable> runnable = new EventRunnable(aInterface);
mEventThreadList[0].mThread->Dispatch(runnable, nsIEventTarget::DISPATCH_NORMAL);
return NS_OK;
}
#else
// Dispatch to the event thread which has the given interface name
for (size_t i = 0; i < mEventThreadList.Length(); i++) {
if (mEventThreadList[i].mInterface.Equals(aInterface)) {
@ -258,6 +274,7 @@ WifiProxyService::WaitForEvent(const nsACString& aInterface)
return NS_OK;
}
}
#endif
return NS_ERROR_FAILURE;
}
@ -282,16 +299,27 @@ void
WifiProxyService::DispatchWifiEvent(const nsAString& aEvent, const nsACString& aInterface)
{
MOZ_ASSERT(NS_IsMainThread());
#if ANDROID_VERSION < 19
mListener->OnWaitEvent(aEvent, aInterface);
#else
// The interface might be embedded in the event string such as
// "IFNAME=wlan0 CTRL-EVENT-BSS-ADDED 65 3c:94:d5:7c:11:8b".
// Parse the interface name from the event string and use p2p0
// as the default interface if "IFNAME" is not found.
nsAutoString event;
nsAutoString embeddedInterface(NS_LITERAL_STRING("p2p0"));
if (StringBeginsWith(aEvent, NS_LITERAL_STRING("IFNAME"))) {
// Jump over IFNAME for gonk-kk.
int32_t ifnameFrom = aEvent.FindChar('=') + 1;
int32_t ifnameTo = aEvent.FindChar(' ') - 1;
embeddedInterface = Substring(aEvent, ifnameFrom, ifnameTo - ifnameFrom + 1);
event = Substring(aEvent, aEvent.FindChar(' ') + 1);
}
else {
event = aEvent;
}
// Call the listener.
mListener->OnWaitEvent(event, aInterface);
mListener->OnWaitEvent(event, NS_ConvertUTF16toUTF8(embeddedInterface));
#endif
}
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(WifiProxyService,

View File

@ -82,6 +82,9 @@ const WPA_SUPPLICANT = "wpa_supplicant";
const DHCP_PROP = "init.svc.dhcpcd";
const DHCP = "dhcpcd";
const MODE_ESS = 0;
const MODE_IBSS = 1;
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
"@mozilla.org/network/manager;1",
"nsINetworkManager");
@ -112,29 +115,38 @@ var WifiManager = (function() {
driverDelay: libcutils.property_get("ro.moz.wifi.driverDelay"),
p2pSupported: libcutils.property_get("ro.moz.wifi.p2p_supported") === "1",
eapSimSupported: libcutils.property_get("ro.moz.wifi.eapsim_supported") === "1",
ibssSupported: libcutils.property_get("ro.moz.wifi.ibss_supported", "true") === "true",
ifname: libcutils.property_get("wifi.interface")
};
}
let {sdkVersion, unloadDriverEnabled, schedScanRecovery,
driverDelay, p2pSupported, eapSimSupported, ifname} = getStartupPrefs();
driverDelay, p2pSupported, eapSimSupported, ibssSupported, ifname} = getStartupPrefs();
let capabilities = {
security: ["OPEN", "WEP", "WPA-PSK", "WPA-EAP"],
eapMethod: ["PEAP", "TTLS"],
eapPhase2: ["MSCHAPV2"],
certificate: ["SERVER"]
certificate: ["SERVER"],
mode: [MODE_ESS]
};
if (eapSimSupported) {
capabilities.eapMethod.unshift("SIM");
}
if (ibssSupported) {
capabilities.mode.push(MODE_IBSS);
}
let wifiListener = {
onWaitEvent: function(event, iface) {
if (manager.ifname === iface && handleEvent(event)) {
waitForEvent(iface);
} else if (p2pSupported) {
if (WifiP2pManager.INTERFACE_NAME === iface) {
// Please refer to
// http://androidxref.com/4.4.2_r1/xref/frameworks/base/wifi/java/android/net/wifi/WifiMonitor.java#519
// for interface event mux/demux rules. In short words, both
// 'p2p0' and 'p2p-' should go to Wifi P2P state machine.
if (WifiP2pManager.INTERFACE_NAME === iface || -1 !== iface.indexOf('p2p-')) {
// If the connection is closed, wifi.c::wifi_wait_for_event()
// will still return 'CTRL-EVENT-TERMINATING - connection closed'
// rather than blocking. So when we see this special event string,
@ -1184,7 +1196,13 @@ var WifiManager = (function() {
{name: "pin", type: "string"},
{name: "pcsc", type: "string"},
{name: "ca_cert", type: "string"},
{name: "subject_match", type: "string"}
{name: "subject_match", type: "string"},
{name: "frequency", type: "integer"},
{name: "mode", type: "integer"}
];
// These fields are only handled in IBSS (aka ad-hoc) mode
var ibssNetworkConfigurationFields = [
"frequency", "mode"
];
manager.getNetworkConfiguration = function(config, callback) {
@ -1219,9 +1237,23 @@ var WifiManager = (function() {
config[name] !== '*'));
}
function getModeFromConfig() {
/* we use the mode from the config, or ESS as default */
return hasValidProperty("mode") ? config["mode"] : MODE_ESS;
}
var mode = getModeFromConfig();
function validForMode(name, mode) {
/* all fields are valid for IBSS */
return (mode == MODE_IBSS) ||
/* IBSS fields are not valid for ESS */
((mode == MODE_ESS) && !(name in ibssNetworkConfigurationFields));
}
for (var n = 0; n < networkConfigurationFields.length; ++n) {
let fieldName = networkConfigurationFields[n].name;
if (!hasValidProperty(fieldName)) {
if (!hasValidProperty(fieldName) || !validForMode(fieldName, mode)) {
++done;
} else {
wifiCommand.setNetworkVariable(netId, fieldName, config[fieldName], function(ok) {
@ -1552,6 +1584,18 @@ function getNetworkKey(network)
return escape(ssid) + encryption;
}
function getMode(flags) {
if (!flags)
return -1;
if (/\[ESS/.test(flags))
return MODE_ESS;
if (/\[IBSS/.test(flags))
return MODE_IBSS;
return -1;
}
function getKeyManagement(flags) {
var types = [];
if (!flags)
@ -1598,8 +1642,10 @@ function calculateSignal(strength) {
return Math.floor(((strength - MIN_RSSI) / (MAX_RSSI - MIN_RSSI)) * 100);
}
function Network(ssid, security, password, capabilities) {
function Network(ssid, mode, frequency, security, password, capabilities) {
this.ssid = ssid;
this.mode = mode;
this.frequency = frequency;
this.security = security;
if (typeof password !== "undefined")
@ -1613,6 +1659,8 @@ function Network(ssid, security, password, capabilities) {
Network.api = {
ssid: "r",
mode: "r",
frequency: "r",
security: "r",
capabilities: "r",
known: "r",
@ -1632,9 +1680,9 @@ Network.api = {
// Note: We never use ScanResult.prototype, so the fact that it's unrelated to
// Network.prototype is OK.
function ScanResult(ssid, bssid, flags, signal) {
Network.call(this, ssid, getKeyManagement(flags), undefined,
getCapabilities(flags));
function ScanResult(ssid, bssid, frequency, flags, signal) {
Network.call(this, ssid, getMode(flags), frequency,
getKeyManagement(flags), undefined, getCapabilities(flags));
this.bssid = bssid;
this.signalStrength = signal;
this.relSignalStrength = calculateSignal(Number(signal));
@ -1846,6 +1894,8 @@ function WifiWorker() {
return null;
}
var ssid = dequote(net.ssid);
var mode = net.mode;
var frequency = net.frequency;
var security = (net.key_mgmt === "NONE" && net.wep_key0) ? ["WEP"] :
(net.key_mgmt && net.key_mgmt !== "NONE") ? [net.key_mgmt.split(" ")[0]] :
[];
@ -1856,7 +1906,7 @@ function WifiWorker() {
password = "*";
}
var pub = new Network(ssid, security, password);
var pub = new Network(ssid, mode, frequency, security, password);
if (net.identity)
pub.identity = dequote(net.identity);
if ("netId" in net)
@ -2058,10 +2108,12 @@ function WifiWorker() {
break;
case "ASSOCIATING":
// id has not yet been filled in, so we can only report the ssid and
// bssid.
// bssid. mode and frequency are simply made up.
self.currentNetwork =
{ bssid: WifiManager.connectionInfo.bssid,
ssid: quote(WifiManager.connectionInfo.ssid) };
ssid: quote(WifiManager.connectionInfo.ssid),
mode: MODE_ESS,
frequency: 0};
self._fireEvent("onconnecting", { network: netToDOM(self.currentNetwork) });
break;
case "ASSOCIATED":
@ -2257,6 +2309,8 @@ function WifiWorker() {
return;
}
let capabilities = WifiManager.getCapabilities();
// Now that we have scan results, there's no more need to continue
// scanning. Ignore any errors from this command.
WifiManager.setScanMode("inactive", function() {});
@ -2270,17 +2324,18 @@ function WifiWorker() {
if (match && match[5]) {
let ssid = match[5],
bssid = match[1],
frequency = match[2],
signalLevel = match[3],
flags = match[4];
// Skip ad-hoc networks which aren't supported (bug 811635).
if (flags && flags.indexOf("[IBSS]") >= 0)
/* Skip networks with unknown or unsupported modes. */
if (capabilities.mode.indexOf(getMode(flags)) == -1)
continue;
// If this is the first time that we've seen this SSID in the scan
// results, add it to the list along with any other information.
// Also, we use the highest signal strength that we see.
let network = new ScanResult(ssid, bssid, flags, signalLevel);
let network = new ScanResult(ssid, bssid, frequency, flags, signalLevel);
let networkKey = getNetworkKey(network);
let eapIndex = -1;

View File

@ -410,7 +410,7 @@ nsDeviceContext::CreateRenderingContext()
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
#endif
pContext->Init(this, dt);
pContext->Init(dt);
pContext->GetDrawTarget()->AddUserData(&sDisablePixelSnapping,
(void*)0x1, nullptr);
pContext->ThebesContext()->SetMatrix(gfxMatrix::Scaling(mPrintingScale,

View File

@ -20,12 +20,6 @@
#include "nsRect.h" // for nsRect, nsIntRect
#include "nsRegion.h" // for nsIntRegionRectIterator, etc
// XXXTodo: rename FORM_TWIPS to FROM_APPUNITS
#define FROM_TWIPS(_x) ((gfxFloat)((_x)/(mP2A)))
#define FROM_TWIPS_INT(_x) (NSToIntRound((gfxFloat)((_x)/(mP2A))))
#define TO_TWIPS(_x) ((nscoord)((_x)*(mP2A)))
#define GFX_RECT_FROM_TWIPS_RECT(_r) (gfxRect(FROM_TWIPS((_r).x), FROM_TWIPS((_r).y), FROM_TWIPS((_r).width), FROM_TWIPS((_r).height)))
// Hard limit substring lengths to 8000 characters ... this lets us statically
// size the cluster buffer array in FindSafeLength
#define MAX_GFX_TEXT_BUF_SIZE 8000
@ -64,103 +58,16 @@ static int32_t FindSafeLength(const char *aString, uint32_t aLength,
//// nsRenderingContext
void
nsRenderingContext::Init(nsDeviceContext* aContext,
gfxContext *aThebesContext)
nsRenderingContext::Init(gfxContext *aThebesContext)
{
mDeviceContext = aContext;
mThebes = aThebesContext;
mThebes->SetLineWidth(1.0);
mP2A = mDeviceContext->AppUnitsPerDevPixel();
}
void
nsRenderingContext::Init(nsDeviceContext* aContext,
DrawTarget *aDrawTarget)
nsRenderingContext::Init(DrawTarget *aDrawTarget)
{
Init(aContext, new gfxContext(aDrawTarget));
}
//
// graphics state
//
void
nsRenderingContext::IntersectClip(const nsRect& aRect)
{
mThebes->NewPath();
gfxRect clipRect(GFX_RECT_FROM_TWIPS_RECT(aRect));
if (mThebes->UserToDevicePixelSnapped(clipRect, true)) {
gfxMatrix mat(mThebes->CurrentMatrix());
mat.Invert();
clipRect = mat.Transform(clipRect);
mThebes->Rectangle(clipRect);
} else {
mThebes->Rectangle(clipRect);
}
mThebes->Clip();
}
void
nsRenderingContext::SetColor(nscolor aColor)
{
/* This sets the color assuming the sRGB color space, since that's
* what all CSS colors are defined to be in by the spec.
*/
mThebes->SetColor(gfxRGBA(aColor));
}
//
// shapes
//
void
nsRenderingContext::DrawLine(const nsPoint& aStartPt, const nsPoint& aEndPt)
{
DrawLine(aStartPt.x, aStartPt.y, aEndPt.x, aEndPt.y);
}
void
nsRenderingContext::DrawLine(nscoord aX0, nscoord aY0,
nscoord aX1, nscoord aY1)
{
gfxPoint p0 = gfxPoint(FROM_TWIPS(aX0), FROM_TWIPS(aY0));
gfxPoint p1 = gfxPoint(FROM_TWIPS(aX1), FROM_TWIPS(aY1));
// we can't draw thick lines with gfx, so we always assume we want
// pixel-aligned lines if the rendering context is at 1.0 scale
gfxMatrix savedMatrix = mThebes->CurrentMatrix();
if (!savedMatrix.HasNonTranslation()) {
p0 = mThebes->UserToDevice(p0);
p1 = mThebes->UserToDevice(p1);
p0.Round();
p1.Round();
mThebes->SetMatrix(gfxMatrix());
mThebes->NewPath();
// snap straight lines
if (p0.x == p1.x) {
mThebes->Line(p0 + gfxPoint(0.5, 0),
p1 + gfxPoint(0.5, 0));
} else if (p0.y == p1.y) {
mThebes->Line(p0 + gfxPoint(0, 0.5),
p1 + gfxPoint(0, 0.5));
} else {
mThebes->Line(p0, p1);
}
mThebes->Stroke();
mThebes->SetMatrix(savedMatrix);
} else {
mThebes->NewPath();
mThebes->Line(p0, p1);
mThebes->Stroke();
}
Init(new gfxContext(aDrawTarget));
}

View File

@ -15,7 +15,6 @@
#include "nsBoundingMetrics.h" // for nsBoundingMetrics
#include "nsColor.h" // for nscolor
#include "nsCoord.h" // for nscoord, NSToIntRound
#include "nsDeviceContext.h" // for nsDeviceContext
#include "nsFontMetrics.h" // for nsFontMetrics
#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING, etc
#include "nsString.h" // for nsString
@ -30,32 +29,16 @@ class nsRenderingContext MOZ_FINAL
typedef mozilla::gfx::DrawTarget DrawTarget;
public:
nsRenderingContext() : mP2A(0.) {}
nsRenderingContext() {}
NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
void Init(nsDeviceContext* aContext, gfxContext* aThebesContext);
void Init(nsDeviceContext* aContext, DrawTarget* aDrawTarget);
void Init(gfxContext* aThebesContext);
void Init(DrawTarget* aDrawTarget);
// These accessors will never return null.
gfxContext *ThebesContext() { return mThebes; }
DrawTarget *GetDrawTarget() { return mThebes->GetDrawTarget(); }
nsDeviceContext *DeviceContext() { return mDeviceContext; }
int32_t AppUnitsPerDevPixel() const {
// we know this is an int (it's stored as a double for convenience)
return int32_t(mP2A);
}
// Graphics state
void IntersectClip(const nsRect& aRect);
void SetColor(nscolor aColor);
// Shapes
void DrawLine(const nsPoint& aStartPt, const nsPoint& aEndPt);
void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
// Text
@ -89,10 +72,7 @@ private:
int32_t GetMaxChunkLength();
nsRefPtr<gfxContext> mThebes;
nsRefPtr<nsDeviceContext> mDeviceContext;
nsRefPtr<nsFontMetrics> mFontMetrics;
double mP2A; // cached app units per device pixel value
};
#endif // NSRENDERINGCONTEXT__H__

View File

@ -721,13 +721,19 @@ gfxContext::CurrentFillRule() const
}
// clipping
void
gfxContext::Clip(const Rect& rect)
{
AzureState::PushedClip clip = { nullptr, rect, mTransform };
CurrentState().pushedClips.AppendElement(clip);
mDT->PushClipRect(rect);
NewPath();
}
void
gfxContext::Clip(const gfxRect& rect)
{
AzureState::PushedClip clip = { nullptr, ToRect(rect), mTransform };
CurrentState().pushedClips.AppendElement(clip);
mDT->PushClipRect(ToRect(rect));
NewPath();
Clip(ToRect(rect));
}
void

View File

@ -40,6 +40,7 @@ class gfxContext MOZ_FINAL {
typedef mozilla::gfx::FillRule FillRule;
typedef mozilla::gfx::Path Path;
typedef mozilla::gfx::Pattern Pattern;
typedef mozilla::gfx::Rect Rect;
NS_INLINE_DECL_REFCOUNTING(gfxContext)
@ -531,6 +532,7 @@ public:
* Helper functions that will create a rect path and call Clip().
* Any current path will be destroyed by these functions!
*/
void Clip(const Rect& rect);
void Clip(const gfxRect& rect); // will clip to a rect
/**
@ -613,7 +615,6 @@ private:
typedef mozilla::gfx::Color Color;
typedef mozilla::gfx::StrokeOptions StrokeOptions;
typedef mozilla::gfx::Float Float;
typedef mozilla::gfx::Rect Rect;
typedef mozilla::gfx::CompositionOp CompositionOp;
typedef mozilla::gfx::PathBuilder PathBuilder;
typedef mozilla::gfx::SourceSurface SourceSurface;

View File

@ -4212,7 +4212,7 @@ static void DebugPaintItem(nsRenderingContext* aDest,
nsRefPtr<gfxContext> context = new gfxContext(tempDT);
context->SetMatrix(gfxMatrix::Translation(-gfxPoint(bounds.x, bounds.y)));
nsRefPtr<nsRenderingContext> ctx = new nsRenderingContext();
ctx->Init(aDest->DeviceContext(), context);
ctx->Init(context);
aItem->Paint(aBuilder, ctx);
RefPtr<SourceSurface> surface = tempDT->Snapshot();
@ -4479,7 +4479,7 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
}
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
rc->Init(presContext->DeviceContext(), aContext);
rc->Init(aContext);
if (shouldDrawRectsSeparately) {
nsIntRegionRectIterator it(aRegionToDraw);

View File

@ -683,7 +683,10 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
} else {
// We're drawing borders around the joined continuation boxes so we need
// to clip that to the slice that we want for this frame.
aRenderingContext.IntersectClip(aBorderArea);
aRenderingContext.ThebesContext()->
Clip(NSRectToRect(aBorderArea,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
}
} else {
MOZ_ASSERT(joinedBorderArea.IsEqualEdges(aBorderArea),
@ -1310,7 +1313,7 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
// Draw the widget shape
gfxContextMatrixAutoSaveRestore save(shadowContext);
nsRefPtr<nsRenderingContext> wrapperCtx = new nsRenderingContext();
wrapperCtx->Init(aPresContext->DeviceContext(), shadowContext);
wrapperCtx->Init(shadowContext);
gfxPoint devPixelOffset =
nsLayoutUtils::PointToGfxPoint(nsPoint(shadowItem->mXOffset,
shadowItem->mYOffset),
@ -1368,7 +1371,10 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
}
}
}
aRenderingContext.IntersectClip(fragmentClip);
aRenderingContext.ThebesContext()->
Clip(NSRectToRect(fragmentClip,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
gfxCornerSizes clipRectRadii;
if (hasBorderRadius) {
@ -3207,7 +3213,9 @@ DrawBorderImage(nsPresContext* aPresContext,
nsRect clip = aBorderArea;
clip.Inflate(imageOutset);
autoSR.EnsureSaved(aRenderingContext.ThebesContext());
aRenderingContext.IntersectClip(clip);
aRenderingContext.ThebesContext()->
Clip(NSRectToRect(clip, aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
}
} else {
borderImgArea = aBorderArea;
@ -3490,6 +3498,7 @@ static void
DrawSolidBorderSegment(nsRenderingContext& aContext,
nsRect aRect,
nscolor aColor,
int32_t aAppUnitsPerDevPixel,
nscoord aTwipsPerPixel,
uint8_t aStartBevelSide = 0,
nscoord aStartBevelOffset = 0,
@ -3497,7 +3506,6 @@ DrawSolidBorderSegment(nsRenderingContext& aContext,
nscoord aEndBevelOffset = 0)
{
DrawTarget* drawTarget = aContext.GetDrawTarget();
int32_t appUnitsPerDevPixel = aContext.AppUnitsPerDevPixel();
ColorPattern color(ToDeviceColor(aColor));
DrawOptions drawOptions(1.f, CompositionOp::OP_OVER, AntialiasMode::NONE);
@ -3507,26 +3515,30 @@ DrawSolidBorderSegment(nsRenderingContext& aContext,
// simple line or rectangle
if ((NS_SIDE_TOP == aStartBevelSide) || (NS_SIDE_BOTTOM == aStartBevelSide)) {
if (1 == aRect.height)
aContext.DrawLine(aRect.TopLeft(), aRect.BottomLeft());
StrokeLineWithSnapping(aRect.TopLeft(), aRect.BottomLeft(),
aAppUnitsPerDevPixel, *drawTarget,
color, StrokeOptions(), drawOptions);
else
drawTarget->FillRect(NSRectToRect(aRect, appUnitsPerDevPixel, *drawTarget),
drawTarget->FillRect(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
color, drawOptions);
}
else {
if (1 == aRect.width)
aContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
StrokeLineWithSnapping(aRect.TopLeft(), aRect.TopRight(),
aAppUnitsPerDevPixel, *drawTarget,
color, StrokeOptions(), drawOptions);
else
drawTarget->FillRect(NSRectToRect(aRect, appUnitsPerDevPixel, *drawTarget),
drawTarget->FillRect(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
color, drawOptions);
}
}
else {
// polygon with beveling
Point poly[4];
SetPoly(NSRectToRect(aRect, appUnitsPerDevPixel), poly);
SetPoly(NSRectToRect(aRect, aAppUnitsPerDevPixel), poly);
Float startBevelOffset =
NSAppUnitsToFloatPixels(aStartBevelOffset, appUnitsPerDevPixel);
NSAppUnitsToFloatPixels(aStartBevelOffset, aAppUnitsPerDevPixel);
switch(aStartBevelSide) {
case NS_SIDE_TOP:
poly[0].x += startBevelOffset;
@ -3542,7 +3554,7 @@ DrawSolidBorderSegment(nsRenderingContext& aContext,
}
Float endBevelOffset =
NSAppUnitsToFloatPixels(aEndBevelOffset, appUnitsPerDevPixel);
NSAppUnitsToFloatPixels(aEndBevelOffset, aAppUnitsPerDevPixel);
switch(aEndBevelSide) {
case NS_SIDE_TOP:
poly[1].x -= endBevelOffset;
@ -3598,14 +3610,13 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
const nsRect& aBorder,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
uint8_t aStartBevelSide,
nscoord aStartBevelOffset,
uint8_t aEndBevelSide,
nscoord aEndBevelOffset)
{
aContext.SetColor (aBorderColor);
bool horizontal = ((NS_SIDE_TOP == aStartBevelSide) || (NS_SIDE_BOTTOM == aStartBevelSide));
nscoord twipsPerPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerCSSPixel);
uint8_t ridgeGroove = NS_STYLE_BORDER_STYLE_RIDGE;
@ -3621,6 +3632,8 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
AntialiasMode oldMode = ctx->CurrentAntialiasMode();
ctx->SetAntialiasMode(AntialiasMode::NONE);
ctx->SetColor(aBorderColor);
switch (aBorderStyle) {
case NS_STYLE_BORDER_STYLE_NONE:
case NS_STYLE_BORDER_STYLE_HIDDEN:
@ -3642,21 +3655,21 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (horizontal) {
GetDashInfo(aBorder.width, dashLength, twipsPerPixel, numDashSpaces, startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, startDashLength, aBorder.height);
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel);
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel);
for (int32_t spaceX = 0; spaceX < numDashSpaces; spaceX++) {
rect.x += rect.width + dashLength;
rect.width = (spaceX == (numDashSpaces - 1)) ? endDashLength : dashLength;
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel);
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel);
}
}
else {
GetDashInfo(aBorder.height, dashLength, twipsPerPixel, numDashSpaces, startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, aBorder.width, startDashLength);
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel);
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel);
for (int32_t spaceY = 0; spaceY < numDashSpaces; spaceY++) {
rect.y += rect.height + dashLength;
rect.height = (spaceY == (numDashSpaces - 1)) ? endDashLength : dashLength;
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel);
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel);
}
}
}
@ -3667,7 +3680,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if ((horizontal && (twipsPerPixel >= aBorder.height)) ||
(!horizontal && (twipsPerPixel >= aBorder.width))) {
// a one pixel border
DrawSolidBorderSegment(aContext, aBorder, aBorderColor, twipsPerPixel,
DrawSolidBorderSegment(aContext, aBorder, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, aStartBevelOffset,
aEndBevelSide, aEndBevelOffset);
}
@ -3679,7 +3692,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
mozilla::css::Side ridgeGrooveSide = (horizontal) ? NS_SIDE_TOP : NS_SIDE_LEFT;
// FIXME: In theory, this should use the visited-dependent
// background color, but I don't care.
aContext.SetColor (
ctx->SetColor(
MakeBevelColor(ridgeGrooveSide, ridgeGroove, aBGColor->mBackgroundColor, aBorderColor));
nsRect rect(aBorder);
nscoord half;
@ -3693,7 +3706,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_TOP == aEndBevelSide) {
rect.width -= endBevel;
}
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
}
else { // left, right
@ -3706,7 +3719,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_LEFT == aEndBevelSide) {
rect.height -= endBevel;
}
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
}
@ -3714,7 +3727,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
ridgeGrooveSide = (NS_SIDE_TOP == ridgeGrooveSide) ? NS_SIDE_BOTTOM : NS_SIDE_RIGHT;
// FIXME: In theory, this should use the visited-dependent
// background color, but I don't care.
aContext.SetColor (
ctx->SetColor(
MakeBevelColor(ridgeGrooveSide, ridgeGroove, aBGColor->mBackgroundColor, aBorderColor));
if (horizontal) {
rect.y = rect.y + half;
@ -3726,7 +3739,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_BOTTOM == aEndBevelSide) {
rect.width -= endBevel;
}
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
}
else {
@ -3739,7 +3752,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_RIGHT == aEndBevelSide) {
rect.height -= endBevel;
}
DrawSolidBorderSegment(aContext, rect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, rect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
}
}
@ -3766,7 +3779,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_TOP == aEndBevelSide) {
topRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aContext, topRect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, topRect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
// draw the botom line or rect
@ -3779,7 +3792,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_BOTTOM == aEndBevelSide) {
bottomRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aContext, bottomRect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, bottomRect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
}
else { // left, right
@ -3793,7 +3806,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_LEFT == aEndBevelSide) {
leftRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aContext, leftRect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, leftRect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
nscoord widthOffset = aBorder.width - thirdWidth;
@ -3805,14 +3818,14 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_RIGHT == aEndBevelSide) {
rightRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aContext, rightRect, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, rightRect, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
startBevel, aEndBevelSide, endBevel);
}
break;
}
// else fall through to solid
case NS_STYLE_BORDER_STYLE_SOLID:
DrawSolidBorderSegment(aContext, aBorder, aBorderColor, twipsPerPixel, aStartBevelSide,
DrawSolidBorderSegment(aContext, aBorder, aBorderColor, aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
aStartBevelOffset, aEndBevelSide, aEndBevelOffset);
break;
case NS_STYLE_BORDER_STYLE_OUTSET:

View File

@ -589,6 +589,7 @@ struct nsCSSRendering {
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
const nsRect& aBorderRect,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
uint8_t aStartBevelSide = 0,
nscoord aStartBevelOffset = 0,

View File

@ -3062,12 +3062,16 @@ nsDisplayBoxShadowInner::Paint(nsDisplayListBuilder* aBuilder,
PROFILER_LABEL("nsDisplayBoxShadowInner", "Paint",
js::ProfileEntry::Category::GRAPHICS);
DrawTarget* drawTarget = aCtx->GetDrawTarget();
gfxContext* gfx = aCtx->ThebesContext();
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
for (uint32_t i = 0; i < rects.Length(); ++i) {
aCtx->ThebesContext()->Save();
aCtx->IntersectClip(rects[i]);
gfx->Save();
gfx->Clip(NSRectToRect(rects[i], appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBoxShadowInner(presContext, *aCtx, mFrame,
borderRect, rects[i]);
aCtx->ThebesContext()->Restore();
gfx->Restore();
}
}

View File

@ -4710,7 +4710,7 @@ nsLayoutUtils::PaintTextShadow(const nsIFrame* aFrame,
// Conjure an nsRenderingContext from a gfxContext for drawing the text
// to blur.
nsRefPtr<nsRenderingContext> renderingContext = new nsRenderingContext();
renderingContext->Init(presCtx->DeviceContext(), shadowContext);
renderingContext->Init(shadowContext);
aDestCtx->Save();
aDestCtx->NewPath();
@ -7060,6 +7060,19 @@ Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel,
return rect;
}
void StrokeLineWithSnapping(const nsPoint& aP1, const nsPoint& aP2,
int32_t aAppUnitsPerDevPixel,
DrawTarget& aDrawTarget,
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aDrawOptions)
{
Point p1 = NSPointToPoint(aP1, aAppUnitsPerDevPixel);
Point p2 = NSPointToPoint(aP2, aAppUnitsPerDevPixel);
SnapLineToDevicePixelsForStroking(p1, p2, aDrawTarget);
aDrawTarget.StrokeLine(p1, p2, aPattern, aStrokeOptions, aDrawOptions);
}
namespace layout {

View File

@ -2425,6 +2425,13 @@ gfx::Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel);
gfx::Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel,
const gfx::DrawTarget& aSnapDT);
void StrokeLineWithSnapping(const nsPoint& aP1, const nsPoint& aP2,
int32_t aAppUnitsPerDevPixel,
gfx::DrawTarget& aDrawTarget,
const gfx::Pattern& aPattern,
const gfx::StrokeOptions& aStrokeOptions = gfx::StrokeOptions(),
const gfx::DrawOptions& aDrawOptions = gfx::DrawOptions());
namespace layout {
/**

View File

@ -3071,7 +3071,7 @@ PresShell::CreateReferenceRenderingContext()
nsRefPtr<nsRenderingContext> rc;
if (mPresContext->IsScreen()) {
rc = new nsRenderingContext();
rc->Init(devCtx, gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
rc->Init(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
} else {
rc = devCtx->CreateRenderingContext();
}
@ -4807,7 +4807,7 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
AutoSaveRestoreRenderingState _(this);
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
rc->Init(devCtx, aThebesContext);
rc->Init(aThebesContext);
bool wouldFlushRetainedLayers = false;
uint32_t flags = nsLayoutUtils::PAINT_IGNORE_SUPPRESSION;
@ -5061,8 +5061,6 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
if (!pc || aArea.width == 0 || aArea.height == 0)
return nullptr;
nsDeviceContext* deviceContext = pc->DeviceContext();
// use the rectangle to create the surface
nsIntRect pixelArea = aArea.ToOutsidePixels(pc->AppUnitsPerDevPixel());
@ -5075,7 +5073,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
// if the image is larger in one or both directions than half the size of
// the available screen area, scale the image down to that size.
nsRect maxSize;
deviceContext->GetClientRect(maxSize);
pc->DeviceContext()->GetClientRect(maxSize);
nscoord maxWidth = pc->AppUnitsToDevPixels(maxSize.width >> 1);
nscoord maxHeight = pc->AppUnitsToDevPixels(maxSize.height >> 1);
bool resize = (pixelArea.width > maxWidth || pixelArea.height > maxHeight);
@ -5128,7 +5126,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
}
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
rc->Init(deviceContext, ctx);
rc->Init(ctx);
gfxMatrix initialTM = ctx->CurrentMatrix();
@ -10109,9 +10107,9 @@ void ReflowCountMgr::PaintCount(const char* aName,
ColorPattern black(ToDeviceColor(Color(0.f, 0.f, 0.f, 1.f)));
drawTarget->FillRect(devPxRect, black);
aRenderingContext->SetColor(color2);
aRenderingContext->ThebesContext()->SetColor(color2);
aRenderingContext->DrawString(buf, strlen(buf), x+15,y+15);
aRenderingContext->SetColor(color);
aRenderingContext->ThebesContext()->SetColor(color);
aRenderingContext->DrawString(buf, strlen(buf), x,y);
aRenderingContext->ThebesContext()->Restore();

View File

@ -1505,9 +1505,13 @@ void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || sFocused != this)
return;
aRenderingContext.ThebesContext()->Save();
gfxContext* gfx = aRenderingContext.ThebesContext();
gfx->Save();
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
aRenderingContext.IntersectClip(clipRect);
gfx->Clip(NSRectToRect(clipRect,
PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
// REVIEW: Why does the old code paint mDisplayFrame again? We've
// already painted it in the children above. So clipping it here won't do
@ -1527,7 +1531,7 @@ void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
StrokeSnappedEdgesOfRect(r, *aRenderingContext.GetDrawTarget(),
color, strokeOptions);
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
}
//---------------------------------------------------------

View File

@ -5,7 +5,9 @@
#include "nsFieldSetFrame.h"
#include "mozilla/gfx/2D.h"
#include "nsCSSAnonBoxes.h"
#include "nsLayoutUtils.h"
#include "nsLegendFrame.h"
#include "nsCSSRendering.h"
#include <algorithm>
@ -21,6 +23,7 @@
#include "mozilla/Maybe.h"
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::layout;
nsContainerFrame*
@ -219,12 +222,15 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.width = legendRect.x - rect.x;
clipRect.height = topBorder;
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(clipRect);
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
// draw right side
@ -233,12 +239,11 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.width = rect.XMost() - legendRect.XMost();
clipRect.height = topBorder;
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(clipRect);
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
// draw bottom
@ -246,12 +251,11 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.y += topBorder;
clipRect.height = mRect.height - (yoff + topBorder);
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(clipRect);
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
} else {
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,

View File

@ -212,7 +212,7 @@ nsDisplayTextOverflowMarker::Paint(nsDisplayListBuilder* aBuilder,
nsLayoutUtils::PaintTextShadow(mFrame, aCtx, mRect, mVisibleRect,
foregroundColor, PaintTextShadowCallback,
(void*)this);
aCtx->SetColor(foregroundColor);
aCtx->ThebesContext()->SetColor(foregroundColor);
PaintTextToContext(aCtx, nsPoint(0, 0));
}

View File

@ -319,7 +319,6 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
nsRefPtr<nsFontMetrics> fm;
ColorPattern color(ToDeviceColor(
nsLayoutUtils::GetColor(this, eCSSProperty_color)));
aRenderingContext.SetColor(nsLayoutUtils::GetColor(this, eCSSProperty_color));
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
@ -421,6 +420,9 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
break;
default:
aRenderingContext.ThebesContext()->SetColor(
nsLayoutUtils::GetColor(this, eCSSProperty_color));
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
GetFontSizeInflation());
GetListItemText(text);

View File

@ -300,7 +300,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
ctx->SetMatrix(
ctx->CurrentMatrix().Translate(-destRect.x, -destRect.y));
context = new nsRenderingContext();
context->Init(aCtx->DeviceContext(), ctx);
context->Init(ctx);
}
}
#endif

View File

@ -11,6 +11,7 @@
#include "gfxUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Helpers.h"
#include "mozilla/Likely.h"
#include "nsGenericHTMLElement.h"
@ -111,7 +112,7 @@ public:
void SetVisibility(bool aVisibility);
void SetColor(nscolor aColor);
void PaintBorder(nsRenderingContext& aRenderingContext, nsPoint aPt);
void PaintBorder(DrawTarget* aDrawTarget, nsPoint aPt);
protected:
nsHTMLFramesetBorderFrame(nsStyleContext* aContext, int32_t aWidth, bool aVertical, bool aVisible);
@ -1491,7 +1492,7 @@ void nsDisplayFramesetBorder::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
static_cast<nsHTMLFramesetBorderFrame*>(mFrame)->
PaintBorder(*aCtx, ToReferenceFrame());
PaintBorder(aCtx->GetDrawTarget(), ToReferenceFrame());
}
void
@ -1503,49 +1504,52 @@ nsHTMLFramesetBorderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
new (aBuilder) nsDisplayFramesetBorder(aBuilder, this));
}
void nsHTMLFramesetBorderFrame::PaintBorder(nsRenderingContext& aRenderingContext,
void nsHTMLFramesetBorderFrame::PaintBorder(DrawTarget* aDrawTarget,
nsPoint aPt)
{
nscolor WHITE = NS_RGB(255, 255, 255);
nscolor bgColor =
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetBackground,
NS_RGB(200,200,200));
nscolor fgColor =
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetForeground,
NS_RGB(0,0,0));
nscolor hltColor =
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DHighlight,
NS_RGB(255,255,255));
nscolor sdwColor =
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DShadow,
NS_RGB(128,128,128));
gfxContext* ctx = aRenderingContext.ThebesContext();
gfxPoint toRefFrame =
nsLayoutUtils::PointToGfxPoint(aPt, PresContext()->AppUnitsPerDevPixel());
gfxContextMatrixAutoSaveRestore autoSR(ctx);
ctx->SetMatrix(ctx->CurrentMatrix().Translate(toRefFrame));
nscoord widthInPixels = nsPresContext::AppUnitsToIntCSSPixels(mWidth);
nscoord pixelWidth = nsPresContext::CSSPixelsToAppUnits(1);
if (widthInPixels <= 0)
return;
nsPoint start(0,0);
nsPoint end((mVertical) ? 0 : mRect.width, (mVertical) ? mRect.height : 0);
ColorPattern bgColor(ToDeviceColor(
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetBackground,
NS_RGB(200, 200, 200))));
nscolor color = WHITE;
ColorPattern fgColor(ToDeviceColor(
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetForeground,
NS_RGB(0, 0, 0))));
ColorPattern hltColor(ToDeviceColor(
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DHighlight,
NS_RGB(255, 255, 255))));
ColorPattern sdwColor(ToDeviceColor(
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DShadow,
NS_RGB(128, 128, 128))));
ColorPattern color(ToDeviceColor(NS_RGB(255, 255, 255))); // default to white
if (mVisibility || mVisibilityOverride) {
color = (NO_COLOR == mColor) ? bgColor : mColor;
color = (NO_COLOR == mColor) ? bgColor :
ColorPattern(ToDeviceColor(mColor));
}
aRenderingContext.SetColor(color);
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
Point toRefFrame = NSPointToPoint(aPt, appUnitsPerDevPixel);
AutoRestoreTransform autoRestoreTransform(aDrawTarget);
aDrawTarget->SetTransform(
aDrawTarget->GetTransform().PreTranslate(toRefFrame));
nsPoint start(0, 0);
nsPoint end = mVertical ? nsPoint(0, mRect.height) : nsPoint(mRect.width, 0);
// draw grey or white first
for (int i = 0; i < widthInPixels; i++) {
aRenderingContext.DrawLine (start, end);
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
color);
if (mVertical) {
start.x += pixelWidth;
end.x = start.x;
@ -1559,30 +1563,30 @@ void nsHTMLFramesetBorderFrame::PaintBorder(nsRenderingContext& aRenderingContex
return;
if (widthInPixels >= 5) {
aRenderingContext.SetColor(hltColor);
start.x = (mVertical) ? pixelWidth : 0;
start.y = (mVertical) ? 0 : pixelWidth;
end.x = (mVertical) ? start.x : mRect.width;
end.y = (mVertical) ? mRect.height : start.y;
aRenderingContext.DrawLine(start, end);
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
hltColor);
}
if (widthInPixels >= 2) {
aRenderingContext.SetColor(sdwColor);
start.x = (mVertical) ? mRect.width - (2 * pixelWidth) : 0;
start.y = (mVertical) ? 0 : mRect.height - (2 * pixelWidth);
end.x = (mVertical) ? start.x : mRect.width;
end.y = (mVertical) ? mRect.height : start.y;
aRenderingContext.DrawLine(start, end);
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
sdwColor);
}
if (widthInPixels >= 1) {
aRenderingContext.SetColor(fgColor);
start.x = (mVertical) ? mRect.width - pixelWidth : 0;
start.y = (mVertical) ? 0 : mRect.height - pixelWidth;
end.x = (mVertical) ? start.x : mRect.width;
end.y = (mVertical) ? mRect.height : start.y;
aRenderingContext.DrawLine(start, end);
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
fgColor);
}
}

View File

@ -1076,7 +1076,7 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
const nsRect& aRect)
{
// Set font and color
aRenderingContext.SetColor(StyleColor()->mColor);
aRenderingContext.ThebesContext()->SetColor(StyleColor()->mColor);
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(this));
@ -1220,9 +1220,13 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext,
return;
}
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
// Clip so we don't render outside the inner rect
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(inner);
gfx->Save();
gfx->Clip(NSRectToRect(inner, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
// Check if we should display image placeholders
if (gIconLoad->mPrefShowPlaceholders) {
@ -1261,7 +1265,6 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext,
// just draw some graffiti in the mean time
if (!iconUsed) {
ColorPattern color(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
nscoord iconXPos = (vis->mDirection == NS_STYLE_DIRECTION_RTL) ?
inner.XMost() - size : inner.x;

View File

@ -4,6 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPageFrame.h"
#include "mozilla/gfx/2D.h"
#include "nsDeviceContext.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsRenderingContext.h"
#include "nsGkAtoms.h"
@ -25,6 +29,7 @@ extern PRLogModuleInfo *GetLayoutPrintingLog();
#endif
using namespace mozilla;
using namespace mozilla::gfx;
nsPageFrame*
NS_NewPageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
@ -372,12 +377,16 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
y = aRect.YMost() - aHeight - mPD->mEdgePaperMargin.bottom;
}
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
// set up new clip and draw the text
aRenderingContext.ThebesContext()->Save();
aRenderingContext.SetColor(NS_RGB(0,0,0));
aRenderingContext.IntersectClip(aRect);
gfx->Save();
gfx->Clip(NSRectToRect(aRect, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
aRenderingContext.ThebesContext()->SetColor(NS_RGB(0,0,0));
nsLayoutUtils::DrawString(this, &aRenderingContext, str.get(), str.Length(), nsPoint(x, y + aAscent));
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
}
}
@ -578,7 +587,7 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
}
nsRect rect(aPt, mRect.Size());
aRenderingContext.SetColor(NS_RGB(0,0,0));
aRenderingContext.ThebesContext()->SetColor(NS_RGB(0,0,0));
// Get the FontMetrics to determine width.height of strings
nsRefPtr<nsFontMetrics> fontMet;

View File

@ -6,6 +6,7 @@
#include "nsSimplePageSequenceFrame.h"
#include "nsCOMPtr.h"
#include "nsDeviceContext.h"
#include "nsPresContext.h"
#include "gfxContext.h"
#include "nsRenderingContext.h"

View File

@ -10,6 +10,7 @@
#include "mozilla/MathAlgorithms.h"
#include "nsCOMPtr.h"
#include "nsDeviceContext.h"
#include "nsIFrame.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"

View File

@ -106,7 +106,7 @@ void nsDisplayMathMLError::Paint(nsDisplayListBuilder* aBuilder,
ColorPattern red(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
drawTarget->FillRect(rect, red);
aCtx->SetColor(NS_RGB(255,255,255));
aCtx->ThebesContext()->SetColor(NS_RGB(255,255,255));
nscoord ascent = aCtx->FontMetrics()->MaxAscent();
NS_NAMED_LITERAL_STRING(errorMsg, "invalid-markup");
aCtx->DrawString(errorMsg.get(), uint32_t(errorMsg.Length()),

View File

@ -774,7 +774,8 @@ void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder,
// paint the frame with the current text color
ColorPattern color(ToDeviceColor(
mFrame->GetVisitedDependentColor(eCSSProperty_color)));
aCtx->SetColor(mFrame->GetVisitedDependentColor(eCSSProperty_color));
aCtx->ThebesContext()->SetColor(
mFrame->GetVisitedDependentColor(eCSSProperty_color));
DrawTarget* drawTarget = aCtx->GetDrawTarget();

View File

@ -604,7 +604,7 @@ void nsDisplayMathMLSlash::Paint(nsDisplayListBuilder* aBuilder,
gfxRect rect = presContext->AppUnitsToGfxUnits(mRect + ToReferenceFrame());
// paint with the current text color
aCtx->SetColor(mFrame->GetVisitedDependentColor(eCSSProperty_color));
aCtx->ThebesContext()->SetColor(mFrame->GetVisitedDependentColor(eCSSProperty_color));
// draw the slash as a parallelogram
gfxContext *gfxCtx = aCtx->ThebesContext();

View File

@ -17,6 +17,7 @@
#include "mozilla/Likely.h"
#include "mozilla/LookAndFeel.h"
#include "nsDeviceContext.h"
#include "nsRuleNode.h"
#include "nscore.h"
#include "nsIWidget.h"

View File

@ -449,7 +449,7 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
PreMultiply(deviceToFilterSpace));
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
tmpCtx->Init(mTargetFrame->PresContext()->DeviceContext(), ctx);
tmpCtx->Init(ctx);
mPaintCallback->Paint(tmpCtx, mTargetFrame, mPaintTransform, &dirty);
mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();

View File

@ -473,6 +473,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
bool isTrivialClip = clipPathFrame ? clipPathFrame->IsTrivial() : true;
DrawTarget* drawTarget = aCtx->GetDrawTarget();
gfxContext* gfx = aCtx->ThebesContext();
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(gfx);
@ -519,8 +520,11 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
|| aFrame->StyleDisplay()->mMixBlendMode != NS_STYLE_BLEND_NORMAL) {
complexEffects = true;
gfx->Save();
aCtx->IntersectClip(aFrame->GetVisualOverflowRectRelativeToSelf() +
toUserSpace);
nsRect clipRect =
aFrame->GetVisualOverflowRectRelativeToSelf() + toUserSpace;
gfx->Clip(NSRectToRect(clipRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
}
@ -638,7 +642,7 @@ PaintFrameCallback::operator()(gfxContext* aContext,
mFrame->AddStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
context->Init(mFrame->PresContext()->DeviceContext(), aContext);
context->Init(aContext);
aContext->Save();
// Clip to aFillRect so that we don't paint outside.

View File

@ -227,7 +227,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft());
nsRefPtr<nsRenderingContext> tmpCtx = new nsRenderingContext();
tmpCtx->Init(this->PresContext()->DeviceContext(), maskDT);
tmpCtx->Init(maskDT);
tmpCtx->ThebesContext()->SetMatrix(maskSurfaceMatrix);
mMatrixForChildren = GetMaskTransform(aMaskedFrame) * aMatrix;

View File

@ -379,7 +379,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
}
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
context->Init(aSource->PresContext()->DeviceContext(), dt);
context->Init(dt);
gfxContext* gfx = context->ThebesContext();
// Fill with transparent black

View File

@ -28,6 +28,7 @@
#include "nsIFrame.h"
#include "nsIPresShell.h"
#include "nsISVGChildFrame.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsRenderingContext.h"
#include "nsStyleCoord.h"
@ -556,6 +557,7 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
if (opacity != 1.0f && CanOptimizeOpacity(aFrame))
opacity = 1.0f;
DrawTarget* drawTarget = aContext->GetDrawTarget();
gfxContext *gfx = aContext->ThebesContext();
bool complexEffects = false;
@ -587,7 +589,9 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
// GetCanvasTM().
overflowRect = overflowRect + aFrame->GetPosition();
}
aContext->IntersectClip(overflowRect);
gfx->Clip(NSRectToRect(overflowRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
}
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
}
@ -1585,7 +1589,7 @@ nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
aContext->GetDrawTarget()->AddUserData(&gfxTextContextPaint::sUserDataKey,
aContextPaint, nullptr);
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
context->Init(frame->PresContext()->DeviceContext(), aContext);
context->Init(aContext);
svgFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED);
gfxMatrix m;
if (frame->GetContent()->IsSVG()) {

View File

@ -335,21 +335,28 @@ nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext,
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aRenderingContext.SetColor(bordercolor);
aRenderingContext.DrawLine(onePixel, 0, mRect.width, 0);
aRenderingContext.DrawLine(0, onePixel, 0, mRect.height);
aRenderingContext.DrawLine(onePixel, mRect.height, mRect.width, mRect.height);
aRenderingContext.DrawLine(mRect.width, onePixel, mRect.width, mRect.height);
StrokeLineWithSnapping(nsPoint(onePixel, 0), nsPoint(mRect.width, 0),
appUnitsPerDevPixel, *drawTarget, color);
StrokeLineWithSnapping(nsPoint(0, onePixel), nsPoint(0, mRect.height),
appUnitsPerDevPixel, *drawTarget, color);
StrokeLineWithSnapping(nsPoint(onePixel, mRect.height),
nsPoint(mRect.width, mRect.height),
appUnitsPerDevPixel, *drawTarget, color);
StrokeLineWithSnapping(nsPoint(mRect.width, onePixel),
nsPoint(mRect.width, mRect.height),
appUnitsPerDevPixel, *drawTarget, color);
//middle
nsRect r(onePixel, onePixel,
mRect.width - onePixel, mRect.height - onePixel);
Rect devPixelRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
drawTarget->StrokeRect(devPixelRect, color);
//shading
aRenderingContext.DrawLine(2*onePixel, mRect.height-2*onePixel,
mRect.width-onePixel, mRect.height- (2*onePixel));
aRenderingContext.DrawLine(mRect.width - (2*onePixel), 2*onePixel,
mRect.width - (2*onePixel), mRect.height-onePixel);
StrokeLineWithSnapping(nsPoint(2*onePixel, mRect.height-2*onePixel),
nsPoint(mRect.width-onePixel, mRect.height- (2*onePixel)),
appUnitsPerDevPixel, *drawTarget, color);
StrokeLineWithSnapping(nsPoint(mRect.width - (2*onePixel), 2*onePixel),
nsPoint(mRect.width - (2*onePixel), mRect.height-onePixel),
appUnitsPerDevPixel, *drawTarget, color);
}
}
}

View File

@ -6929,6 +6929,10 @@ BCVerticalSeg::Paint(BCPaintBorderIterator& aIter,
uint8_t style = NS_STYLE_BORDER_STYLE_SOLID;
nscolor color = 0xFFFFFFFF;
// All the tables frames have the same presContext, so we just use any one
// that exists here:
int32_t appUnitsPerDevPixel = col->PresContext()->AppUnitsPerDevPixel();
switch (mOwner) {
case eTableOwner:
owner = aIter.mTable;
@ -6989,6 +6993,7 @@ BCVerticalSeg::Paint(BCPaintBorderIterator& aIter,
NS_SIDE_RIGHT : NS_SIDE_LEFT;
nsCSSRendering::DrawTableBorderSegment(aRenderingContext, style, color,
aIter.mTableBgColor, segRect,
appUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
topBevelSide, mTopBevelOffset,
bottomBevelSide, bottomBevelOffset);
@ -7109,6 +7114,10 @@ BCHorizontalSeg::Paint(BCPaintBorderIterator& aIter,
nsIFrame* col;
nsIFrame* owner = nullptr;
// All the tables frames have the same presContext, so we just use any one
// that exists here:
int32_t appUnitsPerDevPixel = row->PresContext()->AppUnitsPerDevPixel();
uint8_t style = NS_STYLE_BORDER_STYLE_SOLID;
nscolor color = 0xFFFFFFFF;
@ -7171,6 +7180,7 @@ BCHorizontalSeg::Paint(BCPaintBorderIterator& aIter,
if (aIter.mTableIsLTR) {
nsCSSRendering::DrawTableBorderSegment(aRenderingContext, style, color,
aIter.mTableBgColor, segRect,
appUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
mLeftBevelSide,
nsPresContext::CSSPixelsToAppUnits(mLeftBevelOffset),
@ -7180,6 +7190,7 @@ BCHorizontalSeg::Paint(BCPaintBorderIterator& aIter,
segRect.x -= segRect.width;
nsCSSRendering::DrawTableBorderSegment(aRenderingContext, style, color,
aIter.mTableBgColor, segRect,
appUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
mRightBevelSide, mRightBevelOffset,
mLeftBevelSide,

View File

@ -37,6 +37,7 @@
#include "mozilla/gfx/2D.h"
#include "nsBoxLayoutState.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/Move.h"
#include "nsStyleContext.h"
#include "nsPlaceholderFrame.h"
#include "nsPresContext.h"
@ -1292,7 +1293,7 @@ nsDisplayXULDebug::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
static_cast<nsBoxFrame*>(mFrame)->
PaintXULDebugOverlay(*aCtx, ToReferenceFrame());
PaintXULDebugOverlay(*aCtx->GetDrawTarget(), ToReferenceFrame());
}
static void
@ -1472,8 +1473,7 @@ nsBoxFrame::PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
}
void
nsBoxFrame::PaintXULDebugOverlay(nsRenderingContext& aRenderingContext,
nsPoint aPt)
nsBoxFrame::PaintXULDebugOverlay(DrawTarget& aDrawTarget, nsPoint aPt)
nsMargin border;
GetBorder(border);
@ -1516,14 +1516,12 @@ nsBoxFrame::PaintXULDebugOverlay(nsRenderingContext& aRenderingContext,
nscoord flex = kid->GetFlex(state);
if (!kid->IsCollapsed()) {
aRenderingContext.SetColor(NS_RGB(255,255,255));
if (isHorizontal)
borderSize = cr.width;
else
borderSize = cr.height;
DrawSpacer(GetPresContext(), aRenderingContext, isHorizontal, flex, x, y, borderSize, spacerSize);
DrawSpacer(GetPresContext(), aDrawTarget, isHorizontal, flex, x, y, borderSize, spacerSize);
}
kid = GetNextBox(kid);
@ -1598,28 +1596,34 @@ nsBoxFrame::GetDebug(bool& aDebug)
#ifdef DEBUG_LAYOUT
void
nsBoxFrame::DrawLine(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2)
nsBoxFrame::DrawLine(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2)
{
if (aHorizontal)
aRenderingContext.DrawLine(x1,y1,x2,y2);
else
aRenderingContext.DrawLine(y1,x1,y2,x2);
nsPoint p1(x1, y1);
nsPoint p2(x2, y2);
if (!aHorizontal) {
Swap(p1.x, p1.y);
Swap(p2.x, p2.y);
}
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
StrokeLineWithSnapping(p1, p2, PresContext()->AppUnitsPerDevPixel(),
aDrawTarget, color);
}
void
nsBoxFrame::FillRect(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height)
nsBoxFrame::FillRect(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height)
{
DrawTarget* drawTarget = aRenderingContext->GetDrawTarget();
Rect rect = NSRectToRect(aHorizontal ? nsRect(x, y, width, height) :
nsRect(y, x, height, width),
PresContext()->AppUnitsPerDevPixel(),
*drawTarget);
aDrawTarget);
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
drawTarget->FillRect(rect, white);
aDrawTarget.FillRect(rect, white);
}
void
nsBoxFrame::DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize)
nsBoxFrame::DrawSpacer(nsPresContext* aPresContext, DrawTarget& aDrawTarget,
bool aHorizontal, int32_t flex, nscoord x, nscoord y,
nscoord size, nscoord spacerSize)
{
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
@ -1639,21 +1643,19 @@ nsBoxFrame::DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderi
int halfCoilSize = coilSize/2;
if (flex == 0) {
DrawLine(aRenderingContext, aHorizontal, x,y + spacerSize/2, x + size, y + spacerSize/2);
DrawLine(aDrawTarget, aHorizontal, x,y + spacerSize/2, x + size, y + spacerSize/2);
} else {
for (int i=0; i < coils; i++)
{
DrawLine(aRenderingContext, aHorizontal, offset, center+halfSpacer, offset+halfCoilSize, center-halfSpacer);
DrawLine(aRenderingContext, aHorizontal, offset+halfCoilSize, center-halfSpacer, offset+coilSize, center+halfSpacer);
DrawLine(aDrawTarget, aHorizontal, offset, center+halfSpacer, offset+halfCoilSize, center-halfSpacer);
DrawLine(aDrawTarget, aHorizontal, offset+halfCoilSize, center-halfSpacer, offset+coilSize, center+halfSpacer);
offset += coilSize;
}
}
FillRect(aRenderingContext, aHorizontal, x + size - spacerSize/2, y, spacerSize/2, spacerSize);
FillRect(aRenderingContext, aHorizontal, x, y, spacerSize/2, spacerSize);
//DrawKnob(aPresContext, aRenderingContext, x + size - spacerSize, y, spacerSize);
FillRect(aDrawTarget, aHorizontal, x + size - spacerSize/2, y, spacerSize/2, spacerSize);
FillRect(aDrawTarget, aHorizontal, x, y, spacerSize/2, spacerSize);
}
void

View File

@ -21,6 +21,12 @@
class nsBoxLayoutState;
namespace mozilla {
namespace gfx {
class DrawTarget;
}
}
nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,
bool aIsRoot,
@ -30,6 +36,9 @@ nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
class nsBoxFrame : public nsContainerFrame
{
protected:
typedef mozilla::gfx::DrawTarget DrawTarget;
public:
NS_DECL_FRAMEARENA_HELPERS
#ifdef DEBUG
@ -174,7 +183,7 @@ protected:
virtual void GetBoxName(nsAutoString& aName) MOZ_OVERRIDE;
void PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
nsPoint aPt);
void PaintXULDebugOverlay(nsRenderingContext& aRenderingContext,
void PaintXULDebugOverlay(DrawTarget& aRenderingContext,
nsPoint aPt);
#endif
@ -224,9 +233,9 @@ private:
void GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* value);
void GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* value);
void DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
void DrawLine(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
void FillRect(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
void DrawSpacer(nsPresContext* aPresContext, DrawTarget& aDrawTarget, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
void DrawLine(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
void FillRect(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
#endif
virtual void UpdateMouseThrough();

View File

@ -6,11 +6,17 @@
// YY need to pass isMultiple before create called
#include "nsBoxFrame.h"
#include "mozilla/gfx/2D.h"
#include "nsCSSRendering.h"
#include "nsLayoutUtils.h"
#include "nsRenderingContext.h"
#include "nsStyleContext.h"
#include "nsDisplayList.h"
using namespace mozilla;
using namespace mozilla::gfx;
class nsGroupBoxFrame : public nsBoxFrame {
public:
NS_DECL_FRAMEARENA_HELPERS
@ -123,6 +129,10 @@ nsGroupBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
void
nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsPoint aPt, const nsRect& aDirtyRect) {
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
Sides skipSides;
const nsStyleBorder* borderStyleData = StyleBorder();
const nsMargin& border = borderStyleData->GetComputedBorder();
@ -152,6 +162,7 @@ nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES);
if (groupBox) {
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
// we should probably use PaintBorderEdges to do this but for now just use clipping
// to achieve the same effect.
@ -161,13 +172,11 @@ nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.width = groupRect.x - rect.x;
clipRect.height = border.top;
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(clipRect);
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, skipSides);
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
// draw right side
clipRect = rect;
@ -175,14 +184,11 @@ nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.width = rect.XMost() - groupRect.XMost();
clipRect.height = border.top;
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(clipRect);
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, skipSides);
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
// draw bottom
@ -190,12 +196,11 @@ nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.y += border.top;
clipRect.height = mRect.height - (yoff + border.top);
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(clipRect);
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, skipSides);
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
} else {
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,

View File

@ -507,7 +507,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
nscolor c = aOverrideColor ? *aOverrideColor : StyleColor()->mColor;
ColorPattern color(ToDeviceColor(c));
aRenderingContext.SetColor(c);
aRenderingContext.ThebesContext()->SetColor(c);
nsresult rv = NS_ERROR_FAILURE;

View File

@ -2797,8 +2797,13 @@ nsTreeBodyFrame::PaintTreeBody(nsRenderingContext& aRenderingContext,
{
// Update our available height and our page count.
CalcInnerBox();
aRenderingContext.ThebesContext()->Save();
aRenderingContext.IntersectClip(mInnerBox + aPt);
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
gfx->Save();
gfx->Clip(NSRectToRect(mInnerBox + aPt, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
int32_t oldPageCount = mPageLength;
if (!mHasFixedRowCount)
mPageLength = mInnerBox.height/mRowHeight;
@ -2856,7 +2861,7 @@ nsTreeBodyFrame::PaintTreeBody(nsRenderingContext& aRenderingContext,
PaintDropFeedback(feedbackRect, PresContext(), aRenderingContext, aDirtyRect, aPt);
}
}
aRenderingContext.ThebesContext()->Restore();
gfx->Restore();
}
@ -3613,7 +3618,6 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex,
// Set our color.
ColorPattern color(ToDeviceColor(textContext->StyleColor()->mColor));
aRenderingContext.SetColor(textContext->StyleColor()->mColor);
// Draw decorations.
uint8_t decorations = textContext->StyleTextReset()->mTextDecorationLine;
@ -3647,6 +3651,7 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex,
ctx->PushGroup(gfxContentType::COLOR_ALPHA);
}
ctx->SetColor(textContext->StyleColor()->mColor);
nsLayoutUtils::DrawString(this, &aRenderingContext, text.get(), text.Length(),
textRect.TopLeft() + nsPoint(0, baseline), cellContext);
@ -3752,9 +3757,6 @@ nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
// Adjust the rect for its border and padding.
AdjustForBorderPadding(meterContext, meterRect);
// Set our color.
aRenderingContext.SetColor(meterContext->StyleColor()->mColor);
// Now obtain the value for our cell.
nsAutoString value;
mView->GetCellValue(aRowIndex, aColumn, value);

View File

@ -4857,10 +4857,13 @@ nsHttpChannel::BeginConnect()
if (mLoadFlags & VALIDATE_ALWAYS || BYPASS_LOCAL_CACHE(mLoadFlags))
mCaps |= NS_HTTP_REFRESH_DNS;
if (!mConnectionInfo->UsingHttpProxy()) {
if (!mConnectionInfo->UsingHttpProxy() &&
!(mLoadFlags & (LOAD_NO_NETWORK_IO | LOAD_ONLY_FROM_CACHE))) {
// Start a DNS lookup very early in case the real open is queued the DNS can
// happen in parallel. Do not do so in the presence of an HTTP proxy as
// all lookups other than for the proxy itself are done by the proxy.
// Also we don't do a lookup if the LOAD_NO_NETWORK_IO or
// LOAD_ONLY_FROM_CACHE flags are set.
//
// We keep the DNS prefetch object around so that we can retrieve
// timing information from it. There is no guarantee that we actually

View File

@ -137,13 +137,20 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket(
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGV("AMR packet too short.");
LOGW("AMR packet too short.");
return MALFORMED_PACKET;
}
unsigned payloadHeader = buffer->data()[0];
CHECK_EQ(payloadHeader & 0x0f, 0u); // RR
if (payloadHeader & 0x0f != 0u) {
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGW("Wrong payload header");
return MALFORMED_PACKET;
}
Vector<uint8_t> tableOfContents;
@ -154,7 +161,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket(
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGV("Unable to parse TOC.");
LOGW("Unable to parse TOC.");
return MALFORMED_PACKET;
}
@ -168,7 +175,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket(
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGV("Illegal TOC entry.");
LOGW("Illegal TOC entry.");
return MALFORMED_PACKET;
}
@ -183,7 +190,12 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket(
}
sp<ABuffer> accessUnit = new ABuffer(totalSize);
CopyTimes(accessUnit, buffer);
if (!CopyTimes(accessUnit, buffer)) {
queue->erase(queue->begin());
++mNextExpectedSeqNo;
return MALFORMED_PACKET;
}
size_t dstOffset = 0;
for (size_t i = 0; i < tableOfContents.size(); ++i) {
@ -195,7 +207,7 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket(
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGV("AMR packet too short.");
LOGW("AMR packet too short.");
return MALFORMED_PACKET;
}

View File

@ -21,6 +21,8 @@
#include "ARTPSource.h"
#include "mozilla/Assertions.h"
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
@ -82,7 +84,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addNALUnit(
if (size < 1 || (data[0] & 0x80)) {
// Corrupt.
LOGV("Ignoring corrupt buffer.");
LOGW("Ignoring corrupt buffer.");
queue->erase(queue->begin());
++mNextExpectedSeqNo;
@ -91,10 +93,11 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addNALUnit(
unsigned nalType = data[0] & 0x1f;
if (nalType >= 1 && nalType <= 23) {
addSingleNALUnit(buffer);
bool success = addSingleNALUnit(buffer);
queue->erase(queue->begin());
++mNextExpectedSeqNo;
return OK;
return success ? OK : MALFORMED_PACKET;
} else if (nalType == 28) {
// FU-A
return addFragmentedNALUnit(queue);
@ -115,21 +118,29 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addNALUnit(
}
}
void AAVCAssembler::addSingleNALUnit(const sp<ABuffer> &buffer) {
bool AAVCAssembler::addSingleNALUnit(const sp<ABuffer> &buffer) {
LOGV("addSingleNALUnit of size %d", buffer->size());
#if !LOG_NDEBUG
hexdump(buffer->data(), buffer->size());
#endif
uint32_t rtpTime;
CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
if (!buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime)) {
LOGW("Cannot find rtp-time");
return false;
}
if (!mNALUnits.empty() && rtpTime != mAccessUnitRTPTime) {
submitAccessUnit();
if (!submitAccessUnit()) {
LOGW("Cannot find rtp-time. Malformed packet.");
return false;
}
}
mAccessUnitRTPTime = rtpTime;
mNALUnits.push_back(buffer);
return true;
}
bool AAVCAssembler::addSingleTimeAggregationPacket(const sp<ABuffer> &buffer) {
@ -154,9 +165,14 @@ bool AAVCAssembler::addSingleTimeAggregationPacket(const sp<ABuffer> &buffer) {
sp<ABuffer> unit = new ABuffer(nalSize);
memcpy(unit->data(), &data[2], nalSize);
CopyTimes(unit, buffer);
if (!CopyTimes(unit, buffer)) {
return false;
}
addSingleNALUnit(unit);
if (!addSingleNALUnit(unit)) {
LOGW("addSingleNALUnit() failed");
return false;
}
data += 2 + nalSize;
size -= 2 + nalSize;
@ -171,19 +187,31 @@ bool AAVCAssembler::addSingleTimeAggregationPacket(const sp<ABuffer> &buffer) {
ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
List<sp<ABuffer> > *queue) {
CHECK(!queue->empty());
MOZ_ASSERT(!queue->empty());
sp<ABuffer> buffer = *queue->begin();
const uint8_t *data = buffer->data();
size_t size = buffer->size();
CHECK(size > 0);
if (size <= 0) {
LOGW("Buffer is empty");
queue->erase(queue->begin());
++mNextExpectedSeqNo;
return MALFORMED_PACKET;
}
unsigned indicator = data[0];
CHECK((indicator & 0x1f) == 28);
if ((indicator & 0x1f) != 28) {
LOGW("Indicator is wrong");
queue->erase(queue->begin());
++mNextExpectedSeqNo;
return MALFORMED_PACKET;
}
if (size < 2) {
LOGV("Ignoring malformed FU buffer (size = %d)", size);
LOGW("Ignoring malformed FU buffer (size = %d)", size);
queue->erase(queue->begin());
++mNextExpectedSeqNo;
@ -193,7 +221,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
if (!(data[1] & 0x80)) {
// Start bit not set on the first buffer.
LOGV("Start bit not set on first buffer");
LOGW("Start bit not set on first buffer");
queue->erase(queue->begin());
++mNextExpectedSeqNo;
@ -235,7 +263,7 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
|| data[0] != indicator
|| (data[1] & 0x1f) != nalType
|| (data[1] & 0x80)) {
LOGV("Ignoring malformed FU buffer.");
LOGW("Ignoring malformed FU buffer.");
// Delete the whole start of the FU.
@ -277,7 +305,9 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
++totalSize;
sp<ABuffer> unit = new ABuffer(totalSize);
CopyTimes(unit, *queue->begin());
if (!CopyTimes(unit, *queue->begin())) {
return MALFORMED_PACKET;
}
unit->data()[0] = (nri << 5) | nalType;
@ -299,15 +329,17 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
unit->setRange(0, totalSize);
addSingleNALUnit(unit);
if (!addSingleNALUnit(unit)) {
return MALFORMED_PACKET;
}
LOGV("successfully assembled a NAL unit from fragments.");
return OK;
}
void AAVCAssembler::submitAccessUnit() {
CHECK(!mNALUnits.empty());
bool AAVCAssembler::submitAccessUnit() {
MOZ_ASSERT(!mNALUnits.empty());
LOGV("Access unit complete (%d nal units)", mNALUnits.size());
@ -329,7 +361,9 @@ void AAVCAssembler::submitAccessUnit() {
offset += nal->size();
}
CopyTimes(accessUnit, *mNALUnits.begin());
if (!CopyTimes(accessUnit, *mNALUnits.begin())) {
return false;
}
#if 0
printf(mAccessUnitDamaged ? "X" : ".");
@ -346,6 +380,7 @@ void AAVCAssembler::submitAccessUnit() {
sp<AMessage> msg = mNotifyMsg->dup();
msg->setObject("access-unit", accessUnit);
msg->post();
return true;
}
ARTPAssembler::AssemblyStatus AAVCAssembler::assembleMore(

View File

@ -49,11 +49,11 @@ private:
List<sp<ABuffer> > mNALUnits;
AssemblyStatus addNALUnit(const sp<ARTPSource> &source);
void addSingleNALUnit(const sp<ABuffer> &buffer);
bool addSingleNALUnit(const sp<ABuffer> &buffer);
AssemblyStatus addFragmentedNALUnit(List<sp<ABuffer> > *queue);
bool addSingleTimeAggregationPacket(const sp<ABuffer> &buffer);
void submitAccessUnit();
bool submitAccessUnit();
DISALLOW_EVIL_CONSTRUCTORS(AAVCAssembler);
};

View File

@ -19,6 +19,8 @@
#include "ARTPSource.h"
#include "RtspPrlog.h"
#include "mozilla/Assertions.h"
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
@ -84,10 +86,24 @@ ARTPAssembler::AssemblyStatus AH263Assembler::addPacket(
}
uint32_t rtpTime;
CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
if (!buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime)) {
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGW("Cannot find rtp-time. Malformed packet.");
return MALFORMED_PACKET;
}
if (mPackets.size() > 0 && rtpTime != mAccessUnitRTPTime) {
submitAccessUnit();
if (!submitAccessUnit()) {
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGW("Cannot find rtp-time. Malformed packet.");
return MALFORMED_PACKET;
}
}
mAccessUnitRTPTime = rtpTime;
@ -174,8 +190,8 @@ ARTPAssembler::AssemblyStatus AH263Assembler::addPacket(
return OK;
}
void AH263Assembler::submitAccessUnit() {
CHECK(!mPackets.empty());
bool AH263Assembler::submitAccessUnit() {
MOZ_ASSERT(!mPackets.empty());
#if VERBOSE
LOG(VERBOSE) << "Access unit complete (" << mPackets.size() << " packets)";
@ -204,7 +220,9 @@ void AH263Assembler::submitAccessUnit() {
++it;
}
CopyTimes(accessUnit, *mPackets.begin());
if (!CopyTimes(accessUnit, *mPackets.begin())) {
return false;
}
#if 0
printf(mAccessUnitDamaged ? "X" : ".");
@ -221,6 +239,8 @@ void AH263Assembler::submitAccessUnit() {
sp<AMessage> msg = mNotifyMsg->dup();
msg->setObject("access-unit", accessUnit);
msg->post();
return true;
}
void AH263Assembler::packetLost() {

View File

@ -48,7 +48,7 @@ private:
List<sp<ABuffer> > mPackets;
AssemblyStatus addPacket(const sp<ARTPSource> &source);
void submitAccessUnit();
bool submitAccessUnit();
DISALLOW_EVIL_CONSTRUCTORS(AH263Assembler);
};

View File

@ -21,6 +21,8 @@
#include "ARTPSource.h"
#include "mozilla/Assertions.h"
#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/foundation/ABitReader.h>
#include <media/stagefright/foundation/ABuffer.h>
@ -136,7 +138,9 @@ static status_t parseGASpecificConfig(
}
unsigned extensionFlag3 = bits->getBits(1);
CHECK_EQ(extensionFlag3, 0u); // TBD in version 3
if (extensionFlag3 != 0u) {
return ERROR_UNSUPPORTED; // TBD in version 3
}
}
return OK;
@ -147,7 +151,9 @@ static status_t parseAudioSpecificConfig(ABitReader *bits, sp<ABuffer> *asc) {
size_t totalNumBits = bits->numBitsLeft();
unsigned audioObjectType;
CHECK_EQ(parseAudioObjectType(bits, &audioObjectType), (status_t)OK);
if (parseAudioObjectType(bits, &audioObjectType) != (status_t)OK) {
return ERROR_UNSUPPORTED;
}
unsigned samplingFreqIndex = bits->getBits(4);
if (samplingFreqIndex == 0x0f) {
@ -166,16 +172,22 @@ static status_t parseAudioSpecificConfig(ABitReader *bits, sp<ABuffer> *asc) {
if (extensionSamplingFreqIndex == 0x0f) {
/* unsigned extensionSamplingFrequency = */bits->getBits(24);
}
CHECK_EQ(parseAudioObjectType(bits, &audioObjectType), (status_t)OK);
if (parseAudioObjectType(bits, &audioObjectType) != (status_t)OK) {
return ERROR_UNSUPPORTED;
}
}
CHECK((audioObjectType >= 1 && audioObjectType <= 4)
|| (audioObjectType >= 6 && audioObjectType <= 7)
|| audioObjectType == 17
|| (audioObjectType >= 19 && audioObjectType <= 23));
if (!((audioObjectType >= 1 && audioObjectType <= 4) ||
(audioObjectType >= 6 && audioObjectType <= 7) ||
audioObjectType == 17 ||
(audioObjectType >= 19 && audioObjectType <= 23))) {
return ERROR_UNSUPPORTED;
}
CHECK_EQ(parseGASpecificConfig(
bits, audioObjectType, channelConfiguration), (status_t)OK);
if (parseGASpecificConfig(bits, audioObjectType, channelConfiguration)
!= (status_t)OK) {
return ERROR_UNSUPPORTED;
}
if (audioObjectType == 17
|| (audioObjectType >= 19 && audioObjectType <= 27)) {
@ -186,7 +198,9 @@ static status_t parseAudioSpecificConfig(ABitReader *bits, sp<ABuffer> *asc) {
if (epConfig == 3) {
unsigned directMapping = bits->getBits(1);
CHECK_EQ(directMapping, 1u);
if (directMapping != 1u) {
return ERROR_UNSUPPORTED;
}
}
}
}
@ -198,8 +212,10 @@ static status_t parseAudioSpecificConfig(ABitReader *bits, sp<ABuffer> *asc) {
if (syncExtensionType == 0x2b7) {
LOGI("found syncExtension");
CHECK_EQ(parseAudioObjectType(bits, &extensionAudioObjectType),
(status_t)OK);
if (parseAudioObjectType(bits, &extensionAudioObjectType)
!= (status_t)OK) {
return ERROR_UNSUPPORTED;
}
sbrPresent = bits->getBits(1);
@ -266,28 +282,37 @@ static status_t parseStreamMuxConfig(
audioMuxVersionA = bits->getBits(1);
}
CHECK_EQ(audioMuxVersionA, 0u); // otherwise future spec
if (audioMuxVersionA != 0u) {
return ERROR_UNSUPPORTED; // future spec
}
if (audioMuxVersion != 0) {
if (audioMuxVersion != 0u) {
return ERROR_UNSUPPORTED; // XXX to be implemented;
}
CHECK_EQ(audioMuxVersion, 0u); // XXX to be implemented
unsigned allStreamsSameTimeFraming = bits->getBits(1);
CHECK_EQ(allStreamsSameTimeFraming, 1u); // There's only one stream.
if (allStreamsSameTimeFraming != 1u) {
return ERROR_UNSUPPORTED; // There's only one stream.
}
*numSubFrames = bits->getBits(6);
unsigned numProgram = bits->getBits(4);
CHECK_EQ(numProgram, 0u); // disabled in RTP LATM
if (numProgram != 0u) {
return ERROR_UNSUPPORTED; // disabled in RTP LATM
}
unsigned numLayer = bits->getBits(3);
CHECK_EQ(numLayer, 0u); // disabled in RTP LATM
if (numLayer != 0u) {
return ERROR_UNSUPPORTED; // disabled in RTP LATM
}
if (audioMuxVersion == 0) {
// AudioSpecificConfig
CHECK_EQ(parseAudioSpecificConfig(bits, NULL /* asc */), (status_t)OK);
if (parseAudioSpecificConfig(bits, NULL /* asc */) != (status_t)OK) {
return ERROR_UNSUPPORTED;
}
} else {
TRESPASS(); // XXX to be implemented
return ERROR_UNSUPPORTED; // XXX to be implemented
}
*frameLengthType = bits->getBits(3);
@ -339,7 +364,7 @@ static status_t parseStreamMuxConfig(
*otherDataLenBits = 0;
if (*otherDataPresent) {
if (audioMuxVersion == 1) {
TRESPASS(); // XXX to be implemented
return ERROR_UNSUPPORTED; // XXX to be implemented
} else {
*otherDataLenBits = 0;
@ -362,7 +387,9 @@ static status_t parseStreamMuxConfig(
}
sp<ABuffer> AMPEG4AudioAssembler::removeLATMFraming(const sp<ABuffer> &buffer) {
CHECK(!mMuxConfigPresent); // XXX to be implemented
if (mMuxConfigPresent) {
return NULL; // XXX to be implemented
}
sp<ABuffer> out = new ABuffer(buffer->size());
out->setRange(0, 0);
@ -404,7 +431,9 @@ sp<ABuffer> AMPEG4AudioAssembler::removeLATMFraming(const sp<ABuffer> &buffer) {
default:
{
CHECK_GE(mFixedFrameLength, 0);
if (mFixedFrameLength < 0) {
return NULL;
}
payloadLength = mFixedFrameLength;
break;
@ -425,8 +454,14 @@ sp<ABuffer> AMPEG4AudioAssembler::removeLATMFraming(const sp<ABuffer> &buffer) {
if (mOtherDataPresent) {
// We want to stay byte-aligned.
CHECK((mOtherDataLenBits % 8) == 0);
CHECK_LE(offset + (mOtherDataLenBits / 8), buffer->size());
if (mOtherDataLenBits % 8 != 0) {
mAccessUnitDamaged = true;
return out;
}
if (offset + (mOtherDataLenBits / 8) > buffer->size()) {
mAccessUnitDamaged = true;
return out;
}
offset += mOtherDataLenBits / 8;
}
}
@ -520,10 +555,17 @@ ARTPAssembler::AssemblyStatus AMPEG4AudioAssembler::addPacket(
}
uint32_t rtpTime;
CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
if (!buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime)) {
LOGW("Cannot find rtp-time. Malformed packet.");
return MALFORMED_PACKET;
}
if (mPackets.size() > 0 && rtpTime != mAccessUnitRTPTime) {
submitAccessUnit();
if (!submitAccessUnit()) {
LOGW("Cannot find rtp-time. Malformed packet.");
return MALFORMED_PACKET;
}
}
mAccessUnitRTPTime = rtpTime;
@ -535,8 +577,8 @@ ARTPAssembler::AssemblyStatus AMPEG4AudioAssembler::addPacket(
return OK;
}
void AMPEG4AudioAssembler::submitAccessUnit() {
CHECK(!mPackets.empty());
bool AMPEG4AudioAssembler::submitAccessUnit() {
MOZ_ASSERT(!mPackets.empty());
#if VERBOSE
LOG(VERBOSE) << "Access unit complete (" << mPackets.size() << " packets)";
@ -565,7 +607,9 @@ void AMPEG4AudioAssembler::submitAccessUnit() {
}
accessUnit = removeLATMFraming(accessUnit);
CopyTimes(accessUnit, *mPackets.begin());
if (!accessUnit.get() || !CopyTimes(accessUnit, *mPackets.begin())) {
return false;
}
if (mAccessUnitDamaged) {
accessUnit->meta()->setInt32("damaged", true);
@ -577,6 +621,7 @@ void AMPEG4AudioAssembler::submitAccessUnit() {
sp<AMessage> msg = mNotifyMsg->dup();
msg->setObject("access-unit", accessUnit);
msg->post();
return true;
}
void AMPEG4AudioAssembler::packetLost() {

View File

@ -58,7 +58,7 @@ private:
List<sp<ABuffer> > mPackets;
AssemblyStatus addPacket(const sp<ARTPSource> &source);
void submitAccessUnit();
bool submitAccessUnit();
sp<ABuffer> removeLATMFraming(const sp<ABuffer> &buffer);

View File

@ -21,6 +21,8 @@
#include "ARTPSource.h"
#include "mozilla/Assertions.h"
#include <media/stagefright/foundation/ABitReader.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
@ -216,10 +218,18 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::addPacket(
}
uint32_t rtpTime;
CHECK(buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
if (!buffer->meta()->findInt32("rtp-time", (int32_t *)&rtpTime)) {
LOGW("Cannot find rtp-time. Malformed packet.");
return MALFORMED_PACKET;
}
if (mPackets.size() > 0 && rtpTime != mAccessUnitRTPTime) {
submitAccessUnit();
if (!submitAccessUnit()) {
LOGW("Cannot find rtp-time. Malformed packet.");
return MALFORMED_PACKET;
}
}
// If constantDuration and CTSDelta are not present. We should assume the
@ -236,10 +246,18 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::addPacket(
} else {
// hexdump(buffer->data(), buffer->size());
CHECK_GE(buffer->size(), 2u);
if (buffer->size() < 2u) {
LOGW("Payload format error. Malformed packet.");
return MALFORMED_PACKET;
}
unsigned AU_headers_length = U16_AT(buffer->data()); // in bits
CHECK_GE(buffer->size(), 2 + (AU_headers_length + 7) / 8);
if (buffer->size() < 2 + (AU_headers_length + 7) / 8) {
LOGW("Payload format error. Malformed packet.");
return MALFORMED_PACKET;
}
List<AUHeader> headers;
@ -330,7 +348,11 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::addPacket(
mPreviousAUCount++;
const AUHeader &header = *it;
const AUHeader &first = *headers.begin();
CHECK_LE(offset + header.mSize, buffer->size());
if (offset + header.mSize > buffer->size()) {
LOGW("Payload format error. Malformed packet.");
return MALFORMED_PACKET;
}
sp<ABuffer> accessUnit = new ABuffer(header.mSize);
memcpy(accessUnit->data(), buffer->data() + offset, header.mSize);
@ -345,7 +367,11 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::addPacket(
mPackets.push_back(accessUnit);
}
CHECK_EQ(offset, buffer->size());
if (offset != buffer->size()) {
LOGW("Payload format error. Malformed packet.");
return MALFORMED_PACKET;
}
}
queue->erase(queue->begin());
@ -354,8 +380,8 @@ ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::addPacket(
return OK;
}
void AMPEG4ElementaryAssembler::submitAccessUnit() {
CHECK(!mPackets.empty());
bool AMPEG4ElementaryAssembler::submitAccessUnit() {
MOZ_ASSERT(mPackets.empty());
LOGV("Access unit complete (%d nal units)", mPackets.size());
@ -374,7 +400,9 @@ void AMPEG4ElementaryAssembler::submitAccessUnit() {
sp<ABuffer> accessUnit = new ABuffer((*it)->size());
sp<ABuffer> nal = *it;
memcpy(accessUnit->data(), nal->data(), nal->size());
CopyTimes(accessUnit, nal);
if (!CopyTimes(accessUnit, nal)) {
return false;
}
if (mAccessUnitDamaged) {
accessUnit->meta()->setInt32("damaged", true);
@ -404,7 +432,9 @@ void AMPEG4ElementaryAssembler::submitAccessUnit() {
memcpy(accessUnit->data() + offset, nal->data(), nal->size());
offset += nal->size();
}
CopyTimes(accessUnit, *mPackets.begin());
if (!CopyTimes(accessUnit, *mPackets.begin())) {
return false;
}
if (mAccessUnitDamaged) {
accessUnit->meta()->setInt32("damaged", true);
@ -417,6 +447,7 @@ void AMPEG4ElementaryAssembler::submitAccessUnit() {
mPackets.clear();
mAccessUnitDamaged = false;
return true;
}
ARTPAssembler::AssemblyStatus AMPEG4ElementaryAssembler::assembleMore(

View File

@ -67,7 +67,7 @@ private:
List<sp<ABuffer> > mPackets;
AssemblyStatus addPacket(const sp<ARTPSource> &source);
void submitAccessUnit();
bool submitAccessUnit();
DISALLOW_EVIL_CONSTRUCTORS(AMPEG4ElementaryAssembler);
};

View File

@ -114,8 +114,11 @@ static sp<ABuffer> MakeAVCCodecSpecificData(
}
sp<ABuffer> profileLevelID = decodeHex(val);
CHECK(profileLevelID != NULL);
CHECK_EQ(profileLevelID->size(), 3u);
if (!profileLevelID.get() || profileLevelID->size() != 3u) {
LOGW("Format error in profile-level-id");
return NULL;
}
Vector<sp<ABuffer> > paramSets;
@ -135,21 +138,27 @@ static sp<ABuffer> MakeAVCCodecSpecificData(
AString nalString(val, start, end - start);
sp<ABuffer> nal = decodeBase64(nalString);
CHECK(nal != NULL);
CHECK_GT(nal->size(), 0u);
CHECK_LE(nal->size(), 65535u);
if (!nal.get() || nal->size() <= 0u || nal->size() > 65535u) {
return NULL;
}
uint8_t nalType = nal->data()[0] & 0x1f;
if (numSeqParameterSets == 0) {
CHECK_EQ((unsigned)nalType, 7u);
if ((unsigned)nalType != 7u) {
return NULL;
}
} else if (numPicParameterSets > 0) {
CHECK_EQ((unsigned)nalType, 8u);
if ((unsigned)nalType != 8u) {
return NULL;
}
}
if (nalType == 7) {
++numSeqParameterSets;
totalSeqParameterSetSize += nal->size();
} else {
CHECK_EQ((unsigned)nalType, 8u);
if ((unsigned)nalType != 8u) {
return NULL;
}
++numPicParameterSets;
totalPicParameterSetSize += nal->size();
}
@ -163,8 +172,12 @@ static sp<ABuffer> MakeAVCCodecSpecificData(
start = commaPos + 1;
}
CHECK_LT(numSeqParameterSets, 32u);
CHECK_LE(numPicParameterSets, 255u);
if (numSeqParameterSets >= 32u) {
return NULL;
}
if (numPicParameterSets > 255u) {
return NULL;
}
size_t csdSize =
1 + 3 + 1 + 1
@ -268,19 +281,29 @@ sp<ABuffer> MakeAACCodecSpecificData2(const char *params) {
const char *s = val.c_str();
char *end;
objectType = strtoul(s, &end, 10);
CHECK(end > s && *end == '\0');
if (end <= s || *end != '\0') {
return NULL;
}
} else {
objectType = 0x40; // Audio ISO/IEC 14496-3
}
CHECK(GetAttribute(params, "config", &val));
if (!GetAttribute(params, "config", &val)) {
LOGW("Cannot find attribute config");
return NULL;
}
sp<ABuffer> config = decodeHex(val);
CHECK(config != NULL);
if (!config.get()) {
return NULL;
}
// Make sure size fits into a single byte and doesn't have to
// be encoded.
CHECK_LT(20 + config->size(), 128u);
if (20 + config->size() >= 128u) {
return NULL;
}
static const uint8_t kStaticESDS[] = {
0x03, 22,
@ -368,10 +391,16 @@ static sp<ABuffer> MakeMPEG4VideoCodecSpecificData(
*height = 0;
AString val;
CHECK(GetAttribute(params, "config", &val));
if (!GetAttribute(params, "config", &val)) {
LOGW("Cannot find attribute config");
return NULL;
}
sp<ABuffer> config = decodeHex(val);
CHECK(config != NULL);
if (!config.get()) {
return NULL;
}
if (!ExtractDimensionsMPEG4Config(config, width, height)) {
return NULL;
@ -477,8 +506,11 @@ APacketSource::APacketSource(
mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AAC);
int32_t sampleRate, numChannels;
ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels);
if (!ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels)) {
mInitCheck = ERROR_UNSUPPORTED;
return;
}
mFormat->setInt32(kKeySampleRate, sampleRate);
mFormat->setInt32(kKeyChannelCount, numChannels);
@ -497,8 +529,11 @@ APacketSource::APacketSource(
mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AMR_NB);
int32_t sampleRate, numChannels;
ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels);
if (!ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels)) {
mInitCheck = ERROR_UNSUPPORTED;
return;
}
mFormat->setInt32(kKeySampleRate, sampleRate);
mFormat->setInt32(kKeyChannelCount, numChannels);
@ -510,8 +545,11 @@ APacketSource::APacketSource(
mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AMR_WB);
int32_t sampleRate, numChannels;
ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels);
if (!ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels)) {
mInitCheck = ERROR_UNSUPPORTED;
return;
}
mFormat->setInt32(kKeySampleRate, sampleRate);
mFormat->setInt32(kKeyChannelCount, numChannels);
@ -561,20 +599,28 @@ APacketSource::APacketSource(
mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AAC);
int32_t sampleRate, numChannels;
ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels);
if (!ASessionDescription::ParseFormatDesc(
desc.c_str(), &sampleRate, &numChannels)) {
mInitCheck = ERROR_UNSUPPORTED;
return;
}
mFormat->setInt32(kKeySampleRate, sampleRate);
mFormat->setInt32(kKeyChannelCount, numChannels);
sp<ABuffer> codecSpecificData =
MakeAACCodecSpecificData2(params.c_str());
if (!codecSpecificData.get()) {
mInitCheck = ERROR_UNSUPPORTED;
return;
}
mFormat->setData(
kKeyESDS, 0,
codecSpecificData->data(), codecSpecificData->size());
} else if (ARawAudioAssembler::Supports(desc.c_str())) {
ARawAudioAssembler::MakeFormat(desc.c_str(), mFormat);
if (!ARawAudioAssembler::MakeFormat(desc.c_str(), mFormat)) {
mInitCheck = ERROR_UNSUPPORTED;
}
} else {
mInitCheck = ERROR_UNSUPPORTED;
}

View File

@ -16,6 +16,8 @@
#include "ARTPAssembler.h"
#include "RtspPrlog.h"
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
@ -64,14 +66,19 @@ void ARTPAssembler::onPacketReceived(const sp<ARTPSource> &source) {
}
// static
void ARTPAssembler::CopyTimes(const sp<ABuffer> &to, const sp<ABuffer> &from) {
bool ARTPAssembler::CopyTimes(const sp<ABuffer> &to, const sp<ABuffer> &from) {
uint32_t rtpTime;
CHECK(from->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));
if (!from->meta()->findInt32("rtp-time", (int32_t *)&rtpTime)) {
LOGW("CopyTimes: Cannot find rtp-time");
return false;
}
to->meta()->setInt32("rtp-time", rtpTime);
// Copy the seq number.
to->setInt32Data(from->int32Data());
return true;
}
} // namespace android

View File

@ -44,7 +44,7 @@ protected:
virtual AssemblyStatus assembleMore(const sp<ARTPSource> &source) = 0;
virtual void packetLost() = 0;
static void CopyTimes(const sp<ABuffer> &to, const sp<ABuffer> &from);
static bool CopyTimes(const sp<ABuffer> &to, const sp<ABuffer> &from);
private:
int64_t mFirstFailureTimeUs;

View File

@ -44,7 +44,10 @@ ARTPSession::ARTPSession()
}
status_t ARTPSession::setup(const sp<ASessionDescription> &desc) {
CHECK_EQ(mInitCheck, (status_t)NO_INIT);
if (mInitCheck != (status_t)NO_INIT) {
LOGE("Unexpected mInitCheck");
return NO_INIT;
}
mDesc = desc;
@ -157,12 +160,21 @@ void ARTPSession::onMessageReceived(const sp<AMessage> &msg) {
sp<RefBase> obj;
CHECK(msg->findObject("access-unit", &obj));
if (!msg->findObject("access-unit", &obj)) {
LOGW("Cannot find access-unit");
break;
}
sp<ABuffer> accessUnit = static_cast<ABuffer *>(obj.get());
uint64_t ntpTime;
CHECK(accessUnit->meta()->findInt64(
"ntp-time", (int64_t *)&ntpTime));
if (!accessUnit->meta()->findInt64(
"ntp-time", (int64_t *)&ntpTime)) {
LOGW("Cannot find ntp-time");
break;
}
#if 0
#if 0

View File

@ -140,7 +140,9 @@ status_t ARTPWriter::start(MetaData *params) {
mNumSRsSent = 0;
const char *mime;
CHECK(mSource->getFormat()->findCString(kKeyMIMEType, &mime));
if (!mSource->getFormat()->findCString(kKeyMIMEType, &mime)) {
return ERROR_UNSUPPORTED;
}
mMode = INVALID;
if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) {

View File

@ -748,8 +748,9 @@ bool ARTSPConnection::receiveRTSPResponse() {
if (mAuthType == NONE && mUser.size() > 0
&& parseAuthMethod(response)) {
ssize_t i;
CHECK_EQ((status_t)OK, findPendingRequest(response, &i));
CHECK_GE(i, 0);
if ((status_t)OK != findPendingRequest(response, &i) || i < 0) {
return false;
}
sp<AMessage> reply = mPendingRequests.valueAt(i);
mPendingRequests.removeItemsAt(i);
@ -779,7 +780,9 @@ bool ARTSPConnection::handleServerRequest(const sp<ARTSPResponse> &request) {
// support the method.
ssize_t space1 = request->mStatusLine.find(" ");
CHECK_GE(space1, 0);
if (space1 < 0) {
return false;
}
AString response;
response.append("RTSP/1.0 501 Not Implemented\r\n");
@ -909,15 +912,19 @@ bool ARTSPConnection::parseAuthMethod(const sp<ARTSPResponse> &response) {
if (!strncmp(value.c_str(), "Basic", 5)) {
mAuthType = BASIC;
} else {
CHECK(!strncmp(value.c_str(), "Digest", 6));
if (strncmp(value.c_str(), "Digest", 6)) {
return false;
}
mAuthType = DIGEST;
i = value.find("nonce=");
CHECK_GE(i, 0);
CHECK_EQ(value.c_str()[i + 6], '\"');
if (i < 0 || value.c_str()[i + 6] != '\"') {
return false;
}
ssize_t j = value.find("\"", i + 7);
CHECK_GE(j, 0);
if (j < 0) {
return false;
}
mNonce.setTo(value, i + 7, j - i - 7);
}
@ -983,16 +990,21 @@ static void H(const AString &s, AString *out) {
}
}
static void GetMethodAndURL(
static bool GetMethodAndURL(
const AString &request, AString *method, AString *url) {
ssize_t space1 = request.find(" ");
CHECK_GE(space1, 0);
if (space1 < 0) {
return false;
}
ssize_t space2 = request.find(" ", space1 + 1);
CHECK_GE(space2, 0);
if (space2 < 0) {
return false;
}
method->setTo(request, 0, space1);
url->setTo(request, space1 + 1, space2 - space1);
return true;
}
void ARTSPConnection::addAuthentication(AString *request) {
@ -1002,7 +1014,10 @@ void ARTSPConnection::addAuthentication(AString *request) {
// Find the boundary between headers and the body.
ssize_t i = request->find("\r\n\r\n");
CHECK_GE(i, 0);
if (i < 0) {
LOGE("Failed to find the boundary between headers and the body");
return;
}
if (mAuthType == BASIC) {
AString tmp;
@ -1026,7 +1041,10 @@ void ARTSPConnection::addAuthentication(AString *request) {
CHECK_EQ((int)mAuthType, (int)DIGEST);
AString method, url;
GetMethodAndURL(*request, &method, &url);
if (!GetMethodAndURL(*request, &method, &url)) {
LOGE("Fail to get method and url");
return;
}
AString A1;
A1.append(mUser);
@ -1076,7 +1094,9 @@ void ARTSPConnection::addAuthentication(AString *request) {
void ARTSPConnection::addUserAgent(AString *request) const {
// Find the boundary between headers and the body.
ssize_t i = request->find("\r\n\r\n");
CHECK_GE(i, 0);
if (i < 0) {
LOGE("Failed to find the boundary between headers and the body");
}
request->insert(mUserAgent, i + 2);
}

View File

@ -87,7 +87,7 @@ ARTPAssembler::AssemblyStatus ARawAudioAssembler::addPacket(
queue->erase(queue->begin());
++mNextExpectedSeqNo;
LOGV("raw audio packet too short.");
LOGW("raw audio packet too short.");
return MALFORMED_PACKET;
}
@ -120,22 +120,25 @@ bool ARawAudioAssembler::Supports(const char *desc) {
}
// static
void ARawAudioAssembler::MakeFormat(
bool ARawAudioAssembler::MakeFormat(
const char *desc, const sp<MetaData> &format) {
if (!strncmp(desc, "PCMU/", 5)) {
format->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_G711_MLAW);
} else if (!strncmp(desc, "PCMA/", 5)) {
format->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_G711_ALAW);
} else {
TRESPASS();
return false;
}
int32_t sampleRate, numChannels;
ASessionDescription::ParseFormatDesc(
desc, &sampleRate, &numChannels);
if (!ASessionDescription::ParseFormatDesc(
desc, &sampleRate, &numChannels)) {
return false;
}
format->setInt32(kKeySampleRate, sampleRate);
format->setInt32(kKeyChannelCount, numChannels);
return true;
}
} // namespace android

View File

@ -34,7 +34,7 @@ struct ARawAudioAssembler : public ARTPAssembler {
static bool Supports(const char *desc);
static void MakeFormat(
static bool MakeFormat(
const char *desc, const sp<MetaData> &format);
protected:

View File

@ -201,12 +201,15 @@ bool ASessionDescription::getFormatType(
getFormat(index, &format);
const char *lastSpacePos = strrchr(format.c_str(), ' ');
CHECK(lastSpacePos != NULL);
if (!lastSpacePos) {
return false;
}
char *end;
unsigned long x = strtoul(lastSpacePos + 1, &end, 10);
CHECK_GT(end, lastSpacePos + 1);
CHECK_EQ(*end, '\0');
if (end <= lastSpacePos + 1 || *end != '\0') {
return false;
}
*PT = x;
@ -244,13 +247,15 @@ bool ASessionDescription::getDimensions(
const char *s = value.c_str();
char *end;
*width = strtoul(s, &end, 10);
CHECK_GT(end, s);
CHECK_EQ(*end, '-');
if (end <= s || *end != '-') {
return false;
}
s = end + 1;
*height = strtoul(s, &end, 10);
CHECK_GT(end, s);
CHECK_EQ(*end, '\0');
if (end <= s || *end != '\0') {
return false;
}
return true;
}
@ -258,7 +263,9 @@ bool ASessionDescription::getDimensions(
bool ASessionDescription::getDurationUs(int64_t *durationUs) const {
*durationUs = 0;
CHECK(mIsValid);
if (!mIsValid) {
return false;
}
AString value;
if (!findAttribute(0, "a=range", &value)) {
@ -280,16 +287,22 @@ bool ASessionDescription::getDurationUs(int64_t *durationUs) const {
}
// static
void ASessionDescription::ParseFormatDesc(
bool ASessionDescription::ParseFormatDesc(
const char *desc, int32_t *timescale, int32_t *numChannels) {
const char *slash1 = strchr(desc, '/');
CHECK(slash1 != NULL);
if (!slash1) {
return false;
}
const char *s = slash1 + 1;
char *end;
unsigned long x = strtoul(s, &end, 10);
CHECK_GT(end, s);
CHECK(*end == '\0' || *end == '/');
if (end <= s) {
return false;
}
if (*end != '\0' && *end != '/') {
return false;
}
*timescale = x;
*numChannels = 1;
@ -297,11 +310,13 @@ void ASessionDescription::ParseFormatDesc(
if (*end == '/') {
s = end + 1;
unsigned long x = strtoul(s, &end, 10);
CHECK_GT(end, s);
CHECK_EQ(*end, '\0');
if (end <= s || *end != '\0') {
return false;
}
*numChannels = x;
}
return true;
}
// static

View File

@ -51,7 +51,7 @@ struct ASessionDescription : public RefBase {
bool getDurationUs(int64_t *durationUs) const;
static void ParseFormatDesc(
static bool ParseFormatDesc(
const char *desc, int32_t *timescale, int32_t *numChannels);
bool findAttribute(size_t index, const char *key, AString *value) const;

View File

@ -22,6 +22,8 @@
#include "ARTSPConnection.h"
#include "ASessionDescription.h"
#include "RtspPrlog.h"
#include <ctype.h>
#include <cutils/properties.h>
@ -561,10 +563,13 @@ struct RtspConnectionHandler : public AHandler {
"get something usable...");
AString tmp;
CHECK(MakeURL(
if (!MakeURL(
mSessionURL.c_str(),
mBaseURL.c_str(),
&tmp));
&tmp)) {
LOGE("Fail to make url");
result = ERROR_UNSUPPORTED;
}
mBaseURL = tmp;
}
@ -776,9 +781,9 @@ struct RtspConnectionHandler : public AHandler {
static_cast<ARTSPResponse *>(obj.get());
if (response->mStatusCode != 200) {
result = UNKNOWN_ERROR;
} else if (!parsePlayResponse(response)) {
result = UNKNOWN_ERROR;
} else {
parsePlayResponse(response);
sp<AMessage> timeout = new AMessage(kWhatTimeout, id());
timeout->post(kPlayTimeoutUs);
mPausePending = false;
@ -1145,11 +1150,14 @@ struct RtspConnectionHandler : public AHandler {
if (response->mStatusCode != 200) {
result = UNKNOWN_ERROR;
} else if (!parsePlayResponse(response)) {
result = UNKNOWN_ERROR;
} else {
parsePlayResponse(response);
ssize_t i = response->mHeaders.indexOfKey("rtp-info");
CHECK_GE(i, 0);
if (i < 0) {
LOGE("No RTP info in response");
(new AMessage(kWhatAbort, id()))->post();
}
LOGV("rtp-info: %s", response->mHeaders.valueAt(i).c_str());
@ -1178,7 +1186,10 @@ struct RtspConnectionHandler : public AHandler {
sp<ABuffer> buffer = static_cast<ABuffer *>(obj.get());
int32_t index;
CHECK(buffer->meta()->findInt32("index", &index));
if (!buffer->meta()->findInt32("index", &index)) {
LOGW("Cannot find index");
break;
}
mRTPConn->injectPacket(index, buffer);
break;
@ -1266,7 +1277,7 @@ struct RtspConnectionHandler : public AHandler {
}
}
void parsePlayResponse(const sp<ARTSPResponse> &response) {
bool parsePlayResponse(const sp<ARTSPResponse> &response) {
mSeekable = false;
for (size_t i = 0; i < mTracks.size(); ++i) {
@ -1278,25 +1289,31 @@ struct RtspConnectionHandler : public AHandler {
if (i < 0) {
// Server doesn't even tell use what range it is going to
// play, therefore we won't support seeking.
return;
return false;
}
AString range = response->mHeaders.valueAt(i);
LOGV("Range: %s", range.c_str());
AString val;
CHECK(GetAttribute(range.c_str(), "npt", &val));
if (!GetAttribute(range.c_str(), "npt", &val)) {
LOGE("No npt attribute in range");
return false;
}
float npt1, npt2;
if (!ASessionDescription::parseNTPRange(val.c_str(), &npt1, &npt2)) {
// This is a live stream and therefore not seekable.
LOGI("This is a live stream");
return;
return false;
}
i = response->mHeaders.indexOfKey("rtp-info");
CHECK_GE(i, 0);
if (i < 0) {
LOGE("No RTP info");
return false;
}
AString rtpInfo = response->mHeaders.valueAt(i);
List<AString> streamInfos;
@ -1308,16 +1325,25 @@ struct RtspConnectionHandler : public AHandler {
(*it).trim();
LOGV("streamInfo[%d] = %s", n, (*it).c_str());
CHECK(GetAttribute((*it).c_str(), "url", &val));
if (!GetAttribute((*it).c_str(), "url", &val)) {
LOGE("No url attribute");
return false;
}
size_t trackIndex = 0;
while (trackIndex < mTracks.size()
&& !(val == mTracks.editItemAt(trackIndex).mURL)) {
++trackIndex;
}
CHECK_LT(trackIndex, mTracks.size());
if (trackIndex >= mTracks.size()) {
LOGE("No matching url");
return false;
}
CHECK(GetAttribute((*it).c_str(), "seq", &val));
if (!GetAttribute((*it).c_str(), "seq", &val)) {
LOGE("No seq attribute");
return false;
}
char *end;
unsigned long seq = strtoul(val.c_str(), &end, 10);
@ -1326,7 +1352,10 @@ struct RtspConnectionHandler : public AHandler {
info->mFirstSeqNumInSegment = seq;
info->mNewSegment = true;
CHECK(GetAttribute((*it).c_str(), "rtptime", &val));
if (!GetAttribute((*it).c_str(), "rtptime", &val)) {
LOGE("No rtptime attribute");
return false;
}
uint32_t rtpTime = strtoul(val.c_str(), &end, 10);
@ -1345,6 +1374,7 @@ struct RtspConnectionHandler : public AHandler {
}
mSeekable = true;
return true;
}
sp<MetaData> getTrackFormat(size_t index, int32_t *timeScale) {
@ -1440,10 +1470,26 @@ private:
}
AString url;
CHECK(mSessionDesc->findAttribute(index, "a=control", &url));
if (!mSessionDesc->findAttribute(index, "a=control", &url)) {
LOGW("Unsupported format. Ignoring track #%d.", index);
sp<AMessage> reply = new AMessage(kWhatSetup, id());
reply->setSize("index", index);
reply->setInt32("result", ERROR_UNSUPPORTED);
reply->post();
return;
}
AString trackURL;
CHECK(MakeURL(mBaseURL.c_str(), url.c_str(), &trackURL));
if (!MakeURL(mBaseURL.c_str(), url.c_str(), &trackURL)) {
LOGW("Unsupported format. Ignoring track #%d.", index);
sp<AMessage> reply = new AMessage(kWhatSetup, id());
reply->setSize("index", index);
reply->setInt32("result", ERROR_UNSUPPORTED);
reply->post();
return;
}
mTracks.push(TrackInfo());
TrackInfo *info = &mTracks.editItemAt(mTracks.size() - 1);
@ -1467,8 +1513,16 @@ private:
int32_t timescale;
int32_t numChannels;
ASessionDescription::ParseFormatDesc(
formatDesc.c_str(), &timescale, &numChannels);
if (!ASessionDescription::ParseFormatDesc(
formatDesc.c_str(), &timescale, &numChannels)) {
LOGW("Unsupported format. Ignoring track #%d.", index);
sp<AMessage> reply = new AMessage(kWhatSetup, id());
reply->setSize("index", index);
reply->setInt32("result", ERROR_UNSUPPORTED);
reply->post();
return;
}
info->mTimeScale = timescale;
@ -1617,8 +1671,11 @@ private:
int32_t trackIndex, const TrackInfo *track,
const sp<ABuffer> &accessUnit) {
uint32_t rtpTime;
CHECK(accessUnit->meta()->findInt32(
"rtp-time", (int32_t *)&rtpTime));
if (!accessUnit->meta()->findInt32(
"rtp-time", (int32_t *)&rtpTime)) {
LOGE("No RTP time in access unit meta");
return false;
}
int64_t relRtpTimeUs =
(((int64_t)rtpTime - (int64_t)track->mNormalPlayTimeRTP) * 1000000ll)

View File

@ -231,9 +231,10 @@ void RTSPSource::performPlay(int64_t playTimeUs) {
int64_t duration = 0;
getDuration(&duration);
MOZ_ASSERT(playTimeUs < duration,
MOZ_ASSERT(duration == 0 || playTimeUs < duration,
"Should never receive an out of bounds play time!");
if (playTimeUs >= duration) {
if (duration > 0 && playTimeUs >= duration) {
// if not a live stream and play time out of bounds
return;
}
@ -594,20 +595,26 @@ void RTSPSource::onConnected(bool isSeekable)
meta->SetTotalTracks(numTracks);
meta->SetMimeType(mimeType);
CHECK(format->findInt64(kKeyDuration, &int64Value));
bool success;
success = format->findInt64(kKeyDuration, &int64Value);
MOZ_ASSERT(success);
meta->SetDuration(int64Value);
if (isAudio) {
CHECK(format->findInt32(kKeyChannelCount, &int32Value));
success = format->findInt32(kKeyChannelCount, &int32Value);
MOZ_ASSERT(success);
meta->SetChannelCount(int32Value);
CHECK(format->findInt32(kKeySampleRate, &int32Value));
success = format->findInt32(kKeySampleRate, &int32Value);
MOZ_ASSERT(success);
meta->SetSampleRate(int32Value);
} else {
CHECK(format->findInt32(kKeyWidth, &int32Value));
success = format->findInt32(kKeyWidth, &int32Value);
MOZ_ASSERT(success);
meta->SetWidth(int32Value);
CHECK(format->findInt32(kKeyHeight, &int32Value));
success = format->findInt32(kKeyHeight, &int32Value);
MOZ_ASSERT(success);
meta->SetHeight(int32Value);
}
@ -705,8 +712,9 @@ void RTSPSource::onTrackDataAvailable(size_t trackIndex)
meta = new mozilla::net::RtspMetaData();
CHECK(accessUnit != NULL);
CHECK(accessUnit->meta()->findInt64("timeUs", &int64Value));
MOZ_ASSERT(accessUnit != NULL);
bool success = accessUnit->meta()->findInt64("timeUs", &int64Value);
MOZ_ASSERT(success);
meta->SetTimeStamp(int64Value);
meta->SetFrameType(MEDIASTREAM_FRAMETYPE_NORMAL);

View File

@ -266,28 +266,37 @@ struct MyTransmitter : public AHandler {
}
}
void authenticate(const sp<ARTSPResponse> &response) {
bool authenticate(const sp<ARTSPResponse> &response) {
ssize_t i = response->mHeaders.indexOfKey("www-authenticate");
CHECK_GE(i, 0);
if (i < 0) {
return false;
}
AString value = response->mHeaders.valueAt(i);
if (!strncmp(value.c_str(), "Basic", 5)) {
mAuthType = BASIC;
} else {
CHECK(!strncmp(value.c_str(), "Digest", 6));
if (strncmp(value.c_str(), "Digest", 6)) {
return false;
}
mAuthType = DIGEST;
i = value.find("nonce=");
CHECK_GE(i, 0);
CHECK_EQ(value.c_str()[i + 6], '\"');
if (i < 0 || value.c_str()[i + 6] != '\"') {
return false;
}
ssize_t j = value.find("\"", i + 7);
CHECK_GE(j, 0);
if (j < 0) {
return false;
}
mNonce.setTo(value, i + 7, j - i - 7);
}
issueAnnounce();
return true;
}
void addAuthentication(
@ -383,13 +392,11 @@ struct MyTransmitter : public AHandler {
CHECK(response != NULL);
if (response->mStatusCode == 401) {
if (mAuthType != NONE) {
if (mAuthType != NONE || !authenticate(response)) {
LOG(INFO) << "FAILED to authenticate";
(new AMessage(kWhatQuit, id()))->post();
break;
}
authenticate(response);
break;
}
}
@ -462,14 +469,24 @@ struct MyTransmitter : public AHandler {
sp<RefBase> obj;
CHECK(msg->findObject("response", &obj));
if (!obj.get()) {
LOGE("No response to SETUP");
(new AMessage(kWhatQuit, id()))->post();
break;
}
sp<ARTSPResponse> response;
if (result == OK) {
response = static_cast<ARTSPResponse *>(obj.get());
CHECK(response != NULL);
if (!response.get()) {
LOGE("No response to SETUP");
(new AMessage(kWhatQuit, id()))->post();
break;
}
}
if (result != OK || response->mStatusCode != 200) {
LOGE("SETUP error")
(new AMessage(kWhatQuit, id()))->post();
break;
}

View File

@ -86,7 +86,10 @@ bool UDPPusher::onPush() {
length = fromlel(length);
CHECK_GT(length, 0u);
if (length <= 0u) {
LOGE("Zero length");
return false;
}
sp<ABuffer> buffer = new ABuffer(length);
if (fread(buffer->data(), 1, length, mFile) < length) {
@ -99,6 +102,10 @@ bool UDPPusher::onPush() {
&mRemoteAddr, PR_INTERVAL_NO_WAIT);
CHECK_EQ(n, (ssize_t)buffer->size());
if (n != (ssize_t)buffer->size()) {
LOGE("Sizes don't match");
return false;
}
uint32_t timeMs;
if (fread(&timeMs, 1, sizeof(timeMs), mFile) < sizeof(timeMs)) {
@ -107,7 +114,10 @@ bool UDPPusher::onPush() {
}
timeMs = fromlel(timeMs);
CHECK_GE(timeMs, mFirstTimeMs);
if (timeMs < mFirstTimeMs) {
LOGE("Time is wrong");
return false;
}
timeMs -= mFirstTimeMs;
int64_t whenUs = mFirstTimeUs + timeMs * 1000ll;
@ -143,7 +153,7 @@ void UDPPusher::onMessageReceived(const sp<AMessage> &msg) {
mSocket, buffer->data(), buffer->size(), 0,
&tmp, PR_INTERVAL_NO_WAIT);
CHECK_EQ(n, (ssize_t)buffer->size());
MOZ_ASSERT(n, (ssize_t)buffer->size());
}
break;
}

View File

@ -29,6 +29,7 @@ class SandboxFilterImpl : public SandboxAssembler
public:
virtual void Build() = 0;
virtual ~SandboxFilterImpl() { }
void AllowThreadClone();
};
// Some helper macros to make the code that builds the filter more
@ -72,6 +73,26 @@ public:
#define SYSVIPCCALL(name, NAME) SYSCALL(name)
#endif
void SandboxFilterImpl::AllowThreadClone() {
// WARNING: s390 and cris pass the flags in a different arg -- see
// CLONE_BACKWARDS2 in arch/Kconfig in the kernel source -- but we
// don't support seccomp-bpf on those archs yet.
//
// The glibc source hasn't changed the thread creation clone flags
// since 2004, so this *should* be safe to hard-code. Bionic's
// value has changed a few times, and has converged on the same one
// as glibc; allow any of them.
static const int flags_common = CLONE_VM | CLONE_FS | CLONE_FILES |
CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM;
Allow(SYSCALL_WITH_ARG(clone, 0,
#ifdef ANDROID
flags_common | CLONE_DETACHED, // <= JB 4.2
flags_common, // JB 4.3 or KK 4.4
#endif
flags_common | CLONE_SETTLS // Android L or glibc
| CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID));
}
#ifdef MOZ_CONTENT_SANDBOX
class SandboxFilterImplContent : public SandboxFilterImpl {
protected:
@ -134,7 +155,7 @@ SandboxFilterImplContent::Build() {
Allow(SYSCALL(munmap));
Allow(SYSCALL(mprotect));
Allow(SYSCALL(writev));
Allow(SYSCALL(clone));
AllowThreadClone();
Allow(SYSCALL(brk));
#if SYSCALL_EXISTS(set_thread_area)
Allow(SYSCALL(set_thread_area));
@ -354,23 +375,7 @@ void SandboxFilterImplGMP::Build() {
Allow(SYSCALL(getpid));
Allow(SYSCALL(gettid));
// The glibc source hasn't changed the thread creation clone flags
// since 2004, so this *should* be safe to hard-code. Bionic is
// different, but MOZ_GMP_SANDBOX isn't supported there yet.
//
// At minimum we should require CLONE_THREAD, so that a single
// SIGKILL from the parent will destroy all descendant tasks. In
// general, pinning down as much of the flags word as possible is a
// good idea, because it exposes a lot of subtle (and probably not
// well tested in all cases) kernel functionality.
//
// WARNING: s390 and cris pass the flags in a different arg -- see
// CLONE_BACKWARDS2 in arch/Kconfig in the kernel source -- but we
// don't support seccomp-bpf on those archs yet.
static const int new_thread_flags = CLONE_VM | CLONE_FS | CLONE_FILES |
CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS |
CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID;
Allow(SYSCALL_WITH_ARG(clone, 0, new_thread_flags));
AllowThreadClone();
Allow(SYSCALL_WITH_ARG(prctl, 0, PR_GET_SECCOMP, PR_SET_NAME));

View File

@ -84,12 +84,6 @@
[Parsing: <http://2001::1\]:80> against <http://example.org/foo/bar>]
expected: FAIL
[Parsing: <http://[2001::1\]> against <http://example.org/foo/bar>]
expected: FAIL
[Parsing: <http://[2001::1\]:80> against <http://example.org/foo/bar>]
expected: FAIL
[Parsing: <madeupscheme:/example.com/> against <http://example.org/foo/bar>]
expected: FAIL

View File

@ -84,12 +84,6 @@
[Parsing: <http://2001::1\]:80> against <http://example.org/foo/bar>]
expected: FAIL
[Parsing: <http://[2001::1\]> against <http://example.org/foo/bar>]
expected: FAIL
[Parsing: <http://[2001::1\]:80> against <http://example.org/foo/bar>]
expected: FAIL
[Parsing: <madeupscheme:/example.com/> against <http://example.org/foo/bar>]
expected: FAIL

View File

@ -4,6 +4,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsNativeThemeCocoa.h"
#include "nsDeviceContext.h"
#include "nsObjCExceptions.h"
#include "nsNumberControlFrame.h"
#include "nsRangeFrame.h"

View File

@ -4,8 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsNativeThemeWin.h"
#include "mozilla/EventStates.h"
#include "mozilla/WindowsVersion.h"
#include "nsDeviceContext.h"
#include "nsRenderingContext.h"
#include "nsRect.h"
#include "nsSize.h"