Merge m-c to b2ginbound, a=merge

--HG--
extra : commitid : 8jCHCW0Xzam
This commit is contained in:
Wes Kocher 2015-11-17 13:23:33 -08:00
commit 522a563914
255 changed files with 3691 additions and 3041 deletions

View File

@ -1405,6 +1405,7 @@ pref("loop.debug.twoWayMediaTelemetry", false);
pref("loop.feedback.dateLastSeenSec", 0);
pref("loop.feedback.periodSec", 15770000); // 6 months.
pref("loop.feedback.formURL", "https://www.mozilla.org/firefox/hello/npssurvey/");
pref("loop.feedback.manualFormURL", "https://www.mozilla.org/firefox/hello/feedbacksurvey/");
#ifdef DEBUG
pref("loop.CSP", "default-src 'self' about: file: chrome: http://localhost:*; img-src * data:; font-src 'none'; connect-src wss://*.tokbox.com https://*.opentok.com https://*.tokbox.com wss://*.mozilla.com https://*.mozilla.org wss://*.mozaws.net http://localhost:* ws://localhost:*; media-src blob:");
#else

View File

@ -230,7 +230,7 @@ loop.panel = (function(_, mozL10n) {
*/
handleSubmitFeedback: function(event) {
event.preventDefault();
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.formURL");
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.manualFormURL");
this.props.mozLoop.openURL(helloFeedbackUrl);
this.closeWindow();
},

View File

@ -230,7 +230,7 @@ loop.panel = (function(_, mozL10n) {
*/
handleSubmitFeedback: function(event) {
event.preventDefault();
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.formURL");
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.manualFormURL");
this.props.mozLoop.openURL(helloFeedbackUrl);
this.closeWindow();
},

View File

@ -493,7 +493,7 @@ describe("loop.panel", function() {
beforeEach(function() {
feedbackUrl = "https://example.com";
fakeMozLoop.getLoopPref = function(pref) {
if (pref === "feedback.formURL") {
if (pref === "feedback.manualFormURL") {
return feedbackUrl;
}

View File

@ -95,15 +95,8 @@ var gSearchPane = {
buildDefaultEngineDropDown: function() {
// This is called each time something affects the list of engines.
let list = document.getElementById("defaultEngine");
let currentEngine;
// First, try to preserve the current selection.
if (list.selectedItem)
currentEngine = list.selectedItem.label;
// If there's no current selection, use the current default engine.
if (!currentEngine)
currentEngine = Services.search.currentEngine.name;
// Set selection to the current default engine.
let currentEngine = Services.search.currentEngine.name;
// If the current engine isn't in the list any more, select the first item.
let engines = gEngineView._engineStore._engines;
@ -411,6 +404,7 @@ EngineStore.prototype = {
added++;
}
}
Services.search.resetToOriginalDefaultEngine();
gSearchPane.showRestoreDefaults(false);
gSearchPane.buildDefaultEngineDropDown();
return added;

View File

@ -401,14 +401,12 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
nsCOMPtr<nsIPresShell> shell = document->GetShell();
if (shell) {
// Reload only the chrome URL agent style sheets.
nsCOMArray<nsIStyleSheet> agentSheets;
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
rv = shell->GetAgentStyleSheets(agentSheets);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMArray<nsIStyleSheet> newAgentSheets;
for (int32_t l = 0; l < agentSheets.Count(); ++l) {
nsIStyleSheet *sheet = agentSheets[l];
nsTArray<RefPtr<CSSStyleSheet>> newAgentSheets;
for (CSSStyleSheet* sheet : agentSheets) {
nsIURI* uri = sheet->GetSheetURI();
if (IsChromeURI(uri)) {
@ -418,12 +416,12 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
getter_AddRefs(newSheet));
if (NS_FAILED(rv)) return rv;
if (newSheet) {
rv = newAgentSheets.AppendObject(newSheet) ? NS_OK : NS_ERROR_FAILURE;
rv = newAgentSheets.AppendElement(newSheet) ? NS_OK : NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
}
}
else { // Just use the same sheet.
rv = newAgentSheets.AppendObject(sheet) ? NS_OK : NS_ERROR_FAILURE;
rv = newAgentSheets.AppendElement(sheet) ? NS_OK : NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
}
}
@ -432,27 +430,22 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
NS_ENSURE_SUCCESS(rv, rv);
}
// Build an array of nsIURIs of style sheets we need to load.
nsCOMArray<nsIStyleSheet> oldSheets;
nsCOMArray<nsIStyleSheet> newSheets;
int32_t count = document->GetNumberOfStyleSheets();
// Iterate over the style sheets.
int32_t i;
for (i = 0; i < count; i++) {
// Get the style sheet
nsIStyleSheet *styleSheet = document->GetStyleSheetAt(i);
// Build an array of style sheets we need to reload.
nsTArray<RefPtr<CSSStyleSheet>> oldSheets(count);
nsTArray<RefPtr<CSSStyleSheet>> newSheets(count);
if (!oldSheets.AppendObject(styleSheet)) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Iterate over the style sheets.
for (int32_t i = 0; i < count; i++) {
// Get the style sheet
CSSStyleSheet* styleSheet = document->GetStyleSheetAt(i);
oldSheets.AppendElement(styleSheet);
}
// Iterate over our old sheets and kick off a sync load of the new
// sheet if and only if it's a chrome URL.
for (i = 0; i < count; i++) {
RefPtr<CSSStyleSheet> sheet = do_QueryObject(oldSheets[i]);
for (CSSStyleSheet* sheet : oldSheets) {
nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr;
if (uri && IsChromeURI(uri)) {
@ -462,11 +455,10 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
// only works by sheer dumb luck.
document->LoadChromeSheetSync(uri, false, getter_AddRefs(newSheet));
// Even if it's null, we put in in there.
newSheets.AppendObject(newSheet);
}
else {
newSheets.AppendElement(newSheet);
} else {
// Just use the same sheet.
newSheets.AppendObject(sheet);
newSheets.AppendElement(sheet);
}
}

View File

@ -332,3 +332,4 @@ devtools.jar:
skin/tooltip/arrow-horizontal-light@2x.png (themes/tooltip/arrow-horizontal-light@2x.png)
skin/tooltip/arrow-vertical-light.png (themes/tooltip/arrow-vertical-light.png)
skin/tooltip/arrow-vertical-light@2x.png (themes/tooltip/arrow-vertical-light@2x.png)
skin/images/reload.svg (themes/images/reload.svg)

View File

@ -89,6 +89,7 @@
<!ENTITY runtimePanel_installsimulator "Install Simulator">
<!ENTITY runtimePanel_noadbhelper "Install ADB Helper">
<!ENTITY runtimePanel_nousbdevice "Can't see your device?">
<!ENTITY runtimePanel_refreshDevices_label "Refresh Devices">
<!-- Lense -->
<!ENTITY details_valid_header "valid">

View File

@ -1,9 +1,6 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="9" height="12">
<g transform="matrix(1.0251088,0,0,0.85613344,-3.1546734,-888.94343)">
<path d="m 5.1284819,1038.3667 6.4950901,0 -2.7147491,4.6651 2.9438561,0 -8.1148915,9.3081 1.6126718,-6.8973 -2.2701022,0 z" style="fill:white;"/>
</g>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 9 12" width="16" height="16">
<path d="M5.75 0l-1 5.5 2 .5-3.5 6 1-5-2-.5z" fill="#fff"/>
</svg>

Before

Width:  |  Height:  |  Size: 514 B

After

Width:  |  Height:  |  Size: 364 B

View File

@ -0,0 +1,6 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="14" height="14">
<path d="M12,7H6l2.4-2.4C7.6,4,6.6,3.8,5.5,4.1C4.3,4.5,3.3,5.5,3,6.8 C2.6,9,4.3,11,6.5,11c1,0,2-0.5,2.6-1.2l1.7,1c-1.3,1.6-3.3,2.5-5.6,2c-2-0.5-3.6-2.1-4-4.1C0.4,5.1,3.1,2,6.5,2 c1.3,0,2.4,0.4,3.3,1.2L12,1V7z"/>
</svg>

After

Width:  |  Height:  |  Size: 517 B

View File

@ -26,7 +26,7 @@
<label class="panel-header" id="panel-header-runtimeapps" hidden="true">&projectPanel_runtimeApps;</label>
<div id="project-panel-runtimeapps"/>
<label class="panel-header" id="panel-header-tabs" hidden="true">&projectPanel_tabs;
<button class="panel-item project-panel-item-refreshtabs" id="refresh-tabs">&projectMenu_refreshTabs_label;</button>
<button class="project-panel-item-refreshtabs refresh-icon" id="refresh-tabs" title="&projectMenu_refreshTabs_label;"></button>
</label>
<div id="project-panel-tabs"/>
</div>

View File

@ -19,6 +19,7 @@ window.addEventListener("load", function onLoad() {
document.getElementById("runtime-panel-installsimulator").onclick = ShowAddons;
document.getElementById("runtime-panel-noadbhelper").onclick = ShowAddons;
document.getElementById("runtime-panel-nousbdevice").onclick = ShowTroubleShooting;
document.getElementById("refresh-devices").onclick = RefreshScanners;
runtimeList.update();
runtimeList.updateCommands();
}, true);
@ -48,6 +49,10 @@ function ShowSettings() {
runtimeList.showSettings();
}
function RefreshScanners() {
runtimeList.refreshScanners();
}
function DisconnectRuntime() {
window.parent.Cmds.disconnectRuntime();
}

View File

@ -18,7 +18,9 @@
<body>
<div id="runtime-panel">
<div id="runtime-panel-box">
<label class="panel-header">&runtimePanel_usb;</label>
<label class="panel-header">&runtimePanel_usb;
<button class="runtime-panel-item-refreshdevices refresh-icon" id="refresh-devices" title="&runtimePanel_refreshDevices_label;"></button>
</label>
<button class="panel-item" id="runtime-panel-nousbdevice">&runtimePanel_nousbdevice;</button>
<button class="panel-item" id="runtime-panel-noadbhelper">&runtimePanel_noadbhelper;</button>
<div id="runtime-panel-usb"></div>

View File

@ -158,11 +158,7 @@ ProjectList.prototype = {
let tabs = AppManager.tabStore.tabs;
if (tabs.length > 0) {
tabsHeaderNode.removeAttribute("hidden");
} else {
tabsHeaderNode.setAttribute("hidden", "true");
}
tabsHeaderNode.removeAttribute("hidden");
for (let i = 0; i < tabs.length; i++) {
let tab = tabs[i];

View File

@ -86,6 +86,10 @@ RuntimeList.prototype = {
this._Cmds.showAddons();
},
refreshScanners: function() {
RuntimeScanners.scan();
},
updateCommands: function() {
let doc = this._doc;

View File

@ -54,8 +54,8 @@
let panelNode = docProject.querySelector("#project-panel");
let items = panelNode.querySelectorAll(".panel-item");
// 4 controls, + 2 projects
is(items.length, 6, "6 projects in panel");
// 3 controls, + 2 projects
is(items.length, 5, "5 projects in panel");
is(items[3].querySelector("span").textContent, "A name (in app directory)", "Panel text is correct");
is(items[4].querySelector("span").textContent, "hosted manifest name property", "Panel text is correct");

View File

@ -60,7 +60,7 @@
let panelNode = docProject.querySelector("#project-panel");
let items = panelNode.querySelectorAll(".panel-item");
// 4 controls, + 2 projects
is(items.length, 7, "7 projects in panel");
is(items.length, 6, "6 projects in panel");
is(items[3].querySelector("span").textContent, "A name (in app directory)", "Panel text is correct");
is(items[4].querySelector("span").textContent, "hosted manifest name property", "Panel text is correct");

View File

@ -91,21 +91,19 @@ button.panel-item {
cursor: default;
}
#refresh-tabs {
background-color: #FFF;
border-top: 1px solid #EDEDED;
.refresh-icon {
background-image: url("chrome://devtools/skin/images/reload.svg");
height: 14px;
width: 14px;
border: 0;
opacity: 0.6;
display: inline-block;
margin: 3px;
float: right;
padding: 3px;
text-transform: none;
border-right: 1px solid #CCC;
width: auto;
margin: 0 4px 5px 5px;
}
.panel-item:not(:disabled):hover,
button.panel-item:not(:disabled):hover,
#refresh-tabs:hover {
button.panel-item:not(:disabled):hover {
background-color: #CCF0FD;
border-top: 1px solid #EDEDED;
}

View File

@ -97,7 +97,7 @@ window.busy-determined #action-busy-undetermined {
.panel-list {
display: none;
position: relative;
max-width: 180px;
max-width: 190px;
overflow: hidden;
}

View File

@ -7,17 +7,17 @@
const {Cc, Ci} = require("chrome");
const events = require("sdk/event/core");
const protocol = require("devtools/server/protocol");
const {async} = require("devtools/shared/async-utils");
const {Arg, method, RetVal, types} = protocol;
const {LongStringActor} = require("devtools/server/actors/string");
const {DebuggerServer} = require("devtools/server/main");
const Services = require("Services");
const promise = require("promise");
const {isWindowIncluded} = require("devtools/shared/layout/utils");
const { setTimeout, clearTimeout } = require("sdk/timers");
const {setTimeout, clearTimeout} = require("sdk/timers");
loader.lazyImporter(this, "OS", "resource://gre/modules/osfile.jsm");
loader.lazyImporter(this, "Sqlite", "resource://gre/modules/Sqlite.jsm");
loader.lazyImporter(this, "Task", "resource://gre/modules/Task.jsm", "Task");
var gTrackedMessageManager = new Map();
@ -245,7 +245,7 @@ StorageActors.defaults = function(typeName, observationTopic, storeObjectType) {
* @param {window} window
* The window which was added.
*/
onWindowReady: async(function*(window) {
onWindowReady: Task.async(function*(window) {
let host = this.getHostName(window.location);
if (!this.hostVsStores.has(host)) {
yield this.populateStoresForHost(host, window);
@ -329,7 +329,7 @@ StorageActors.defaults = function(typeName, observationTopic, storeObjectType) {
* - total - The total number of entries possible.
* - data - The requested values.
*/
getStoreObjects: method(async(function*(host, names, options = {}) {
getStoreObjects: method(Task.async(function*(host, names, options = {}) {
let offset = options.offset || 0;
let size = options.size || MAX_STORE_OBJECT_COUNT;
if (size > MAX_STORE_OBJECT_COUNT) {
@ -1143,7 +1143,7 @@ StorageActors.createActor({
* method, as that method is called in initialize method of the actor, which
* cannot be asynchronous.
*/
preListStores: async(function*() {
preListStores: Task.async(function*() {
this.hostVsStores = new Map();
for (let host of this.hosts) {
@ -1151,7 +1151,7 @@ StorageActors.createActor({
}
}),
populateStoresForHost: async(function*(host) {
populateStoresForHost: Task.async(function*(host) {
let storeMap = new Map();
let {names} = yield this.getDBNamesForHost(host);
@ -1292,7 +1292,7 @@ var indexedDBHelpers = {
* `name` for the given `host`. The stored metadata information is of
* `DatabaseMetadata` type.
*/
getDBMetaData: async(function*(host, name) {
getDBMetaData: Task.async(function*(host, name) {
let request = this.openWithOrigin(host, name);
let success = promise.defer();
@ -1333,7 +1333,7 @@ var indexedDBHelpers = {
/**
* Fetches all the databases and their metadata for the given `host`.
*/
getDBNamesForHost: async(function*(host) {
getDBNamesForHost: Task.async(function*(host) {
let sanitizedHost = this.getSanitizedHost(host);
let directory = OS.Path.join(OS.Constants.Path.profileDir, "storage",
"default", sanitizedHost, "idb");
@ -1389,7 +1389,7 @@ var indexedDBHelpers = {
* Retrieves the proper indexed db database name from the provided .sqlite
* file location.
*/
getNameFromDatabaseFile: async(function*(path) {
getNameFromDatabaseFile: Task.async(function*(path) {
let connection = null;
let retryCount = 0;
@ -1422,7 +1422,7 @@ var indexedDBHelpers = {
}),
getValuesForHost:
async(function*(host, name = "null", options, hostVsStores) {
Task.async(function*(host, name = "null", options, hostVsStores) {
name = JSON.parse(name);
if (!name || !name.length) {
// This means that details about the db in this particular host are
@ -1824,7 +1824,7 @@ var StorageActor = exports.StorageActor = protocol.ActorClass({
* host: <hostname>
* }]
*/
listStores: method(async(function*() {
listStores: method(Task.async(function*() {
let toReturn = {};
for (let [name, value] of this.childActorPool) {

View File

@ -17,20 +17,6 @@ var {Cu} = require("chrome");
var {Task} = require("resource://gre/modules/Task.jsm");
var Promise = require("promise");
/**
* Create an async function from a generator function.
*
* @param Function func
* The generator function that to wrap as an async function.
* @return Function
* The async function.
*/
exports.async = function async(func) {
return function(...args) {
return Task.spawn(func.apply(this, args));
};
};
/**
* Create an async function that only executes once per instance of an object.
* Once called on a given object, the same promise will be returned for any

View File

@ -1341,7 +1341,6 @@ using namespace devtools;
/* static */ void
ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
JSContext* cx,
const HeapSnapshotBoundaries& boundaries,
nsAString& outFilePath,
ErrorResult& rv)
@ -1360,6 +1359,7 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
ZeroCopyNSIOutputStream zeroCopyStream(outputStream);
::google::protobuf::io::GzipOutputStream gzipStream(&zeroCopyStream);
JSContext* cx = global.Context();
StreamWriter writer(cx, gzipStream, wantNames);
if (NS_WARN_IF(!writer.init())) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
@ -1405,7 +1405,6 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
/* static */ already_AddRefed<HeapSnapshot>
ThreadSafeChromeUtils::ReadHeapSnapshot(GlobalObject& global,
JSContext* cx,
const nsAString& filePath,
ErrorResult& rv)
{
@ -1423,7 +1422,8 @@ ThreadSafeChromeUtils::ReadHeapSnapshot(GlobalObject& global,
return nullptr;
RefPtr<HeapSnapshot> snapshot = HeapSnapshot::Create(
cx, global, reinterpret_cast<const uint8_t*>(mm.address()), mm.size(), rv);
global.Context(), global, reinterpret_cast<const uint8_t*>(mm.address()),
mm.size(), rv);
if (!rv.Failed())
Telemetry::AccumulateTimeDelta(Telemetry::DEVTOOLS_READ_HEAP_SNAPSHOT_MS,

View File

@ -12,16 +12,15 @@ Object.defineProperty(this, "Promise", {
value: require("promise"),
writable: false, configurable: false
});
const {async, asyncOnce, promiseInvoke, promiseCall} = require("devtools/shared/async-utils");
const {asyncOnce, promiseInvoke, promiseCall} = require("devtools/shared/async-utils");
function run_test() {
do_test_pending();
Task.spawn(function*() {
for (let helper of [async, asyncOnce]) {
yield test_async_args(helper);
yield test_async_return(helper);
yield test_async_throw(helper);
}
yield test_async_args(asyncOnce);
yield test_async_return(asyncOnce);
yield test_async_throw(asyncOnce);
yield test_async_once();
yield test_async_invoke();
do_test_finished();

View File

@ -25,14 +25,12 @@ class ThreadSafeChromeUtils
public:
// Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
static void SaveHeapSnapshot(GlobalObject& global,
JSContext* cx,
const HeapSnapshotBoundaries& boundaries,
nsAString& filePath,
ErrorResult& rv);
// Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
static already_AddRefed<devtools::HeapSnapshot> ReadHeapSnapshot(GlobalObject& global,
JSContext* cx,
const nsAString& filePath,
ErrorResult& rv);

View File

@ -99,7 +99,6 @@
#include "mozilla/Preferences.h"
#include "nsIContentIterator.h"
#include "nsIDOMStyleSheet.h"
#include "nsIStyleSheet.h"
#include "nsIStyleSheetService.h"
#include "nsContentPermissionHelper.h"
#include "nsNetUtil.h"
@ -3244,7 +3243,7 @@ nsDOMWindowUtils::AddSheet(nsIDOMStyleSheet *aSheet, uint32_t aSheetType)
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsIDocument::additionalSheetType type = convertSheetType(aSheetType);
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
if (sheet->GetOwningDocument()) {
return NS_ERROR_INVALID_ARG;

View File

@ -725,15 +725,6 @@ nsDOMStyleSheetList::Length()
// been added or removed.
if (-1 == mLength) {
mLength = mDocument->GetNumberOfStyleSheets();
#ifdef DEBUG
int32_t i;
for (i = 0; i < mLength; i++) {
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
}
#endif
}
return mLength;
}
@ -747,7 +738,7 @@ nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
}
aFound = true;
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex);
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(aIndex);
NS_ASSERTION(sheet, "Must have a sheet");
return static_cast<CSSStyleSheet*>(sheet);
@ -761,27 +752,21 @@ nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
void
nsDOMStyleSheetList::StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
CSSStyleSheet* aStyleSheet,
bool aDocumentSheet)
{
if (aDocumentSheet && -1 != mLength) {
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(aStyleSheet));
if (domss) {
mLength++;
}
mLength++;
}
}
void
nsDOMStyleSheetList::StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
CSSStyleSheet* aStyleSheet,
bool aDocumentSheet)
{
if (aDocumentSheet && -1 != mLength) {
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(aStyleSheet));
if (domss) {
mLength--;
}
mLength--;
}
}
@ -1347,7 +1332,7 @@ nsDOMStyleSheetSetList::EnsureFresh()
int32_t count = mDocument->GetNumberOfStyleSheets();
nsAutoString title;
for (int32_t index = 0; index < count; index++) {
nsIStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
sheet->GetTitle(title);
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
@ -1624,9 +1609,7 @@ nsDocument::~nsDocument()
nsAutoScriptBlocker scriptBlocker;
int32_t indx; // must be signed
uint32_t count = mChildren.ChildCount();
for (indx = int32_t(count) - 1; indx >= 0; --indx) {
for (uint32_t indx = mChildren.ChildCount(); indx-- != 0; ) {
mChildren.ChildAt(indx)->UnbindFromTree();
mChildren.RemoveChildAt(indx);
}
@ -1634,9 +1617,8 @@ nsDocument::~nsDocument()
mCachedRootElement = nullptr;
// Let the stylesheets know we're going away
indx = mStyleSheets.Count();
while (--indx >= 0) {
mStyleSheets[indx]->SetOwningDocument(nullptr);
for (CSSStyleSheet* sheet : mStyleSheets) {
sheet->SetOwningDocument(nullptr);
}
if (mAttrStyleSheet) {
mAttrStyleSheet->SetOwningDocument(nullptr);
@ -2296,9 +2278,7 @@ void
nsDocument::RemoveDocStyleSheetsFromStyleSets()
{
// The stylesheets should forget us
int32_t indx = mStyleSheets.Count();
while (--indx >= 0) {
nsIStyleSheet* sheet = mStyleSheets[indx];
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
sheet->SetOwningDocument(nullptr);
if (sheet->IsApplicable()) {
@ -2312,12 +2292,12 @@ nsDocument::RemoveDocStyleSheetsFromStyleSets()
}
void
nsDocument::RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, SheetType aType)
nsDocument::RemoveStyleSheetsFromStyleSets(
nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
SheetType aType)
{
// The stylesheets should forget us
int32_t indx = aSheets.Count();
while (--indx >= 0) {
nsIStyleSheet* sheet = aSheets[indx];
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
sheet->SetOwningDocument(nullptr);
if (sheet->IsApplicable()) {
@ -2326,10 +2306,8 @@ nsDocument::RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, S
shell->StyleSet()->RemoveStyleSheet(aType, sheet);
}
}
// XXX Tell observers?
}
}
void
@ -2379,21 +2357,13 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
}
}
static bool
AppendAuthorSheet(nsIStyleSheet *aSheet, void *aData)
{
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
styleSet->AppendStyleSheet(SheetType::Doc, aSheet);
return true;
}
static void
AppendSheetsToStyleSet(nsStyleSet* aStyleSet,
const nsCOMArray<nsIStyleSheet>& aSheets,
const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
SheetType aType)
{
for (int32_t i = aSheets.Count() - 1; i >= 0; --i) {
aStyleSet->AppendStyleSheet(aType, aSheets[i]);
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
aStyleSet->AppendStyleSheet(aType, sheet);
}
}
@ -2405,9 +2375,7 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0,
"Style set already has document sheets?");
int32_t i;
for (i = mStyleSheets.Count() - 1; i >= 0; --i) {
nsIStyleSheet* sheet = mStyleSheets[i];
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
if (sheet->IsApplicable()) {
aStyleSet->AddDocStyleSheet(sheet, this);
}
@ -2415,13 +2383,13 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
sheetService->AuthorStyleSheets()->EnumerateForwards(AppendAuthorSheet,
aStyleSet);
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
}
}
// Iterate backwards to maintain order
for (i = mOnDemandBuiltInUASheets.Count() - 1; i >= 0; --i) {
nsIStyleSheet* sheet = mOnDemandBuiltInUASheets[i];
for (CSSStyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
@ -4017,8 +3985,7 @@ nsDocument::RemoveChildAt(uint32_t aIndex, bool aNotify)
void
nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
{
// Contains() takes nsISupport*, so annoyingly we have to cast here
if (mOnDemandBuiltInUASheets.Contains(static_cast<nsIStyleSheet*>(aSheet))) {
if (mOnDemandBuiltInUASheets.Contains(aSheet)) {
return;
}
BeginUpdate(UPDATE_STYLE);
@ -4029,8 +3996,7 @@ nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
void
nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
{
// Contains() takes nsISupport*, so annoyingly we have to cast here
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(static_cast<nsIStyleSheet*>(aSheet)));
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(aSheet));
// Prepend here so that we store the sheets in mOnDemandBuiltInUASheets in
// the same order that they should end up in the style set.
@ -4054,24 +4020,23 @@ nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
int32_t
nsDocument::GetNumberOfStyleSheets() const
{
return mStyleSheets.Count();
return mStyleSheets.Length();
}
nsIStyleSheet*
CSSStyleSheet*
nsDocument::GetStyleSheetAt(int32_t aIndex) const
{
NS_ENSURE_TRUE(0 <= aIndex && aIndex < mStyleSheets.Count(), nullptr);
return mStyleSheets[aIndex];
return mStyleSheets.SafeElementAt(aIndex, nullptr);
}
int32_t
nsDocument::GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const
nsDocument::GetIndexOfStyleSheet(CSSStyleSheet* aSheet) const
{
return mStyleSheets.IndexOf(aSheet);
}
void
nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
{
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
@ -4081,15 +4046,10 @@ nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
#define DO_STYLESHEET_NOTIFICATION(className, type, memberName, argName) \
do { \
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet); \
if (!cssSheet) { \
return; \
} \
\
className##Init init; \
init.mBubbles = true; \
init.mCancelable = true; \
init.mStylesheet = cssSheet; \
init.mStylesheet = aSheet; \
init.memberName = argName; \
\
RefPtr<className> event = \
@ -4103,7 +4063,7 @@ nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
} while (0);
void
nsDocument::NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet)
nsDocument::NotifyStyleSheetAdded(CSSStyleSheet* aSheet, bool aDocumentSheet)
{
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetAdded, (this, aSheet, aDocumentSheet));
@ -4116,7 +4076,7 @@ nsDocument::NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet)
}
void
nsDocument::NotifyStyleSheetRemoved(nsIStyleSheet* aSheet, bool aDocumentSheet)
nsDocument::NotifyStyleSheetRemoved(CSSStyleSheet* aSheet, bool aDocumentSheet)
{
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetRemoved, (this, aSheet, aDocumentSheet));
@ -4129,10 +4089,10 @@ nsDocument::NotifyStyleSheetRemoved(nsIStyleSheet* aSheet, bool aDocumentSheet)
}
void
nsDocument::AddStyleSheet(nsIStyleSheet* aSheet)
nsDocument::AddStyleSheet(CSSStyleSheet* aSheet)
{
NS_PRECONDITION(aSheet, "null arg");
mStyleSheets.AppendObject(aSheet);
mStyleSheets.AppendElement(aSheet);
aSheet->SetOwningDocument(this);
if (aSheet->IsApplicable()) {
@ -4143,7 +4103,7 @@ nsDocument::AddStyleSheet(nsIStyleSheet* aSheet)
}
void
nsDocument::RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet)
nsDocument::RemoveStyleSheetFromStyleSets(CSSStyleSheet* aSheet)
{
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
@ -4152,12 +4112,12 @@ nsDocument::RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet)
}
void
nsDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
nsDocument::RemoveStyleSheet(CSSStyleSheet* aSheet)
{
NS_PRECONDITION(aSheet, "null arg");
nsCOMPtr<nsIStyleSheet> sheet = aSheet; // hold ref so it won't die too soon
RefPtr<CSSStyleSheet> sheet = aSheet; // hold ref so it won't die too soon
if (!mStyleSheets.RemoveObject(aSheet)) {
if (!mStyleSheets.RemoveElement(aSheet)) {
NS_ASSERTION(mInUnlinkOrDeletion, "stylesheet not found");
return;
}
@ -4174,17 +4134,17 @@ nsDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
}
void
nsDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
nsCOMArray<nsIStyleSheet>& aNewSheets)
nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
{
BeginUpdate(UPDATE_STYLE);
// XXX Need to set the sheet on the ownernode, if any
NS_PRECONDITION(aOldSheets.Count() == aNewSheets.Count(),
NS_PRECONDITION(aOldSheets.Length() == aNewSheets.Length(),
"The lists must be the same length!");
int32_t count = aOldSheets.Count();
int32_t count = aOldSheets.Length();
nsCOMPtr<nsIStyleSheet> oldSheet;
RefPtr<CSSStyleSheet> oldSheet;
int32_t i;
for (i = 0; i < count; ++i) {
oldSheet = aOldSheets[i];
@ -4195,9 +4155,9 @@ nsDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
RemoveStyleSheet(oldSheet); // This does the right notifications
// Now put the new one in its place. If it's null, just ignore it.
nsIStyleSheet* newSheet = aNewSheets[i];
CSSStyleSheet* newSheet = aNewSheets[i];
if (newSheet) {
mStyleSheets.InsertObjectAt(newSheet, oldIndex);
mStyleSheets.InsertElementAt(oldIndex, newSheet);
newSheet->SetOwningDocument(this);
if (newSheet->IsApplicable()) {
AddStyleSheetToStyleSets(newSheet);
@ -4211,10 +4171,11 @@ nsDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
}
void
nsDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex)
nsDocument::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex)
{
NS_PRECONDITION(aSheet, "null ptr");
mStyleSheets.InsertObjectAt(aSheet, aIndex);
mStyleSheets.InsertElementAt(aIndex, aSheet);
aSheet->SetOwningDocument(this);
@ -4227,13 +4188,13 @@ nsDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex)
void
nsDocument::SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
nsDocument::SetStyleSheetApplicableState(CSSStyleSheet* aSheet,
bool aApplicable)
{
NS_PRECONDITION(aSheet, "null arg");
// If we're actually in the document style sheet list
if (-1 != mStyleSheets.IndexOf(aSheet)) {
if (mStyleSheets.IndexOf(aSheet) != mStyleSheets.NoIndex) {
if (aApplicable) {
AddStyleSheetToStyleSets(aSheet);
} else {
@ -4294,9 +4255,9 @@ ConvertAdditionalSheetType(nsIDocument::additionalSheetType aType)
}
static int32_t
FindSheet(const nsCOMArray<nsIStyleSheet>& aSheets, nsIURI* aSheetURI)
FindSheet(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets, nsIURI* aSheetURI)
{
for (int32_t i = aSheets.Count() - 1; i >= 0; i-- ) {
for (int32_t i = aSheets.Length() - 1; i >= 0; i-- ) {
bool bEqual;
nsIURI* uri = aSheets[i]->GetSheetURI();
@ -4350,7 +4311,7 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
}
nsresult
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aSheet)
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, CSSStyleSheet* aSheet)
{
if (mAdditionalSheets[aType].Contains(aSheet))
return NS_ERROR_INVALID_ARG;
@ -4358,7 +4319,7 @@ nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aS
if (!aSheet->IsApplicable())
return NS_ERROR_INVALID_ARG;
mAdditionalSheets[aType].AppendObject(aSheet);
mAdditionalSheets[aType].AppendElement(aSheet);
BeginUpdate(UPDATE_STYLE);
nsCOMPtr<nsIPresShell> shell = GetShell();
@ -4379,12 +4340,12 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
{
MOZ_ASSERT(aSheetURI);
nsCOMArray<nsIStyleSheet>& sheets = mAdditionalSheets[aType];
nsTArray<RefPtr<CSSStyleSheet>>& sheets = mAdditionalSheets[aType];
int32_t i = FindSheet(mAdditionalSheets[aType], aSheetURI);
if (i >= 0) {
nsCOMPtr<nsIStyleSheet> sheetRef = sheets[i];
sheets.RemoveObjectAt(i);
RefPtr<CSSStyleSheet> sheetRef = sheets[i];
sheets.RemoveElementAt(i);
BeginUpdate(UPDATE_STYLE);
if (!mIsGoingAway) {
@ -4405,10 +4366,10 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
}
}
nsIStyleSheet*
CSSStyleSheet*
nsDocument::FirstAdditionalAuthorSheet()
{
return mAdditionalSheets[eAuthorSheet].SafeObjectAt(0);
return mAdditionalSheets[eAuthorSheet].SafeElementAt(0, nullptr);
}
nsIGlobalObject*
@ -5155,7 +5116,7 @@ nsDocument::DocumentStatesChanged(EventStates aStateMask)
}
void
nsDocument::StyleRuleChanged(nsIStyleSheet* aSheet,
nsDocument::StyleRuleChanged(CSSStyleSheet* aSheet,
css::Rule* aOldStyleRule,
css::Rule* aNewStyleRule)
{
@ -5173,7 +5134,7 @@ nsDocument::StyleRuleChanged(nsIStyleSheet* aSheet,
}
void
nsDocument::StyleRuleAdded(nsIStyleSheet* aSheet,
nsDocument::StyleRuleAdded(CSSStyleSheet* aSheet,
css::Rule* aStyleRule)
{
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleAdded,
@ -5189,7 +5150,7 @@ nsDocument::StyleRuleAdded(nsIStyleSheet* aSheet,
}
void
nsDocument::StyleRuleRemoved(nsIStyleSheet* aSheet,
nsDocument::StyleRuleRemoved(CSSStyleSheet* aSheet,
css::Rule* aStyleRule)
{
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleRemoved,
@ -6428,13 +6389,11 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
int32_t count = GetNumberOfStyleSheets();
nsAutoString title;
for (int32_t index = 0; index < count; index++) {
nsIStyleSheet* sheet = GetStyleSheetAt(index);
CSSStyleSheet* sheet = GetStyleSheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
nsCOMPtr<nsIDOMStyleSheet> domSheet = do_QueryInterface(sheet);
NS_ASSERTION(domSheet, "Sheet must QI to nsIDOMStyleSheet");
bool disabled;
domSheet->GetDisabled(&disabled);
sheet->GetDisabled(&disabled);
if (disabled) {
// Disabled sheets don't affect the currently selected set
continue;
@ -6544,7 +6503,7 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
int32_t count = GetNumberOfStyleSheets();
nsAutoString title;
for (int32_t index = 0; index < count; index++) {
nsIStyleSheet* sheet = GetStyleSheetAt(index);
CSSStyleSheet* sheet = GetStyleSheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
sheet->GetTitle(title);
if (!title.IsEmpty()) {
@ -10173,7 +10132,7 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
int32_t sheetsCount = GetNumberOfStyleSheets();
for (int32_t i = 0; i < sheetsCount; ++i) {
RefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
if (sheet) {
if (sheet->IsApplicable()) {
RefPtr<CSSStyleSheet> clonedSheet =
@ -10186,11 +10145,8 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
}
}
sheetsCount = thisAsDoc->mOnDemandBuiltInUASheets.Count();
// Iterate backwards to maintain order
for (int32_t i = sheetsCount - 1; i >= 0; --i) {
RefPtr<CSSStyleSheet> sheet =
do_QueryObject(thisAsDoc->mOnDemandBuiltInUASheets[i]);
for (CSSStyleSheet* sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
if (sheet) {
if (sheet->IsApplicable()) {
RefPtr<CSSStyleSheet> clonedSheet =
@ -12278,7 +12234,7 @@ nsDocument::OnAppThemeChanged()
}
for (int32_t i = 0; i < GetNumberOfStyleSheets(); i++) {
RefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
if (!sheet) {
continue;
}
@ -12645,15 +12601,19 @@ nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
}
static size_t
SizeOfStyleSheetsElementIncludingThis(nsIStyleSheet* aStyleSheet,
MallocSizeOf aMallocSizeOf,
void* aData)
SizeOfOwnedSheetArrayExcludingThis(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
MallocSizeOf aMallocSizeOf)
{
if (!aStyleSheet->GetOwningDocument()) {
// Avoid over-reporting shared sheets.
return 0;
size_t n = 0;
n += aSheets.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (CSSStyleSheet* sheet : aSheets) {
if (!sheet->GetOwningDocument()) {
// Avoid over-reporting shared sheets.
continue;
}
n += sheet->SizeOfIncludingThis(aMallocSizeOf);
}
return aStyleSheet->SizeOfIncludingThis(aMallocSizeOf);
return n;
}
size_t
@ -12704,26 +12664,18 @@ nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
}
aWindowSizes->mStyleSheetsSize +=
mStyleSheets.SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
aWindowSizes->mMallocSizeOf);
SizeOfOwnedSheetArrayExcludingThis(mStyleSheets,
aWindowSizes->mMallocSizeOf);
// Note that we do not own the sheets pointed to by mOnDemandBuiltInUASheets
// (the nsLayoutStyleSheetCache singleton does) so pass nullptr as the
// aSizeOfElementIncludingThis callback argument.
// (the nsLayoutStyleSheetCache singleton does).
aWindowSizes->mStyleSheetsSize +=
mOnDemandBuiltInUASheets.SizeOfExcludingThis(nullptr,
aWindowSizes->mMallocSizeOf);
aWindowSizes->mStyleSheetsSize +=
mAdditionalSheets[eAgentSheet].
SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
aWindowSizes->mMallocSizeOf);
aWindowSizes->mStyleSheetsSize +=
mAdditionalSheets[eUserSheet].
SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
aWindowSizes->mMallocSizeOf);
aWindowSizes->mStyleSheetsSize +=
mAdditionalSheets[eAuthorSheet].
SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
aWindowSizes->mMallocSizeOf);
mOnDemandBuiltInUASheets.ShallowSizeOfExcludingThis(
aWindowSizes->mMallocSizeOf);
for (auto& sheetArray : mAdditionalSheets) {
aWindowSizes->mStyleSheetsSize +=
SizeOfOwnedSheetArrayExcludingThis(sheetArray,
aWindowSizes->mMallocSizeOf);
}
// Lumping in the loader with the style-sheets size is not ideal,
// but most of the things in there are in fact stylesheets, so it
// doesn't seem worthwhile to separate it out.

View File

@ -801,24 +801,29 @@ public:
* These are ordered, highest priority last
*/
virtual int32_t GetNumberOfStyleSheets() const override;
virtual nsIStyleSheet* GetStyleSheetAt(int32_t aIndex) const override;
virtual int32_t GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const override;
virtual void AddStyleSheet(nsIStyleSheet* aSheet) override;
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) override;
virtual mozilla::CSSStyleSheet* GetStyleSheetAt(int32_t aIndex) const override;
virtual int32_t GetIndexOfStyleSheet(mozilla::CSSStyleSheet* aSheet) const override;
virtual void AddStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
virtual void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
nsCOMArray<nsIStyleSheet>& aNewSheets) override;
virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
virtual void UpdateStyleSheets(
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aOldSheets,
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets) override;
virtual void AddStyleSheetToStyleSets(mozilla::CSSStyleSheet* aSheet);
virtual void RemoveStyleSheetFromStyleSets(mozilla::CSSStyleSheet* aSheet);
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex) override;
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
int32_t aIndex) override;
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
bool aApplicable) override;
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) override;
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aSheet) override;
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* sheetURI) override;
virtual nsIStyleSheet* FirstAdditionalAuthorSheet() override;
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
nsIURI* aSheetURI) override;
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
mozilla::CSSStyleSheet* aSheet) override;
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
nsIURI* sheetURI) override;
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() override;
virtual nsIChannel* GetChannel() const override {
return mChannel;
@ -878,12 +883,12 @@ public:
virtual void DocumentStatesChanged(
mozilla::EventStates aStateMask) override;
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aOldStyleRule,
mozilla::css::Rule* aNewStyleRule) override;
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aStyleRule) override;
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aStyleRule) override;
virtual void FlushPendingNotifications(mozFlushType aType) override;
@ -1494,8 +1499,9 @@ protected:
nsCompatibility aCompatMode);
void RemoveDocStyleSheetsFromStyleSets();
void RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets,
mozilla::SheetType aType);
void RemoveStyleSheetsFromStyleSets(
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets,
mozilla::SheetType aType);
void ResetStylesheetsToURI(nsIURI* aURI);
void FillStyleSet(nsStyleSet* aStyleSet);
@ -1548,9 +1554,9 @@ protected:
// EndLoad() has already happened.
nsWeakPtr mWeakSink;
nsCOMArray<nsIStyleSheet> mStyleSheets;
nsCOMArray<nsIStyleSheet> mOnDemandBuiltInUASheets;
nsCOMArray<nsIStyleSheet> mAdditionalSheets[AdditionalSheetTypeCount];
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mStyleSheets;
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mOnDemandBuiltInUASheets;
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];
// Array of observers
nsTObserverArray<nsIDocumentObserver*> mObservers;
@ -1709,8 +1715,8 @@ private:
friend class nsUnblockOnloadEvent;
// Recomputes the visibility state but doesn't set the new value.
mozilla::dom::VisibilityState GetVisibilityState() const;
void NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet);
void NotifyStyleSheetRemoved(nsIStyleSheet* aSheet, bool aDocumentSheet);
void NotifyStyleSheetAdded(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
void NotifyStyleSheetRemoved(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
void PostUnblockOnloadEvent();
void DoUnblockOnload();

View File

@ -72,7 +72,6 @@ class nsIRequest;
class nsIRunnable;
class nsIStreamListener;
class nsIStructuredCloneContainer;
class nsIStyleSheet;
class nsIURI;
class nsIVariant;
class nsLocation;
@ -156,8 +155,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
} // namespace mozilla
#define NS_IDOCUMENT_IID \
{ 0x4307abe8, 0x5386, 0x4024, \
{ 0xa2, 0xfe, 0x4a, 0x80, 0xe8, 0x47, 0x46, 0x90 } }
{ 0xecc9e376, 0x6c31, 0x4f04, \
{ 0xbe, 0xde, 0xd6, 0x27, 0x61, 0xd7, 0x00, 0x84 } }
// Enum for requesting a particular type of document when creating a doc
enum DocumentFlavor {
@ -925,7 +924,7 @@ public:
* @return the stylesheet at aIndex. Null if aIndex is out of range.
* @throws no exceptions
*/
virtual nsIStyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0;
virtual mozilla::CSSStyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0;
/**
* Insert a sheet at a particular spot in the stylesheet list (zero-based)
@ -934,7 +933,8 @@ public:
* adjusted for the "special" sheets.
* @throws no exceptions
*/
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex) = 0;
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
int32_t aIndex) = 0;
/**
* Get the index of a particular stylesheet. This will _always_
@ -942,7 +942,7 @@ public:
* @param aSheet the sheet to get the index of
* @return aIndex the index of the sheet in the full list
*/
virtual int32_t GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const = 0;
virtual int32_t GetIndexOfStyleSheet(mozilla::CSSStyleSheet* aSheet) const = 0;
/**
* Replace the stylesheets in aOldSheets with the stylesheets in
@ -952,24 +952,25 @@ public:
* may be null; if so the corresponding sheets in the first list
* will simply be removed.
*/
virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
nsCOMArray<nsIStyleSheet>& aNewSheets) = 0;
virtual void UpdateStyleSheets(
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aOldSheets,
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets) = 0;
/**
* Add a stylesheet to the document
*/
virtual void AddStyleSheet(nsIStyleSheet* aSheet) = 0;
virtual void AddStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
/**
* Remove a stylesheet from the document
*/
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
virtual void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
/**
* Notify the document that the applicable state of the sheet changed
* and that observers should be notified and style sets updated
*/
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
bool aApplicable) = 0;
enum additionalSheetType {
@ -979,10 +980,13 @@ public:
AdditionalSheetTypeCount
};
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) = 0;
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aSheet) = 0;
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* sheetURI) = 0;
virtual nsIStyleSheet* FirstAdditionalAuthorSheet() = 0;
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
nsIURI* aSheetURI) = 0;
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
mozilla::CSSStyleSheet* aSheet) = 0;
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
nsIURI* sheetURI) = 0;
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() = 0;
/**
* Get this document's CSSLoader. This is guaranteed to not return null.
@ -1285,12 +1289,12 @@ public:
// Observation hooks for style data to propagate notifications
// to document observers
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aOldStyleRule,
mozilla::css::Rule* aNewStyleRule) = 0;
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aStyleRule) = 0;
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aStyleRule) = 0;
/**

View File

@ -11,18 +11,18 @@
#include "nsIMutationObserver.h"
class nsIContent;
class nsIStyleSheet;
class nsIDocument;
namespace mozilla {
class CSSStyleSheet;
namespace css {
class Rule;
} // namespace css
} // namespace mozilla
#define NS_IDOCUMENT_OBSERVER_IID \
{ 0xce1d53d0, 0x4739, 0x44e5, \
{ 0xb4, 0xae, 0x60, 0xe8, 0x82, 0xcb, 0x73, 0x1b } }
{ 0x21c8ad67, 0x3a7d, 0x4881, \
{ 0xa5, 0x43, 0xcb, 0xa9, 0xbb, 0xe4, 0x9e, 0x39 } }
typedef uint32_t nsUpdateType;
@ -102,7 +102,7 @@ public:
* false if sheet is not (i.e., UA or user sheet)
*/
virtual void StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
mozilla::CSSStyleSheet* aStyleSheet,
bool aDocumentSheet) = 0;
/**
@ -117,7 +117,7 @@ public:
* false if sheet is not (i.e., UA or user sheet)
*/
virtual void StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
mozilla::CSSStyleSheet* aStyleSheet,
bool aDocumentSheet) = 0;
/**
@ -133,7 +133,7 @@ public:
* it is not applicable
*/
virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
mozilla::CSSStyleSheet* aStyleSheet,
bool aApplicable) = 0;
/**
@ -160,7 +160,7 @@ public:
* @param aNewStyleRule The rule being added.
*/
virtual void StyleRuleChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aOldStyleRule,
mozilla::css::Rule* aNewStyleRule) = 0;
@ -176,7 +176,7 @@ public:
* @param aStyleRule the rule that was added
*/
virtual void StyleRuleAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aStyleRule) = 0;
/**
@ -191,7 +191,7 @@ public:
* @param aStyleRule the rule that was removed
*/
virtual void StyleRuleRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
mozilla::CSSStyleSheet* aStyleSheet,
mozilla::css::Rule* aStyleRule) = 0;
};
@ -221,33 +221,34 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
virtual void StyleSheetAdded(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
bool aDocumentSheet) override;
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
virtual void StyleSheetRemoved(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
bool aDocumentSheet) override;
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet,\
bool aApplicable) override;
virtual void StyleSheetApplicableStateChanged( \
nsIDocument* aDocument, \
mozilla::CSSStyleSheet* aStyleSheet, \
bool aApplicable) override;
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
virtual void StyleRuleChanged(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
mozilla::css::Rule* aOldStyleRule, \
mozilla::css::Rule* aNewStyleRule) override;
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
virtual void StyleRuleAdded(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
mozilla::css::Rule* aStyleRule) override;
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
virtual void StyleRuleRemoved(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
mozilla::css::Rule* aStyleRule) override;
#define NS_DECL_NSIDOCUMENTOBSERVER \
@ -307,38 +308,38 @@ NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
void \
_class::StyleSheetAdded(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
bool aDocumentSheet) \
mozilla::CSSStyleSheet* aStyleSheet, \
bool aDocumentSheet) \
{ \
} \
void \
_class::StyleSheetRemoved(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
bool aDocumentSheet) \
mozilla::CSSStyleSheet* aStyleSheet, \
bool aDocumentSheet) \
{ \
} \
void \
_class::StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
bool aApplicable) \
mozilla::CSSStyleSheet* aStyleSheet,\
bool aApplicable) \
{ \
} \
void \
_class::StyleRuleChanged(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
mozilla::css::Rule* aOldStyleRule, \
mozilla::css::Rule* aNewStyleRule) \
{ \
} \
void \
_class::StyleRuleAdded(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
mozilla::css::Rule* aStyleRule) \
{ \
} \
void \
_class::StyleRuleRemoved(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
mozilla::CSSStyleSheet* aStyleSheet, \
mozilla::css::Rule* aStyleRule) \
{ \
}

View File

@ -184,6 +184,14 @@ nsMappedAttributes::MapRuleInfoInto(nsRuleData* aRuleData)
}
}
/* virtual */ bool
nsMappedAttributes::MightMapInheritedStyleData()
{
// Just assume that we do, rather than adding checks to all of the different
// kinds of attribute mapping functions we have.
return true;
}
#ifdef DEBUG
/* virtual */ void
nsMappedAttributes::List(FILE* out, int32_t aIndent) const

View File

@ -74,6 +74,7 @@ public:
// nsIStyleRule
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
virtual bool MightMapInheritedStyleData() override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif

View File

@ -288,17 +288,6 @@ UpdateIsElementInStyleScopeFlagOnSubtree(Element* aElement)
}
}
static Element*
GetScopeElement(nsIStyleSheet* aSheet)
{
RefPtr<CSSStyleSheet> cssStyleSheet = do_QueryObject(aSheet);
if (!cssStyleSheet) {
return nullptr;
}
return cssStyleSheet->GetScopeElement();
}
nsresult
nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
ShadowRoot* aOldShadowRoot,
@ -330,7 +319,8 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
return NS_OK;
}
Element* oldScopeElement = GetScopeElement(mStyleSheet);
Element* oldScopeElement =
mStyleSheet ? mStyleSheet->GetScopeElement() : nullptr;
if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
MOZ_ASSERT(!(aOldDocument && aOldShadowRoot),

View File

@ -1340,7 +1340,6 @@ DOMInterfaces = {
# collection of static methods, so we have this `concrete: False` hack.
'concrete': False,
'headerFile': 'mozilla/dom/ChromeUtils.h',
'implicitJSContext': ['readHeapSnapshot', 'saveHeapSnapshot']
},
'TouchList': {

View File

@ -2388,15 +2388,11 @@ void
nsGonkCameraControl::OnNewPreviewFrame(layers::TextureClient* aBuffer)
{
#ifdef MOZ_WIDGET_GONK
RefPtr<Image> frame = mImageContainer->CreateImage(ImageFormat::GRALLOC_PLANAR_YCBCR);
RefPtr<GrallocImage> frame = new GrallocImage();
GrallocImage* videoImage = static_cast<GrallocImage*>(frame.get());
GrallocImage::GrallocData data;
data.mGraphicBuffer = aBuffer;
data.mPicSize = IntSize(mCurrentConfiguration.mPreviewSize.width,
mCurrentConfiguration.mPreviewSize.height);
videoImage->SetData(data);
IntSize picSize(mCurrentConfiguration.mPreviewSize.width,
mCurrentConfiguration.mPreviewSize.height);
frame->SetData(aBuffer, picSize);
if (mCapturePoster.exchange(false)) {
CreatePoster(frame,

View File

@ -151,15 +151,7 @@ static already_AddRefed<layers::Image>
CreateImageFromSurface(SourceSurface* aSurface, ErrorResult& aRv)
{
MOZ_ASSERT(aSurface);
layers::CairoImage::Data cairoData;
cairoData.mSize = aSurface->GetSize();
cairoData.mSourceSurface = aSurface;
RefPtr<layers::CairoImage> image = new layers::CairoImage();
image->SetData(cairoData);
RefPtr<layers::CairoImage> image = new layers::CairoImage(aSurface->GetSize(), aSurface);
return image.forget();
}

View File

@ -168,6 +168,12 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
}
}
/* virtual */ bool
BodyRule::MightMapInheritedStyleData()
{
return false;
}
#ifdef DEBUG
/* virtual */ void
BodyRule::List(FILE* out, int32_t aIndent) const

View File

@ -28,6 +28,7 @@ public:
// nsIStyleRule interface
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
virtual bool MightMapInheritedStyleData() override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif

View File

@ -1173,13 +1173,7 @@ void
HTMLCanvasElement::SetFrameCapture(already_AddRefed<SourceSurface> aSurface)
{
RefPtr<SourceSurface> surface = aSurface;
CairoImage::Data imageData;
imageData.mSize = surface->GetSize();
imageData.mSourceSurface = surface;
RefPtr<CairoImage> image = new CairoImage();
image->SetData(imageData);
RefPtr<CairoImage> image = new CairoImage(surface->GetSize(), surface);
// Loop backwards to allow removing elements in the loop.
for (int i = mRequestedFrameListeners.Length() - 1; i >= 0; --i) {

View File

@ -21,7 +21,6 @@
#include "nsIDOMEvent.h"
#include "nsIDOMStyleSheet.h"
#include "nsINode.h"
#include "nsIStyleSheet.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsIURL.h"
#include "nsPIDOMWindow.h"

View File

@ -979,8 +979,13 @@ void HTMLMediaElement::NotifyMediaTrackEnabled(MediaTrack* aTrack)
if (!aTrack) {
return;
}
#ifdef DEBUG
nsString id;
aTrack->GetId(id);
LOG(LogLevel::Debug, ("MediaElement %p MediaStreamTrack %p enabled", this));
LOG(LogLevel::Debug, ("MediaElement %p MediaStreamTrack enabled with id %s",
this, NS_ConvertUTF16toUTF8(id).get()));
#endif
// TODO: We are dealing with single audio track and video track for now.
if (AudioTrack* track = aTrack->AsAudioTrack()) {

View File

@ -8,7 +8,6 @@
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsIDOMStyleSheet.h"
#include "nsIStyleSheet.h"
#include "nsIDocument.h"
#include "nsUnicharUtils.h"
#include "nsThreadUtils.h"

View File

@ -2641,12 +2641,12 @@ nsHTMLDocument::TearingDownEditor(nsIEditor *aEditor)
if (!presShell)
return;
nsCOMArray<nsIStyleSheet> agentSheets;
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
presShell->GetAgentStyleSheets(agentSheets);
agentSheets.RemoveObject(nsLayoutStylesheetCache::ContentEditableSheet());
agentSheets.RemoveElement(nsLayoutStylesheetCache::ContentEditableSheet());
if (oldState == eDesignMode)
agentSheets.RemoveObject(nsLayoutStylesheetCache::DesignModeSheet());
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
presShell->SetAgentStyleSheets(agentSheets);
@ -2780,18 +2780,15 @@ nsHTMLDocument::EditingStateChanged()
// Before making this window editable, we need to modify UA style sheet
// because new style may change whether focused element will be focusable
// or not.
nsCOMArray<nsIStyleSheet> agentSheets;
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
rv = presShell->GetAgentStyleSheets(agentSheets);
NS_ENSURE_SUCCESS(rv, rv);
CSSStyleSheet* contentEditableSheet =
nsLayoutStylesheetCache::ContentEditableSheet();
bool result;
if (!agentSheets.Contains(contentEditableSheet)) {
bool result = agentSheets.AppendObject(contentEditableSheet);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
agentSheets.AppendElement(contentEditableSheet);
}
// Should we update the editable state of all the nodes in the document? We
@ -2802,8 +2799,7 @@ nsHTMLDocument::EditingStateChanged()
CSSStyleSheet* designModeSheet =
nsLayoutStylesheetCache::DesignModeSheet();
if (!agentSheets.Contains(designModeSheet)) {
result = agentSheets.AppendObject(designModeSheet);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
agentSheets.AppendElement(designModeSheet);
}
updateState = true;
@ -2811,7 +2807,7 @@ nsHTMLDocument::EditingStateChanged()
}
else if (oldState == eDesignMode) {
// designMode is being turned off (contentEditable is still on).
agentSheets.RemoveObject(nsLayoutStylesheetCache::DesignModeSheet());
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
updateState = true;
}

View File

@ -57,3 +57,21 @@ interface nsIPushNotificationService : nsISupports
*/
jsval clearForDomain(in string domain);
};
[scriptable, uuid(a2555e70-46f8-4b52-bf02-d978b979d143)]
interface nsIPushQuotaManager : nsISupports
{
/**
* Informs the quota manager that a notification
* for the given origin has been shown. Used to
* determine if push quota should be relaxed.
*/
void notificationForOriginShown(in string origin);
/**
* Informs the quota manager that a notification
* for the given origin has been closed. Used to
* determine if push quota should be relaxed.
*/
void notificationForOriginClosed(in string origin);
};

View File

@ -36,6 +36,7 @@
#include "imgIContainer.h"
#include "mozIApplication.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/CSSStyleSheet.h"
#include "mozilla/DataStorage.h"
#include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
#include "mozilla/docshell/OfflineCacheUpdateParent.h"
@ -142,7 +143,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsISiteSecurityService.h"
#include "nsISpellChecker.h"
#include "nsIStyleSheet.h"
#include "nsISupportsPrimitives.h"
#include "nsISystemMessagesInternal.h"
#include "nsITimer.h"
@ -2576,24 +2576,21 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
// This looks like a lot of work, but in a normal browser session we just
// send two loads.
nsCOMArray<nsIStyleSheet>& agentSheets = *sheetService->AgentStyleSheets();
for (uint32_t i = 0; i < agentSheets.Length(); i++) {
for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
URIParams uri;
SerializeURI(agentSheets[i]->GetSheetURI(), uri);
SerializeURI(sheet->GetSheetURI(), uri);
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
}
nsCOMArray<nsIStyleSheet>& userSheets = *sheetService->UserStyleSheets();
for (uint32_t i = 0; i < userSheets.Length(); i++) {
for (CSSStyleSheet* sheet : *sheetService->UserStyleSheets()) {
URIParams uri;
SerializeURI(userSheets[i]->GetSheetURI(), uri);
SerializeURI(sheet->GetSheetURI(), uri);
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
}
nsCOMArray<nsIStyleSheet>& authorSheets = *sheetService->AuthorStyleSheets();
for (uint32_t i = 0; i < authorSheets.Length(); i++) {
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
URIParams uri;
SerializeURI(authorSheets[i]->GetSheetURI(), uri);
SerializeURI(sheet->GetSheetURI(), uri);
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
}
}

View File

@ -1044,10 +1044,9 @@ DOMHwMediaStream::DOMHwMediaStream()
{
#ifdef MOZ_WIDGET_GONK
mImageContainer = LayerManager::CreateImageContainer(ImageContainer::ASYNCHRONOUS_OVERLAY);
RefPtr<Image> img = mImageContainer->CreateImage(ImageFormat::OVERLAY_IMAGE);
mOverlayImage = static_cast<layers::OverlayImage*>(img.get());
mOverlayImage = mImageContainer->CreateOverlayImage();
nsAutoTArray<ImageContainer::NonOwningImage,1> images;
images.AppendElement(ImageContainer::NonOwningImage(img));
images.AppendElement(ImageContainer::NonOwningImage(mOverlayImage));
mImageContainer->SetCurrentImages(images);
#endif
}

View File

@ -312,11 +312,11 @@ VideoData::Create(const VideoInfo& aInfo,
// format.
#ifdef MOZ_WIDGET_GONK
if (IsYV12Format(Y, Cb, Cr) && !IsInEmulator()) {
v->mImage = aContainer->CreateImage(ImageFormat::GRALLOC_PLANAR_YCBCR);
v->mImage = new layers::GrallocImage();
}
#endif
if (!v->mImage) {
v->mImage = aContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
v->mImage = aContainer->CreatePlanarYCbCrImage();
}
} else {
v->mImage = aImage;
@ -328,7 +328,8 @@ VideoData::Create(const VideoInfo& aInfo,
NS_ASSERTION(v->mImage->GetFormat() == ImageFormat::PLANAR_YCBCR ||
v->mImage->GetFormat() == ImageFormat::GRALLOC_PLANAR_YCBCR,
"Wrong format?");
PlanarYCbCrImage* videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
PlanarYCbCrImage* videoImage = v->mImage->AsPlanarYCbCrImage();
MOZ_ASSERT(videoImage);
bool shouldCopyData = (aImage == nullptr);
if (!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
@ -339,11 +340,11 @@ VideoData::Create(const VideoInfo& aInfo,
#ifdef MOZ_WIDGET_GONK
if (!videoImage->IsValid() && !aImage && IsYV12Format(Y, Cb, Cr)) {
// Failed to allocate gralloc. Try fallback.
v->mImage = aContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
v->mImage = aContainer->CreatePlanarYCbCrImage();
if (!v->mImage) {
return nullptr;
}
videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
videoImage = v->mImage->AsPlanarYCbCrImage();
if(!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
true /* aCopyData */)) {
return nullptr;
@ -460,22 +461,9 @@ VideoData::Create(const VideoInfo& aInfo,
aInfo.mDisplay,
0));
v->mImage = aContainer->CreateImage(ImageFormat::GRALLOC_PLANAR_YCBCR);
if (!v->mImage) {
return nullptr;
}
NS_ASSERTION(v->mImage->GetFormat() == ImageFormat::GRALLOC_PLANAR_YCBCR,
"Wrong format?");
typedef mozilla::layers::GrallocImage GrallocImage;
GrallocImage* videoImage = static_cast<GrallocImage*>(v->mImage.get());
GrallocImage::GrallocData data;
data.mPicSize = aPicture.Size();
data.mGraphicBuffer = aBuffer;
if (!videoImage->SetData(data)) {
return nullptr;
}
RefPtr<layers::GrallocImage> image = new layers::GrallocImage();
image->SetData(aBuffer, aPicture.Size());
v->mImage = image;
return v.forget();
}

View File

@ -828,13 +828,11 @@ MediaStreamGraphImpl::PlayVideo(MediaStream* aStream)
if (frame->GetForceBlack()) {
if (!blackImage) {
blackImage = aStream->mVideoOutputs[0]->
GetImageContainer()->CreateImage(ImageFormat::PLANAR_YCBCR);
blackImage = aStream->mVideoOutputs[0]->GetImageContainer()->CreatePlanarYCbCrImage();
if (blackImage) {
// Sets the image to a single black pixel, which will be scaled to
// fill the rendered size.
SetImageToBlackPixel(static_cast<PlanarYCbCrImage*>
(blackImage.get()));
SetImageToBlackPixel(blackImage->AsPlanarYCbCrImage());
}
}
if (blackImage) {

View File

@ -43,17 +43,14 @@ VideoFrame::TakeFrom(VideoFrame* aFrame)
/* static */ already_AddRefed<Image>
VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
{
RefPtr<ImageContainer> container;
RefPtr<Image> image;
container = LayerManager::CreateImageContainer();
image = container->CreateImage(ImageFormat::PLANAR_YCBCR);
RefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
RefPtr<PlanarYCbCrImage> image = container->CreatePlanarYCbCrImage();
if (!image) {
MOZ_ASSERT(false);
return nullptr;
}
int len = ((aSize.width * aSize.height) * 3 / 2);
PlanarYCbCrImage* planar = static_cast<PlanarYCbCrImage*>(image.get());
// Generate a black image.
ScopedDeletePtr<uint8_t> frame(new uint8_t[len]);
@ -80,7 +77,7 @@ VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
data.mStereoMode = StereoMode::MONO;
// SetData copies data, so we can free data.
if (!planar->SetData(data)) {
if (!image->SetData(data)) {
MOZ_ASSERT(false);
return nullptr;
}

View File

@ -387,8 +387,8 @@ uint8_t *
AndroidMediaReader::ImageBufferCallback::CreateI420Image(size_t aWidth,
size_t aHeight)
{
mImage = mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
PlanarYCbCrImage *yuvImage = static_cast<PlanarYCbCrImage *>(mImage.get());
RefPtr<PlanarYCbCrImage> yuvImage = mImageContainer->CreatePlanarYCbCrImage();
mImage = yuvImage;
if (!yuvImage) {
NS_WARNING("Could not create I420 image");

View File

@ -45,8 +45,7 @@ GstFlowReturn GStreamerReader::AllocateVideoBufferFull(GstPad* aPad,
if (container == nullptr) {
return GST_FLOW_ERROR;
}
RefPtr<PlanarYCbCrImage> image =
container->CreateImage(ImageFormat::PLANAR_YCBCR).downcast<PlanarYCbCrImage>();
RefPtr<PlanarYCbCrImage> image = container->CreatePlanarYCbCrImage();
/* prepare a GstBuffer pointing to the underlying PlanarYCbCrImage buffer */
GstBuffer* buf = GST_BUFFER(gst_moz_video_buffer_new());

View File

@ -127,14 +127,8 @@ public:
return NS_ERROR_FAILURE;
}
RefPtr<layers::Image> img = mImageContainer->CreateImage(ImageFormat::SURFACE_TEXTURE);
layers::SurfaceTextureImage::Data data;
data.mSurfTex = mSurfaceTexture.get();
data.mSize = mConfig.mDisplay;
data.mOriginPos = gl::OriginPos::BottomLeft;
layers::SurfaceTextureImage* stImg = static_cast<layers::SurfaceTextureImage*>(img.get());
stImg->SetData(data);
RefPtr<layers::Image> img =
new SurfaceTextureImage(mSurfaceTexture.get(), mConfig.mDisplay, gl::OriginPos::BottomLeft);
if (WantCopy()) {
EGLImage eglImage = CopySurface(img);
@ -156,16 +150,10 @@ public:
NS_WARNING("No EGL fence support detected, rendering artifacts may occur!");
}
img = mImageContainer->CreateImage(ImageFormat::EGLIMAGE);
layers::EGLImageImage::Data data;
data.mImage = eglImage;
data.mSync = eglSync;
data.mOwns = true;
data.mSize = mConfig.mDisplay;
data.mOriginPos = gl::OriginPos::TopLeft;
layers::EGLImageImage* typedImg = static_cast<layers::EGLImageImage*>(img.get());
typedImg->SetData(data);
img = new layers::EGLImageImage(
eglImage, eglSync,
mConfig.mDisplay, gl::OriginPos::TopLeft,
true /* owns */);
}
nsresult rv;

View File

@ -397,11 +397,7 @@ AppleVDADecoder::OutputFrame(CVPixelBufferRef aImage,
RefPtr<MacIOSurface> macSurface = new MacIOSurface(surface);
RefPtr<layers::Image> image =
mImageContainer->CreateImage(ImageFormat::MAC_IOSURFACE);
layers::MacIOSurfaceImage* videoImage =
static_cast<layers::MacIOSurfaceImage*>(image.get());
videoImage->SetSurface(macSurface);
RefPtr<layers::Image> image = new MacIOSurfaceImage(macSurface);
data =
VideoData::CreateFromImage(info,

View File

@ -331,10 +331,8 @@ FFmpegH264Decoder<LIBAV_VER>::AllocateYUV420PVideoBuffer(
size_t allocSize = pitch * decodeHeight + (chroma_pitch * chroma_height) * 2;
RefPtr<Image> image =
mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
PlanarYCbCrImage* ycbcr = static_cast<PlanarYCbCrImage*>(image.get());
uint8_t* buffer = ycbcr->AllocateAndGetNewBuffer(allocSize + 64);
RefPtr<PlanarYCbCrImage> image = mImageContainer->CreatePlanarYCbCrImage();
uint8_t* buffer = image->AllocateAndGetNewBuffer(allocSize + 64);
// FFmpeg requires a 16/32 bytes-aligned buffer, align it on 64 to be safe
buffer = reinterpret_cast<uint8_t*>((reinterpret_cast<uintptr_t>(buffer) + 63) & ~63);

View File

@ -420,17 +420,13 @@ D3D9DXVA2Manager::CopyToImage(IMFSample* aSample,
getter_AddRefs(surface));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<Image> image = aImageContainer->CreateImage(ImageFormat::D3D9_RGB32_TEXTURE);
NS_ENSURE_TRUE(image, E_FAIL);
NS_ASSERTION(image->GetFormat() == ImageFormat::D3D9_RGB32_TEXTURE,
"Wrong format?");
RefPtr<D3D9SurfaceImage> image = new D3D9SurfaceImage(mFirstFrame);
hr = image->AllocateAndCopy(mTextureClientAllocator, surface, aRegion);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
D3D9SurfaceImage* videoImage = static_cast<D3D9SurfaceImage*>(image.get());
hr = videoImage->SetData(D3D9SurfaceImage::Data(surface, aRegion, mTextureClientAllocator, mFirstFrame));
mFirstFrame = false;
image.forget(aOutImage);
return S_OK;
}
@ -714,23 +710,16 @@ D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample,
// to create a copy of that frame as a sharable resource, save its share
// handle, and put that handle into the rendering pipeline.
ImageFormat format = ImageFormat::D3D11_SHARE_HANDLE_TEXTURE;
RefPtr<Image> image(aContainer->CreateImage(format));
NS_ENSURE_TRUE(image, E_FAIL);
NS_ASSERTION(image->GetFormat() == ImageFormat::D3D11_SHARE_HANDLE_TEXTURE,
"Wrong format?");
RefPtr<D3D11ShareHandleImage> image =
new D3D11ShareHandleImage(gfx::IntSize(mWidth, mHeight), aRegion);
bool ok = image->AllocateTexture(mTextureClientAllocator);
NS_ENSURE_TRUE(ok, E_FAIL);
D3D11ShareHandleImage* videoImage = static_cast<D3D11ShareHandleImage*>(image.get());
HRESULT hr = videoImage->SetData(D3D11ShareHandleImage::Data(mTextureClientAllocator,
gfx::IntSize(mWidth, mHeight),
aRegion));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = mTransform->Input(aVideoSample);
HRESULT hr = mTransform->Input(aVideoSample);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFSample> sample;
RefPtr<ID3D11Texture2D> texture = videoImage->GetTexture();
RefPtr<ID3D11Texture2D> texture = image->GetTexture();
hr = CreateOutputSample(sample, texture);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);

View File

@ -367,12 +367,8 @@ WMFVideoMFTManager::ConfigureVideoFrameGeometry()
NS_ENSURE_TRUE(videoFormat == MFVideoFormat_NV12 || !mUseHwAccel, E_FAIL);
NS_ENSURE_TRUE(videoFormat == MFVideoFormat_YV12 || mUseHwAccel, E_FAIL);
UINT32 width = 0, height = 0;
hr = MFGetAttributeSize(mediaType, MF_MT_FRAME_SIZE, &width, &height);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
mVideoInfo.mImage.width = width;
mVideoInfo.mImage.height = height;
UINT32 width = mVideoInfo.mImage.width;
UINT32 height = mVideoInfo.mImage.height;
nsIntRect pictureRegion = mVideoInfo.mImage;
// Calculate and validate the picture region and frame dimensions after
// scaling by the pixel aspect ratio.

View File

@ -72,6 +72,8 @@ skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 1021776, too --ing
skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
[test_peerConnection_basicAudioRequireEOC.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_basicAudioPcmaPcmuOnly.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_basicAudioVideo.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' || (android_version == '18' && debug) # b2g(Bug 960442, video support for WebRTC is disabled on b2g), android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoCombined.html]

View File

@ -62,6 +62,7 @@ function PeerConnectionTest(options) {
options.h264 = "h264" in options ? options.h264 : false;
options.bundle = "bundle" in options ? options.bundle : true;
options.rtcpmux = "rtcpmux" in options ? options.rtcpmux : true;
options.opus = "opus" in options ? options.opus : true;
if (typeof turnServers !== "undefined") {
if ((!options.turn_disabled_local) && (turnServers.local)) {

View File

@ -45,6 +45,14 @@ removeBundle: function(sdp) {
return sdp.replace(/a=group:BUNDLE .*\r\n/g, "");
},
reduceAudioMLineToPcmuPcma: function(sdp) {
return sdp.replace(/m=audio .*\r\n/g, "m=audio 9 UDP/TLS/RTP/SAVPF 0 8\r\n");
},
removeAllRtpMaps: function(sdp) {
return sdp.replace(/a=rtpmap:.*\r\n/g, "");
},
verifySdp: function(desc, expectedType, offerConstraintsList, offerOptions,
testOptions) {
info("Examining this SessionDescription: " + JSON.stringify(desc));
@ -76,7 +84,7 @@ verifySdp: function(desc, expectedType, offerConstraintsList, offerOptions,
ok(!desc.sdp.includes("m=audio"), "audio m-line is absent from SDP");
} else {
ok(desc.sdp.includes("m=audio"), "audio m-line is present in SDP");
ok(desc.sdp.includes("a=rtpmap:109 opus/48000/2"), "OPUS codec is present in SDP");
is(testOptions.opus, desc.sdp.includes("a=rtpmap:109 opus/48000/2"), "OPUS codec is present in SDP");
//TODO: ideally the rtcp-mux should be for the m=audio, and not just
// anywhere in the SDP (JS SDP parser bug 1045429)
is(testOptions.rtcpmux, desc.sdp.includes("a=rtcp-mux"), "RTCP Mux is offered in SDP");

View File

@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "796892",
title: "Only offer PCMA and PMCU in mline (no rtpmaps)"
});
var test;
runNetworkTest(function (options) {
options = options || { };
options.opus = false;
test = new PeerConnectionTest(options);
test.chain.insertBefore("PC_REMOTE_GET_OFFER", [
function PC_LOCAL_REDUCE_MLINE_REMOVE_RTPMAPS(test) {
test.originalOffer.sdp =
sdputils.reduceAudioMLineToPcmuPcma(test.originalOffer.sdp);
test.originalOffer.sdp =
sdputils.removeAllRtpMaps(test.originalOffer.sdp);
info("SDP without Rtpmaps: " + JSON.stringify(test.originalOffer));
}
]);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -236,9 +236,7 @@ MediaEngineDefaultVideoSource::Notify(nsITimer* aTimer)
}
// Allocate a single solid color image
RefPtr<layers::Image> image = mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
RefPtr<layers::PlanarYCbCrImage> ycbcr_image =
static_cast<layers::PlanarYCbCrImage*>(image.get());
RefPtr<layers::PlanarYCbCrImage> ycbcr_image = mImageContainer->CreatePlanarYCbCrImage();
layers::PlanarYCbCrData data;
AllocateSolidColorFrame(data, mOpts.mWidth, mOpts.mHeight, 0x80, mCb, mCr);

View File

@ -738,9 +738,9 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
graphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_MASK, &pMem);
uint8_t* srcPtr = static_cast<uint8_t*>(pMem);
// Create a video frame and append it to the track.
ImageFormat format = ImageFormat::GONK_CAMERA_IMAGE;
RefPtr<layers::Image> image = mImageContainer->CreateImage(format);
RefPtr<layers::PlanarYCbCrImage> image = new GonkCameraImage();
uint32_t dstWidth;
uint32_t dstHeight;
@ -755,7 +755,6 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
uint32_t half_width = dstWidth / 2;
layers::GrallocImage* videoImage = static_cast<layers::GrallocImage*>(image.get());
MOZ_ASSERT(mTextureClientAllocator);
RefPtr<layers::TextureClient> textureClient
= mTextureClientAllocator->CreateOrRecycle(gfx::SurfaceFormat::YUV,
@ -764,8 +763,7 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
layers::TextureFlags::DEFAULT,
layers::ALLOC_DISALLOW_BUFFERTEXTURECLIENT);
if (textureClient) {
RefPtr<layers::GrallocTextureClientOGL> grallocTextureClient =
static_cast<layers::GrallocTextureClientOGL*>(textureClient.get());
RefPtr<layers::GrallocTextureClientOGL> grallocTextureClient = textureClient->AsGrallocTextureClientOGL();
android::sp<android::GraphicBuffer> destBuffer = grallocTextureClient->GetGraphicBuffer();
@ -788,16 +786,11 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
libyuv::FOURCC_NV21);
destBuffer->unlock();
layers::GrallocImage::GrallocData data;
data.mPicSize = gfx::IntSize(dstWidth, dstHeight);
data.mGraphicBuffer = textureClient;
videoImage->SetData(data);
image->AsGrallocImage()->SetData(textureClient, gfx::IntSize(dstWidth, dstHeight));
} else {
// Handle out of gralloc case.
image = mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
layers::PlanarYCbCrImage* videoImage = static_cast<layers::PlanarYCbCrImage*>(image.get());
uint8_t* dstPtr = videoImage->AllocateAndGetNewBuffer(size);
image = mImageContainer->CreatePlanarYCbCrImage();
uint8_t* dstPtr = image->AsPlanarYCbCrImage()->AllocateAndGetNewBuffer(size);
libyuv::ConvertToI420(srcPtr, size,
dstPtr, dstWidth,
@ -825,7 +818,7 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
data.mPicSize = IntSize(dstWidth, dstHeight);
data.mStereoMode = StereoMode::MONO;
videoImage->SetDataNoCopy(data);
image->AsPlanarYCbCrImage()->SetDataNoCopy(data);
}
graphicBuffer->unlock();

View File

@ -294,8 +294,7 @@ MediaEngineRemoteVideoSource::DeliverFrame(unsigned char* buffer,
}
// Create a video frame and append it to the track.
RefPtr<layers::Image> image = mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
layers::PlanarYCbCrImage* videoImage = static_cast<layers::PlanarYCbCrImage*>(image.get());
RefPtr<layers::PlanarYCbCrImage> image = mImageContainer->CreatePlanarYCbCrImage();
uint8_t* frame = static_cast<uint8_t*> (buffer);
const uint8_t lumaBpp = 8;
@ -315,7 +314,7 @@ MediaEngineRemoteVideoSource::DeliverFrame(unsigned char* buffer,
data.mPicSize = IntSize(mWidth, mHeight);
data.mStereoMode = StereoMode::MONO;
if (!videoImage->SetData(data)) {
if (!image->SetData(data)) {
MOZ_ASSERT(false);
return 0;
}

View File

@ -298,13 +298,7 @@ MediaEngineTabVideoSource::Draw() {
return;
}
layers::CairoImage::Data cairoData;
cairoData.mSize = size;
cairoData.mSourceSurface = surface;
RefPtr<layers::CairoImage> image = new layers::CairoImage();
image->SetData(cairoData);
RefPtr<layers::CairoImage> image = new layers::CairoImage(size, surface);
MonitorAutoLock mon(mMonitor);
mImage = image;

View File

@ -51,6 +51,10 @@
#include "nsIDOMDesktopNotification.h"
#endif
#ifndef MOZ_SIMPLEPUSH
#include "nsIPushNotificationService.h"
#endif
namespace mozilla {
namespace dom {
@ -678,6 +682,8 @@ protected:
{
AssertIsOnMainThread();
}
nsresult AdjustPushQuota(const char* aTopic);
};
NS_IMPL_ISUPPORTS(NotificationObserver, nsIObserver)
@ -1173,11 +1179,39 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
ContentChild::GetSingleton()->SendOpenNotificationSettings(
IPC::Principal(mPrincipal));
return NS_OK;
} else if (!strcmp("alertshow", aTopic) ||
!strcmp("alertfinished", aTopic)) {
Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic)));
}
return mObserver->Observe(aSubject, aTopic, aData);
}
nsresult
NotificationObserver::AdjustPushQuota(const char* aTopic)
{
#ifdef MOZ_SIMPLEPUSH
return NS_ERROR_NOT_IMPLEMENTED;
#else
nsCOMPtr<nsIPushQuotaManager> pushQuotaManager =
do_GetService("@mozilla.org/push/NotificationService;1");
if (!pushQuotaManager) {
return NS_ERROR_FAILURE;
}
nsAutoCString origin;
nsresult rv = mPrincipal->GetOrigin(origin);
if (NS_FAILED(rv)) {
return rv;
}
if (!strcmp("alertshow", aTopic)) {
return pushQuotaManager->NotificationForOriginShown(origin.get());
}
return pushQuotaManager->NotificationForOriginClosed(origin.get());
#endif
}
NS_IMETHODIMP
MainThreadNotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData)

View File

@ -179,16 +179,10 @@ AttachToContainerAsEGLImage(ImageContainer* container,
return;
}
RefPtr<Image> img = container->CreateImage(ImageFormat::EGLIMAGE);
EGLImageImage::Data data;
data.mImage = image;
data.mSize = gfx::IntSize(rect.width, rect.height);
data.mOriginPos = instance->OriginPos();
EGLImageImage* typedImg = static_cast<EGLImageImage*>(img.get());
typedImg->SetData(data);
RefPtr<EGLImageImage> img = new EGLImageImage(
image, nullptr,
gfx::IntSize(rect.width, rect.height), instance->OriginPos(),
false /* owns */);
*out_image = img;
}
@ -206,16 +200,10 @@ AttachToContainerAsSurfaceTexture(ImageContainer* container,
return;
}
RefPtr<Image> img = container->CreateImage(ImageFormat::SURFACE_TEXTURE);
SurfaceTextureImage::Data data;
data.mSurfTex = surfTex;
data.mSize = gfx::IntSize(rect.width, rect.height);
data.mOriginPos = instance->OriginPos();
SurfaceTextureImage* typedImg = static_cast<SurfaceTextureImage*>(img.get());
typedImg->SetData(data);
RefPtr<Image> img = new SurfaceTextureImage(
surfTex,
gfx::IntSize(rect.width, rect.height),
instance->OriginPos());
*out_image = img;
}
#endif
@ -1339,16 +1327,10 @@ nsPluginInstanceOwner::GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInf
{
RefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
RefPtr<Image> img = container->CreateImage(ImageFormat::SURFACE_TEXTURE);
SurfaceTextureImage::Data data;
data.mSurfTex = aVideoInfo->mSurfaceTexture;
data.mOriginPos = gl::OriginPos::BottomLeft;
data.mSize = gfx::IntSize(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height);
SurfaceTextureImage* typedImg = static_cast<SurfaceTextureImage*>(img.get());
typedImg->SetData(data);
RefPtr<Image> img = new SurfaceTextureImage(
aVideoInfo->mSurfaceTexture,
gfx::IntSize(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height),
gl::OriginPos::BottomLeft);
container->SetCurrentImageInTransaction(img);
return container.forget();

View File

@ -615,18 +615,15 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
updatedRect.bottom - updatedRect.top);
surface->MarkDirty(ur);
ImageContainer *container = GetImageContainer();
RefPtr<Image> image = container->CreateImage(ImageFormat::CAIRO_SURFACE);
NS_ASSERTION(image->GetFormat() == ImageFormat::CAIRO_SURFACE, "Wrong format?");
CairoImage* cairoImage = static_cast<CairoImage*>(image.get());
CairoImage::Data cairoData;
cairoData.mSize = surface->GetSize();
cairoData.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface);
cairoImage->SetData(cairoData);
RefPtr<gfx::SourceSurface> sourceSurface =
gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface);
RefPtr<CairoImage> image = new CairoImage(surface->GetSize(), sourceSurface);
nsAutoTArray<ImageContainer::NonOwningImage,1> imageList;
imageList.AppendElement(
ImageContainer::NonOwningImage(image));
ImageContainer *container = GetImageContainer();
container->SetCurrentImages(imageList);
}
else if (mImageContainer) {
@ -697,17 +694,8 @@ PluginInstanceParent::GetImageContainer(ImageContainer** aContainer)
#ifdef XP_MACOSX
if (ioSurface) {
RefPtr<Image> image = container->CreateImage(ImageFormat::MAC_IOSURFACE);
if (!image) {
return NS_ERROR_FAILURE;
}
NS_ASSERTION(image->GetFormat() == ImageFormat::MAC_IOSURFACE, "Wrong format?");
MacIOSurfaceImage* pluginImage = static_cast<MacIOSurfaceImage*>(image.get());
pluginImage->SetSurface(ioSurface);
container->SetCurrentImageInTransaction(pluginImage);
RefPtr<Image> image = new MacIOSurfaceImage(ioSurface);
container->SetCurrentImageInTransaction(image);
NS_IF_ADDREF(container);
*aContainer = container;

View File

@ -74,7 +74,8 @@ AddSandboxAllowedFile(vector<std::wstring>& aAllowedFiles, nsIProperties* aDirSv
static void
AddSandboxAllowedFiles(int32_t aSandboxLevel,
vector<std::wstring>& aAllowedFilesRead,
vector<std::wstring>& aAllowedFilesReadWrite)
vector<std::wstring>& aAllowedFilesReadWrite,
vector<std::wstring>& aAllowedDirectories)
{
if (aSandboxLevel < 2) {
return;
@ -95,12 +96,21 @@ AddSandboxAllowedFiles(int32_t aSandboxLevel,
}
// Level 2 and above is now using low integrity, so we need to give write
// access to the Flash directories.
// access to the Flash directories. Access also has to be given to create
// the parent directories as they may not exist.
// This should be made Flash specific (Bug 1171396).
AddSandboxAllowedFile(aAllowedFilesReadWrite, dirSvc, NS_WIN_APPDATA_DIR,
NS_LITERAL_STRING("\\Macromedia\\Flash Player\\*"));
AddSandboxAllowedFile(aAllowedDirectories, dirSvc, NS_WIN_APPDATA_DIR,
NS_LITERAL_STRING("\\Macromedia\\Flash Player"));
AddSandboxAllowedFile(aAllowedDirectories, dirSvc, NS_WIN_APPDATA_DIR,
NS_LITERAL_STRING("\\Macromedia"));
AddSandboxAllowedFile(aAllowedFilesReadWrite, dirSvc, NS_WIN_APPDATA_DIR,
NS_LITERAL_STRING("\\Adobe\\Flash Player\\*"));
AddSandboxAllowedFile(aAllowedDirectories, dirSvc, NS_WIN_APPDATA_DIR,
NS_LITERAL_STRING("\\Adobe\\Flash Player"));
AddSandboxAllowedFile(aAllowedDirectories, dirSvc, NS_WIN_APPDATA_DIR,
NS_LITERAL_STRING("\\Adobe"));
// Write access to the Temp directory is needed in some mochitest crash
// tests.
@ -117,7 +127,7 @@ PluginProcessParent::Launch(mozilla::UniquePtr<LaunchCompleteTask> aLaunchComple
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
mSandboxLevel = aSandboxLevel;
AddSandboxAllowedFiles(mSandboxLevel, mAllowedFilesRead,
mAllowedFilesReadWrite);
mAllowedFilesReadWrite, mAllowedDirectories);
#else
if (aSandboxLevel != 0) {
MOZ_ASSERT(false,

View File

@ -36,7 +36,8 @@ PushNotificationService.prototype = {
_xpcom_factory: XPCOMUtils.generateSingletonFactory(PushNotificationService),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference,
Ci.nsIPushNotificationService]),
Ci.nsIPushNotificationService,
Ci.nsIPushQuotaManager,]),
register: function register(scope, originAttributes) {
return PushService.register({
@ -74,6 +75,26 @@ PushNotificationService.prototype = {
}
break;
}
},
// nsIPushQuotaManager methods
notificationForOriginShown: function(origin) {
if (!isParent) {
Services.cpmm.sendAsyncMessage("Push:NotificationForOriginShown", origin);
return;
}
PushService._notificationForOriginShown(origin);
},
notificationForOriginClosed: function(origin) {
if (!isParent) {
Services.cpmm.sendAsyncMessage("Push:NotificationForOriginClosed", origin);
return;
}
PushService._notificationForOriginClosed(origin);
}
};

View File

@ -65,25 +65,15 @@ PushRecord.prototype = {
this.quota = 0;
return;
}
let currentQuota;
if (lastVisit > this.lastPush) {
// If the user visited the site since the last time we received a
// notification, reset the quota.
let daysElapsed = (Date.now() - lastVisit) / 24 / 60 / 60 / 1000;
currentQuota = Math.min(
this.quota = Math.min(
Math.round(8 * Math.pow(daysElapsed, -0.8)),
prefs.get("maxQuotaPerSubscription")
);
Services.telemetry.getHistogramById("PUSH_API_QUOTA_RESET_TO").add(currentQuota - 1);
} else {
// The user hasn't visited the site since the last notification.
currentQuota = this.quota;
}
this.quota = Math.max(currentQuota - 1, 0);
// We check for ctime > 0 to skip older records that did not have ctime.
if (this.isExpired() && this.ctime > 0) {
let duration = Date.now() - this.ctime;
Services.telemetry.getHistogramById("PUSH_API_QUOTA_EXPIRATION_TIME").add(duration / 1000);
Services.telemetry.getHistogramById("PUSH_API_QUOTA_RESET_TO").add(this.quota);
}
},
@ -93,6 +83,15 @@ PushRecord.prototype = {
this.lastPush = Date.now();
},
reduceQuota() {
this.quota = Math.max(this.quota - 1, 0);
// We check for ctime > 0 to skip older records that did not have ctime.
if (this.isExpired() && this.ctime > 0) {
let duration = Date.now() - this.ctime;
Services.telemetry.getHistogramById("PUSH_API_QUOTA_EXPIRATION_TIME").add(duration / 1000);
}
},
/**
* Queries the Places database for the last time a user visited the site
* associated with a push registration.

View File

@ -45,6 +45,8 @@ const prefs = new Preferences("dom.push.");
const kCHILD_PROCESS_MESSAGES = ["Push:Register", "Push:Unregister",
"Push:Registration", "Push:RegisterEventNotificationListener",
"Push:NotificationForOriginShown",
"Push:NotificationForOriginClosed",
"child-process-shutdown"];
const PUSH_SERVICE_UNINIT = 0;
@ -97,6 +99,11 @@ this.PushService = {
_db: null,
_options: null,
_alarmID: null,
_visibleNotifications: new Map(),
// Callback that is called after attempting to
// reduce the quota for a record. Used for testing purposes.
_updateQuotaTestCallback: null,
_childListeners: [],
@ -883,13 +890,10 @@ this.PushService = {
if (shouldNotify) {
notified = this._notifyApp(record, message);
}
if (record.isExpired()) {
this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_EXPIRED);
// Drop the registration in the background. If the user returns to the
// site, the service worker will be notified on the next `idle-daily`
// event.
this._backgroundUnregister(record);
}
// Update quota after the delay, at which point
// we check for visible notifications.
setTimeout(() => this._updateQuota(keyID),
prefs.get("quotaUpdateDelay"));
return notified;
});
}).catch(error => {
@ -897,6 +901,66 @@ this.PushService = {
});
},
_updateQuota: function(keyID) {
console.debug("updateQuota()");
this._db.update(keyID, record => {
// Record may have expired from an earlier quota update.
if (record.isExpired()) {
console.debug(
"updateQuota: Trying to update quota for expired record", record);
return null;
}
// If there are visible notifications, don't apply the quota penalty
// for the message.
if (!this._visibleNotifications.has(record.uri.prePath)) {
record.reduceQuota();
}
return record;
}).then(record => {
if (record && record.isExpired()) {
this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_EXPIRED);
// Drop the registration in the background. If the user returns to the
// site, the service worker will be notified on the next `idle-daily`
// event.
this._backgroundUnregister(record);
}
if (this._updateQuotaTestCallback) {
// Callback so that test may be notified when the quota update is complete.
this._updateQuotaTestCallback();
}
}).catch(error => {
console.debug("updateQuota: Error while trying to update quota", error);
});
},
_notificationForOriginShown(origin) {
console.debug("notificationForOriginShown()", origin);
let count;
if (this._visibleNotifications.has(origin)) {
count = this._visibleNotifications.get(origin);
} else {
count = 0;
}
this._visibleNotifications.set(origin, count + 1);
},
_notificationForOriginClosed(origin) {
console.debug("notificationForOriginClosed()", origin);
let count;
if (this._visibleNotifications.has(origin)) {
count = this._visibleNotifications.get(origin);
} else {
console.debug("notificationForOriginClosed: closing notification that has not been shown?");
return;
}
if (count > 1) {
this._visibleNotifications.set(origin, count - 1);
} else {
this._visibleNotifications.delete(origin);
}
},
_notifyApp: function(aPushRecord, message) {
if (!aPushRecord || !aPushRecord.scope ||
aPushRecord.originAttributes === undefined) {
@ -1055,6 +1119,20 @@ this.PushService = {
this._childListeners.splice(i, 1);
}
}
console.debug("receiveMessage: Clearing notifications from child");
this._visibleNotifications.clear();
return;
}
if (aMessage.name === "Push:NotificationForOriginShown") {
console.debug("receiveMessage: Notification shown from child");
this._notificationForOriginShown(aMessage.data);
return;
}
if (aMessage.name === "Push:NotificationForOriginClosed") {
console.debug("receiveMessage: Notification closed from child");
this._notificationForOriginClosed(aMessage.data);
return;
}

View File

@ -222,6 +222,7 @@ function setPrefs(prefs = {}) {
'http2.retryInterval': 500,
'http2.reset_retry_count_after_ms': 60000,
maxQuotaPerSubscription: 16,
quotaUpdateDelay: 3000,
}, prefs);
for (let pref in defaultPrefs) {
servicePrefs.set(pref, defaultPrefs[pref]);

View File

@ -0,0 +1,115 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
const {PushDB, PushService, PushServiceWebSocket} = serviceExports;
Cu.import("resource://gre/modules/Task.jsm");
const userAgentID = 'aaabf1f8-2f68-44f1-a920-b88e9e7d7559';
const nsIPushQuotaManager = Components.interfaces.nsIPushQuotaManager;
function run_test() {
do_get_profile();
setPrefs({
userAgentID,
});
run_next_test();
}
add_task(function* test_expiration_origin_threshold() {
let db = PushServiceWebSocket.newPushDB();
do_register_cleanup(() => {
db.drop().then(_ => db.close())
PushService._notificationForOriginClosed("https://example.com");
});
// Simulate a notification being shown for the origin,
// this should relax the quota and allow as many push messages
// as we want.
PushService._notificationForOriginShown("https://example.com");
yield db.put({
channelID: 'f56645a9-1f32-4655-92ad-ddc37f6d54fb',
pushEndpoint: 'https://example.org/push/1',
scope: 'https://example.com/quota',
pushCount: 0,
lastPush: 0,
version: null,
originAttributes: '',
quota: 16,
});
// A visit one day ago should provide a quota of 8 messages.
yield addVisit({
uri: 'https://example.com/login',
title: 'Sign in to see your auctions',
visits: [{
visitDate: (Date.now() - 1 * 24 * 60 * 60 * 1000) * 1000,
transitionType: Ci.nsINavHistoryService.TRANSITION_LINK,
}],
});
let numMessages = 10;
let updates = 0;
let notifyPromise = promiseObserverNotification('push-notification', (subject, data) => {
dump(updates++);
return updates == numMessages;
});
let updateQuotaPromise = new Promise((resolve, reject) => {
let quotaUpdateCount = 0;
PushService._updateQuotaTestCallback = function() {
quotaUpdateCount++;
if (quotaUpdateCount == 10) {
resolve();
}
};
});
PushService.init({
serverURI: 'wss://push.example.org/',
networkInfo: new MockDesktopNetworkInfo(),
db,
makeWebSocket(uri) {
return new MockWebSocket(uri, {
onHello(request) {
this.serverSendMsg(JSON.stringify({
messageType: 'hello',
status: 200,
uaid: userAgentID,
}));
// If the origin has visible notifications, the
// message should not affect quota.
for (let version = 1; version <= 10; version++) {
this.serverSendMsg(JSON.stringify({
messageType: 'notification',
updates: [{
channelID: 'f56645a9-1f32-4655-92ad-ddc37f6d54fb',
version,
}],
}));
}
},
onUnregister(request) {
ok(false, "Channel should not be unregistered.");
},
// We expect to receive acks, but don't care about their
// contents.
onACK(request) {},
});
},
});
yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
'Timed out waiting for notifications');
yield waitForPromise(updateQuotaPromise, DEFAULT_TIMEOUT,
'Timed out waiting for quota to be updated');
let expiredRecord = yield db.getByKeyID('f56645a9-1f32-4655-92ad-ddc37f6d54fb');
notStrictEqual(expiredRecord.quota, 0, 'Expired record not updated');
});

View File

@ -17,6 +17,7 @@ run-sequentially = This will delete all existing push subscriptions.
[test_quota_exceeded.js]
[test_quota_observer.js]
[test_quota_with_notification.js]
[test_register_case.js]
[test_register_flush.js]
[test_register_invalid_channel.js]

View File

@ -53,7 +53,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsIServiceManager.h"
#include "mozilla/css/StyleRule.h"
#include "nsIStyleSheet.h"
#include "nsIURL.h"
#include "nsViewManager.h"
#include "nsIWidget.h"

View File

@ -19,10 +19,8 @@
using namespace mozilla;
class nsIStyleSheet;
static void
AddStyleSheet(nsIEditor* aEditor, nsIStyleSheet* aSheet)
AddStyleSheet(nsIEditor* aEditor, CSSStyleSheet* aSheet)
{
nsCOMPtr<nsIDOMDocument> domDoc;
aEditor->GetDocument(getter_AddRefs(domDoc));
@ -35,7 +33,7 @@ AddStyleSheet(nsIEditor* aEditor, nsIStyleSheet* aSheet)
}
static void
RemoveStyleSheet(nsIEditor *aEditor, nsIStyleSheet *aSheet)
RemoveStyleSheet(nsIEditor* aEditor, CSSStyleSheet* aSheet)
{
nsCOMPtr<nsIDOMDocument> domDoc;
aEditor->GetDocument(getter_AddRefs(domDoc));

View File

@ -16,7 +16,6 @@
#include "nsIOutputStream.h"
#include "nsIInputStream.h"
#include "nsIChannel.h"
#include "nsIStyleSheet.h"
#include "nsIDocumentEncoder.h"
#include "nsITransport.h"
#include "nsIProgressEventSink.h"

View File

@ -684,7 +684,7 @@ GLBlitHelper::BlitGrallocImage(layers::GrallocImage* grallocImage)
bool
GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
{
AndroidSurfaceTexture* surfaceTexture = stImage->GetData()->mSurfTex;
AndroidSurfaceTexture* surfaceTexture = stImage->GetSurfaceTexture();
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
@ -713,8 +713,8 @@ GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
bool
GLBlitHelper::BlitEGLImageImage(layers::EGLImageImage* image)
{
EGLImage eglImage = image->GetData()->mImage;
EGLSync eglSync = image->GetData()->mSync;
EGLImage eglImage = image->GetImage();
EGLSync eglSync = image->GetSync();
if (eglSync) {
EGLint status = sEGLLibrary.fClientWaitSync(EGL_DISPLAY(), eglSync, 0, LOCAL_EGL_FOREVER);
@ -841,13 +841,12 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
#ifdef MOZ_WIDGET_ANDROID
case ImageFormat::SURFACE_TEXTURE:
type = ConvertSurfaceTexture;
srcOrigin = static_cast<layers::SurfaceTextureImage*>(srcImage)->GetData()
->mOriginPos;
srcOrigin = srcImage->AsSurfaceTextureImage()->GetOriginPos();
break;
case ImageFormat::EGLIMAGE:
type = ConvertEGLImage;
srcOrigin = static_cast<layers::EGLImageImage*>(srcImage)->GetData()->mOriginPos;
srcOrigin = srcImage->AsEGLImageImage()->GetOriginPos();
break;
#endif
#ifdef XP_MACOSX
@ -893,7 +892,7 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
#ifdef XP_MACOSX
case ConvertMacIOSurfaceImage:
return BlitMacIOSurfaceImage(static_cast<layers::MacIOSurfaceImage*>(srcImage));
return BlitMacIOSurfaceImage(srcImage->AsMacIOSurfaceImage());
#endif
default:

View File

@ -16,20 +16,19 @@
namespace mozilla {
namespace layers {
HRESULT
D3D11ShareHandleImage::SetData(const Data& aData)
D3D11ShareHandleImage::D3D11ShareHandleImage(const gfx::IntSize& aSize,
const gfx::IntRect& aRect)
: Image(nullptr, ImageFormat::D3D11_SHARE_HANDLE_TEXTURE),
mSize(aSize),
mPictureRect(aRect)
{
mPictureRect = aData.mRegion;
mSize = aData.mSize;
}
mTextureClient =
aData.mAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8,
mSize);
if (!mTextureClient) {
return E_FAIL;
}
return S_OK;
bool
D3D11ShareHandleImage::AllocateTexture(D3D11RecycleAllocator* aAllocator)
{
mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
return !!mTextureClient;
}
gfx::IntSize

View File

@ -45,40 +45,22 @@ protected:
// passed into SetData(), so that it can be accessed from other D3D devices.
// This class also manages the synchronization of the copy, to ensure the
// resource is ready to use.
class D3D11ShareHandleImage : public Image {
class D3D11ShareHandleImage final : public Image {
public:
D3D11ShareHandleImage(const gfx::IntSize& aSize,
const gfx::IntRect& aRect);
~D3D11ShareHandleImage() override {}
struct Data {
Data(D3D11RecycleAllocator* aAllocator,
const gfx::IntSize& aSize,
const gfx::IntRect& aRegion)
: mAllocator(aAllocator)
, mSize(aSize)
, mRegion(aRegion) {}
RefPtr<D3D11RecycleAllocator> mAllocator;
gfx::IntSize mSize;
gfx::IntRect mRegion;
};
D3D11ShareHandleImage() : Image(NULL, ImageFormat::D3D11_SHARE_HANDLE_TEXTURE), mSize(0, 0) {}
virtual ~D3D11ShareHandleImage() {}
// Copies the surface into a sharable texture's surface, and initializes
// the image.
HRESULT SetData(const Data& aData);
bool AllocateTexture(D3D11RecycleAllocator* aAllocator);
gfx::IntSize GetSize() override;
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;
virtual gfx::IntRect GetPictureRect() override { return mPictureRect; }
ID3D11Texture2D* GetTexture() const;
virtual gfx::IntRect GetPictureRect() override { return mPictureRect; }
private:
gfx::IntSize mSize;
gfx::IntRect mPictureRect;
RefPtr<TextureClientD3D11> mTextureClient;

View File

@ -15,11 +15,11 @@ namespace mozilla {
namespace layers {
D3D9SurfaceImage::D3D9SurfaceImage()
D3D9SurfaceImage::D3D9SurfaceImage(bool aIsFirstFrame)
: Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE)
, mSize(0, 0)
, mValid(false)
, mIsFirstFrame(false)
, mIsFirstFrame(aIsFirstFrame)
{}
D3D9SurfaceImage::~D3D9SurfaceImage()
@ -27,11 +27,13 @@ D3D9SurfaceImage::~D3D9SurfaceImage()
}
HRESULT
D3D9SurfaceImage::SetData(const Data& aData)
D3D9SurfaceImage::AllocateAndCopy(D3D9RecycleAllocator* aAllocator,
IDirect3DSurface9* aSurface,
const gfx::IntRect& aRegion)
{
NS_ENSURE_TRUE(aData.mSurface, E_POINTER);
NS_ENSURE_TRUE(aSurface, E_POINTER);
HRESULT hr;
RefPtr<IDirect3DSurface9> surface = aData.mSurface;
RefPtr<IDirect3DSurface9> surface = aSurface;
RefPtr<IDirect3DDevice9> device;
hr = surface->GetDevice(getter_AddRefs(device));
@ -54,10 +56,8 @@ D3D9SurfaceImage::SetData(const Data& aData)
// DXVA surfaces aren't created sharable, so we need to copy the surface
// to a sharable texture to that it's accessible to the layer manager's
// device.
const gfx::IntRect& region = aData.mRegion;
RefPtr<SharedTextureClientD3D9> textureClient =
aData.mAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8X8,
region.Size());
aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8X8, aRegion.Size());
if (!textureClient) {
return E_FAIL;
}
@ -68,7 +68,7 @@ D3D9SurfaceImage::SetData(const Data& aData)
return E_FAIL;
}
RECT src = { region.x, region.y, region.x+region.width, region.y+region.height };
RECT src = { aRegion.x, aRegion.y, aRegion.x+aRegion.width, aRegion.y+aRegion.height };
hr = device->StretchRect(surface, &src, textureSurface, nullptr, D3DTEXF_NONE);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
@ -82,10 +82,8 @@ D3D9SurfaceImage::SetData(const Data& aData)
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
mTextureClient = textureClient;
mSize = region.Size();
mSize = aRegion.Size();
mQuery = query;
mIsFirstFrame = aData.mIsFirstFrame;
return S_OK;
}

View File

@ -47,30 +47,12 @@ protected:
// resource is ready to use.
class D3D9SurfaceImage : public Image {
public:
struct Data {
Data(IDirect3DSurface9* aSurface,
const gfx::IntRect& aRegion,
D3D9RecycleAllocator* aAllocator,
bool aIsFirstFrame)
: mSurface(aSurface)
, mRegion(aRegion)
, mAllocator(aAllocator)
, mIsFirstFrame(aIsFirstFrame)
{}
RefPtr<IDirect3DSurface9> mSurface;
gfx::IntRect mRegion;
RefPtr<D3D9RecycleAllocator> mAllocator;
bool mIsFirstFrame;
};
D3D9SurfaceImage();
explicit D3D9SurfaceImage(bool aIsFirstFrame);
virtual ~D3D9SurfaceImage();
// Copies the surface into a sharable texture's surface, and initializes
// the image.
HRESULT SetData(const Data& aData);
HRESULT AllocateAndCopy(D3D9RecycleAllocator* aAllocator,
IDirect3DSurface9* aSurface,
const gfx::IntRect& aRegion);
// Returns the description of the shared surface.
const D3DSURFACE_DESC& GetDesc() const;

View File

@ -16,20 +16,32 @@ namespace layers {
static RefPtr<GLContext> sSnapshotContext;
EGLImageImage::EGLImageImage(EGLImage aImage, EGLSync aSync,
const gfx::IntSize& aSize, const gl::OriginPos& aOrigin,
bool aOwns)
: GLImage(ImageFormat::EGLIMAGE),
mImage(aImage),
mSync(aSync),
mSize(aSize),
mPos(aOrigin),
mOwns(aOwns)
{
}
EGLImageImage::~EGLImageImage()
{
if (!mData.mOwns) {
if (!mOwns) {
return;
}
if (mData.mImage) {
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), mData.mImage);
mData.mImage = nullptr;
if (mImage) {
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), mImage);
mImage = nullptr;
}
if (mData.mSync) {
sEGLLibrary.fDestroySync(EGL_DISPLAY(), mData.mSync);
mData.mSync = nullptr;
if (mSync) {
sEGLLibrary.fDestroySync(EGL_DISPLAY(), mSync);
mSync = nullptr;
}
}
@ -82,5 +94,17 @@ GLImage::GetAsSourceSurface()
return source.forget();
}
#ifdef MOZ_WIDGET_ANDROID
SurfaceTextureImage::SurfaceTextureImage(gl::AndroidSurfaceTexture* aSurfTex,
const gfx::IntSize& aSize,
gl::OriginPos aOriginPos)
: GLImage(ImageFormat::SURFACE_TEXTURE),
mSurfaceTexture(aSurfTex),
mSize(aSize),
mOriginPos(aOriginPos)
{
}
#endif
} // namespace layers
} // namespace mozilla

View File

@ -28,52 +28,60 @@ public:
class EGLImageImage : public GLImage {
public:
struct Data {
EGLImage mImage;
EGLSync mSync;
gfx::IntSize mSize;
gl::OriginPos mOriginPos;
bool mOwns;
EGLImageImage(EGLImage aImage, EGLSync aSync,
const gfx::IntSize& aSize, const gl::OriginPos& aOrigin,
bool aOwns);
Data() : mImage(nullptr), mSync(nullptr), mSize(0, 0),
mOriginPos(gl::OriginPos::TopLeft), mOwns(false)
{
}
};
gfx::IntSize GetSize() override { return mSize; }
gl::OriginPos GetOriginPos() const {
return mPos;
}
EGLImage GetImage() const {
return mImage;
}
EGLSync GetSync() const {
return mSync;
}
void SetData(const Data& aData) { mData = aData; }
const Data* GetData() { return &mData; }
gfx::IntSize GetSize() { return mData.mSize; }
EGLImageImage() : GLImage(ImageFormat::EGLIMAGE) {}
EGLImageImage* AsEGLImageImage() override {
return this;
}
protected:
virtual ~EGLImageImage();
private:
Data mData;
EGLImage mImage;
EGLSync mSync;
gfx::IntSize mSize;
gl::OriginPos mPos;
bool mOwns;
};
#ifdef MOZ_WIDGET_ANDROID
class SurfaceTextureImage : public GLImage {
public:
struct Data {
mozilla::gl::AndroidSurfaceTexture* mSurfTex;
gfx::IntSize mSize;
gl::OriginPos mOriginPos;
};
SurfaceTextureImage(gl::AndroidSurfaceTexture* aSurfTex,
const gfx::IntSize& aSize,
gl::OriginPos aOriginPos);
void SetData(const Data& aData) { mData = aData; }
const Data* GetData() { return &mData; }
gfx::IntSize GetSize() override { return mSize; }
gl::AndroidSurfaceTexture* GetSurfaceTexture() const {
return mSurfaceTexture;
}
gl::OriginPos GetOriginPos() const {
return mOriginPos;
}
gfx::IntSize GetSize() { return mData.mSize; }
SurfaceTextureImage() : GLImage(ImageFormat::SURFACE_TEXTURE) {}
SurfaceTextureImage* AsSurfaceTextureImage() override {
return this;
}
private:
Data mData;
gl::AndroidSurfaceTexture* mSurfaceTexture;
gfx::IntSize mSize;
gl::OriginPos mOriginPos;
};
#endif // MOZ_WIDGET_ANDROID

View File

@ -147,11 +147,12 @@ GrallocImage::SetData(const Data& aData)
return true;
}
bool GrallocImage::SetData(const GrallocData& aData)
void
GrallocImage::SetData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize)
{
mTextureClient = static_cast<GrallocTextureClientOGL*>(aData.mGraphicBuffer.get());
mSize = aData.mPicSize;
return true;
MOZ_ASSERT(aGraphicBuffer->AsGrallocTextureClientOGL());
mTextureClient = aGraphicBuffer->AsGrallocTextureClientOGL();
mSize = aSize;
}
/**

View File

@ -53,11 +53,6 @@ class GrallocImage : public RecyclingPlanarYCbCrImage
typedef PlanarYCbCrData Data;
static int32_t sColorIdMap[];
public:
struct GrallocData {
RefPtr<TextureClient> mGraphicBuffer;
gfx::IntSize mPicSize;
};
GrallocImage();
virtual ~GrallocImage();
@ -72,7 +67,7 @@ public:
* Share the SurfaceDescriptor without making the copy, in order
* to support functioning in all different layer managers.
*/
virtual bool SetData(const GrallocData& aData);
void SetData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize);
// From [android 4.0.4]/hardware/msm7k/libgralloc-qsd8k/gralloc_priv.h
enum {

View File

@ -17,6 +17,8 @@
#include "mozilla/layers/PImageContainerChild.h"
#include "mozilla/layers/ImageClient.h" // for ImageClient
#include "mozilla/layers/LayersMessages.h"
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
#include "mozilla/layers/SharedRGBImage.h"
#include "nsISupportsUtils.h" // for NS_IF_ADDREF
#include "YCbCrUtils.h" // for YCbCr conversions
#ifdef MOZ_WIDGET_GONK
@ -30,14 +32,11 @@
#ifdef XP_MACOSX
#include "mozilla/gfx/QuartzSupport.h"
#include "MacIOSurfaceImage.h"
#endif
#ifdef XP_WIN
#include "gfxWindowsPlatform.h"
#include <d3d10_1.h>
#include "D3D9SurfaceImage.h"
#include "D3D11ShareHandleImage.h"
#endif
namespace mozilla {
@ -51,63 +50,10 @@ Atomic<int32_t> Image::sSerialCounter(0);
Atomic<uint32_t> ImageContainer::sGenerationCounter(0);
already_AddRefed<Image>
ImageFactory::CreateImage(ImageFormat aFormat,
const gfx::IntSize &,
BufferRecycleBin *aRecycleBin)
RefPtr<PlanarYCbCrImage>
ImageFactory::CreatePlanarYCbCrImage(const gfx::IntSize& aScaleHint, BufferRecycleBin *aRecycleBin)
{
RefPtr<Image> img;
#ifdef MOZ_WIDGET_GONK
if (aFormat == ImageFormat::GRALLOC_PLANAR_YCBCR) {
img = new GrallocImage();
return img.forget();
}
if (aFormat == ImageFormat::OVERLAY_IMAGE) {
img = new OverlayImage();
return img.forget();
}
#endif
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_CAMERA) && defined(MOZ_WEBRTC)
if (aFormat == ImageFormat::GONK_CAMERA_IMAGE) {
img = new GonkCameraImage();
return img.forget();
}
#endif
if (aFormat == ImageFormat::PLANAR_YCBCR) {
img = new RecyclingPlanarYCbCrImage(aRecycleBin);
return img.forget();
}
if (aFormat == ImageFormat::CAIRO_SURFACE) {
img = new CairoImage();
return img.forget();
}
#ifdef MOZ_WIDGET_ANDROID
if (aFormat == ImageFormat::SURFACE_TEXTURE) {
img = new SurfaceTextureImage();
return img.forget();
}
#endif
if (aFormat == ImageFormat::EGLIMAGE) {
img = new EGLImageImage();
return img.forget();
}
#ifdef XP_MACOSX
if (aFormat == ImageFormat::MAC_IOSURFACE) {
img = new MacIOSurfaceImage();
return img.forget();
}
#endif
#ifdef XP_WIN
if (aFormat == ImageFormat::D3D11_SHARE_HANDLE_TEXTURE) {
img = new D3D11ShareHandleImage();
return img.forget();
}
if (aFormat == ImageFormat::D3D9_RGB32_TEXTURE) {
img = new D3D9SurfaceImage();
return img.forget();
}
#endif
return nullptr;
return new RecyclingPlanarYCbCrImage(aRecycleBin);
}
BufferRecycleBin::BufferRecycleBin()
@ -208,31 +154,42 @@ ImageContainer::~ImageContainer()
}
}
already_AddRefed<Image>
ImageContainer::CreateImage(ImageFormat aFormat)
RefPtr<PlanarYCbCrImage>
ImageContainer::CreatePlanarYCbCrImage()
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mImageClient && mImageClient->AsImageClientSingle()) {
return new SharedPlanarYCbCrImage(mImageClient);
}
return mImageFactory->CreatePlanarYCbCrImage(mScaleHint, mRecycleBin);
}
RefPtr<SharedRGBImage>
ImageContainer::CreateSharedRGBImage()
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mImageClient || !mImageClient->AsImageClientSingle()) {
return nullptr;
}
return new SharedRGBImage(mImageClient);
}
#ifdef MOZ_WIDGET_GONK
if (aFormat == ImageFormat::OVERLAY_IMAGE) {
if (mImageClient && mImageClient->GetTextureInfo().mCompositableType != CompositableType::IMAGE_OVERLAY) {
// If this ImageContainer is async but the image type mismatch, fix it here
if (ImageBridgeChild::IsCreated()) {
ImageBridgeChild::DispatchReleaseImageClient(mImageClient);
mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(
CompositableType::IMAGE_OVERLAY, this).take();
}
RefPtr<OverlayImage>
ImageContainer::CreateOverlayImage()
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mImageClient && mImageClient->GetTextureInfo().mCompositableType != CompositableType::IMAGE_OVERLAY) {
// If this ImageContainer is async but the image type mismatch, fix it here
if (ImageBridgeChild::IsCreated()) {
ImageBridgeChild::DispatchReleaseImageClient(mImageClient);
mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(
CompositableType::IMAGE_OVERLAY, this).take();
}
}
#endif
if (mImageClient) {
RefPtr<Image> img = mImageClient->CreateImage(aFormat);
if (img) {
return img.forget();
}
}
return mImageFactory->CreateImage(aFormat, mScaleHint, mRecycleBin);
return new OverlayImage();
}
#endif
void
ImageContainer::SetCurrentImageInternal(const nsTArray<NonOwningImage>& aImages)
@ -592,8 +549,10 @@ PlanarYCbCrImage::GetAsSourceSurface()
return surface.forget();
}
CairoImage::CairoImage()
: Image(nullptr, ImageFormat::CAIRO_SURFACE)
CairoImage::CairoImage(const gfx::IntSize& aSize, gfx::SourceSurface* aSourceSurface)
: Image(nullptr, ImageFormat::CAIRO_SURFACE),
mSize(aSize),
mSourceSurface(aSourceSurface)
{}
CairoImage::~CairoImage()

View File

@ -103,6 +103,7 @@ class ImageCompositeNotification;
class ImageContainerChild;
class PImageContainerChild;
class SharedPlanarYCbCrImage;
class PlanarYCbCrImage;
class TextureClient;
class CompositableClient;
class GrallocImage;
@ -115,6 +116,17 @@ protected:
ImageBackendData() {}
};
/* Forward declarations for Image derivatives. */
class EGLImageImage;
class SharedRGBImage;
#ifdef MOZ_WIDGET_ANDROID
class SurfaceTextureImage;
#elif defined(XP_MACOSX)
class MacIOSurfaceImage;
#elif defined(MOZ_WIDGET_GONK)
class OverlayImage;
#endif
/**
* A class representing a buffer of pixel data. The data can be in one
* of various formats including YCbCr.
@ -161,11 +173,21 @@ public:
virtual uint8_t* GetBuffer() { return nullptr; }
/**
* For use with the CompositableClient only (so that the later can
* synchronize the TextureClient with the TextureHost).
*/
* For use with the CompositableClient only (so that the later can
* synchronize the TextureClient with the TextureHost).
*/
virtual TextureClient* GetTextureClient(CompositableClient* aClient) { return nullptr; }
/* Access to derived classes. */
virtual EGLImageImage* AsEGLImageImage() { return nullptr; }
#ifdef MOZ_WIDGET_ANDROID
virtual SurfaceTextureImage* AsSurfaceTextureImage() { return nullptr; }
#endif
#ifdef XP_MACOSX
virtual MacIOSurfaceImage* AsMacIOSurfaceImage() { return nullptr; }
#endif
virtual PlanarYCbCrImage* AsPlanarYCbCrImage() { return nullptr; }
protected:
Image(void* aImplData, ImageFormat aFormat) :
mImplData(aImplData),
@ -252,10 +274,9 @@ protected:
ImageFactory() {}
virtual ~ImageFactory() {}
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat,
const gfx::IntSize &aScaleHint,
BufferRecycleBin *aRecycleBin);
virtual RefPtr<PlanarYCbCrImage> CreatePlanarYCbCrImage(
const gfx::IntSize& aScaleHint,
BufferRecycleBin *aRecycleBin);
};
/**
@ -292,16 +313,14 @@ public:
typedef uint32_t FrameID;
typedef uint32_t ProducerID;
RefPtr<PlanarYCbCrImage> CreatePlanarYCbCrImage();
/**
* Create an Image in one of the given formats.
* Picks the "best" format from the list and creates an Image of that
* format.
* Returns null if this backend does not support any of the formats.
* Can be called on any thread. This method takes mReentrantMonitor
* when accessing thread-shared state.
*/
B2G_ACL_EXPORT already_AddRefed<Image> CreateImage(ImageFormat aFormat);
// Factory methods for shared image types.
RefPtr<SharedRGBImage> CreateSharedRGBImage();
#ifdef MOZ_WIDGET_GONK
RefPtr<OverlayImage> CreateOverlayImage();
#endif
struct NonOwningImage {
explicit NonOwningImage(Image* aImage = nullptr,
@ -704,6 +723,8 @@ public:
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const = 0;
PlanarYCbCrImage* AsPlanarYCbCrImage() { return this; }
protected:
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface();
@ -748,22 +769,6 @@ protected:
*/
class CairoImage final : public Image {
public:
struct Data {
gfx::IntSize mSize;
RefPtr<gfx::SourceSurface> mSourceSurface;
};
/**
* This can only be called on the main thread. It may add a reference
* to the surface (which will eventually be released on the main thread).
* The surface must not be modified after this call!!!
*/
void SetData(const Data& aData)
{
mSize = aData.mSize;
mSourceSurface = aData.mSourceSurface;
}
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override
{
RefPtr<gfx::SourceSurface> surface(mSourceSurface);
@ -774,11 +779,11 @@ public:
virtual gfx::IntSize GetSize() override { return mSize; }
CairoImage();
CairoImage(const gfx::IntSize& aSize, gfx::SourceSurface* aSourceSurface);
~CairoImage();
private:
gfx::IntSize mSize;
nsCountedRef<nsMainThreadSourceSurfaceRef> mSourceSurface;
nsDataHashtable<nsUint32HashKey, RefPtr<TextureClient> > mTextureClients;
};

View File

@ -17,7 +17,11 @@ namespace layers {
class MacIOSurfaceImage : public Image {
public:
void SetSurface(MacIOSurface* aSurface) { mSurface = aSurface; }
explicit MacIOSurfaceImage(MacIOSurface* aSurface)
: Image(nullptr, ImageFormat::MAC_IOSURFACE),
mSurface(aSurface)
{}
MacIOSurface* GetSurface() { return mSurface; }
gfx::IntSize GetSize() override {
@ -28,7 +32,9 @@ public:
virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;
MacIOSurfaceImage() : Image(nullptr, ImageFormat::MAC_IOSURFACE) {}
virtual MacIOSurfaceImage* AsMacIOSurfaceImage() override {
return this;
}
private:
RefPtr<MacIOSurface> mSurface;

View File

@ -78,17 +78,10 @@ class BasicImageFactory : public ImageFactory
public:
BasicImageFactory() {}
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat,
const gfx::IntSize &aScaleHint,
BufferRecycleBin *aRecycleBin)
virtual RefPtr<PlanarYCbCrImage>
CreatePlanarYCbCrImage(const gfx::IntSize& aScaleHint, BufferRecycleBin* aRecycleBin)
{
RefPtr<Image> image;
if (aFormat == ImageFormat::PLANAR_YCBCR) {
image = new BasicPlanarYCbCrImage(aScaleHint, gfxPlatform::GetPlatform()->GetOffscreenFormat(), aRecycleBin);
return image.forget();
}
return ImageFactory::CreateImage(aFormat, aScaleHint, aRecycleBin);
return new BasicPlanarYCbCrImage(aScaleHint, gfxPlatform::GetPlatform()->GetOffscreenFormat(), aRecycleBin);
}
};

View File

@ -111,16 +111,18 @@ BasicLayerManager::PushGroupForLayer(gfxContext* aContext, Layer* aLayer, const
IntRect surfRect;
ToRect(rect).ToIntRect(&surfRect);
RefPtr<DrawTarget> dt = aContext->GetDrawTarget()->CreateSimilarDrawTarget(surfRect.Size(), SurfaceFormat::B8G8R8A8);
if (!surfRect.IsEmpty()) {
RefPtr<DrawTarget> dt = aContext->GetDrawTarget()->CreateSimilarDrawTarget(surfRect.Size(), SurfaceFormat::B8G8R8A8);
RefPtr<gfxContext> ctx = new gfxContext(dt, ToRect(rect).TopLeft());
ctx->SetMatrix(oldMat);
RefPtr<gfxContext> ctx = new gfxContext(dt, ToRect(rect).TopLeft());
ctx->SetMatrix(oldMat);
group.mGroupOffset = surfRect.TopLeft();
group.mGroupTarget = ctx;
group.mGroupOffset = surfRect.TopLeft();
group.mGroupTarget = ctx;
group.mMaskSurface = GetMaskForLayer(aLayer, &group.mMaskTransform);
return group;
group.mMaskSurface = GetMaskForLayer(aLayer, &group.mMaskTransform);
return group;
}
}
Matrix maskTransform;

View File

@ -21,8 +21,6 @@
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
#include "mozilla/layers/SharedRGBImage.h"
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
#include "mozilla/layers/TextureClientOGL.h" // for SurfaceTextureClient
#include "mozilla/mozalloc.h" // for operator delete, etc
@ -204,18 +202,17 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
gfx::IntSize size = image->GetSize();
if (image->GetFormat() == ImageFormat::EGLIMAGE) {
EGLImageImage* typedImage = static_cast<EGLImageImage*>(image);
EGLImageImage* typedImage = image->AsEGLImageImage();
texture = new EGLImageTextureClient(GetForwarder(),
mTextureFlags,
typedImage,
size);
#ifdef MOZ_WIDGET_ANDROID
} else if (image->GetFormat() == ImageFormat::SURFACE_TEXTURE) {
SurfaceTextureImage* typedImage = static_cast<SurfaceTextureImage*>(image);
const SurfaceTextureImage::Data* data = typedImage->GetData();
SurfaceTextureImage* typedImage = image->AsSurfaceTextureImage();
texture = new SurfaceTextureClient(GetForwarder(), mTextureFlags,
data->mSurfTex, size,
data->mOriginPos);
typedImage->GetSurfaceTexture(), size,
typedImage->GetOriginPos());
#endif
} else {
MOZ_ASSERT(false, "Bad ImageFormat.");
@ -320,27 +317,6 @@ ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
return true;
}
already_AddRefed<Image>
ImageClientSingle::CreateImage(ImageFormat aFormat)
{
RefPtr<Image> img;
switch (aFormat) {
case ImageFormat::PLANAR_YCBCR:
img = new SharedPlanarYCbCrImage(this);
return img.forget();
case ImageFormat::SHARED_RGB:
img = new SharedRGBImage(this);
return img.forget();
#ifdef MOZ_WIDGET_GONK
case ImageFormat::GRALLOC_PLANAR_YCBCR:
img = new GrallocImage();
return img.forget();
#endif
default:
return nullptr;
}
}
#ifdef MOZ_WIDGET_GONK
ImageClientOverlay::ImageClientOverlay(CompositableForwarder* aFwd,
TextureFlags aFlags)
@ -375,20 +351,6 @@ ImageClientOverlay::UpdateImage(ImageContainer* aContainer, uint32_t aContentFla
}
return true;
}
already_AddRefed<Image>
ImageClientOverlay::CreateImage(ImageFormat aFormat)
{
RefPtr<Image> img;
switch (aFormat) {
case ImageFormat::OVERLAY_IMAGE:
img = new OverlayImage();
return img.forget();
default:
return nullptr;
}
}
#endif
} // namespace layers
} // namespace mozilla

View File

@ -29,6 +29,7 @@ class AsyncTransactionTracker;
class Image;
class ImageContainer;
class ShadowableLayer;
class ImageClientSingle;
/**
* Image clients are used by basic image layers on the content thread, they
@ -56,8 +57,6 @@ public:
*/
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) = 0;
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) = 0;
void SetLayer(ClientLayer* aLayer) { mLayer = aLayer; }
ClientLayer* GetLayer() const { return mLayer; }
@ -72,6 +71,8 @@ public:
void RemoveTextureWithWaiter(TextureClient* aTexture,
AsyncTransactionWaiter* aAsyncTransactionWaiter = nullptr);
virtual ImageClientSingle* AsImageClientSingle() { return nullptr; }
protected:
ImageClient(CompositableForwarder* aFwd, TextureFlags aFlags,
CompositableType aType);
@ -99,10 +100,10 @@ public:
virtual TextureInfo GetTextureInfo() const override;
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) override;
virtual void FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter) override;
ImageClientSingle* AsImageClientSingle() override { return this; }
protected:
struct Buffer {
RefPtr<TextureClient> mTextureClient;
@ -135,12 +136,6 @@ public:
MOZ_ASSERT(!aChild, "ImageClientBridge should not have IPDL actor");
}
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) override
{
NS_WARNING("Should not create an image through an ImageClientBridge");
return nullptr;
}
protected:
uint64_t mAsyncContainerID;
};
@ -160,7 +155,6 @@ public:
TextureFlags aFlags);
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat);
TextureInfo GetTextureInfo() const override
{
return TextureInfo(CompositableType::IMAGE_OVERLAY);

View File

@ -56,6 +56,7 @@ class TextureClientRecycleAllocator;
class TextureClientPool;
#endif
class KeepAlive;
class GrallocTextureClientOGL;
/**
* TextureClient is the abstraction that allows us to share data between the
@ -234,6 +235,7 @@ public:
}
virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; }
virtual GrallocTextureClientOGL* AsGrallocTextureClientOGL() { return nullptr; }
/**
* Locks the shared data, allowing the caller to get access to it.

View File

@ -41,19 +41,16 @@ CreateSharedRGBImage(ImageContainer *aImageContainer,
return nullptr;
}
RefPtr<Image> image = aImageContainer->CreateImage(ImageFormat::SHARED_RGB);
if (!image) {
RefPtr<SharedRGBImage> rgbImage = aImageContainer->CreateSharedRGBImage();
if (!rgbImage) {
NS_WARNING("Failed to create SharedRGBImage");
return nullptr;
}
RefPtr<SharedRGBImage> rgbImage = static_cast<SharedRGBImage*>(image.get());
if (!rgbImage->Allocate(aSize, gfx::ImageFormatToSurfaceFormat(aImageFormat))) {
NS_WARNING("Failed to allocate a shared image");
return nullptr;
}
return image.forget();
return rgbImage.forget();
}
SharedRGBImage::SharedRGBImage(ImageClient* aCompositable)

View File

@ -64,6 +64,10 @@ public:
virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true) override;
GrallocTextureClientOGL* AsGrallocTextureClientOGL() override {
return this;
}
void SetTextureFlags(TextureFlags aFlags) { AddFlags(aFlags); }
gfx::IntSize GetSize() const override { return mSize; }

View File

@ -34,7 +34,7 @@ EGLImageTextureClient::EGLImageTextureClient(ISurfaceAllocator* aAllocator,
AddFlags(TextureFlags::DEALLOCATE_CLIENT);
if (aImage->GetData()->mOriginPos == gl::OriginPos::BottomLeft) {
if (aImage->GetOriginPos() == gl::OriginPos::BottomLeft) {
AddFlags(TextureFlags::ORIGIN_BOTTOM_LEFT);
}
}
@ -45,10 +45,11 @@ EGLImageTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
MOZ_ASSERT(IsValid());
MOZ_ASSERT(IsAllocated());
const EGLImageImage::Data* data = mImage->GetData();
const bool hasAlpha = true;
aOutDescriptor = EGLImageDescriptor((uintptr_t)data->mImage, (uintptr_t)data->mSync,
mSize, hasAlpha);
aOutDescriptor =
EGLImageDescriptor((uintptr_t)mImage->GetImage(),
(uintptr_t)mImage->GetSync(),
mImage->GetSize(), hasAlpha);
return true;
}

View File

@ -310,6 +310,7 @@ private:
DECL_GFX_PREF(Once, "layers.componentalpha.enabled", ComponentAlphaEnabled, bool, true);
#endif
DECL_GFX_PREF(Live, "layers.composer2d.enabled", Composer2DCompositionEnabled, bool, false);
DECL_GFX_PREF(Live, "layers.screen-recording.enabled", ScreenRecordingEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.d3d11.disable-warp", LayersD3D11DisableWARP, bool, false);
DECL_GFX_PREF(Once, "layers.d3d11.force-warp", LayersD3D11ForceWARP, bool, false);
DECL_GFX_PREF(Live, "layers.deaa.enabled", LayersDEAAEnabled, bool, false);

View File

@ -11,8 +11,7 @@
#include "prinrval.h"
#include "nsString.h"
// Declared in imgRequest.cpp.
extern PRLogModuleInfo* GetImgLog();
static mozilla::LazyLogModule gImgLog("imgRequest");
#define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
@ -21,7 +20,7 @@ using mozilla::LogLevel;
class LogScope {
public:
LogScope(PRLogModuleInfo* aLog, void* aFrom, const char* aFunc)
LogScope(mozilla::LogModule* aLog, void* aFrom, const char* aFunc)
: mLog(aLog)
, mFrom(aFrom)
, mFunc(aFunc)
@ -31,7 +30,7 @@ public:
}
/* const char * constructor */
LogScope(PRLogModuleInfo* aLog, void* from, const char* fn,
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
const char* paramName, const char* paramValue)
: mLog(aLog)
, mFrom(from)
@ -43,7 +42,7 @@ public:
}
/* void ptr constructor */
LogScope(PRLogModuleInfo* aLog, void* from, const char* fn,
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
const char* paramName, const void* paramValue)
: mLog(aLog)
, mFrom(from)
@ -55,7 +54,7 @@ public:
}
/* int32_t constructor */
LogScope(PRLogModuleInfo* aLog, void* from, const char* fn,
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
const char* paramName, int32_t paramValue)
: mLog(aLog)
, mFrom(from)
@ -67,7 +66,7 @@ public:
}
/* uint32_t constructor */
LogScope(PRLogModuleInfo* aLog, void* from, const char* fn,
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
const char* paramName, uint32_t paramValue)
: mLog(aLog)
, mFrom(from)
@ -85,20 +84,20 @@ public:
}
private:
PRLogModuleInfo* mLog;
mozilla::LogModule* mLog;
void* mFrom;
const char* mFunc;
};
class LogFunc {
public:
LogFunc(PRLogModuleInfo* aLog, void* from, const char* fn)
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn)
{
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s\n",
GIVE_ME_MS_NOW(), from, fn));
}
LogFunc(PRLogModuleInfo* aLog, void* from, const char* fn,
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
const char* paramName, const char* paramValue)
{
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\")\n",
@ -106,7 +105,7 @@ public:
paramName, paramValue));
}
LogFunc(PRLogModuleInfo* aLog, void* from, const char* fn,
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
const char* paramName, const void* paramValue)
{
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%p\")\n",
@ -115,7 +114,7 @@ public:
}
LogFunc(PRLogModuleInfo* aLog, void* from, const char* fn,
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
const char* paramName, uint32_t paramValue)
{
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\")\n",
@ -128,7 +127,7 @@ public:
class LogMessage {
public:
LogMessage(PRLogModuleInfo* aLog, void* from, const char* fn,
LogMessage(mozilla::LogModule* aLog, void* from, const char* fn,
const char* msg)
{
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s -- %s\n",

View File

@ -157,16 +157,16 @@ ProgressTracker::Notify(IProgressObserver* aObserver)
{
MOZ_ASSERT(NS_IsMainThread());
if (MOZ_LOG_TEST(GetImgLog(), LogLevel::Debug)) {
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
RefPtr<Image> image = GetImage();
if (image && image->GetURI()) {
RefPtr<ImageURL> uri(image->GetURI());
nsAutoCString spec;
uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(GetImgLog(),
LOG_FUNC_WITH_PARAM(gImgLog,
"ProgressTracker::Notify async", "uri", spec.get());
} else {
LOG_FUNC_WITH_PARAM(GetImgLog(),
LOG_FUNC_WITH_PARAM(gImgLog,
"ProgressTracker::Notify async", "uri", "<unknown>");
}
}
@ -226,13 +226,13 @@ ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver)
{
MOZ_ASSERT(NS_IsMainThread());
if (MOZ_LOG_TEST(GetImgLog(), LogLevel::Debug)) {
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
RefPtr<Image> image = GetImage();
nsAutoCString spec;
if (image && image->GetURI()) {
image->GetURI()->GetSpec(spec);
}
LOG_FUNC_WITH_PARAM(GetImgLog(),
LOG_FUNC_WITH_PARAM(gImgLog,
"ProgressTracker::NotifyCurrentState", "uri", spec.get());
}
@ -406,7 +406,7 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver)
if (image && image->GetURI()) {
image->GetURI()->GetSpec(spec);
}
LOG_SCOPE_WITH_PARAM(GetImgLog(),
LOG_SCOPE_WITH_PARAM(gImgLog,
"ProgressTracker::SyncNotify", "uri", spec.get());
nsIntRect rect;

View File

@ -628,17 +628,11 @@ RasterImage::GetCurrentImage(ImageContainer* aContainer, uint32_t aFlags)
return MakePair(drawResult, RefPtr<layers::Image>());
}
CairoImage::Data cairoData;
GetWidth(&cairoData.mSize.width);
GetHeight(&cairoData.mSize.height);
cairoData.mSourceSurface = surface;
RefPtr<layers::Image> image =
aContainer->CreateImage(ImageFormat::CAIRO_SURFACE);
MOZ_ASSERT(image);
static_cast<CairoImage*>(image.get())->SetData(cairoData);
IntSize size;
GetWidth(&size.width);
GetHeight(&size.height);
RefPtr<layers::Image> image = new layers::CairoImage(size, surface);
return MakePair(drawResult, Move(image));
}
@ -1640,7 +1634,7 @@ RasterImage::DoError()
// Invalidate to get rid of any partially-drawn image content.
NotifyProgress(NoProgress, IntRect(0, 0, mSize.width, mSize.height));
MOZ_LOG(GetImgLog(), LogLevel::Error,
MOZ_LOG(gImgLog, LogLevel::Error,
("RasterImage: [this=%p] Error detected for image\n", this));
}

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