merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2016-01-11 12:13:10 +01:00
commit 230a5fbc61
91 changed files with 2148 additions and 1888 deletions

View File

@ -395,7 +395,7 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
if (aImage->GetFormat() == ImageFormat::PLANAR_YCBCR) {
nsTArray<uint8_t> data;
layers::PlanarYCbCrImage* ycbcrImage = static_cast<layers::PlanarYCbCrImage*> (aImage);
gfxImageFormat format = gfxImageFormat::ARGB32;
gfxImageFormat format = SurfaceFormat::A8R8G8B8_UINT32;
uint32_t stride = GetAlignedStride<16>(aSize.width * 4);
size_t length = BufferSizeFromStrideAndHeight(stride, aSize.height);
data.SetCapacity(length);

View File

@ -3096,6 +3096,10 @@ nsDOMWindowUtils::ExitFullscreen()
{
nsCOMPtr<nsIDocument> doc = GetDocument();
NS_ENSURE_STATE(doc);
// Although we would not use the old size if we have already exited
// fullscreen, we still want to cleanup in case we haven't.
nsSize oldSize = OldWindowSize::GetAndRemove(doc->GetWindow());
if (!doc->IsFullScreenDoc()) {
return NS_OK;
}
@ -3104,9 +3108,7 @@ nsDOMWindowUtils::ExitFullscreen()
// set the window dimensions in advance. Since the resize message
// comes after the fullscreen change call, doing so could avoid an
// extra resize reflow after this point.
FullscreenChangePrepare prepare(
GetPresShell(), OldWindowSize::GetAndRemove(doc->GetWindow()));
FullscreenChangePrepare prepare(GetPresShell(), oldSize);
nsIDocument::ExitFullscreenInDocTree(doc);
return NS_OK;
}

View File

@ -5423,7 +5423,7 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w
uint32_t copyWidth = dirtyRect.Width();
uint32_t copyHeight = dirtyRect.Height();
RefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfx::IntSize(copyWidth, copyHeight),
gfxImageFormat::ARGB32,
SurfaceFormat::A8R8G8B8_UINT32,
false);
if (!imgsurf || imgsurf->CairoStatus()) {
return NS_ERROR_FAILURE;

View File

@ -1,8 +1,11 @@
[DEFAULT]
support-files =
bug592641_img.jpg
dummy_page.html
file_bug649778.html
file_bug649778.html^headers^
file_fullscreen-api-keys.html
head.js
[browser_bug592641.js]
[browser_bug649778.js]
@ -14,3 +17,5 @@ support-files =
file_bug1108547-2.html
file_bug1108547-3.html
[browser_DOMDocElementInserted.js]
[browser_fullscreen-api-keys.js]
[browser_fullscreen-contextmenu-esc.js]

View File

@ -0,0 +1,164 @@
"use strict";
/** Test for Bug 545812 **/
// List of key codes which should exit full-screen mode.
const kKeyList = [
{ code: "VK_ESCAPE", suppressed: true},
{ code: "VK_F11", suppressed: false},
];
function frameScript() {
let doc = content.document;
addMessageListener("Test:RequestFullscreen", () => {
doc.body.mozRequestFullScreen();
});
addMessageListener("Test:DispatchUntrustedKeyEvents", msg => {
var evt = new content.CustomEvent("Test:DispatchKeyEvents", {
detail: { code: msg.data }
});
content.dispatchEvent(evt);
});
doc.addEventListener("mozfullscreenchange", () => {
sendAsyncMessage("Test:FullscreenChanged", !!doc.mozFullScreenElement);
});
function keyHandler(evt) {
sendAsyncMessage("Test:KeyReceived", {
type: evt.type,
keyCode: evt.keyCode
});
}
doc.addEventListener("keydown", keyHandler, true);
doc.addEventListener("keyup", keyHandler, true);
doc.addEventListener("keypress", keyHandler, true);
function waitUntilActive() {
if (doc.docShell.isActive && doc.hasFocus()) {
sendAsyncMessage("Test:Activated");
} else {
setTimeout(waitUntilActive, 10);
}
}
waitUntilActive();
}
var gMessageManager;
function listenOneMessage(aMsg, aListener) {
function listener({ data }) {
gMessageManager.removeMessageListener(aMsg, listener);
aListener(data);
}
gMessageManager.addMessageListener(aMsg, listener);
}
function promiseOneMessage(aMsg) {
return new Promise(resolve => listenOneMessage(aMsg, resolve));
}
function captureUnexpectedFullscreenChange() {
ok(false, "Caught an unexpected fullscreen change");
}
function* temporaryRemoveUnexpectedFullscreenChangeCapture(callback) {
gMessageManager.removeMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
yield* callback();
gMessageManager.addMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
}
function captureUnexpectedKeyEvent(type) {
ok(false, `Caught an unexpected ${type} event`);
}
function* temporaryRemoveUnexpectedKeyEventCapture(callback) {
gMessageManager.removeMessageListener(
"Test:KeyReceived", captureUnexpectedKeyEvent);
yield* callback();
gMessageManager.addMessageListener(
"Test:KeyReceived", captureUnexpectedKeyEvent);
}
function* receiveExpectedKeyEvents(keyCode) {
info("Waiting for key events");
let events = ["keydown", "keypress", "keyup"];
while (events.length > 0) {
let evt = yield promiseOneMessage("Test:KeyReceived");
let expected = events.shift();
is(evt.type, expected, `Should receive a ${expected} event`);
is(evt.keyCode, keyCode,
`Should receive the event with key code ${keyCode}`);
}
}
const kPage = "http://example.org/browser/" +
"dom/html/test/file_fullscreen-api-keys.html";
add_task(function* () {
yield pushPrefs(
["full-screen-api.transition-duration.enter", "0 0"],
["full-screen-api.transition-duration.leave", "0 0"]);
let tab = gBrowser.addTab(kPage);
let browser = tab.linkedBrowser;
gBrowser.selectedTab = tab;
registerCleanupFunction(() => gBrowser.removeTab(tab));
yield waitForDocLoadComplete();
gMessageManager = browser.messageManager;
gMessageManager.loadFrameScript(
"data:,(" + frameScript.toString() + ")();", false);
// Wait for the document being actived, so that
// fullscreen request won't be denied.
yield promiseOneMessage("Test:Activated");
// Register listener to capture unexpected events
gMessageManager.addMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
gMessageManager.addMessageListener(
"Test:KeyReceived", captureUnexpectedKeyEvent);
registerCleanupFunction(() => {
gMessageManager.removeMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
gMessageManager.removeMessageListener(
"Test:KeyReceived", captureUnexpectedKeyEvent);
});
for (let {code, suppressed} of kKeyList) {
var keyCode = KeyEvent["DOM_" + code];
info(`Test keycode ${code} (${keyCode})`);
info("Enter fullscreen");
yield* temporaryRemoveUnexpectedFullscreenChangeCapture(function* () {
gMessageManager.sendAsyncMessage("Test:RequestFullscreen");
let state = yield promiseOneMessage("Test:FullscreenChanged");
ok(state, "The content should have entered fullscreen");
ok(document.mozFullScreenElement,
"The chrome should also be in fullscreen");
});
info("Dispatch untrusted key events from content");
yield* temporaryRemoveUnexpectedKeyEventCapture(function* () {
gMessageManager.sendAsyncMessage("Test:DispatchUntrustedKeyEvents", code);
yield* receiveExpectedKeyEvents(keyCode);
});
info("Send trusted key events");
yield* temporaryRemoveUnexpectedFullscreenChangeCapture(function* () {
yield* temporaryRemoveUnexpectedKeyEventCapture(function* () {
EventUtils.synthesizeKey(code, {});
if (!suppressed) {
yield* receiveExpectedKeyEvents(keyCode);
}
let state = yield promiseOneMessage("Test:FullscreenChanged");
ok(!state, "The content should have exited fullscreen");
ok(!document.mozFullScreenElement,
"The chrome should also have exited fullscreen");
});
});
}
});

View File

@ -0,0 +1,105 @@
"use strict";
function frameScript() {
addMessageListener("Test:RequestFullscreen", () => {
content.document.body.mozRequestFullScreen();
});
content.document.addEventListener("mozfullscreenchange", () => {
sendAsyncMessage("Test:FullscreenChanged", content.document.mozFullScreen);
});
addMessageListener("Test:QueryFullscreenState", () => {
sendAsyncMessage("Test:FullscreenState", content.document.mozFullScreen);
});
function waitUntilActive() {
let doc = content.document;
if (doc.docShell.isActive && doc.hasFocus()) {
sendAsyncMessage("Test:Activated");
} else {
setTimeout(waitUntilActive, 10);
}
}
waitUntilActive();
}
var gMessageManager;
function listenOneMessage(aMsg, aListener) {
function listener({ data }) {
gMessageManager.removeMessageListener(aMsg, listener);
aListener(data);
}
gMessageManager.addMessageListener(aMsg, listener);
}
function promiseOneMessage(aMsg) {
return new Promise(resolve => listenOneMessage(aMsg, resolve));
}
function captureUnexpectedFullscreenChange() {
ok(false, "Caught an unexpected fullscreen change");
}
const kPage = "http://example.org/browser/dom/html/test/dummy_page.html";
add_task(function* () {
yield pushPrefs(
["full-screen-api.transition-duration.enter", "0 0"],
["full-screen-api.transition-duration.leave", "0 0"]);
let tab = gBrowser.addTab(kPage);
registerCleanupFunction(() => gBrowser.removeTab(tab));
let browser = tab.linkedBrowser;
gBrowser.selectedTab = tab;
yield waitForDocLoadComplete();
gMessageManager = browser.messageManager;
gMessageManager.loadFrameScript(
"data:,(" + frameScript.toString() + ")();", false);
// Wait for the document being activated, so that
// fullscreen request won't be denied.
yield promiseOneMessage("Test:Activated");
let contextMenu = document.getElementById("contentAreaContextMenu");
ok(contextMenu, "Got context menu");
let state;
info("Enter DOM fullscreen");
gMessageManager.sendAsyncMessage("Test:RequestFullscreen");
state = yield promiseOneMessage("Test:FullscreenChanged");
ok(state, "The content should have entered fullscreen");
ok(document.mozFullScreen, "The chrome should also be in fullscreen");
gMessageManager.addMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
info("Open context menu");
is(contextMenu.state, "closed", "Should not have opened context menu");
let popupShownPromise = promiseWaitForEvent(window, "popupshown");
EventUtils.synthesizeMouse(browser, screen.width / 2, screen.height / 2,
{type: "contextmenu", button: 2}, window);
yield popupShownPromise;
is(contextMenu.state, "open", "Should have opened context menu");
info("Send the first escape");
let popupHidePromise = promiseWaitForEvent(window, "popuphidden");
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield popupHidePromise;
is(contextMenu.state, "closed", "Should have closed context menu");
// Wait a small time to confirm that the first ESC key
// does not exit fullscreen.
yield new Promise(resolve => setTimeout(resolve, 1000));
gMessageManager.sendAsyncMessage("Test:QueryFullscreenState");
state = yield promiseOneMessage("Test:FullscreenState");
ok(state, "The content should still be in fullscreen");
ok(document.mozFullScreen, "The chrome should still be in fullscreen");
info("Send the second escape");
gMessageManager.removeMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
let fullscreenExitPromise = promiseOneMessage("Test:FullscreenChanged");
EventUtils.synthesizeKey("VK_ESCAPE", {});
state = yield fullscreenExitPromise;
ok(!state, "The content should have exited fullscreen");
ok(!document.mozFullScreen, "The chrome should have exited fullscreen");
});

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dummy test page</title>
<meta charset="utf-8"/>
</head>
<body>
<p>Dummy test page</p>
</body>
</html>

View File

@ -1,129 +1,32 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=545812
Test that restricted key pressed drop documents out of DOM full-screen mode.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test for Bug 545812</title>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="file_fullscreen-utils.js"></script>
<style>
body {
background-color: black;
}
</style>
<meta charset="UTF-8">
</head>
<body>
<script>
window.addEventListener("Test:DispatchKeyEvents", aEvent => {
var keyCode = KeyEvent["DOM_" + aEvent.detail.code];
<script type="application/javascript">
/** Test for Bug 545812 **/
// List of key codes which should exit full-screen mode.
var keyList = [
{ code: "VK_ESCAPE", suppressed: true},
{ code: "VK_F11", suppressed: false},
];
function ok(condition, msg) {
opener.ok(condition, "[keys] " + msg);
}
function is(a, b, msg) {
opener.is(a, b, "[keys] " + msg);
}
var gKeyTestIndex = 0;
var gKeyName;
var gKeyCode;
var gKeySuppressed;
var gKeyReceived = false;
function keyHandler(event) {
gKeyReceived = true;
}
function checkKeyEffect() {
is(gKeySuppressed, !gKeyReceived, "Should not receive key events for " + gKeyName);
is(document.mozFullScreen, false, "Should exit full-screen mode for " + gKeyName + " press");
if (gKeyTestIndex < keyList.length) {
setTimeout(testNextKey, 0);
} else {
opener.nextTest();
}
}
function testTrustedKeyEvents() {
document.body.focus();
gKeyReceived = false;
addFullscreenChangeContinuation("exit", checkKeyEffect);
synthesizeKey(gKeyName, {});
}
function testScriptInitiatedKeyEvents() {
// Script initiated untrusted key events should not cause full-screen exit.
document.body.focus();
gKeyReceived = false;
var evt = document.createEvent("KeyEvents");
evt.initKeyEvent("keydown", true, true, window,
false, false, false, false,
gKeyCode, 0);
keyCode, 0);
document.body.dispatchEvent(evt);
evt = document.createEvent("KeyEvents");
evt.initKeyEvent("keypress", true, true, window,
false, false, false, false,
gKeyCode, 0);
keyCode, 0);
document.body.dispatchEvent(evt);
evt = document.createEvent("KeyEvents");
evt.initKeyEvent("keyup", true, true, window,
false, false, false, false,
gKeyCode, 0);
keyCode, 0);
document.body.dispatchEvent(evt);
ok(gKeyReceived, "dispatchEvent should dispatch events synchronously");
ok(document.mozFullScreen,
"Should remain in full-screen mode for script initiated key events for " + gKeyName);
}
function testNextKey() {
if (!document.mozFullScreen) {
// Async request fullscreen to avoid the request be accidentally
// cancelled due to unfinished clean-up of exiting fullscreen.
setTimeout(() => {
addFullscreenChangeContinuation("enter", reallyTestNextKey);
document.body.mozRequestFullScreen();
}, 0);
}
else {
reallyTestNextKey();
}
}
function reallyTestNextKey() {
ok(document.mozFullScreen, "Must be in full-screen mode");
gKeyName = keyList[gKeyTestIndex].code;
gKeyCode = KeyEvent["DOM_" + gKeyName];
gKeySuppressed = keyList[gKeyTestIndex].suppressed;
gKeyTestIndex++;
testScriptInitiatedKeyEvents();
testTrustedKeyEvents();
}
window.addEventListener("keydown", keyHandler, true);
window.addEventListener("keyup", keyHandler, true);
window.addEventListener("keypress", keyHandler, true);
function begin() {
testNextKey();
}
});
</script>
</pre>
</body>
</html>

View File

@ -1,98 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=910532
Verify that an ESC key press canceling the context menu
won't exit DOM fullscreen.
-->
<head>
<meta charset="UTF-8">
<title>Text for bug 910532</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="file_fullscreen-utils.js"></script>
<style>
body:-moz-full-screen {
background-color: red;
}
</style>
</head>
<body>
<script type="application/javascript">
const Ci = SpecialPowers.Ci;
SimpleTest.requestFlakyTimeout("We need to wait a small time to confirm " +
"that the first ESC key does not exit fullscreen.");
function ok(condition, msg) {
opener.ok(condition, "[esc-context-menu] " + msg);
}
function is(a, b, msg) {
opener.is(a, b, "[esc-context-menu] " + msg);
}
var contextMenu;
var escapeSent = 0;
function sendEscape() {
escapeSent++;
synthesizeKey("VK_ESCAPE", {});
}
function begin() {
// Copy from browser/base/content/test/general/test_contextmenu.html
var chromeWin = SpecialPowers.wrap(window)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow)
.QueryInterface(Ci.nsIDOMChromeWindow);
contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
ok(contextMenu, "Got context menu XUL");
addFullscreenChangeContinuation("enter", fullscreenEntered);
document.body.mozRequestFullScreen();
}
function finish() {
opener.nextTest();
}
function fullscreenEntered(event) {
ok(document.mozFullScreen, "Should have entered fullscreen mode");
is(document.mozFullScreenElement, document.body, "FSE should be doc");
contextMenu.addEventListener("popupshown", contextMenuOpened, false);
is(contextMenu.state, "closed", "Should not have opened context menu");
synthesizeMouseAtCenter(document.body, {type: 'contextmenu', button: 2});
}
function contextMenuOpened(event) {
contextMenu.removeEventListener("popupshown", contextMenuOpened);
is(contextMenu.state, "open", "Should have opened context menu");
addFullscreenChangeContinuation("exit", fullscreenExited);
contextMenu.addEventListener("popuphidden", contextMenuClosed, false);
sendEscape();
}
function contextMenuClosed(event) {
is(contextMenu.state, "closed", "Should have closed context menu");
setTimeout(function () {
ok(document.mozFullScreen, "Should still be in fullscreen mode");
sendEscape();
}, 100);
}
function fullscreenExited(event) {
is(escapeSent, 2, "Only the second escape should exit fullscreen");
ok(!document.mozFullScreen, "Should have left fullscreen mode");
finish();
}
</script>
</body>
</html>

View File

@ -61,6 +61,10 @@ function e(id) {
return document.getElementById(id);
}
function removeElement(e) {
e.parentNode.removeChild(e);
}
const isMacOs = navigator.appVersion.indexOf("Macintosh") != -1;
var windowedPlugin = null;
@ -111,6 +115,10 @@ function nonMacTest2() {
function nonMacTest3() {
ok(!document.mozFullScreen, "Full-screen should have been revoked when windowed-plugin was focused.");
// Remove windowed plugins before closing the window
// to work around bug 1237853.
removeElement(e("windowed-plugin"));
removeElement(e("subdoc-plugin").contentDocument.getElementById("windowed-plugin"));
opener.nextTest();
}

View File

@ -3,16 +3,16 @@
// Note this only returns true once the transition from normal to
// fullscreen mode is complete.
function inFullscreenMode(win) {
return win.outerWidth == win.screen.width &&
win.outerHeight == win.screen.height;
return win.innerWidth == win.screen.width &&
win.innerHeight == win.screen.height;
}
// Returns true if the window is in normal mode, i.e. non fullscreen mode.
// Note this only returns true once the transition from fullscreen back to
// normal mode is complete.
function inNormalMode(win) {
return win.outerWidth == win.normalSize.w &&
win.outerHeight == win.normalSize.h;
return win.innerWidth == win.normalSize.w &&
win.innerHeight == win.normalSize.h;
}
// Adds a listener that will be called once a fullscreen transition
@ -30,8 +30,8 @@ function addFullscreenChangeContinuation(type, callback, inDoc) {
// Remember the window size in non-fullscreen mode.
if (!topWin.normalSize) {
topWin.normalSize = {
w: window.outerWidth,
h: window.outerHeight
w: window.innerWidth,
h: window.innerHeight
};
}
function checkCondition() {

54
dom/html/test/head.js Normal file
View File

@ -0,0 +1,54 @@
function pushPrefs(...aPrefs) {
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
});
}
function promiseWaitForEvent(object, eventName, capturing = false, chrome = false) {
return new Promise((resolve) => {
function listener(event) {
info("Saw " + eventName);
object.removeEventListener(eventName, listener, capturing, chrome);
resolve(event);
}
info("Waiting for " + eventName);
object.addEventListener(eventName, listener, capturing, chrome);
});
}
/**
* Waits for the next load to complete in any browser or the given browser.
* If a <tabbrowser> is given it waits for a load in any of its browsers.
*
* @return promise
*/
function waitForDocLoadComplete(aBrowser=gBrowser) {
return new Promise(resolve => {
let listener = {
onStateChange: function (webProgress, req, flags, status) {
let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK |
Ci.nsIWebProgressListener.STATE_STOP;
info("Saw state " + flags.toString(16) + " and status " + status.toString(16));
// When a load needs to be retargetted to a new process it is cancelled
// with NS_BINDING_ABORTED so ignore that case
if ((flags & docStop) == docStop && status != Cr.NS_BINDING_ABORTED) {
aBrowser.removeProgressListener(this);
waitForDocLoadComplete.listeners.delete(this);
let chan = req.QueryInterface(Ci.nsIChannel);
info("Browser loaded " + chan.originalURI.spec);
resolve();
}
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference])
};
aBrowser.addProgressListener(listener);
waitForDocLoadComplete.listeners.add(listener);
info("Waiting for browser load");
});
}
// Keep a set of progress listeners for waitForDocLoadComplete() to make sure
// they're not GC'ed before we saw the page load.
waitForDocLoadComplete.listeners = new Set();
registerCleanupFunction(() => waitForDocLoadComplete.listeners.clear());

View File

@ -46,11 +46,9 @@ support-files =
file_bug893537.html
file_formSubmission_img.jpg
file_formSubmission_text.txt
file_fullscreen-api-keys.html
file_fullscreen-api.html
file_fullscreen-denied-inner.html
file_fullscreen-denied.html
file_fullscreen-esc-context-menu.html
file_fullscreen-esc-exit-inner.html
file_fullscreen-esc-exit.html
file_fullscreen-hidden.html
@ -466,7 +464,7 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' #TIMED_OUT # b2g(NS_ERROR_FI
skip-if = toolkit == 'android'
[test_formelements.html]
[test_fullscreen-api.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT # b2g(time out, some kind of focus issue) b2g-debug(time out, some kind of focus issue) b2g-desktop(time out, some kind of focus issue)
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' # b2g(time out, some kind of focus issue) b2g-debug(time out, some kind of focus issue) b2g-desktop(time out, some kind of focus issue)
[test_fullscreen-api-race.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' || toolkit == 'cocoa' || e10s # just copy the conditions from the test above
[test_hidden.html]

View File

@ -30,11 +30,9 @@ SimpleTest.requestFlakyTimeout("untriaged");
var gTestWindows = [
"file_fullscreen-multiple.html",
"file_fullscreen-rollback.html",
"file_fullscreen-esc-context-menu.html",
"file_fullscreen-esc-exit.html",
"file_fullscreen-denied.html",
"file_fullscreen-api.html",
"file_fullscreen-api-keys.html",
"file_fullscreen-plugins.html",
"file_fullscreen-hidden.html",
"file_fullscreen-svg-element.html",

View File

@ -337,9 +337,6 @@ MediaDecoderStateMachine::InitializationTask(MediaDecoder* aDecoder)
{
MOZ_ASSERT(OnTaskQueue());
mStreamSink = new DecodedStream(mTaskQueue, mAudioQueue, mVideoQueue,
mOutputStreamManager, mSameOriginMedia.Ref());
// Connect mirrors.
mBuffered.Connect(mReader->CanonicalBuffered());
mEstimatedDuration.Connect(aDecoder->CanonicalEstimatedDuration());
@ -389,11 +386,10 @@ MediaDecoderStateMachine::CreateAudioSink()
already_AddRefed<media::MediaSink>
MediaDecoderStateMachine::CreateMediaSink(bool aAudioCaptured)
{
// TODO: We can't really create a new DecodedStream until OutputStreamManager
// is extracted. It is tricky that the implementation of DecodedStream
// happens to allow reuse after shutdown without creating a new one.
RefPtr<media::MediaSink> audioSink = aAudioCaptured ?
mStreamSink : CreateAudioSink();
RefPtr<media::MediaSink> audioSink = aAudioCaptured
? new DecodedStream(mTaskQueue, mAudioQueue, mVideoQueue,
mOutputStreamManager, mSameOriginMedia.Ref())
: CreateAudioSink();
RefPtr<media::MediaSink> mediaSink =
new VideoSink(mTaskQueue, audioSink, mVideoQueue,

View File

@ -1187,13 +1187,6 @@ private:
// Data about MediaStreams that are being fed by the decoder.
const RefPtr<OutputStreamManager> mOutputStreamManager;
// The SourceMediaStream we are using to feed the mOutputStreams. This stream
// is never exposed outside the decoder.
// Only written on the main thread while holding the monitor. Therefore it
// can be read on any thread while holding the monitor, or on the main thread
// without holding the monitor.
RefPtr<DecodedStream> mStreamSink;
// Media data resource from the decoder.
RefPtr<MediaResource> mResource;

View File

@ -367,7 +367,7 @@ AndroidMediaReader::ImageBufferCallback::operator()(size_t aWidth, size_t aHeigh
case MPAPI::RGB565:
image = mozilla::layers::CreateSharedRGBImage(mImageContainer,
nsIntSize(aWidth, aHeight),
gfxImageFormat::RGB16_565);
SurfaceFormat::R5G6B5_UINT16);
if (!image) {
NS_WARNING("Could not create rgb image");
return nullptr;

View File

@ -244,7 +244,7 @@ MediaEngineTabVideoSource::Draw() {
}
}
gfxImageFormat format = gfxImageFormat::RGB24;
gfxImageFormat format = SurfaceFormat::X8R8G8B8_UINT32;
uint32_t stride = gfxASurface::FormatStrideForWidth(format, size.width);
if (mDataSize < static_cast<size_t>(stride * size.height)) {

View File

@ -2922,7 +2922,7 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
aFrameRect.height != pluginSurface->Height()) {
pluginSurface = new gfxImageSurface(gfx::IntSize(aFrameRect.width, aFrameRect.height),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
if (!pluginSurface)
return;
}

View File

@ -3067,15 +3067,15 @@ PluginInstanceChild::CreateOptSurface(void)
// Use an opaque surface unless we're transparent and *don't* have
// a background to source from.
gfxImageFormat format =
(mIsTransparent && !mBackground) ? gfxImageFormat::ARGB32 :
gfxImageFormat::RGB24;
(mIsTransparent && !mBackground) ? SurfaceFormat::A8R8G8B8_UINT32 :
SurfaceFormat::X8R8G8B8_UINT32;
#ifdef MOZ_X11
Display* dpy = mWsInfo.display;
Screen* screen = DefaultScreenOfDisplay(dpy);
if (format == gfxImageFormat::RGB24 &&
if (format == SurfaceFormat::X8R8G8B8_UINT32 &&
DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
format = gfxImageFormat::RGB16_565;
format = SurfaceFormat::R5G6B5_UINT16;
}
if (mSurfaceType == gfxSurfaceType::Xlib) {
@ -3517,7 +3517,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
gfxImageSurface* surfaceAsImage =
static_cast<gfxImageSurface*>(aSurface);
useSurfaceSubimageForBlack =
(surfaceAsImage->Format() == gfxImageFormat::ARGB32);
(surfaceAsImage->Format() == SurfaceFormat::A8R8G8B8_UINT32);
// If we're going to use a subimage, nudge the rect so that we
// can use optimal alpha recovery. If we're not using a
// subimage, the temporaries should automatically get
@ -3536,7 +3536,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
gfxPoint deviceOffset = -targetRect.TopLeft();
// We always use a temporary "white image"
whiteImage = new gfxImageSurface(targetSize, gfxImageFormat::RGB24);
whiteImage = new gfxImageSurface(targetSize, SurfaceFormat::X8R8G8B8_UINT32);
if (whiteImage->CairoStatus()) {
return;
}
@ -3577,7 +3577,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
blackImage = surface->GetSubimage(targetRect);
} else {
blackImage = new gfxImageSurface(targetSize,
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
}
// Paint onto black background

View File

@ -1214,7 +1214,7 @@ PluginInstanceParent::CreateBackground(const nsIntSize& aSize)
gfxSharedImageSurface::CreateUnsafe(
this,
mozilla::gfx::IntSize(aSize.width, aSize.height),
gfxImageFormat::RGB24);
mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32);
return !!mBackground;
#else
return false;

View File

@ -342,6 +342,9 @@ enum class JobStatus {
} // namespace gfx
} // namespace mozilla
// XXX: temporary
typedef mozilla::gfx::SurfaceFormat gfxImageFormat;
#if defined(XP_WIN) && defined(MOZ_GFX)
#ifdef GFX2D_INTERNAL
#define GFX2D_API __declspec(dllexport)

View File

@ -58,10 +58,10 @@ public:
/**
* Read the image data contained in aTexture, and return it as an ImageSurface.
* If GL_RGBA is given as the format, a gfxImageFormat::ARGB32 surface is returned.
* If GL_RGBA is given as the format, a SurfaceFormat::A8R8G8B8_UINT32 surface is returned.
* Not implemented yet:
* If GL_RGB is given as the format, a gfxImageFormat::RGB24 surface is returned.
* If GL_LUMINANCE is given as the format, a gfxImageFormat::A8 surface is returned.
* If GL_RGB is given as the format, a SurfaceFormat::X8R8G8B8_UINT32 surface is returned.
* If GL_LUMINANCE is given as the format, a SurfaceFormat::A8 surface is returned.
*
* THIS IS EXPENSIVE. It is ridiculously expensive. Only do this
* if you absolutely positively must, and never in any performance

View File

@ -212,7 +212,7 @@ protected:
TextureImage(const gfx::IntSize& aSize,
GLenum aWrapMode, ContentType aContentType,
Flags aFlags = NoFlags,
ImageFormat aImageFormat = gfxImageFormat::Unknown);
ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
// Protected destructor, to discourage deletion outside of Release():
virtual ~TextureImage() {}
@ -248,7 +248,7 @@ public:
ContentType aContentType,
GLContext* aContext,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
virtual void BindTexture(GLenum aTextureUnit);
@ -298,7 +298,7 @@ public:
gfx::IntSize aSize,
TextureImage::ContentType,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
~TiledTextureImage();
void DumpDiv();
virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion);
@ -348,7 +348,7 @@ CreateBasicTextureImage(GLContext* aGL,
TextureImage::ContentType aContentType,
GLenum aWrapMode,
TextureImage::Flags aFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
/**
* Return a valid, allocated TextureImage of |aSize| with
@ -373,7 +373,7 @@ CreateTextureImage(GLContext* gl,
TextureImage::ContentType aContentType,
GLenum aWrapMode,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
} // namespace gl
} // namespace mozilla

View File

@ -29,7 +29,7 @@ SharedSurface_GLXDrawable::Create(GLContext* prodGL,
UniquePtr<SharedSurface_GLXDrawable> ret;
Display* display = DefaultXDisplay();
Screen* screen = XDefaultScreenOfDisplay(display);
Visual* visual = gfxXlibSurface::FindVisual(screen, gfxImageFormat::ARGB32);
Visual* visual = gfxXlibSurface::FindVisual(screen, gfx::SurfaceFormat::A8R8G8B8_UINT32);
RefPtr<gfxXlibSurface> surf = gfxXlibSurface::Create(screen, visual, size);
if (!deallocateClient)

View File

@ -24,7 +24,7 @@ public:
ContentType aContentType,
GLContext* aContext,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
~TextureImageCGL();

View File

@ -22,7 +22,7 @@ public:
GLContext* aContext,
Flags aFlags = TextureImage::NoFlags,
TextureState aTextureState = Created,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = SurfaceFormat::UNKNOWN);
virtual ~TextureImageEGL();

View File

@ -229,14 +229,6 @@ struct ParamTraits<mozilla::layers::ScaleMode>
mozilla::layers::ScaleMode::SENTINEL>
{};
template <>
struct ParamTraits<gfxImageFormat>
: public ContiguousEnumSerializer<
gfxImageFormat,
gfxImageFormat::ARGB32,
gfxImageFormat::Unknown>
{};
template <>
struct ParamTraits<mozilla::gfx::AttributeName>
: public ContiguousEnumSerializer<
@ -287,8 +279,8 @@ struct ParamTraits<mozilla::layers::DiagnosticTypes>
template <>
struct ParamTraits<mozilla::PixelFormat>
: public EnumSerializer<mozilla::PixelFormat,
gfxImageFormat::ARGB32,
gfxImageFormat::Unknown>
SurfaceFormat::A8R8G8B8_UINT32,
SurfaceFormat::UNKNOWN>
{};
*/

View File

@ -43,7 +43,7 @@ SharedDIBSurface::InitSurface(uint32_t aWidth, uint32_t aHeight,
long stride = long(aWidth * SharedDIB::kBytesPerPixel);
unsigned char* data = reinterpret_cast<unsigned char*>(mSharedDIB.GetBits());
gfxImageFormat format = aTransparent ? gfxImageFormat::ARGB32 : gfxImageFormat::RGB24;
gfxImageFormat format = aTransparent ? SurfaceFormat::A8R8G8B8_UINT32 : SurfaceFormat::X8R8G8B8_UINT32;
gfxImageSurface::InitWithData(data, IntSize(aWidth, aHeight),
stride, format);

View File

@ -378,7 +378,7 @@ ImageContainer::NotifyCompositeInternal(const ImageCompositeNotification& aNotif
PlanarYCbCrImage::PlanarYCbCrImage()
: Image(nullptr, ImageFormat::PLANAR_YCBCR)
, mOffscreenFormat(gfxImageFormat::Unknown)
, mOffscreenFormat(SurfaceFormat::UNKNOWN)
, mBufferSize(0)
{
}
@ -480,7 +480,7 @@ RecyclingPlanarYCbCrImage::SetData(const Data &aData)
gfxImageFormat
PlanarYCbCrImage::GetOffscreenFormat()
{
return mOffscreenFormat == gfxImageFormat::Unknown ?
return mOffscreenFormat == SurfaceFormat::UNKNOWN ?
gfxPlatform::GetPlatform()->GetOffscreenFormat() :
mOffscreenFormat;
}

View File

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ImageDataSerializer.h"
#include <string.h> // for memcpy
#include "gfx2DGlue.h" // for SurfaceFormatToImageFormat
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc

View File

@ -789,7 +789,7 @@ Transform(const gfxImageSurface* aDest,
gfxPoint aDestOffset)
{
IntSize destSize = aDest->GetSize();
pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormat::ARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == SurfaceFormat::A8R8G8B8_UINT32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
destSize.width,
destSize.height,
(uint32_t*)aDest->Data(),
@ -862,10 +862,9 @@ Transform3D(RefPtr<SourceSurface> aSource,
aDestRect.RoundOut();
// Create a surface the size of the transformed object.
RefPtr<gfxASurface> dest = aDest->CurrentSurface();
RefPtr<gfxImageSurface> destImage = new gfxImageSurface(IntSize(aDestRect.width,
aDestRect.height),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
gfxPoint offset = aDestRect.TopLeft();
// Include a translation to the correct origin.

View File

@ -422,17 +422,15 @@ LayerManagerComposite::UpdateAndRender()
mInvalidRegion.SetEmpty();
}
// Update cached layer tree information.
mClonedLayerTreeProperties = LayerProperties::CloneFrom(GetRoot());
if (invalid.IsEmpty() && !mWindowOverlayChanged) {
// Composition requested, but nothing has changed. Don't do any work.
mClonedLayerTreeProperties = LayerProperties::CloneFrom(GetRoot());
return;
}
// We don't want our debug overlay to cause more frames to happen
// so we will invalidate after we've decided if something changed.
InvalidateDebugOverlay(mRenderBounds);
InvalidateDebugOverlay(invalid, mRenderBounds);
if (!didEffectiveTransforms) {
// The results of our drawing always go directly into a pixel buffer,
@ -450,6 +448,9 @@ LayerManagerComposite::UpdateAndRender()
#endif
mGeometryChanged = false;
mWindowOverlayChanged = false;
// Update cached layer tree information.
mClonedLayerTreeProperties = LayerProperties::CloneFrom(GetRoot());
}
already_AddRefed<DrawTarget>
@ -520,23 +521,18 @@ LayerManagerComposite::RootLayer() const
#endif
void
LayerManagerComposite::InvalidateDebugOverlay(const IntRect& aBounds)
LayerManagerComposite::InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const IntRect& aBounds)
{
bool drawFps = gfxPrefs::LayersDrawFPS();
bool drawFrameCounter = gfxPrefs::DrawFrameCounter();
bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars();
if (drawFps || drawFrameCounter) {
AddInvalidRegion(nsIntRect(0, 0, 256, 256));
aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 256, 256));
}
if (drawFrameColorBars) {
AddInvalidRegion(nsIntRect(0, 0, 10, aBounds.height));
aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 10, aBounds.height));
}
if (drawFrameColorBars) {
AddInvalidRegion(nsIntRect(0, 0, 10, aBounds.height));
}
}
static uint16_t sFrameCount = 0;

View File

@ -328,7 +328,7 @@ private:
/**
* We need to know our invalid region before we're ready to render.
*/
void InvalidateDebugOverlay(const gfx::IntRect& aBounds);
void InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const gfx::IntRect& aBounds);
/**
* Render debug overlays such as the FPS/FrameCounter above the frame.

View File

@ -31,9 +31,9 @@ CreateSharedRGBImage(ImageContainer *aImageContainer,
gfx::IntSize aSize,
gfxImageFormat aImageFormat)
{
NS_ASSERTION(aImageFormat == gfxImageFormat::ARGB32 ||
aImageFormat == gfxImageFormat::RGB24 ||
aImageFormat == gfxImageFormat::RGB16_565,
NS_ASSERTION(aImageFormat == gfx::SurfaceFormat::A8R8G8B8_UINT32 ||
aImageFormat == gfx::SurfaceFormat::X8R8G8B8_UINT32 ||
aImageFormat == gfx::SurfaceFormat::R5G6B5_UINT16,
"RGB formats supported only");
if (!aImageContainer) {

View File

@ -115,7 +115,7 @@ CompositorOGL::CreateContext()
if (!context && gfxEnv::LayersPreferOffscreen()) {
SurfaceCaps caps = SurfaceCaps::ForRGB();
caps.preserve = false;
caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == gfxImageFormat::RGB16_565;
caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == SurfaceFormat::R5G6B5_UINT16;
context = GLContextProvider::CreateOffscreen(mSurfaceSize,
caps, CreateContextFlags::REQUIRE_COMPAT_PROFILE);

View File

@ -213,9 +213,9 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
TEST(Layers, TextureSerialization) {
// the test is run on all the following image formats
gfxImageFormat formats[3] = {
gfxImageFormat::ARGB32,
gfxImageFormat::RGB24,
gfxImageFormat::A8,
SurfaceFormat::A8R8G8B8_UINT32,
SurfaceFormat::X8R8G8B8_UINT32,
SurfaceFormat::A8,
};
for (int f = 0; f < 3; ++f) {
@ -240,9 +240,9 @@ TEST(Layers, TextureSerialization) {
}
TEST(Layers, TextureYCbCrSerialization) {
RefPtr<gfxImageSurface> ySurface = new gfxImageSurface(IntSize(400,300), gfxImageFormat::A8);
RefPtr<gfxImageSurface> cbSurface = new gfxImageSurface(IntSize(200,150), gfxImageFormat::A8);
RefPtr<gfxImageSurface> crSurface = new gfxImageSurface(IntSize(200,150), gfxImageFormat::A8);
RefPtr<gfxImageSurface> ySurface = new gfxImageSurface(IntSize(400,300), SurfaceFormat::A8);
RefPtr<gfxImageSurface> cbSurface = new gfxImageSurface(IntSize(200,150), SurfaceFormat::A8);
RefPtr<gfxImageSurface> crSurface = new gfxImageSurface(IntSize(200,150), SurfaceFormat::A8);
SetupSurface(ySurface.get());
SetupSurface(cbSurface.get());
SetupSurface(crSurface.get());

View File

@ -44,7 +44,7 @@ TestNewSurface () {
int failures = 0;
int destroyed = 0;
RefPtr<gfxASurface> s = new gfxImageSurface (mozilla::gfx::IntSize(10, 10), gfxImageFormat::ARGB32);
RefPtr<gfxASurface> s = new gfxImageSurface (mozilla::gfx::IntSize(10, 10), SurfaceFormat::A8R8G8B8_UINT32);
cairo_surface_t *cs = s->CairoSurface();
cairo_surface_set_user_data (cs, &destruction_key, &destroyed, SurfaceDestroyNotifier);

View File

@ -80,31 +80,31 @@ inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
{
switch (aFormat) {
case SurfaceFormat::B8G8R8A8:
return gfxImageFormat::ARGB32;
return SurfaceFormat::A8R8G8B8_UINT32;
case SurfaceFormat::B8G8R8X8:
return gfxImageFormat::RGB24;
return SurfaceFormat::X8R8G8B8_UINT32;
case SurfaceFormat::R5G6B5_UINT16:
return gfxImageFormat::RGB16_565;
return SurfaceFormat::R5G6B5_UINT16;
case SurfaceFormat::A8:
return gfxImageFormat::A8;
return SurfaceFormat::A8;
default:
return gfxImageFormat::Unknown;
return SurfaceFormat::UNKNOWN;
}
}
inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
{
switch (aFormat) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return SurfaceFormat::B8G8R8A8;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return SurfaceFormat::B8G8R8X8;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return SurfaceFormat::R5G6B5_UINT16;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return SurfaceFormat::A8;
default:
case gfxImageFormat::Unknown:
case SurfaceFormat::UNKNOWN:
return SurfaceFormat::B8G8R8A8;
}
}

View File

@ -344,7 +344,7 @@ already_AddRefed<gfxImageSurface>
gfxASurface::GetAsReadableARGB32ImageSurface()
{
RefPtr<gfxImageSurface> imgSurface = GetAsImageSurface();
if (!imgSurface || imgSurface->Format() != gfxImageFormat::ARGB32) {
if (!imgSurface || imgSurface->Format() != SurfaceFormat::A8R8G8B8_UINT32) {
imgSurface = CopyToARGB32ImageSurface();
}
return imgSurface.forget();
@ -359,7 +359,7 @@ gfxASurface::CopyToARGB32ImageSurface()
const IntSize size = GetSize();
RefPtr<gfxImageSurface> imgSurface =
new gfxImageSurface(size, gfxImageFormat::ARGB32);
new gfxImageSurface(size, SurfaceFormat::A8R8G8B8_UINT32);
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height));
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, this);
@ -425,7 +425,7 @@ gfxASurface::CheckSurfaceSize(const IntSize& sz, int32_t limit)
int32_t
gfxASurface::FormatStrideForWidth(gfxImageFormat format, int32_t width)
{
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
return cairo_format_stride_for_width(cformat, (int)width);
}
@ -463,15 +463,15 @@ gfxContentType
gfxASurface::ContentFromFormat(gfxImageFormat format)
{
switch (format) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return gfxContentType::COLOR_ALPHA;
case gfxImageFormat::RGB24:
case gfxImageFormat::RGB16_565:
case SurfaceFormat::X8R8G8B8_UINT32:
case SurfaceFormat::R5G6B5_UINT16:
return gfxContentType::COLOR;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return gfxContentType::ALPHA;
case gfxImageFormat::Unknown:
case SurfaceFormat::UNKNOWN:
default:
return gfxContentType::COLOR;
}
@ -504,12 +504,12 @@ int32_t
gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
{
switch (format) {
case gfxImageFormat::ARGB32:
case gfxImageFormat::RGB24:
case SurfaceFormat::A8R8G8B8_UINT32:
case SurfaceFormat::X8R8G8B8_UINT32:
return 4;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return 2;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return 1;
default:
NS_WARNING("Unknown byte per pixel value for Image format");
@ -667,15 +667,15 @@ gfxASurface::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
gfxASurface::BytesPerPixel(gfxImageFormat aImageFormat)
{
switch (aImageFormat) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return 4;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return 4;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return 2;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return 1;
case gfxImageFormat::Unknown:
case SurfaceFormat::UNKNOWN:
default:
NS_NOTREACHED("Not really sure what you want me to say here");
return 0;

View File

@ -17,10 +17,10 @@ gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
mozilla::gfx::IntSize size = blackSurf->GetSize();
if (size != whiteSurf->GetSize() ||
(blackSurf->Format() != gfxImageFormat::ARGB32 &&
blackSurf->Format() != gfxImageFormat::RGB24) ||
(whiteSurf->Format() != gfxImageFormat::ARGB32 &&
whiteSurf->Format() != gfxImageFormat::RGB24))
(blackSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
blackSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) ||
(whiteSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
whiteSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32))
return false;
#ifdef MOZILLA_MAY_SUPPORT_SSE2

View File

@ -33,10 +33,10 @@ gfxAlphaRecovery::RecoverAlphaSSE2(gfxImageSurface* blackSurf,
mozilla::gfx::IntSize size = blackSurf->GetSize();
if (size != whiteSurf->GetSize() ||
(blackSurf->Format() != gfxImageFormat::ARGB32 &&
blackSurf->Format() != gfxImageFormat::RGB24) ||
(whiteSurf->Format() != gfxImageFormat::ARGB32 &&
whiteSurf->Format() != gfxImageFormat::RGB24))
(blackSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
blackSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) ||
(whiteSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
whiteSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32))
return false;
blackSurf->Flush();
@ -140,7 +140,7 @@ ByteAlignment(int32_t aAlignToLog2, int32_t aX, int32_t aY=0, int32_t aStride=1)
gfxAlphaRecovery::AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect,
gfxImageSurface* aSurface)
{
NS_ASSERTION(gfxImageFormat::ARGB32 == aSurface->Format(),
NS_ASSERTION(mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 == aSurface->Format(),
"Thebes grew support for non-ARGB32 COLOR_ALPHA?");
static const int32_t kByteAlignLog2 = GoodAlignmentLog2();
static const int32_t bpp = 4;

View File

@ -101,11 +101,11 @@ gfxAndroidPlatform::gfxAndroidPlatform()
RegisterStrongMemoryReporter(new FreetypeReporter());
mOffscreenFormat = GetScreenDepth() == 16
? gfxImageFormat::RGB16_565
: gfxImageFormat::RGB24;
? SurfaceFormat::R5G6B5_UINT16
: SurfaceFormat::X8R8G8B8_UINT32;
if (gfxPrefs::AndroidRGB16Force()) {
mOffscreenFormat = gfxImageFormat::RGB16_565;
mOffscreenFormat = SurfaceFormat::R5G6B5_UINT16;
}
#ifdef MOZ_WIDGET_GONK

View File

@ -511,14 +511,13 @@ CreateBoxShadow(SourceSurface* aBlurMask, const Color& aShadowColor)
}
static already_AddRefed<SourceSurface>
GetBlur(DrawTarget& aDT,
GetBlur(gfxContext* aDestinationCtx,
const IntSize& aRectSize,
const IntSize& aBlurRadius,
RectCornerRadii* aCornerRadii,
const Color& aShadowColor,
IntMargin& aExtendDestBy,
IntMargin& aSlice,
gfxContext* aDestinationCtx)
IntMargin& aSlice)
{
if (!gBlurCache) {
gBlurCache = new BlurCache();
@ -536,9 +535,11 @@ GetBlur(DrawTarget& aDT,
minSize = aRectSize;
}
DrawTarget& destDT = *aDestinationCtx->GetDrawTarget();
BlurCacheData* cached = gBlurCache->Lookup(minSize, aBlurRadius,
aCornerRadii, aShadowColor,
aDT.GetBackendType());
destDT.GetBackendType());
if (cached && !useDestRect) {
// See CreateBlurMask() for these values
aExtendDestBy = cached->mExtendDest;
@ -548,7 +549,8 @@ GetBlur(DrawTarget& aDT,
}
RefPtr<SourceSurface> blurMask =
CreateBlurMask(minSize, aCornerRadii, aBlurRadius, aExtendDestBy, aSlice, aDT);
CreateBlurMask(minSize, aCornerRadii, aBlurRadius, aExtendDestBy, aSlice,
destDT);
if (!blurMask) {
return nullptr;
@ -563,7 +565,8 @@ GetBlur(DrawTarget& aDT,
// Since we're just going to paint the actual rect to the destination
aSlice.SizeTo(0, 0, 0, 0);
} else {
CacheBlur(aDT, minSize, aBlurRadius, aCornerRadii, aShadowColor, aExtendDestBy, boxShadow);
CacheBlur(destDT, minSize, aBlurRadius, aCornerRadii, aShadowColor,
aExtendDestBy, boxShadow);
}
return boxShadow.forget();
}
@ -701,22 +704,21 @@ gfxAlphaBoxBlur::BlurRectangle(gfxContext* aDestinationCtx,
const gfxRect& aDirtyRect,
const gfxRect& aSkipRect)
{
DrawTarget& destDrawTarget = *aDestinationCtx->GetDrawTarget();
IntSize blurRadius = CalculateBlurRadius(aBlurStdDev);
IntRect rect = RoundedToInt(ToRect(aRect));
IntMargin extendDestBy;
IntMargin slice;
RefPtr<SourceSurface> boxShadow = GetBlur(destDrawTarget,
RefPtr<SourceSurface> boxShadow = GetBlur(aDestinationCtx,
rect.Size(), blurRadius,
aCornerRadii, aShadowColor,
extendDestBy, slice,
aDestinationCtx);
extendDestBy, slice);
if (!boxShadow) {
return;
}
DrawTarget& destDrawTarget = *aDestinationCtx->GetDrawTarget();
destDrawTarget.PushClipRect(ToRect(aDirtyRect));
// Copy the right parts from boxShadow into destDrawTarget. The middle parts
@ -921,7 +923,7 @@ gfxAlphaBoxBlur::GetInsetBlur(IntMargin& aExtendDestBy,
const bool& aHasBorderRadius,
const Point aShadowOffset,
bool& aMovedOffset,
gfxContext* aDestinationCtx)
DrawTarget* aDestDrawTarget)
{
if (!gBlurCache) {
gBlurCache = new BlurCache();
@ -948,13 +950,12 @@ gfxAlphaBoxBlur::GetInsetBlur(IntMargin& aExtendDestBy,
aMovedOffset = true;
}
DrawTarget* destDrawTarget = aDestinationCtx->GetDrawTarget();
BlurCacheData* cached =
gBlurCache->LookupInsetBoxShadow(outerRect.Size(), innerRect.Size(),
aBlurRadius, aSpreadRadius,
&aInnerClipRadii, aShadowColor,
aHasBorderRadius,
destDrawTarget->GetBackendType());
aDestDrawTarget->GetBackendType());
if (cached && !useDestRect) {
aExtendDestBy = cached->mExtendDest;
// Need to extend it twice: once for the outer rect and once for the inner rect.
@ -1011,7 +1012,7 @@ gfxAlphaBoxBlur::GetInsetBlur(IntMargin& aExtendDestBy,
CacheInsetBlur(outerRect.Size(), innerRect.Size(),
aBlurRadius, aSpreadRadius,
&aInnerClipRadii, aShadowColor,
aHasBorderRadius, destDrawTarget->GetBackendType(),
aHasBorderRadius, aDestDrawTarget->GetBackendType(),
aExtendDestBy, minInsetBlur);
}
@ -1041,6 +1042,8 @@ gfxAlphaBoxBlur::BlurInsetBox(gfxContext* aDestinationCtx,
const Rect aSkipRect,
const Point aShadowOffset)
{
DrawTarget* destDrawTarget = aDestinationCtx->GetDrawTarget();
// Blur inset shadows ALWAYS have a 0 spread radius.
if ((aBlurRadius.width <= 0 && aBlurRadius.height <= 0)) {
FillDestinationPath(aDestinationCtx, aDestinationRect, aShadowClipRect,
@ -1056,7 +1059,7 @@ gfxAlphaBoxBlur::BlurInsetBox(gfxContext* aDestinationCtx,
aBlurRadius, aSpreadRadius,
aInnerClipRadii, aShadowColor,
aHasBorderRadius, aShadowOffset,
didMoveOffset, aDestinationCtx);
didMoveOffset, destDrawTarget);
if (!minInsetBlur) {
return;
}
@ -1073,7 +1076,6 @@ gfxAlphaBoxBlur::BlurInsetBox(gfxContext* aDestinationCtx,
Rect dstInner = dstOuter;
dstInner.Deflate(Margin(slice));
DrawTarget* destDrawTarget = aDestinationCtx->GetDrawTarget();
if (dstOuter.Size() == srcOuter.Size()) {
destDrawTarget->DrawSurface(minInsetBlur, dstOuter, srcOuter);
} else {

View File

@ -48,6 +48,7 @@ namespace mozilla {
class gfxAlphaBoxBlur
{
typedef mozilla::gfx::Color Color;
typedef mozilla::gfx::DrawTarget DrawTarget;
typedef mozilla::gfx::RectCornerRadii RectCornerRadii;
public:
@ -89,7 +90,8 @@ public:
return mContext;
}
already_AddRefed<mozilla::gfx::SourceSurface> DoBlur(mozilla::gfx::DrawTarget* aDT, mozilla::gfx::IntPoint* aTopLeft);
already_AddRefed<mozilla::gfx::SourceSurface>
DoBlur(DrawTarget* aDT, mozilla::gfx::IntPoint* aTopLeft);
/**
* Does the actual blurring/spreading and mask applying. Users of this
@ -176,7 +178,7 @@ protected:
const bool& aHasBorderRadius,
const mozilla::gfx::Point aShadowOffset,
bool& aMovedOffset,
gfxContext* aDestinationCtx);
DrawTarget* aDestDrawTarget);
/**
* The context of the temporary alpha surface.

View File

@ -12,6 +12,7 @@
#include "cairo.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "gfx2DGlue.h"
#include <algorithm>
@ -21,7 +22,7 @@ using namespace mozilla::gfx;
gfxImageSurface::gfxImageSurface()
: mSize(0, 0),
mOwnsData(false),
mFormat(gfxImageFormat::Unknown),
mFormat(SurfaceFormat::UNKNOWN),
mStride(0)
{
}
@ -37,7 +38,7 @@ gfxImageSurface::InitFromSurface(cairo_surface_t *csurf)
mSize.width = cairo_image_surface_get_width(csurf);
mSize.height = cairo_image_surface_get_height(csurf);
mData = cairo_image_surface_get_data(csurf);
mFormat = gfxCairoFormatToImageFormat(cairo_image_surface_get_format(csurf));
mFormat = CairoFormatToGfxFormat(cairo_image_surface_get_format(csurf));
mOwnsData = false;
mStride = cairo_image_surface_get_stride(csurf);
@ -71,7 +72,7 @@ gfxImageSurface::InitWithData(unsigned char *aData, const IntSize& aSize,
if (!CheckSurfaceSize(aSize))
MakeInvalid();
cairo_format_t cformat = gfxImageFormatToCairoFormat(mFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(mFormat);
cairo_surface_t *surface =
cairo_image_surface_create_for_data((unsigned char*)mData,
cformat,
@ -141,7 +142,7 @@ gfxImageSurface::AllocateAndInit(long aStride, int32_t aMinimalAllocation,
mOwnsData = true;
cairo_format_t cformat = gfxImageFormatToCairoFormat(mFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(mFormat);
cairo_surface_t *surface =
cairo_image_surface_create_for_data((unsigned char*)mData,
cformat,
@ -169,7 +170,7 @@ gfxImageSurface::gfxImageSurface(cairo_surface_t *csurf)
mSize.width = cairo_image_surface_get_width(csurf);
mSize.height = cairo_image_surface_get_height(csurf);
mData = cairo_image_surface_get_data(csurf);
mFormat = gfxCairoFormatToImageFormat(cairo_image_surface_get_format(csurf));
mFormat = CairoFormatToGfxFormat(cairo_image_surface_get_format(csurf));
mOwnsData = false;
mStride = cairo_image_surface_get_stride(csurf);
@ -187,13 +188,13 @@ gfxImageSurface::ComputeStride(const IntSize& aSize, gfxImageFormat aFormat)
{
long stride;
if (aFormat == gfxImageFormat::ARGB32)
if (aFormat == SurfaceFormat::A8R8G8B8_UINT32)
stride = aSize.width * 4;
else if (aFormat == gfxImageFormat::RGB24)
else if (aFormat == SurfaceFormat::X8R8G8B8_UINT32)
stride = aSize.width * 4;
else if (aFormat == gfxImageFormat::RGB16_565)
else if (aFormat == SurfaceFormat::R5G6B5_UINT16)
stride = aSize.width * 2;
else if (aFormat == gfxImageFormat::A8)
else if (aFormat == SurfaceFormat::A8)
stride = aSize.width;
else {
NS_WARNING("Unknown format specified to gfxImageSurface!");
@ -249,10 +250,10 @@ static bool
FormatsAreCompatible(gfxImageFormat a1, gfxImageFormat a2)
{
if (a1 != a2 &&
!(a1 == gfxImageFormat::ARGB32 &&
a2 == gfxImageFormat::RGB24) &&
!(a1 == gfxImageFormat::RGB24 &&
a2 == gfxImageFormat::ARGB32)) {
!(a1 == SurfaceFormat::A8R8G8B8_UINT32 &&
a2 == SurfaceFormat::X8R8G8B8_UINT32) &&
!(a1 == SurfaceFormat::X8R8G8B8_UINT32 &&
a2 == SurfaceFormat::A8R8G8B8_UINT32)) {
return false;
}
@ -348,9 +349,9 @@ gfxImageSurface::GetSubimage(const gfxRect& aRect)
(Stride() * (int)r.Y()) +
(int)r.X() * gfxASurface::BytePerPixelFromFormat(Format());
if (format == gfxImageFormat::ARGB32 &&
if (format == SurfaceFormat::A8R8G8B8_UINT32 &&
GetOpaqueRect().Contains(aRect)) {
format = gfxImageFormat::RGB24;
format = SurfaceFormat::X8R8G8B8_UINT32;
}
RefPtr<gfxSubimageSurface> image =

View File

@ -577,7 +577,7 @@ gfxPlatform::Init()
gPlatform->mScreenReferenceSurface =
gPlatform->CreateOffscreenSurface(IntSize(1, 1),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
if (!gPlatform->mScreenReferenceSurface) {
NS_RUNTIMEABORT("Could not initialize mScreenReferenceSurface");
}
@ -1864,11 +1864,11 @@ gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
switch (aContent) {
case gfxContentType::COLOR:
switch (GetOffscreenFormat()) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return mozilla::gfx::SurfaceFormat::B8G8R8A8;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return mozilla::gfx::SurfaceFormat::B8G8R8X8;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return mozilla::gfx::SurfaceFormat::R5G6B5_UINT16;
default:
NS_NOTREACHED("unknown gfxImageFormat for gfxContentType::COLOR");
@ -1891,12 +1891,12 @@ gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
case gfxContentType::COLOR:
return GetOffscreenFormat();
case gfxContentType::ALPHA:
return gfxImageFormat::A8;
return SurfaceFormat::A8;
case gfxContentType::COLOR_ALPHA:
return gfxImageFormat::ARGB32;
return SurfaceFormat::A8R8G8B8_UINT32;
default:
NS_NOTREACHED("unknown gfxContentType");
return gfxImageFormat::ARGB32;
return SurfaceFormat::A8R8G8B8_UINT32;
}
}

View File

@ -536,7 +536,7 @@ public:
virtual gfxImageFormat OptimalFormatForContent(gfxContentType aContent);
virtual gfxImageFormat GetOffscreenFormat()
{ return gfxImageFormat::RGB24; }
{ return mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32; }
/**
* Returns a logger if one is available and logging is enabled

View File

@ -365,10 +365,10 @@ gfxPlatformGtk::GetOffscreenFormat()
// Make sure there is a screen
GdkScreen *screen = gdk_screen_get_default();
if (screen && gdk_visual_get_depth(gdk_visual_get_system()) == 16) {
return gfxImageFormat::RGB16_565;
return SurfaceFormat::R5G6B5_UINT16;
}
return gfxImageFormat::RGB24;
return SurfaceFormat::X8R8G8B8_UINT32;
}
void gfxPlatformGtk::FontsPrefsChanged(const char *aPref)

View File

@ -21,7 +21,7 @@ gfxQPainterSurface::gfxQPainterSurface(QPainter *painter)
gfxQPainterSurface::gfxQPainterSurface(const mozilla::gfx::IntSize& size, gfxImageFormat format)
{
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *csurf =
cairo_qt_surface_create_with_qimage(cformat, size.width, size.height);
mPainter = cairo_qt_surface_get_qpainter (csurf);

View File

@ -46,7 +46,7 @@ using namespace mozilla::gfx;
gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nullptr;
static gfxImageFormat sOffscreenFormat = gfxImageFormat::RGB24;
static gfxImageFormat sOffscreenFormat = SurfaceFormat::X8R8G8B8_UINT32;
gfxQtPlatform::gfxQtPlatform()
{
@ -55,7 +55,7 @@ gfxQtPlatform::gfxQtPlatform()
int32_t depth = GetScreenDepth();
if (depth == 16) {
sOffscreenFormat = gfxImageFormat::RGB16_565;
sOffscreenFormat = SurfaceFormat::R5G6B5_UINT16;
}
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);

View File

@ -6,6 +6,7 @@
#include "gfxQuartzSurface.h"
#include "gfxContext.h"
#include "gfxImageSurface.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "cairo-quartz.h"
@ -26,7 +27,7 @@ gfxQuartzSurface::gfxQuartzSurface(const gfxSize& desiredSize, gfxImageFormat fo
unsigned int width = static_cast<unsigned int>(mSize.width);
unsigned int height = static_cast<unsigned int>(mSize.height);
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *surf = cairo_quartz_surface_create(cformat, width, height);
mCGContext = cairo_quartz_surface_get_cg_context (surf);
@ -109,7 +110,7 @@ gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
unsigned int width = static_cast<unsigned int>(mSize.width);
unsigned int height = static_cast<unsigned int>(mSize.height);
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *surf = cairo_quartz_surface_create_for_data
(data, cformat, width, height, stride);
@ -132,7 +133,7 @@ gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
if (!CheckSurfaceSize(aSize))
MakeInvalid();
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *surf = cairo_quartz_surface_create_for_data
(data, cformat, aSize.width, aSize.height, stride);

View File

@ -44,34 +44,6 @@ enum class gfxBreakPriority {
eNormalBreak
};
/**
* The format for an image surface. For all formats with alpha data, 0
* means transparent, 1 or 255 means fully opaque.
*
* XXX: it's vital that the values here match the values in cairo_format_t,
* otherwise gfxCairoFormatToImageFormat() and gfxImageFormatToCairoFormat()
* won't work.
*/
enum class gfxImageFormat {
ARGB32 = 0, ///< ARGB data in native endianness, using premultiplied alpha
RGB24 = 1, ///< xRGB data in native endianness
A8 = 2, ///< Only an alpha channel
RGB16_565 = 4, ///< RGB_565 data in native endianness
Unknown
};
// XXX: temporary
// This works because the gfxImageFormat enum is defined so as to match the
// cairo_format_t enum.
#define gfxCairoFormatToImageFormat(aFormat) \
((gfxImageFormat)aFormat)
// XXX: temporary
// This works because the gfxImageFormat enum is defined so as to match the
// cairo_format_t enum.
#define gfxImageFormatToCairoFormat(aFormat) \
((cairo_format_t)aFormat)
enum class gfxSurfaceType {
Image,
PDF,

View File

@ -789,11 +789,11 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext,
gfxUtils::ImageFormatToDepth(gfxImageFormat aFormat)
{
switch (aFormat) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return 32;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return 24;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return 16;
default:
break;
@ -985,7 +985,7 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
bool prescale = aSuggestedSize.width > 0 && aSuggestedSize.height > 0 &&
aSuggestedSize != aData.mPicSize;
if (aSuggestedFormat == gfxImageFormat::RGB16_565) {
if (aSuggestedFormat == SurfaceFormat::R5G6B5_UINT16) {
#if defined(HAVE_YCBCR_TO_RGB565)
if (prescale &&
!IsScaleYCbCrToRGB565Fast(aData.mPicX,
@ -1005,14 +1005,14 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
}
#else
// yuv2rgb16 function not available
aSuggestedFormat = gfxImageFormat::RGB24;
aSuggestedFormat = SurfaceFormat::X8R8G8B8_UINT32;
#endif
}
else if (aSuggestedFormat != gfxImageFormat::RGB24) {
else if (aSuggestedFormat != SurfaceFormat::X8R8G8B8_UINT32) {
// No other formats are currently supported.
aSuggestedFormat = gfxImageFormat::RGB24;
aSuggestedFormat = SurfaceFormat::X8R8G8B8_UINT32;
}
if (aSuggestedFormat == gfxImageFormat::RGB24) {
if (aSuggestedFormat == SurfaceFormat::X8R8G8B8_UINT32) {
/* ScaleYCbCrToRGB32 does not support a picture offset, nor 4:4:4 data.
See bugs 639415 and 640073. */
if (aData.mPicX != 0 || aData.mPicY != 0 || yuvtype == YV24)
@ -1045,7 +1045,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
// Convert from YCbCr to RGB now, scaling the image if needed.
if (aDestSize != aData.mPicSize) {
#if defined(HAVE_YCBCR_TO_RGB565)
if (aDestFormat == gfxImageFormat::RGB16_565) {
if (aDestFormat == SurfaceFormat::R5G6B5_UINT16) {
ScaleYCbCrToRGB565(aData.mYChannel,
aData.mCbChannel,
aData.mCrChannel,
@ -1079,7 +1079,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
FILTER_BILINEAR);
} else { // no prescale
#if defined(HAVE_YCBCR_TO_RGB565)
if (aDestFormat == gfxImageFormat::RGB16_565) {
if (aDestFormat == SurfaceFormat::R5G6B5_UINT16) {
ConvertYCbCrToRGB565(aData.mYChannel,
aData.mCbChannel,
aData.mCrChannel,
@ -1092,7 +1092,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
aData.mCbCrStride,
aStride,
yuvtype);
} else // aDestFormat != gfxImageFormat::RGB16_565
} else // aDestFormat != SurfaceFormat::R5G6B5_UINT16
#endif
ConvertYCbCrToRGB32(aData.mYChannel,
aData.mCbChannel,

View File

@ -49,7 +49,7 @@ public:
* If aDestSurface is given, it must have identical format, dimensions, and
* stride as the source.
*
* If the source is not gfxImageFormat::ARGB32, no operation is performed. If
* If the source is not SurfaceFormat::A8R8G8B8_UINT32, no operation is performed. If
* aDestSurface is given, the data is copied over.
*/
static bool PremultiplyDataSurface(DataSourceSurface* srcSurf,
@ -137,7 +137,7 @@ public:
/**
* Helper function for ConvertYCbCrToRGB that finds the
* RGB buffer size and format for given YCbCrImage.
* @param aSuggestedFormat will be set to gfxImageFormat::RGB24
* @param aSuggestedFormat will be set to SurfaceFormat::X8R8G8B8_UINT32
* if the desired format is not supported.
* @param aSuggestedSize will be set to the picture size from aData
* if either the suggested size was {0,0}

View File

@ -6,6 +6,7 @@
#include "gfxWindowsSurface.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "mozilla/gfx/Logging.h"
#include "cairo.h"
@ -59,7 +60,7 @@ gfxWindowsSurface::gfxWindowsSurface(const mozilla::gfx::IntSize& realSize, gfxI
if (!CheckSurfaceSize(size))
MakeInvalid(size);
cairo_format_t cformat = gfxImageFormatToCairoFormat(imageFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(imageFormat);
cairo_surface_t *surf =
cairo_win32_surface_create_with_dib(cformat, size.width, size.height);
@ -80,7 +81,7 @@ gfxWindowsSurface::gfxWindowsSurface(HDC dc, const mozilla::gfx::IntSize& realSi
if (!CheckSurfaceSize(size))
MakeInvalid(size);
cairo_format_t cformat = gfxImageFormatToCairoFormat(imageFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(imageFormat);
cairo_surface_t *surf =
cairo_win32_surface_create_with_ddb(dc, cformat,
size.width, size.height);
@ -89,7 +90,8 @@ gfxWindowsSurface::gfxWindowsSurface(HDC dc, const mozilla::gfx::IntSize& realSi
if (mSurfaceValid) {
// DDBs will generally only use 3 bytes per pixel when RGB24
int bytesPerPixel = ((imageFormat == gfxImageFormat::RGB24) ? 3 : 4);
int bytesPerPixel =
((imageFormat == mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) ? 3 : 4);
RecordMemoryUsed(size.width * size.height * bytesPerPixel + sizeof(gfxWindowsSurface));
}
@ -143,7 +145,7 @@ gfxWindowsSurface::CreateSimilarSurface(gfxContentType aContent,
// have a DIB.
gfxImageFormat gformat =
gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent);
cairo_format_t cformat = gfxImageFormatToCairoFormat(gformat);
cairo_format_t cformat = GfxFormatToCairoFormat(gformat);
surface = cairo_win32_surface_create_with_dib(cformat, aSize.width,
aSize.height);
} else {

View File

@ -35,12 +35,12 @@ public:
// Create a DIB surface
gfxWindowsSurface(const mozilla::gfx::IntSize& size,
gfxImageFormat imageFormat = gfxImageFormat::RGB24);
gfxImageFormat imageFormat = mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32);
// Create a DDB surface; dc may be nullptr to use the screen DC
gfxWindowsSurface(HDC dc,
const mozilla::gfx::IntSize& size,
gfxImageFormat imageFormat = gfxImageFormat::RGB24);
gfxImageFormat imageFormat = mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32);
gfxWindowsSurface(cairo_surface_t *csurf);

View File

@ -13,6 +13,7 @@
#include "cairo-xlib.h"
#include "cairo-xlib-xrender.h"
#include "mozilla/gfx/BorrowedContext.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "gfx2DGlue.h"
using namespace mozilla;
@ -352,7 +353,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget,
} else if (cairoTargetType == CAIRO_SURFACE_TYPE_IMAGE || drawTarget) {
gfxImageFormat imageFormat =
drawTarget ? SurfaceFormatToImageFormat(drawTarget->GetFormat()) :
gfxCairoFormatToImageFormat(cairo_image_surface_get_format(cairoTarget));
CairoFormatToGfxFormat(cairo_image_surface_get_format(cairoTarget));
target_visual = gfxXlibSurface::FindVisual(screen, imageFormat);
Display *dpy = DisplayOfScreen(screen);
if (target_visual) {
@ -389,7 +390,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget,
supportsAlternateScreen ? target_screen : screen;
Visual *argbVisual =
gfxXlibSurface::FindVisual(visualScreen,
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
if (argbVisual) {
visual = argbVisual;
screen = visualScreen;
@ -399,7 +400,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget,
// No advantage in using the target screen.
Visual *rgb24Visual =
gfxXlibSurface::FindVisual(screen,
gfxImageFormat::RGB24);
SurfaceFormat::X8R8G8B8_UINT32);
if (rgb24Visual) {
visual = rgb24Visual;
}
@ -596,7 +597,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
}
RefPtr<gfxImageSurface> blackImage =
CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::ARGB32);
CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::A8R8G8B8_UINT32);
cairo_t* tmpCtx = cairo_create(tempXlibSurface);
cairo_set_source_rgba(tmpCtx, 1.0, 1.0, 1.0, 1.0);
@ -605,7 +606,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
cairo_destroy(tmpCtx);
DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft());
RefPtr<gfxImageSurface> whiteImage =
CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::RGB24);
CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::X8R8G8B8_UINT32);
if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS &&
whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) {

View File

@ -504,25 +504,25 @@ gfxXlibSurface::FindVisual(Screen *screen, gfxImageFormat format)
int depth;
unsigned long red_mask, green_mask, blue_mask;
switch (format) {
case gfxImageFormat::ARGB32:
case gfx::SurfaceFormat::A8R8G8B8_UINT32:
depth = 32;
red_mask = 0xff0000;
green_mask = 0xff00;
blue_mask = 0xff;
break;
case gfxImageFormat::RGB24:
case gfx::SurfaceFormat::X8R8G8B8_UINT32:
depth = 24;
red_mask = 0xff0000;
green_mask = 0xff00;
blue_mask = 0xff;
break;
case gfxImageFormat::RGB16_565:
case gfx::SurfaceFormat::R5G6B5_UINT16:
depth = 16;
red_mask = 0xf800;
green_mask = 0x7e0;
blue_mask = 0x1f;
break;
case gfxImageFormat::A8:
case gfx::SurfaceFormat::A8:
default:
return nullptr;
}
@ -551,11 +551,11 @@ XRenderPictFormat*
gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
{
switch (format) {
case gfxImageFormat::ARGB32:
case gfx::SurfaceFormat::A8R8G8B8_UINT32:
return XRenderFindStandardFormat (dpy, PictStandardARGB32);
case gfxImageFormat::RGB24:
case gfx::SurfaceFormat::X8R8G8B8_UINT32:
return XRenderFindStandardFormat (dpy, PictStandardRGB24);
case gfxImageFormat::RGB16_565: {
case gfx::SurfaceFormat::R5G6B5_UINT16: {
// PictStandardRGB16_565 is not standard Xrender format
// we should try to find related visual
// and find xrender format by visual
@ -564,7 +564,7 @@ gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
return nullptr;
return XRenderFindVisualFormat(dpy, visual);
}
case gfxImageFormat::A8:
case gfx::SurfaceFormat::A8:
return XRenderFindStandardFormat (dpy, PictStandardA8);
default:
break;

View File

@ -135,7 +135,7 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
aData.mCbCrStride,
aStride,
yuvtype);
} else // aDestFormat != gfxImageFormat::RGB16_565
} else // aDestFormat != SurfaceFormat::R5G6B5_UINT16
#endif
ConvertYCbCrToRGB32(aData.mYChannel, //
aData.mCbChannel,

View File

@ -3868,7 +3868,7 @@ GetDashInfo(nscoord aBorderLength,
}
void
nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
@ -3891,14 +3891,6 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
aEndBevelOffset = 0;
}
gfxContext *ctx = aContext.ThebesContext();
AntialiasMode oldMode = ctx->CurrentAntialiasMode();
ctx->SetAntialiasMode(AntialiasMode::NONE);
ctx->SetColor(Color::FromABGR(aBorderColor));
DrawTarget& drawTarget = *aContext.GetDrawTarget();
switch (aBorderStyle) {
case NS_STYLE_BORDER_STYLE_NONE:
case NS_STYLE_BORDER_STYLE_HIDDEN:
@ -3921,36 +3913,36 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
GetDashInfo(aBorder.width, dashLength, twipsPerPixel, numDashSpaces,
startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, startDashLength, aBorder.height);
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
rect.x += startDashLength + dashLength;
rect.width = aBorder.width
- (startDashLength + endDashLength + dashLength);
DrawDashedSegment(drawTarget, rect, dashLength, aBorderColor,
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, horizontal);
rect.x += rect.width;
rect.width = endDashLength;
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
}
else {
GetDashInfo(aBorder.height, dashLength, twipsPerPixel, numDashSpaces,
startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, aBorder.width, startDashLength);
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
rect.y += rect.height + dashLength;
rect.height = aBorder.height
- (startDashLength + endDashLength + dashLength);
DrawDashedSegment(drawTarget, rect, dashLength, aBorderColor,
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, horizontal);
rect.y += rect.height;
rect.height = endDashLength;
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
}
}
@ -3962,7 +3954,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if ((horizontal && (twipsPerPixel >= aBorder.height)) ||
(!horizontal && (twipsPerPixel >= aBorder.width))) {
// a one pixel border
DrawSolidBorderSegment(drawTarget, aBorder, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, aBorder, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, aStartBevelOffset,
aEndBevelSide, aEndBevelOffset);
@ -3978,8 +3970,6 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
nscolor bevelColor = MakeBevelColor(ridgeGrooveSide, ridgeGroove,
aBGColor->mBackgroundColor,
aBorderColor);
// XXXbz is this SetColor call still needed?
ctx->SetColor(Color::FromABGR(bevelColor));
nsRect rect(aBorder);
nscoord half;
if (horizontal) { // top, bottom
@ -3992,7 +3982,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_TOP == aEndBevelSide) {
rect.width -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4007,7 +3997,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_LEFT == aEndBevelSide) {
rect.height -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4019,8 +4009,6 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
// background color, but I don't care.
bevelColor = MakeBevelColor(ridgeGrooveSide, ridgeGroove,
aBGColor->mBackgroundColor, aBorderColor);
// XXXbz is this SetColor call still needed?
ctx->SetColor(Color::FromABGR(bevelColor));
if (horizontal) {
rect.y = rect.y + half;
rect.height = aBorder.height - half;
@ -4031,7 +4019,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_BOTTOM == aEndBevelSide) {
rect.width -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4046,7 +4034,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_RIGHT == aEndBevelSide) {
rect.height -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4075,7 +4063,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_TOP == aEndBevelSide) {
topRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, topRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, topRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4090,7 +4078,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_BOTTOM == aEndBevelSide) {
bottomRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, bottomRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, bottomRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4106,7 +4094,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_LEFT == aEndBevelSide) {
leftRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, leftRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, leftRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4120,7 +4108,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_RIGHT == aEndBevelSide) {
rightRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, rightRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rightRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4130,7 +4118,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
// else fall through to solid
MOZ_FALLTHROUGH;
case NS_STYLE_BORDER_STYLE_SOLID:
DrawSolidBorderSegment(drawTarget, aBorder, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, aBorder, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
aStartBevelOffset, aEndBevelSide, aEndBevelOffset);
break;
@ -4142,8 +4130,6 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
NS_ASSERTION(false, "Unexpected 'auto' table border");
break;
}
ctx->SetAntialiasMode(oldMode);
}
// End table border-collapsing section

View File

@ -644,8 +644,8 @@ struct nsCSSRendering {
// Draw a border segment in the table collapsing border model without
// beveling corners
static void DrawTableBorderSegment(nsRenderingContext& aContext,
uint8_t aBorderStyle,
static void DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
const nsRect& aBorderRect,

View File

@ -5264,6 +5264,8 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
{
const nsIFrame *frame = aProperties.mFrame;
NS_ASSERTION(frame || !(aFlags & INCLUDE_PERSPECTIVE), "Must have a frame to compute perspective!");
MOZ_ASSERT((aFlags & (OFFSET_BY_ORIGIN|BASIS_AT_ORIGIN)) != (OFFSET_BY_ORIGIN|BASIS_AT_ORIGIN),
"Can't specify offset by origin as well as basis at origin!");
if (aOutAncestor) {
*aOutAncestor = nsLayoutUtils::GetCrossDocParentFrame(frame);
@ -5380,6 +5382,10 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
}
}
if (aFlags & BASIS_AT_ORIGIN) {
result.ChangeBasis(roundedOrigin);
}
if ((aFlags & INCLUDE_PRESERVE3D_ANCESTORS) &&
frame && frame->Combines3DTransformWithAncestors()) {
// Include the transform set on our parent
@ -5398,6 +5404,8 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
uint32_t flags = aFlags & (INCLUDE_PRESERVE3D_ANCESTORS|INCLUDE_PERSPECTIVE);
if (!frame->IsTransformed()) {
flags |= OFFSET_BY_ORIGIN;
} else {
flags |= BASIS_AT_ORIGIN;
}
Matrix4x4 parent =
GetResultingTransformMatrixInternal(props,
@ -5542,15 +5550,13 @@ nsDisplayTransform::GetTransform()
mTransform = mTransformGetter(mFrame, scale);
mTransform.ChangeBasis(newOrigin.x, newOrigin.y, newOrigin.z);
} else if (!mIsTransformSeparator) {
bool isReference =
DebugOnly<bool> isReference =
mFrame->IsTransformed() ||
mFrame->Combines3DTransformWithAncestors() || mFrame->Extend3DContext();
uint32_t flags = INCLUDE_PERSPECTIVE;
if (isReference) {
flags |= OFFSET_BY_ORIGIN;
}
mTransform = GetResultingTransformMatrix(mFrame, ToReferenceFrame(),
scale, flags);
MOZ_ASSERT(isReference);
mTransform =
GetResultingTransformMatrix(mFrame, ToReferenceFrame(),
scale, INCLUDE_PERSPECTIVE|OFFSET_BY_ORIGIN);
}
}
return mTransform;
@ -6022,7 +6028,7 @@ nsRect nsDisplayTransform::TransformRect(const nsRect &aUntransformedBounds,
float factor = aFrame->PresContext()->AppUnitsPerDevPixel();
uint32_t flags = INCLUDE_PERSPECTIVE;
uint32_t flags = INCLUDE_PERSPECTIVE|BASIS_AT_ORIGIN;
if (aPreserves3D) {
flags |= INCLUDE_PRESERVE3D_ANCESTORS;
}
@ -6043,7 +6049,7 @@ bool nsDisplayTransform::UntransformRect(const nsRect &aTransformedBounds,
float factor = aFrame->PresContext()->AppUnitsPerDevPixel();
uint32_t flags = INCLUDE_PERSPECTIVE;
uint32_t flags = INCLUDE_PERSPECTIVE|BASIS_AT_ORIGIN;
if (aPreserves3D) {
flags |= INCLUDE_PRESERVE3D_ANCESTORS;
}
@ -6101,6 +6107,18 @@ void
nsDisplayTransform::WriteDebugInfo(std::stringstream& aStream)
{
AppendToString(aStream, GetTransform());
if (IsTransformSeparator()) {
aStream << " transform-separator";
}
if (IsLeafOf3DContext()) {
aStream << " 3d-context-leaf";
}
if (mFrame->Extend3DContext()) {
aStream << " extends-3d-context";
}
if (mFrame->Combines3DTransformWithAncestors()) {
aStream << " combines-3d-with-ancestors";
}
}
nsDisplayPerspective::nsDisplayPerspective(nsDisplayListBuilder* aBuilder,
@ -6111,7 +6129,10 @@ nsDisplayPerspective::nsDisplayPerspective(nsDisplayListBuilder* aBuilder,
, mList(aBuilder, aPerspectiveFrame, aList)
, mTransformFrame(aTransformFrame)
, mIndex(aBuilder->AllocatePerspectiveItemIndex())
{}
{
MOZ_ASSERT(mList.GetChildren()->Count() == 1);
MOZ_ASSERT(mList.GetChildren()->GetTop()->GetType() == TYPE_TRANSFORM);
}
already_AddRefed<Layer>
nsDisplayPerspective::BuildLayer(nsDisplayListBuilder *aBuilder,

View File

@ -4016,6 +4016,9 @@ public:
* specify a value.
* @param aFlags OFFSET_BY_ORIGIN The resulting matrix will be translated
* by aOrigin. This translation is applied *before* the CSS transform.
* @param aFlags BASIS_AT_ORIGIN The resulting matrix will have its basis
* changed to be at aOrigin. This is mutually exclusive with
* OFFSET_BY_ORIGIN.
* @param aFlags INCLUDE_PRESERVE3D_ANCESTORS The computed transform will
* include the transform of any ancestors participating in the same
* 3d rendering context.
@ -4024,8 +4027,9 @@ public:
*/
enum {
OFFSET_BY_ORIGIN = 1 << 0,
INCLUDE_PRESERVE3D_ANCESTORS = 1 << 1,
INCLUDE_PERSPECTIVE = 1 << 2,
BASIS_AT_ORIGIN = 1 << 1,
INCLUDE_PRESERVE3D_ANCESTORS = 1 << 2,
INCLUDE_PERSPECTIVE = 1 << 3,
};
static Matrix4x4 GetResultingTransformMatrix(const nsIFrame* aFrame,
const nsPoint& aOrigin,
@ -4210,7 +4214,7 @@ public:
virtual bool ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder) override
{
return mList.ShouldBuildLayerEvenIfInvisible(aBuilder);
return mList.GetChildren()->GetTop()->ShouldBuildLayerEvenIfInvisible(aBuilder);
}
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,

View File

@ -866,11 +866,15 @@ nsIFrame*
GetScrollFrameFromContent(nsIContent* aContent)
{
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame && aContent->OwnerDoc()->GetRootElement() == aContent) {
if (aContent->OwnerDoc()->GetRootElement() == aContent) {
nsIPresShell* presShell = frame ? frame->PresContext()->PresShell() : nullptr;
if (!presShell) {
presShell = aContent->OwnerDoc()->GetShell();
}
// We want the scroll frame, the root scroll frame differs from all
// others in that the primary frame is not the scroll frame.
if (nsIFrame* rootScrollFrame =
frame->PresContext()->PresShell()->GetRootScrollFrame()) {
nsIFrame* rootScrollFrame = presShell ? presShell->GetRootScrollFrame() : nullptr;
if (rootScrollFrame) {
frame = rootScrollFrame;
}
}

View File

@ -30,6 +30,7 @@
#include "mozilla/ToString.h"
#include "nsHTMLReflowMetrics.h"
#include "ImageContainer.h"
#include "gfx2DGlue.h"
#include <limits>
#include <algorithm>

View File

@ -5081,7 +5081,8 @@ nsIFrame::GetTransformMatrix(const nsIFrame* aStopAtAncestor,
int32_t scaleFactor = PresContext()->AppUnitsPerDevPixel();
Matrix4x4 result = nsDisplayTransform::GetResultingTransformMatrix(this,
nsPoint(0, 0), scaleFactor, nsDisplayTransform::INCLUDE_PERSPECTIVE,
nsPoint(0, 0), scaleFactor,
nsDisplayTransform::INCLUDE_PERSPECTIVE|nsDisplayTransform::BASIS_AT_ORIGIN,
nullptr, aOutAncestor);
// XXXjwatt: seems like this will double count offsets in the face of preserve-3d:
nsPoint delta = GetOffsetToCrossDoc(*aOutAncestor);

View File

@ -0,0 +1,12 @@
<html>
<head>
</head>
<body>
<div style="perspective:100px;">
<div style="transform-style: preserve-3d">
<div style="width:100px; height:100px; background-color:red; transform: rotatex(1deg);">
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,12 @@
<html>
<head>
</head>
<body>
<div style="perspective:100px; transform-style: preserve-3d;">
<div style="transform-style: preserve-3d">
<div style="width:100px; height:100px; background-color:red; transform: rotatex(1deg);">
</div>
</div>
</div>
</body>
</html>

View File

@ -21,6 +21,7 @@ fuzzy-if(gtkWidget||winWidget,8,376) fuzzy-if(Android,8,441) fuzzy-if(cocoaWidge
== preserve3d-3a.html preserve3d-3-ref.html
skip-if(B2G||Mulet) == preserve3d-4a.html green-rect.html # Initial mulet triage: parity with B2G/B2G Desktop
fuzzy-if(gtkWidget,4,200) fuzzy-if(Android&&AndroidVersion>=15,4,300) fuzzy-if(winWidget&&!layersGPUAccelerated,2,100) == preserve3d-5a.html preserve3d-5-ref.html
== preserve3d-6a.html preserve3d-6-ref.html
== scale3d-z.html scalez-1-ref.html
fuzzy-if(winWidget,102,580) fuzzy-if(d2d,143,681) fuzzy-if(OSX>=1008,224,924) == scale3d-all.html scale3d-1-ref.html # subpixel AA
fuzzy-if(winWidget,102,580) fuzzy-if(d2d,143,681) fuzzy-if(OSX>=1008,224,924) == scale3d-all-separate.html scale3d-1-ref.html # subpixel AA

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -283,7 +284,8 @@ AppendCSSShadowValue(const nsCSSShadowItem *aShadow,
// Like nsStyleCoord::CalcValue, but with length in float pixels instead
// of nscoord.
struct PixelCalcValue {
struct PixelCalcValue
{
float mLength, mPercent;
bool mHasPercent;
};
@ -3858,11 +3860,11 @@ void
StyleAnimationValue::SetAndAdoptCSSValueTripletValue(
nsCSSValueTriplet *aValueTriplet, Unit aUnit)
{
FreeValue();
MOZ_ASSERT(IsCSSValueTripletUnit(aUnit), "bad unit");
MOZ_ASSERT(aValueTriplet != nullptr, "value pairs may not be null");
mUnit = aUnit;
mValue.mCSSValueTriplet = aValueTriplet; // take ownership
FreeValue();
MOZ_ASSERT(IsCSSValueTripletUnit(aUnit), "bad unit");
MOZ_ASSERT(aValueTriplet != nullptr, "value pairs may not be null");
mUnit = aUnit;
mValue.mCSSValueTriplet = aValueTriplet; // take ownership
}
void

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -33,11 +34,11 @@ using namespace mozilla::css;
static bool
MoveValue(nsCSSValue* aSource, nsCSSValue* aDest)
{
bool changed = (*aSource != *aDest);
aDest->~nsCSSValue();
memcpy(aDest, aSource, sizeof(nsCSSValue));
new (aSource) nsCSSValue();
return changed;
bool changed = (*aSource != *aDest);
aDest->~nsCSSValue();
memcpy(aDest, aSource, sizeof(nsCSSValue));
new (aSource) nsCSSValue();
return changed;
}
/**
@ -87,9 +88,9 @@ ConvertBoxOrientToFlexDirection(const nsCSSValue* aBoxOrientVal,
static bool
ShouldIgnoreColors(nsRuleData *aRuleData)
{
return aRuleData->mLevel != SheetType::Agent &&
aRuleData->mLevel != SheetType::User &&
!aRuleData->mPresContext->UseDocumentColors();
return aRuleData->mLevel != SheetType::Agent &&
aRuleData->mLevel != SheetType::User &&
!aRuleData->mPresContext->UseDocumentColors();
}
/**
@ -175,61 +176,61 @@ MapSinglePropertyInto(nsCSSProperty aSrcProp,
nsCSSValue* aTargetValue,
nsRuleData* aRuleData)
{
MOZ_ASSERT(!nsCSSProps::PropHasFlags(aTargetProp, CSS_PROPERTY_LOGICAL),
"Can't map into a logical property");
MOZ_ASSERT(aSrcProp == aTargetProp ||
nsCSSProps::PropHasFlags(aSrcProp, CSS_PROPERTY_LOGICAL),
"Source & target property must be the same, except when we're "
"doing a logical-to-physical property mapping");
MOZ_ASSERT(aSrcValue->GetUnit() != eCSSUnit_Null, "oops");
MOZ_ASSERT(!nsCSSProps::PropHasFlags(aTargetProp, CSS_PROPERTY_LOGICAL),
"Can't map into a logical property");
MOZ_ASSERT(aSrcProp == aTargetProp ||
nsCSSProps::PropHasFlags(aSrcProp, CSS_PROPERTY_LOGICAL),
"Source & target property must be the same, except when we're "
"doing a logical-to-physical property mapping");
MOZ_ASSERT(aSrcValue->GetUnit() != eCSSUnit_Null, "oops");
// Handle logical properties that have custom value-mapping behavior:
Maybe<nsCSSValue> convertedVal; // storage for converted value, if needed
bool hasCustomValMapping =
nsCSSProps::PropHasFlags(aSrcProp,
CSS_PROPERTY_LOGICAL_SINGLE_CUSTOM_VALMAPPING);
if (hasCustomValMapping) {
if (aSrcProp == eCSSProperty_webkit_box_orient) {
aSrcValue = ConvertBoxOrientToFlexDirection(aSrcValue, aRuleData,
convertedVal);
}
// Handle logical properties that have custom value-mapping behavior:
Maybe<nsCSSValue> convertedVal; // storage for converted value, if needed
bool hasCustomValMapping =
nsCSSProps::PropHasFlags(aSrcProp,
CSS_PROPERTY_LOGICAL_SINGLE_CUSTOM_VALMAPPING);
if (hasCustomValMapping) {
if (aSrcProp == eCSSProperty_webkit_box_orient) {
aSrcValue = ConvertBoxOrientToFlexDirection(aSrcValue, aRuleData,
convertedVal);
}
}
// Although aTargetValue is the nsCSSValue we are going to write into,
// we also look at its value before writing into it. This is done
// when aTargetValue is a token stream value, which is the case when we
// have just re-parsed a property that had a variable reference (in
// nsCSSParser::ParsePropertyWithVariableReferences). TryToStartImageLoad
// then records any resulting ImageValue objects in the
// CSSVariableImageTable, to give them the appropriate lifetime.
MOZ_ASSERT(aTargetValue->GetUnit() == eCSSUnit_TokenStream ||
aTargetValue->GetUnit() == eCSSUnit_Null,
"aTargetValue must only be a token stream (when re-parsing "
"properties with variable references) or null");
// Although aTargetValue is the nsCSSValue we are going to write into,
// we also look at its value before writing into it. This is done
// when aTargetValue is a token stream value, which is the case when we
// have just re-parsed a property that had a variable reference (in
// nsCSSParser::ParsePropertyWithVariableReferences). TryToStartImageLoad
// then records any resulting ImageValue objects in the
// CSSVariableImageTable, to give them the appropriate lifetime.
MOZ_ASSERT(aTargetValue->GetUnit() == eCSSUnit_TokenStream ||
aTargetValue->GetUnit() == eCSSUnit_Null,
"aTargetValue must only be a token stream (when re-parsing "
"properties with variable references) or null");
if (ShouldStartImageLoads(aRuleData, aTargetProp)) {
nsIDocument* doc = aRuleData->mPresContext->Document();
TryToStartImageLoad(*aSrcValue, doc, aRuleData->mStyleContext,
aTargetProp,
aTargetValue->GetUnit() == eCSSUnit_TokenStream);
}
*aTargetValue = *aSrcValue;
if (nsCSSProps::PropHasFlags(aTargetProp,
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED) &&
ShouldIgnoreColors(aRuleData))
{
if (aTargetProp == eCSSProperty_background_color) {
// Force non-'transparent' background
// colors to the user's default.
if (aTargetValue->IsNonTransparentColor()) {
aTargetValue->SetColorValue(aRuleData->mPresContext->
DefaultBackgroundColor());
}
} else {
// Ignore 'color', 'border-*-color', etc.
*aTargetValue = nsCSSValue();
}
if (ShouldStartImageLoads(aRuleData, aTargetProp)) {
nsIDocument* doc = aRuleData->mPresContext->Document();
TryToStartImageLoad(*aSrcValue, doc, aRuleData->mStyleContext,
aTargetProp,
aTargetValue->GetUnit() == eCSSUnit_TokenStream);
}
*aTargetValue = *aSrcValue;
if (nsCSSProps::PropHasFlags(aTargetProp,
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED) &&
ShouldIgnoreColors(aRuleData))
{
if (aTargetProp == eCSSProperty_background_color) {
// Force non-'transparent' background
// colors to the user's default.
if (aTargetValue->IsNonTransparentColor()) {
aTargetValue->SetColorValue(aRuleData->mPresContext->
DefaultBackgroundColor());
}
} else {
// Ignore 'color', 'border-*-color', etc.
*aTargetValue = nsCSSValue();
}
}
}
/**
@ -312,69 +313,69 @@ EnsurePhysicalProperty(nsCSSProperty aProperty, nsRuleData* aRuleData)
void
nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
{
// If we have no data for these structs, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(aRuleData->mSIDs & mStyleBits))
return;
// If we have no data for these structs, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(aRuleData->mSIDs & mStyleBits))
return;
// We process these in reverse order so that we end up mapping the
// right property when one can be expressed using both logical and
// physical property names.
for (uint32_t i = mNumProps; i-- > 0; ) {
nsCSSProperty iProp = PropertyAtIndex(i);
if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
aRuleData->mSIDs) {
nsCSSProperty physicalProp = EnsurePhysicalProperty(iProp,
aRuleData);
if (physicalProp != iProp) {
// We can't cache anything on the rule tree if we use any data from
// the style context, since data cached in the rule tree could be
// used with a style context with a different value.
uint8_t wm = WritingMode(aRuleData->mStyleContext).GetBits();
aRuleData->mConditions.SetWritingModeDependency(wm);
}
nsCSSValue* target = aRuleData->ValueFor(physicalProp);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtIndex(i);
// In order for variable resolution to have the right information
// about the stylesheet level of a value, that level needs to be
// stored on the token stream. We can't do that at creation time
// because the CSS parser (which creates the object) has no idea
// about the stylesheet level, so we do it here instead, where
// the rule walking will have just updated aRuleData.
if (val->GetUnit() == eCSSUnit_TokenStream) {
val->GetTokenStreamValue()->mLevel = aRuleData->mLevel;
}
MapSinglePropertyInto(iProp, val, physicalProp, target,
aRuleData);
}
// We process these in reverse order so that we end up mapping the
// right property when one can be expressed using both logical and
// physical property names.
for (uint32_t i = mNumProps; i-- > 0; ) {
nsCSSProperty iProp = PropertyAtIndex(i);
if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
aRuleData->mSIDs) {
nsCSSProperty physicalProp = EnsurePhysicalProperty(iProp,
aRuleData);
if (physicalProp != iProp) {
// We can't cache anything on the rule tree if we use any data from
// the style context, since data cached in the rule tree could be
// used with a style context with a different value.
uint8_t wm = WritingMode(aRuleData->mStyleContext).GetBits();
aRuleData->mConditions.SetWritingModeDependency(wm);
}
nsCSSValue* target = aRuleData->ValueFor(physicalProp);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtIndex(i);
// In order for variable resolution to have the right information
// about the stylesheet level of a value, that level needs to be
// stored on the token stream. We can't do that at creation time
// because the CSS parser (which creates the object) has no idea
// about the stylesheet level, so we do it here instead, where
// the rule walking will have just updated aRuleData.
if (val->GetUnit() == eCSSUnit_TokenStream) {
val->GetTokenStreamValue()->mLevel = aRuleData->mLevel;
}
MapSinglePropertyInto(iProp, val, physicalProp, target,
aRuleData);
}
}
}
}
const nsCSSValue*
nsCSSCompressedDataBlock::ValueFor(nsCSSProperty aProperty) const
{
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"Don't call for shorthands");
// If we have no data for this struct, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[aProperty]) &
mStyleBits))
return nullptr;
for (uint32_t i = 0; i < mNumProps; i++) {
if (PropertyAtIndex(i) == aProperty) {
return ValueAtIndex(i);
}
}
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"Don't call for shorthands");
// If we have no data for this struct, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[aProperty]) &
mStyleBits))
return nullptr;
for (uint32_t i = 0; i < mNumProps; i++) {
if (PropertyAtIndex(i) == aProperty) {
return ValueAtIndex(i);
}
}
return nullptr;
}
bool
@ -382,64 +383,64 @@ nsCSSCompressedDataBlock::TryReplaceValue(nsCSSProperty aProperty,
nsCSSExpandedDataBlock& aFromBlock,
bool *aChanged)
{
nsCSSValue* newValue = aFromBlock.PropertyAt(aProperty);
MOZ_ASSERT(newValue && newValue->GetUnit() != eCSSUnit_Null,
"cannot replace with empty value");
nsCSSValue* newValue = aFromBlock.PropertyAt(aProperty);
MOZ_ASSERT(newValue && newValue->GetUnit() != eCSSUnit_Null,
"cannot replace with empty value");
const nsCSSValue* oldValue = ValueFor(aProperty);
if (!oldValue) {
*aChanged = false;
return false;
}
const nsCSSValue* oldValue = ValueFor(aProperty);
if (!oldValue) {
*aChanged = false;
return false;
}
*aChanged = MoveValue(newValue, const_cast<nsCSSValue*>(oldValue));
aFromBlock.ClearPropertyBit(aProperty);
return true;
*aChanged = MoveValue(newValue, const_cast<nsCSSValue*>(oldValue));
aFromBlock.ClearPropertyBit(aProperty);
return true;
}
nsCSSCompressedDataBlock*
nsCSSCompressedDataBlock::Clone() const
{
nsAutoPtr<nsCSSCompressedDataBlock>
result(new(mNumProps) nsCSSCompressedDataBlock(mNumProps));
nsAutoPtr<nsCSSCompressedDataBlock>
result(new(mNumProps) nsCSSCompressedDataBlock(mNumProps));
result->mStyleBits = mStyleBits;
result->mStyleBits = mStyleBits;
for (uint32_t i = 0; i < mNumProps; i++) {
result->SetPropertyAtIndex(i, PropertyAtIndex(i));
result->CopyValueToIndex(i, ValueAtIndex(i));
}
for (uint32_t i = 0; i < mNumProps; i++) {
result->SetPropertyAtIndex(i, PropertyAtIndex(i));
result->CopyValueToIndex(i, ValueAtIndex(i));
}
return result.forget();
return result.forget();
}
nsCSSCompressedDataBlock::~nsCSSCompressedDataBlock()
{
for (uint32_t i = 0; i < mNumProps; i++) {
for (uint32_t i = 0; i < mNumProps; i++) {
#ifdef DEBUG
(void)PropertyAtIndex(i); // this checks the property is in range
(void)PropertyAtIndex(i); // this checks the property is in range
#endif
const nsCSSValue* val = ValueAtIndex(i);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
val->~nsCSSValue();
}
const nsCSSValue* val = ValueAtIndex(i);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
val->~nsCSSValue();
}
}
/* static */ nsCSSCompressedDataBlock*
nsCSSCompressedDataBlock::CreateEmptyBlock()
{
nsCSSCompressedDataBlock *result = new(0) nsCSSCompressedDataBlock(0);
return result;
nsCSSCompressedDataBlock *result = new(0) nsCSSCompressedDataBlock(0);
return result;
}
size_t
nsCSSCompressedDataBlock::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
for (uint32_t i = 0; i < mNumProps; i++) {
n += ValueAtIndex(i)->SizeOfExcludingThis(aMallocSizeOf);
}
return n;
size_t n = aMallocSizeOf(this);
for (uint32_t i = 0; i < mNumProps; i++) {
n += ValueAtIndex(i)->SizeOfExcludingThis(aMallocSizeOf);
}
return n;
}
bool
@ -481,84 +482,84 @@ nsCSSCompressedDataBlock::HasDefaultBorderImageRepeat() const
nsCSSExpandedDataBlock::nsCSSExpandedDataBlock()
{
AssertInitialState();
AssertInitialState();
}
nsCSSExpandedDataBlock::~nsCSSExpandedDataBlock()
{
AssertInitialState();
AssertInitialState();
}
void
nsCSSExpandedDataBlock::DoExpand(nsCSSCompressedDataBlock *aBlock,
bool aImportant)
{
/*
* Save needless copying and allocation by copying the memory
* corresponding to the stored data in the compressed block.
*/
for (uint32_t i = 0; i < aBlock->mNumProps; i++) {
nsCSSProperty iProp = aBlock->PropertyAtIndex(i);
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(!HasPropertyBit(iProp),
"compressed block has property multiple times");
SetPropertyBit(iProp);
if (aImportant)
SetImportantBit(iProp);
/*
* Save needless copying and allocation by copying the memory
* corresponding to the stored data in the compressed block.
*/
for (uint32_t i = 0; i < aBlock->mNumProps; i++) {
nsCSSProperty iProp = aBlock->PropertyAtIndex(i);
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(!HasPropertyBit(iProp),
"compressed block has property multiple times");
SetPropertyBit(iProp);
if (aImportant)
SetImportantBit(iProp);
const nsCSSValue* val = aBlock->ValueAtIndex(i);
nsCSSValue* dest = PropertyAt(iProp);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
MOZ_ASSERT(dest->GetUnit() == eCSSUnit_Null,
"expanding into non-empty block");
const nsCSSValue* val = aBlock->ValueAtIndex(i);
nsCSSValue* dest = PropertyAt(iProp);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
MOZ_ASSERT(dest->GetUnit() == eCSSUnit_Null,
"expanding into non-empty block");
#ifdef NS_BUILD_REFCNT_LOGGING
dest->~nsCSSValue();
dest->~nsCSSValue();
#endif
memcpy(dest, val, sizeof(nsCSSValue));
}
memcpy(dest, val, sizeof(nsCSSValue));
}
// Set the number of properties to zero so that we don't destroy the
// remnants of what we just copied.
aBlock->SetNumPropsToZero();
delete aBlock;
// Set the number of properties to zero so that we don't destroy the
// remnants of what we just copied.
aBlock->SetNumPropsToZero();
delete aBlock;
}
void
nsCSSExpandedDataBlock::Expand(nsCSSCompressedDataBlock *aNormalBlock,
nsCSSCompressedDataBlock *aImportantBlock)
{
MOZ_ASSERT(aNormalBlock, "unexpected null block");
AssertInitialState();
MOZ_ASSERT(aNormalBlock, "unexpected null block");
AssertInitialState();
DoExpand(aNormalBlock, false);
if (aImportantBlock) {
DoExpand(aImportantBlock, true);
}
DoExpand(aNormalBlock, false);
if (aImportantBlock) {
DoExpand(aImportantBlock, true);
}
}
void
nsCSSExpandedDataBlock::ComputeNumProps(uint32_t* aNumPropsNormal,
uint32_t* aNumPropsImportant)
{
*aNumPropsNormal = *aNumPropsImportant = 0;
for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) {
if (!mPropertiesSet.HasPropertyInChunk(iHigh))
continue;
for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) {
if (!mPropertiesSet.HasPropertyAt(iHigh, iLow))
continue;
*aNumPropsNormal = *aNumPropsImportant = 0;
for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) {
if (!mPropertiesSet.HasPropertyInChunk(iHigh))
continue;
for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) {
if (!mPropertiesSet.HasPropertyAt(iHigh, iLow))
continue;
#ifdef DEBUG
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
#endif
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(PropertyAt(iProp)->GetUnit() != eCSSUnit_Null,
"null value while computing size");
if (mPropertiesImportant.HasPropertyAt(iHigh, iLow))
(*aNumPropsImportant)++;
else
(*aNumPropsNormal)++;
}
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(PropertyAt(iProp)->GetUnit() != eCSSUnit_Null,
"null value while computing size");
if (mPropertiesImportant.HasPropertyAt(iHigh, iLow))
(*aNumPropsImportant)++;
else
(*aNumPropsNormal)++;
}
}
}
void
@ -566,110 +567,110 @@ nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSCompressedDataBlock **aImportantBlock,
const nsTArray<uint32_t>& aOrder)
{
nsAutoPtr<nsCSSCompressedDataBlock> result_normal, result_important;
uint32_t i_normal = 0, i_important = 0;
nsAutoPtr<nsCSSCompressedDataBlock> result_normal, result_important;
uint32_t i_normal = 0, i_important = 0;
uint32_t numPropsNormal, numPropsImportant;
ComputeNumProps(&numPropsNormal, &numPropsImportant);
uint32_t numPropsNormal, numPropsImportant;
ComputeNumProps(&numPropsNormal, &numPropsImportant);
result_normal =
new(numPropsNormal) nsCSSCompressedDataBlock(numPropsNormal);
result_normal =
new(numPropsNormal) nsCSSCompressedDataBlock(numPropsNormal);
if (numPropsImportant != 0) {
result_important =
new(numPropsImportant) nsCSSCompressedDataBlock(numPropsImportant);
} else {
result_important = nullptr;
if (numPropsImportant != 0) {
result_important =
new(numPropsImportant) nsCSSCompressedDataBlock(numPropsImportant);
} else {
result_important = nullptr;
}
/*
* Save needless copying and allocation by copying the memory
* corresponding to the stored data in the expanded block, and then
* clearing the data in the expanded block.
*/
for (size_t i = 0; i < aOrder.Length(); i++) {
nsCSSProperty iProp = static_cast<nsCSSProperty>(aOrder[i]);
if (iProp >= eCSSProperty_COUNT) {
// a custom property
continue;
}
MOZ_ASSERT(mPropertiesSet.HasProperty(iProp),
"aOrder identifies a property not in the expanded "
"data block");
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
bool important = mPropertiesImportant.HasProperty(iProp);
nsCSSCompressedDataBlock *result =
important ? result_important : result_normal;
uint32_t* ip = important ? &i_important : &i_normal;
nsCSSValue* val = PropertyAt(iProp);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null,
"Null value while compressing");
result->SetPropertyAtIndex(*ip, iProp);
result->RawCopyValueToIndex(*ip, val);
new (val) nsCSSValue();
(*ip)++;
result->mStyleBits |=
nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]);
}
/*
* Save needless copying and allocation by copying the memory
* corresponding to the stored data in the expanded block, and then
* clearing the data in the expanded block.
*/
for (size_t i = 0; i < aOrder.Length(); i++) {
nsCSSProperty iProp = static_cast<nsCSSProperty>(aOrder[i]);
if (iProp >= eCSSProperty_COUNT) {
// a custom property
continue;
}
MOZ_ASSERT(mPropertiesSet.HasProperty(iProp),
"aOrder identifies a property not in the expanded "
"data block");
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
bool important = mPropertiesImportant.HasProperty(iProp);
nsCSSCompressedDataBlock *result =
important ? result_important : result_normal;
uint32_t* ip = important ? &i_important : &i_normal;
nsCSSValue* val = PropertyAt(iProp);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null,
"Null value while compressing");
result->SetPropertyAtIndex(*ip, iProp);
result->RawCopyValueToIndex(*ip, val);
new (val) nsCSSValue();
(*ip)++;
result->mStyleBits |=
nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]);
}
MOZ_ASSERT(numPropsNormal == i_normal, "bad numProps");
MOZ_ASSERT(numPropsNormal == i_normal, "bad numProps");
if (result_important) {
MOZ_ASSERT(numPropsImportant == i_important, "bad numProps");
}
if (result_important) {
MOZ_ASSERT(numPropsImportant == i_important, "bad numProps");
}
#ifdef DEBUG
{
// assert that we didn't have any other properties on this expanded data
// block that we didn't find in aOrder
uint32_t numPropsInSet = 0;
for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; iHigh++) {
if (!mPropertiesSet.HasPropertyInChunk(iHigh)) {
continue;
}
for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; iLow++) {
if (mPropertiesSet.HasPropertyAt(iHigh, iLow)) {
numPropsInSet++;
}
}
{
// assert that we didn't have any other properties on this expanded data
// block that we didn't find in aOrder
uint32_t numPropsInSet = 0;
for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; iHigh++) {
if (!mPropertiesSet.HasPropertyInChunk(iHigh)) {
continue;
}
for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; iLow++) {
if (mPropertiesSet.HasPropertyAt(iHigh, iLow)) {
numPropsInSet++;
}
}
MOZ_ASSERT(numPropsNormal + numPropsImportant == numPropsInSet,
"aOrder missing properties from the expanded data block");
}
MOZ_ASSERT(numPropsNormal + numPropsImportant == numPropsInSet,
"aOrder missing properties from the expanded data block");
}
#endif
ClearSets();
AssertInitialState();
*aNormalBlock = result_normal.forget();
*aImportantBlock = result_important.forget();
ClearSets();
AssertInitialState();
*aNormalBlock = result_normal.forget();
*aImportantBlock = result_important.forget();
}
void
nsCSSExpandedDataBlock::AddLonghandProperty(nsCSSProperty aProperty,
const nsCSSValue& aValue)
{
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"property out of range");
nsCSSValue& storage = *static_cast<nsCSSValue*>(PropertyAt(aProperty));
storage = aValue;
SetPropertyBit(aProperty);
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"property out of range");
nsCSSValue& storage = *static_cast<nsCSSValue*>(PropertyAt(aProperty));
storage = aValue;
SetPropertyBit(aProperty);
}
void
nsCSSExpandedDataBlock::Clear()
{
for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) {
if (!mPropertiesSet.HasPropertyInChunk(iHigh))
continue;
for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) {
if (!mPropertiesSet.HasPropertyAt(iHigh, iLow))
continue;
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
ClearLonghandProperty(iProp);
}
for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) {
if (!mPropertiesSet.HasPropertyInChunk(iHigh))
continue;
for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) {
if (!mPropertiesSet.HasPropertyAt(iHigh, iLow))
continue;
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
ClearLonghandProperty(iProp);
}
}
AssertInitialState();
AssertInitialState();
}
void
@ -688,11 +689,11 @@ nsCSSExpandedDataBlock::ClearProperty(nsCSSProperty aPropID)
void
nsCSSExpandedDataBlock::ClearLonghandProperty(nsCSSProperty aPropID)
{
MOZ_ASSERT(!nsCSSProps::IsShorthand(aPropID), "out of range");
MOZ_ASSERT(!nsCSSProps::IsShorthand(aPropID), "out of range");
ClearPropertyBit(aPropID);
ClearImportantBit(aPropID);
PropertyAt(aPropID)->Reset();
ClearPropertyBit(aPropID);
ClearImportantBit(aPropID);
PropertyAt(aPropID)->Reset();
}
bool
@ -705,26 +706,26 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
css::Declaration* aDeclaration,
nsIDocument* aSheetDocument)
{
if (!nsCSSProps::IsShorthand(aPropID)) {
return DoTransferFromBlock(aFromBlock, aPropID,
if (!nsCSSProps::IsShorthand(aPropID)) {
return DoTransferFromBlock(aFromBlock, aPropID,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
// We can pass eIgnoreEnabledState (here, and in ClearProperty above) rather
// than a value corresponding to whether we're parsing a UA style sheet or
// certified app because we assert in nsCSSProps::AddRefTable that shorthand
// properties available in these contexts also have all of their
// subproperties available in these contexts.
bool changed = false;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, aEnabledState) {
changed |= DoTransferFromBlock(aFromBlock, *p,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
// We can pass eIgnoreEnabledState (here, and in ClearProperty above) rather
// than a value corresponding to whether we're parsing a UA style sheet or
// certified app because we assert in nsCSSProps::AddRefTable that shorthand
// properties available in these contexts also have all of their
// subproperties available in these contexts.
bool changed = false;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, aEnabledState) {
changed |= DoTransferFromBlock(aFromBlock, *p,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
return changed;
}
return changed;
}
bool
@ -809,13 +810,13 @@ nsCSSExpandedDataBlock::MapRuleInfoInto(nsCSSProperty aPropID,
void
nsCSSExpandedDataBlock::DoAssertInitialState()
{
mPropertiesSet.AssertIsEmpty("not initial state");
mPropertiesImportant.AssertIsEmpty("not initial state");
mPropertiesSet.AssertIsEmpty("not initial state");
mPropertiesImportant.AssertIsEmpty("not initial state");
for (uint32_t i = 0; i < eCSSProperty_COUNT_no_shorthands; ++i) {
nsCSSProperty prop = nsCSSProperty(i);
MOZ_ASSERT(PropertyAt(prop)->GetUnit() == eCSSUnit_Null,
"not initial state");
}
for (uint32_t i = 0; i < eCSSProperty_COUNT_no_shorthands; ++i) {
nsCSSProperty prop = nsCSSProperty(i);
MOZ_ASSERT(PropertyAt(prop)->GetUnit() == eCSSUnit_Null,
"not initial state");
}
}
#endif

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -34,137 +35,138 @@ class Declaration;
* |css::Declaration|). Mutation is accomplished through
* |nsCSSExpandedDataBlock| or in some cases via direct slot access.
*/
class nsCSSCompressedDataBlock {
class nsCSSCompressedDataBlock
{
private:
friend class nsCSSExpandedDataBlock;
friend class nsCSSExpandedDataBlock;
// Only this class (via |CreateEmptyBlock|) or nsCSSExpandedDataBlock
// (in |Compress|) can create compressed data blocks.
explicit nsCSSCompressedDataBlock(uint32_t aNumProps)
: mStyleBits(0), mNumProps(aNumProps)
{}
// Only this class (via |CreateEmptyBlock|) or nsCSSExpandedDataBlock
// (in |Compress|) can create compressed data blocks.
explicit nsCSSCompressedDataBlock(uint32_t aNumProps)
: mStyleBits(0), mNumProps(aNumProps)
{}
public:
~nsCSSCompressedDataBlock();
~nsCSSCompressedDataBlock();
/**
* Do what |nsIStyleRule::MapRuleInfoInto| needs to do for a style
* rule using this block for storage.
*/
void MapRuleInfoInto(nsRuleData *aRuleData) const;
/**
* Do what |nsIStyleRule::MapRuleInfoInto| needs to do for a style
* rule using this block for storage.
*/
void MapRuleInfoInto(nsRuleData *aRuleData) const;
/**
* Return the location at which the *value* for the property is
* stored, or null if the block does not contain a value for the
* property.
*
* Inefficient (by design).
*
* Must not be called for shorthands.
*/
const nsCSSValue* ValueFor(nsCSSProperty aProperty) const;
/**
* Return the location at which the *value* for the property is
* stored, or null if the block does not contain a value for the
* property.
*
* Inefficient (by design).
*
* Must not be called for shorthands.
*/
const nsCSSValue* ValueFor(nsCSSProperty aProperty) const;
/**
* Attempt to replace the value for |aProperty| stored in this block
* with the matching value stored in |aFromBlock|.
* This method will fail (returning false) if |aProperty| is not
* already in this block. It will set |aChanged| to true if it
* actually made a change to the block, but regardless, if it
* returns true, the value in |aFromBlock| was erased.
*/
bool TryReplaceValue(nsCSSProperty aProperty,
nsCSSExpandedDataBlock& aFromBlock,
bool* aChanged);
/**
* Attempt to replace the value for |aProperty| stored in this block
* with the matching value stored in |aFromBlock|.
* This method will fail (returning false) if |aProperty| is not
* already in this block. It will set |aChanged| to true if it
* actually made a change to the block, but regardless, if it
* returns true, the value in |aFromBlock| was erased.
*/
bool TryReplaceValue(nsCSSProperty aProperty,
nsCSSExpandedDataBlock& aFromBlock,
bool* aChanged);
/**
* Clone this block, or return null on out-of-memory.
*/
nsCSSCompressedDataBlock* Clone() const;
/**
* Clone this block, or return null on out-of-memory.
*/
nsCSSCompressedDataBlock* Clone() const;
/**
* Create a new nsCSSCompressedDataBlock holding no declarations.
*/
static nsCSSCompressedDataBlock* CreateEmptyBlock();
/**
* Create a new nsCSSCompressedDataBlock holding no declarations.
*/
static nsCSSCompressedDataBlock* CreateEmptyBlock();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool HasDefaultBorderImageSlice() const;
bool HasDefaultBorderImageWidth() const;
bool HasDefaultBorderImageOutset() const;
bool HasDefaultBorderImageRepeat() const;
bool HasDefaultBorderImageSlice() const;
bool HasDefaultBorderImageWidth() const;
bool HasDefaultBorderImageOutset() const;
bool HasDefaultBorderImageRepeat() const;
bool HasInheritedStyleData() const
{
return mStyleBits & NS_STYLE_INHERITED_STRUCT_MASK;
}
bool HasInheritedStyleData() const
{
return mStyleBits & NS_STYLE_INHERITED_STRUCT_MASK;
}
private:
void* operator new(size_t aBaseSize, uint32_t aNumProps) {
MOZ_ASSERT(aBaseSize == sizeof(nsCSSCompressedDataBlock),
"unexpected size for nsCSSCompressedDataBlock");
return ::operator new(aBaseSize + DataSize(aNumProps));
}
void* operator new(size_t aBaseSize, uint32_t aNumProps) {
MOZ_ASSERT(aBaseSize == sizeof(nsCSSCompressedDataBlock),
"unexpected size for nsCSSCompressedDataBlock");
return ::operator new(aBaseSize + DataSize(aNumProps));
}
public:
// Ideally, |nsCSSProperty| would be |enum nsCSSProperty : int16_t|. But
// not all of the compilers we use are modern enough to support small
// enums. So we manually squeeze nsCSSProperty into 16 bits ourselves.
// The static assertion below ensures it fits.
typedef int16_t CompressedCSSProperty;
static const size_t MaxCompressedCSSProperty = INT16_MAX;
// Ideally, |nsCSSProperty| would be |enum nsCSSProperty : int16_t|. But
// not all of the compilers we use are modern enough to support small
// enums. So we manually squeeze nsCSSProperty into 16 bits ourselves.
// The static assertion below ensures it fits.
typedef int16_t CompressedCSSProperty;
static const size_t MaxCompressedCSSProperty = INT16_MAX;
private:
static size_t DataSize(uint32_t aNumProps) {
return size_t(aNumProps) *
(sizeof(nsCSSValue) + sizeof(CompressedCSSProperty));
}
static size_t DataSize(uint32_t aNumProps) {
return size_t(aNumProps) *
(sizeof(nsCSSValue) + sizeof(CompressedCSSProperty));
}
int32_t mStyleBits; // the structs for which we have data, according to
// |nsCachedStyleData::GetBitForSID|.
uint32_t mNumProps;
// nsCSSValue elements are stored after these fields, and
// nsCSSProperty elements are stored -- each one compressed as a
// CompressedCSSProperty -- after the nsCSSValue elements. Space for them
// is allocated in |operator new| above. The static assertions following
// this class make sure that the value and property elements are aligned
// appropriately.
int32_t mStyleBits; // the structs for which we have data, according to
// |nsCachedStyleData::GetBitForSID|.
uint32_t mNumProps;
// nsCSSValue elements are stored after these fields, and
// nsCSSProperty elements are stored -- each one compressed as a
// CompressedCSSProperty -- after the nsCSSValue elements. Space for them
// is allocated in |operator new| above. The static assertions following
// this class make sure that the value and property elements are aligned
// appropriately.
nsCSSValue* Values() const {
return (nsCSSValue*)(this + 1);
}
nsCSSValue* Values() const {
return (nsCSSValue*)(this + 1);
}
CompressedCSSProperty* CompressedProperties() const {
return (CompressedCSSProperty*)(Values() + mNumProps);
}
CompressedCSSProperty* CompressedProperties() const {
return (CompressedCSSProperty*)(Values() + mNumProps);
}
nsCSSValue* ValueAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "value index out of range");
return Values() + i;
}
nsCSSValue* ValueAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "value index out of range");
return Values() + i;
}
nsCSSProperty PropertyAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "property index out of range");
nsCSSProperty prop = (nsCSSProperty)CompressedProperties()[i];
MOZ_ASSERT(!nsCSSProps::IsShorthand(prop), "out of range");
return prop;
}
nsCSSProperty PropertyAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "property index out of range");
nsCSSProperty prop = (nsCSSProperty)CompressedProperties()[i];
MOZ_ASSERT(!nsCSSProps::IsShorthand(prop), "out of range");
return prop;
}
void CopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
new (ValueAtIndex(i)) nsCSSValue(*aValue);
}
void CopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
new (ValueAtIndex(i)) nsCSSValue(*aValue);
}
void RawCopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
memcpy(ValueAtIndex(i), aValue, sizeof(nsCSSValue));
}
void RawCopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
memcpy(ValueAtIndex(i), aValue, sizeof(nsCSSValue));
}
void SetPropertyAtIndex(uint32_t i, nsCSSProperty aProperty) {
MOZ_ASSERT(i < mNumProps, "set property index out of range");
CompressedProperties()[i] = (CompressedCSSProperty)aProperty;
}
void SetPropertyAtIndex(uint32_t i, nsCSSProperty aProperty) {
MOZ_ASSERT(i < mNumProps, "set property index out of range");
CompressedProperties()[i] = (CompressedCSSProperty)aProperty;
}
void SetNumPropsToZero() {
mNumProps = 0;
}
void SetNumPropsToZero() {
mNumProps = 0;
}
};
// Make sure the values and properties are aligned appropriately. (These
@ -172,198 +174,199 @@ private:
static_assert(sizeof(nsCSSCompressedDataBlock) == 8,
"nsCSSCompressedDataBlock's size has changed");
static_assert(NS_ALIGNMENT_OF(nsCSSValue) == 4 || NS_ALIGNMENT_OF(nsCSSValue) == 8,
"nsCSSValue doesn't align with nsCSSCompressedDataBlock");
"nsCSSValue doesn't align with nsCSSCompressedDataBlock");
static_assert(NS_ALIGNMENT_OF(nsCSSCompressedDataBlock::CompressedCSSProperty) == 2,
"CompressedCSSProperty doesn't align with nsCSSValue");
"CompressedCSSProperty doesn't align with nsCSSValue");
// Make sure that sizeof(CompressedCSSProperty) is big enough.
static_assert(eCSSProperty_COUNT_no_shorthands <=
nsCSSCompressedDataBlock::MaxCompressedCSSProperty,
"nsCSSProperty doesn't fit in StoredSizeOfCSSProperty");
class nsCSSExpandedDataBlock {
friend class nsCSSCompressedDataBlock;
class nsCSSExpandedDataBlock
{
friend class nsCSSCompressedDataBlock;
public:
nsCSSExpandedDataBlock();
~nsCSSExpandedDataBlock();
nsCSSExpandedDataBlock();
~nsCSSExpandedDataBlock();
private:
/* Property storage may not be accessed directly; use AddLonghandProperty
* and friends.
*/
nsCSSValue mValues[eCSSProperty_COUNT_no_shorthands];
/* Property storage may not be accessed directly; use AddLonghandProperty
* and friends.
*/
nsCSSValue mValues[eCSSProperty_COUNT_no_shorthands];
public:
/**
* Transfer all of the state from a pair of compressed data blocks
* to this expanded block. This expanded block must be clear
* beforehand.
*
* This method DELETES both of the compressed data blocks it is
* passed. (This is necessary because ownership of sub-objects
* is transferred to the expanded block.)
*/
void Expand(nsCSSCompressedDataBlock *aNormalBlock,
nsCSSCompressedDataBlock *aImportantBlock);
/**
* Transfer all of the state from a pair of compressed data blocks
* to this expanded block. This expanded block must be clear
* beforehand.
*
* This method DELETES both of the compressed data blocks it is
* passed. (This is necessary because ownership of sub-objects
* is transferred to the expanded block.)
*/
void Expand(nsCSSCompressedDataBlock *aNormalBlock,
nsCSSCompressedDataBlock *aImportantBlock);
/**
* Allocate new compressed blocks and transfer all of the state
* from this expanded block to the new blocks, clearing this
* expanded block. A normal block will always be allocated, but
* an important block will only be allocated if there are
* !important properties in the expanded block; otherwise
* |*aImportantBlock| will be set to null.
*
* aOrder is an array of nsCSSProperty values specifying the order
* to store values in the two data blocks.
*/
void Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSCompressedDataBlock **aImportantBlock,
const nsTArray<uint32_t>& aOrder);
/**
* Allocate new compressed blocks and transfer all of the state
* from this expanded block to the new blocks, clearing this
* expanded block. A normal block will always be allocated, but
* an important block will only be allocated if there are
* !important properties in the expanded block; otherwise
* |*aImportantBlock| will be set to null.
*
* aOrder is an array of nsCSSProperty values specifying the order
* to store values in the two data blocks.
*/
void Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSCompressedDataBlock **aImportantBlock,
const nsTArray<uint32_t>& aOrder);
/**
* Copy a value into this expanded block. This does NOT destroy
* the source value object. |aProperty| cannot be a shorthand.
*/
void AddLonghandProperty(nsCSSProperty aProperty, const nsCSSValue& aValue);
/**
* Copy a value into this expanded block. This does NOT destroy
* the source value object. |aProperty| cannot be a shorthand.
*/
void AddLonghandProperty(nsCSSProperty aProperty, const nsCSSValue& aValue);
/**
* Clear the state of this expanded block.
*/
void Clear();
/**
* Clear the state of this expanded block.
*/
void Clear();
/**
* Clear the data for the given property (including the set and
* important bits). Can be used with shorthand properties.
*/
void ClearProperty(nsCSSProperty aPropID);
/**
* Clear the data for the given property (including the set and
* important bits). Can be used with shorthand properties.
*/
void ClearProperty(nsCSSProperty aPropID);
/**
* Same as ClearProperty, but faster and cannot be used with shorthands.
*/
void ClearLonghandProperty(nsCSSProperty aPropID);
/**
* Same as ClearProperty, but faster and cannot be used with shorthands.
*/
void ClearLonghandProperty(nsCSSProperty aPropID);
/**
* Transfer the state for |aPropID| (which may be a shorthand)
* from |aFromBlock| to this block. The property being transferred
* is !important if |aIsImportant| is true, and should replace an
* existing !important property regardless of its own importance
* if |aOverrideImportant| is true. |aEnabledState| is used to
* determine which longhand components of |aPropID| (if it is a
* shorthand) to transfer.
*
* Returns true if something changed, false otherwise. Calls
* |ValueAppended| on |aDeclaration| if the property was not
* previously set, or in any case if |aMustCallValueAppended| is true.
* Calls |SetDocumentAndPageUseCounter| on |aSheetDocument| if it is
* non-null and |aPropID| has a use counter.
*/
bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
nsCSSProps::EnabledState aEnabledState,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
/**
* Transfer the state for |aPropID| (which may be a shorthand)
* from |aFromBlock| to this block. The property being transferred
* is !important if |aIsImportant| is true, and should replace an
* existing !important property regardless of its own importance
* if |aOverrideImportant| is true. |aEnabledState| is used to
* determine which longhand components of |aPropID| (if it is a
* shorthand) to transfer.
*
* Returns true if something changed, false otherwise. Calls
* |ValueAppended| on |aDeclaration| if the property was not
* previously set, or in any case if |aMustCallValueAppended| is true.
* Calls |SetDocumentAndPageUseCounter| on |aSheetDocument| if it is
* non-null and |aPropID| has a use counter.
*/
bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
nsCSSProps::EnabledState aEnabledState,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
/**
* Copies the values for aPropID into the specified aRuleData object.
*
* This is used for copying parsed-at-computed-value-time properties
* that had variable references. aPropID must be a longhand property.
*/
void MapRuleInfoInto(nsCSSProperty aPropID, nsRuleData* aRuleData) const;
/**
* Copies the values for aPropID into the specified aRuleData object.
*
* This is used for copying parsed-at-computed-value-time properties
* that had variable references. aPropID must be a longhand property.
*/
void MapRuleInfoInto(nsCSSProperty aPropID, nsRuleData* aRuleData) const;
void AssertInitialState() {
void AssertInitialState() {
#ifdef DEBUG
DoAssertInitialState();
DoAssertInitialState();
#endif
}
}
private:
/**
* Compute the number of properties that will be present in the
* result of |Compress|.
*/
void ComputeNumProps(uint32_t* aNumPropsNormal,
uint32_t* aNumPropsImportant);
void DoExpand(nsCSSCompressedDataBlock *aBlock, bool aImportant);
/**
* Compute the number of properties that will be present in the
* result of |Compress|.
*/
void ComputeNumProps(uint32_t* aNumPropsNormal,
uint32_t* aNumPropsImportant);
/**
* Worker for TransferFromBlock; cannot be used with shorthands.
*/
bool DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
void DoExpand(nsCSSCompressedDataBlock *aBlock, bool aImportant);
/**
* Worker for TransferFromBlock; cannot be used with shorthands.
*/
bool DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
#ifdef DEBUG
void DoAssertInitialState();
void DoAssertInitialState();
#endif
/*
* mPropertiesSet stores a bit for every property that is present,
* to optimize compression of blocks with small numbers of
* properties (the norm) and to allow quickly checking whether a
* property is set in this block.
*/
nsCSSPropertySet mPropertiesSet;
/*
* mPropertiesImportant indicates which properties are '!important'.
*/
nsCSSPropertySet mPropertiesImportant;
/*
* mPropertiesSet stores a bit for every property that is present,
* to optimize compression of blocks with small numbers of
* properties (the norm) and to allow quickly checking whether a
* property is set in this block.
*/
nsCSSPropertySet mPropertiesSet;
/*
* mPropertiesImportant indicates which properties are '!important'.
*/
nsCSSPropertySet mPropertiesImportant;
/*
* Return the storage location within |this| of the value of the
* property |aProperty|.
*/
nsCSSValue* PropertyAt(nsCSSProperty aProperty) {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
const nsCSSValue* PropertyAt(nsCSSProperty aProperty) const {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
/*
* Return the storage location within |this| of the value of the
* property |aProperty|.
*/
nsCSSValue* PropertyAt(nsCSSProperty aProperty) {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
const nsCSSValue* PropertyAt(nsCSSProperty aProperty) const {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
void SetPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.AddProperty(aProperty);
}
void SetPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.AddProperty(aProperty);
}
void ClearPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.RemoveProperty(aProperty);
}
void ClearPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.RemoveProperty(aProperty);
}
bool HasPropertyBit(nsCSSProperty aProperty) {
return mPropertiesSet.HasProperty(aProperty);
}
bool HasPropertyBit(nsCSSProperty aProperty) {
return mPropertiesSet.HasProperty(aProperty);
}
void SetImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.AddProperty(aProperty);
}
void SetImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.AddProperty(aProperty);
}
void ClearImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.RemoveProperty(aProperty);
}
void ClearImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.RemoveProperty(aProperty);
}
bool HasImportantBit(nsCSSProperty aProperty) {
return mPropertiesImportant.HasProperty(aProperty);
}
bool HasImportantBit(nsCSSProperty aProperty) {
return mPropertiesImportant.HasProperty(aProperty);
}
void ClearSets() {
mPropertiesSet.Empty();
mPropertiesImportant.Empty();
}
void ClearSets() {
mPropertiesSet.Empty();
mPropertiesImportant.Empty();
}
};
#endif /* !defined(nsCSSDataBlock_h__) */

View File

@ -542,48 +542,48 @@ void nsCSSValue::SetPairValue(const nsCSSValue& xValue,
void nsCSSValue::SetTripletValue(const nsCSSValueTriplet* aValue)
{
// triplet should not be used for null/inherit/initial values
MOZ_ASSERT(aValue &&
aValue->mXValue.GetUnit() != eCSSUnit_Null &&
aValue->mYValue.GetUnit() != eCSSUnit_Null &&
aValue->mZValue.GetUnit() != eCSSUnit_Null &&
aValue->mXValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mYValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mZValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
aValue->mZValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
aValue->mZValue.GetUnit() != eCSSUnit_Unset,
"missing or inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(aValue->mXValue, aValue->mYValue, aValue->mZValue);
mValue.mTriplet->AddRef();
// triplet should not be used for null/inherit/initial values
MOZ_ASSERT(aValue &&
aValue->mXValue.GetUnit() != eCSSUnit_Null &&
aValue->mYValue.GetUnit() != eCSSUnit_Null &&
aValue->mZValue.GetUnit() != eCSSUnit_Null &&
aValue->mXValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mYValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mZValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
aValue->mZValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
aValue->mZValue.GetUnit() != eCSSUnit_Unset,
"missing or inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(aValue->mXValue, aValue->mYValue, aValue->mZValue);
mValue.mTriplet->AddRef();
}
void nsCSSValue::SetTripletValue(const nsCSSValue& xValue,
const nsCSSValue& yValue,
const nsCSSValue& zValue)
{
// Only allow Null for the z component
MOZ_ASSERT(xValue.GetUnit() != eCSSUnit_Null &&
yValue.GetUnit() != eCSSUnit_Null &&
xValue.GetUnit() != eCSSUnit_Inherit &&
yValue.GetUnit() != eCSSUnit_Inherit &&
zValue.GetUnit() != eCSSUnit_Inherit &&
xValue.GetUnit() != eCSSUnit_Initial &&
yValue.GetUnit() != eCSSUnit_Initial &&
zValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset &&
zValue.GetUnit() != eCSSUnit_Unset,
"inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(xValue, yValue, zValue);
mValue.mTriplet->AddRef();
// Only allow Null for the z component
MOZ_ASSERT(xValue.GetUnit() != eCSSUnit_Null &&
yValue.GetUnit() != eCSSUnit_Null &&
xValue.GetUnit() != eCSSUnit_Inherit &&
yValue.GetUnit() != eCSSUnit_Inherit &&
zValue.GetUnit() != eCSSUnit_Inherit &&
xValue.GetUnit() != eCSSUnit_Initial &&
yValue.GetUnit() != eCSSUnit_Initial &&
zValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset &&
zValue.GetUnit() != eCSSUnit_Unset,
"inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(xValue, yValue, zValue);
mValue.mTriplet->AddRef();
}
nsCSSRect& nsCSSValue::SetRectValue()
@ -1975,9 +1975,9 @@ nsCSSValueList::Clone() const
void
nsCSSValueList::CloneInto(nsCSSValueList* aList) const
{
NS_ASSERTION(!aList->mNext, "Must be an empty list!");
aList->mValue = mValue;
aList->mNext = mNext ? mNext->Clone() : nullptr;
NS_ASSERTION(!aList->mNext, "Must be an empty list!");
aList->mValue = mValue;
aList->mNext = mNext ? mNext->Clone() : nullptr;
}
static void
@ -2304,15 +2304,15 @@ nsCSSValueTriplet::AppendToString(nsCSSProperty aProperty,
nsAString& aResult,
nsCSSValue::Serialization aSerialization) const
{
mXValue.AppendToString(aProperty, aResult, aSerialization);
if (mYValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mYValue.AppendToString(aProperty, aResult, aSerialization);
if (mZValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mZValue.AppendToString(aProperty, aResult, aSerialization);
}
mXValue.AppendToString(aProperty, aResult, aSerialization);
if (mYValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mYValue.AppendToString(aProperty, aResult, aSerialization);
if (mZValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mZValue.AppendToString(aProperty, aResult, aSerialization);
}
}
}
size_t

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set tw=78 expandtab softtabstop=2 ts=2 sw=2: */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -1278,29 +1278,29 @@ nsComputedDOMStyle::DoGetPerspectiveOrigin()
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetPerspective()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueToCoord(val, StyleDisplay()->mChildPerspective, false);
return val.forget();
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueToCoord(val, StyleDisplay()->mChildPerspective, false);
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetBackfaceVisibility()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mBackfaceVisibility,
nsCSSProps::kBackfaceVisibilityKTable));
return val.forget();
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mBackfaceVisibility,
nsCSSProps::kBackfaceVisibilityKTable));
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetTransformStyle()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mTransformStyle,
nsCSSProps::kTransformStyleKTable));
return val.forget();
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mTransformStyle,
nsCSSProps::kTransformStyleKTable));
return val.forget();
}
/* If the property is "none", hand back "none" wrapped in a value.

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -20,64 +21,66 @@ typedef nsresult
const nsMediaFeature* aFeature,
nsCSSValue& aResult);
struct nsMediaFeature {
nsIAtom **mName; // extra indirection to point to nsGkAtoms members
struct nsMediaFeature
{
nsIAtom **mName; // extra indirection to point to nsGkAtoms members
enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed };
RangeType mRangeType;
enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed };
RangeType mRangeType;
enum ValueType {
// All value types allow eCSSUnit_Null to indicate that no value
// was given (in addition to the types listed below).
eLength, // values are such that nsCSSValue::IsLengthUnit() is true
eInteger, // values are eCSSUnit_Integer
eFloat, // values are eCSSUnit_Number
eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only)
eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer
eResolution, // values are in eCSSUnit_Inch (for dpi),
// eCSSUnit_Pixel (for dppx), or
// eCSSUnit_Centimeter (for dpcm)
eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table)
eIdent // values are eCSSUnit_Ident
// Note that a number of pieces of code (both for parsing and
// for matching of valueless expressions) assume that all numeric
// value types cannot be negative. The parsing code also does
// not allow zeros in eIntRatio types.
};
ValueType mValueType;
enum ValueType {
// All value types allow eCSSUnit_Null to indicate that no value
// was given (in addition to the types listed below).
eLength, // values are such that nsCSSValue::IsLengthUnit() is true
eInteger, // values are eCSSUnit_Integer
eFloat, // values are eCSSUnit_Number
eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only)
eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer
eResolution, // values are in eCSSUnit_Inch (for dpi),
// eCSSUnit_Pixel (for dppx), or
// eCSSUnit_Centimeter (for dpcm)
eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table)
eIdent // values are eCSSUnit_Ident
// Note that a number of pieces of code (both for parsing and
// for matching of valueless expressions) assume that all numeric
// value types cannot be negative. The parsing code also does
// not allow zeros in eIntRatio types.
};
ValueType mValueType;
enum RequirementFlags : uint8_t {
// Bitfield of requirements that must be satisfied in order for this
// media feature to be active.
eNoRequirements = 0,
eHasWebkitPrefix = 1 // Feature name must start w/ "-webkit-", even
// before any "min-"/"max-" qualifier.
};
uint8_t mReqFlags;
enum RequirementFlags : uint8_t {
// Bitfield of requirements that must be satisfied in order for this
// media feature to be active.
eNoRequirements = 0,
eHasWebkitPrefix = 1 // Feature name must start w/ "-webkit-", even
// before any "min-"/"max-" qualifier.
};
uint8_t mReqFlags;
union {
// In static arrays, it's the first member that's initialized. We
// need that to be void* so we can initialize both other types.
// This member should never be accessed by name.
const void* mInitializer_;
// If mValueType == eEnumerated: const int32_t*: keyword table in
// the same format as the keyword tables in nsCSSProps.
const nsCSSProps::KTableEntry* mKeywordTable;
// If mGetter == GetSystemMetric (which implies mValueType ==
// eBoolInteger): nsIAtom * const *, for the system metric.
nsIAtom * const * mMetric;
} mData;
union {
// In static arrays, it's the first member that's initialized. We
// need that to be void* so we can initialize both other types.
// This member should never be accessed by name.
const void* mInitializer_;
// If mValueType == eEnumerated: const int32_t*: keyword table in
// the same format as the keyword tables in nsCSSProps.
const nsCSSProps::KTableEntry* mKeywordTable;
// If mGetter == GetSystemMetric (which implies mValueType ==
// eBoolInteger): nsIAtom * const *, for the system metric.
nsIAtom * const * mMetric;
} mData;
// A function that returns the current value for this feature for a
// given presentation. If it returns eCSSUnit_Null, the feature is
// not present.
nsMediaFeatureValueGetter mGetter;
// A function that returns the current value for this feature for a
// given presentation. If it returns eCSSUnit_Null, the feature is
// not present.
nsMediaFeatureValueGetter mGetter;
};
class nsMediaFeatures {
class nsMediaFeatures
{
public:
// Terminated with an entry whose mName is null.
static const nsMediaFeature features[];
// Terminated with an entry whose mName is null.
static const nsMediaFeature features[];
};
#endif /* !defined(nsMediaFeatures_h_) */

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -526,9 +527,9 @@ nsROCSSPrimitiveValue::GetRGBColorValue(ErrorResult& aRv)
void
nsROCSSPrimitiveValue::SetNumber(float aValue)
{
Reset();
mValue.mFloat = aValue;
mType = CSS_NUMBER;
Reset();
mValue.mFloat = aValue;
mType = CSS_NUMBER;
}
void

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -820,44 +821,43 @@ nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
// --------------------
// nsStyleSVG
//
nsStyleSVG::nsStyleSVG()
nsStyleSVG::nsStyleSVG()
{
MOZ_COUNT_CTOR(nsStyleSVG);
mFill.mType = eStyleSVGPaintType_Color;
mFill.mPaint.mColor = NS_RGB(0,0,0);
mFill.mFallbackColor = NS_RGB(0,0,0);
mStroke.mType = eStyleSVGPaintType_None;
mStroke.mPaint.mColor = NS_RGB(0,0,0);
mStroke.mFallbackColor = NS_RGB(0,0,0);
mStrokeDasharray = nullptr;
MOZ_COUNT_CTOR(nsStyleSVG);
mFill.mType = eStyleSVGPaintType_Color;
mFill.mPaint.mColor = NS_RGB(0,0,0);
mFill.mFallbackColor = NS_RGB(0,0,0);
mStroke.mType = eStyleSVGPaintType_None;
mStroke.mPaint.mColor = NS_RGB(0,0,0);
mStroke.mFallbackColor = NS_RGB(0,0,0);
mStrokeDasharray = nullptr;
mStrokeDashoffset.SetCoordValue(0);
mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));
mStrokeDashoffset.SetCoordValue(0);
mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));
mFillOpacity = 1.0f;
mStrokeMiterlimit = 4.0f;
mStrokeOpacity = 1.0f;
mFillOpacity = 1.0f;
mStrokeMiterlimit = 4.0f;
mStrokeOpacity = 1.0f;
mStrokeDasharrayLength = 0;
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
mPaintOrder = NS_STYLE_PAINT_ORDER_NORMAL;
mShapeRendering = NS_STYLE_SHAPE_RENDERING_AUTO;
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
mTextAnchor = NS_STYLE_TEXT_ANCHOR_START;
mTextRendering = NS_STYLE_TEXT_RENDERING_AUTO;
mFillOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeDasharrayFromObject = false;
mStrokeDashoffsetFromObject = false;
mStrokeWidthFromObject = false;
}
nsStyleSVG::~nsStyleSVG()
mStrokeDasharrayLength = 0;
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
mPaintOrder = NS_STYLE_PAINT_ORDER_NORMAL;
mShapeRendering = NS_STYLE_SHAPE_RENDERING_AUTO;
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
mTextAnchor = NS_STYLE_TEXT_ANCHOR_START;
mTextRendering = NS_STYLE_TEXT_RENDERING_AUTO;
mFillOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeDasharrayFromObject = false;
mStrokeDashoffsetFromObject = false;
mStrokeWidthFromObject = false;
}
nsStyleSVG::~nsStyleSVG()
{
MOZ_COUNT_DTOR(nsStyleSVG);
delete [] mStrokeDasharray;
@ -1240,21 +1240,21 @@ nsStyleFilter::SetDropShadow(nsCSSShadowArray* aDropShadow)
// --------------------
// nsStyleSVGReset
//
nsStyleSVGReset::nsStyleSVGReset()
nsStyleSVGReset::nsStyleSVGReset()
{
MOZ_COUNT_CTOR(nsStyleSVGReset);
mStopColor = NS_RGB(0,0,0);
mFloodColor = NS_RGB(0,0,0);
mLightingColor = NS_RGB(255,255,255);
mMask = nullptr;
mStopOpacity = 1.0f;
mFloodOpacity = 1.0f;
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
mVectorEffect = NS_STYLE_VECTOR_EFFECT_NONE;
mMaskType = NS_STYLE_MASK_TYPE_LUMINANCE;
MOZ_COUNT_CTOR(nsStyleSVGReset);
mStopColor = NS_RGB(0,0,0);
mFloodColor = NS_RGB(0,0,0);
mLightingColor = NS_RGB(255,255,255);
mMask = nullptr;
mStopOpacity = 1.0f;
mFloodOpacity = 1.0f;
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
mVectorEffect = NS_STYLE_VECTOR_EFFECT_NONE;
mMaskType = NS_STYLE_MASK_TYPE_LUMINANCE;
}
nsStyleSVGReset::~nsStyleSVGReset()
nsStyleSVGReset::~nsStyleSVGReset()
{
MOZ_COUNT_DTOR(nsStyleSVGReset);
}

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -97,7 +98,8 @@ static_assert(int(mozilla::SheetType::Count) - 1 <=
// The lifetime of these objects is managed by the presshell's arena.
struct nsStyleFont {
struct nsStyleFont
{
nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext);
nsStyleFont(const nsStyleFont& aStyleFont);
explicit nsStyleFont(nsPresContext *aPresContext);
@ -174,7 +176,8 @@ struct nsStyleFont {
nsCOMPtr<nsIAtom> mLanguage; // [inherited]
};
struct nsStyleGradientStop {
struct nsStyleGradientStop
{
nsStyleCoord mLocation; // percent, coord, calc, none
nscolor mColor;
bool mIsInterpolationHint;
@ -184,7 +187,8 @@ struct nsStyleGradientStop {
bool operator!=(const nsStyleGradientStop&) const = delete;
};
class nsStyleGradient final {
class nsStyleGradient final
{
public:
nsStyleGradient();
uint8_t mShape; // NS_STYLE_GRADIENT_SHAPE_*
@ -239,7 +243,8 @@ enum nsStyleImageType {
* region of an image. (Currently, this feature is only supported with an
* image of type (1)).
*/
struct nsStyleImage {
struct nsStyleImage
{
nsStyleImage();
~nsStyleImage();
nsStyleImage(const nsStyleImage& aOther);
@ -360,7 +365,8 @@ private:
#endif
};
struct nsStyleColor {
struct nsStyleColor
{
explicit nsStyleColor(nsPresContext* aPresContext);
nsStyleColor(const nsStyleColor& aOther);
~nsStyleColor(void) {
@ -392,7 +398,8 @@ struct nsStyleColor {
nscolor mColor; // [inherited]
};
struct nsStyleBackground {
struct nsStyleBackground
{
nsStyleBackground();
nsStyleBackground(const nsStyleBackground& aOther);
~nsStyleBackground();
@ -629,7 +636,8 @@ struct nsStyleBackground {
#define NS_SPACING_BORDER 2
struct nsStyleMargin {
struct nsStyleMargin
{
nsStyleMargin(void);
nsStyleMargin(const nsStyleMargin& aMargin);
~nsStyleMargin(void) {
@ -673,7 +681,8 @@ protected:
};
struct nsStylePadding {
struct nsStylePadding
{
nsStylePadding(void);
nsStylePadding(const nsStylePadding& aPadding);
~nsStylePadding(void) {
@ -721,7 +730,8 @@ protected:
nsMargin mCachedPadding;
};
struct nsBorderColors {
struct nsBorderColors
{
nsBorderColors* mNext;
nscolor mColor;
@ -750,7 +760,8 @@ private:
nsBorderColors* Clone(bool aDeep) const;
};
struct nsCSSShadowItem {
struct nsCSSShadowItem
{
nscoord mXOffset;
nscoord mYOffset;
nscoord mRadius;
@ -781,74 +792,75 @@ struct nsCSSShadowItem {
}
};
class nsCSSShadowArray final {
public:
void* operator new(size_t aBaseSize, uint32_t aArrayLen) {
// We can allocate both this nsCSSShadowArray and the
// actual array in one allocation. The amount of memory to
// allocate is equal to the class's size + the number of bytes for all
// but the first array item (because aBaseSize includes one
// item, see the private declarations)
return ::operator new(aBaseSize +
(aArrayLen - 1) * sizeof(nsCSSShadowItem));
}
class nsCSSShadowArray final
{
public:
void* operator new(size_t aBaseSize, uint32_t aArrayLen) {
// We can allocate both this nsCSSShadowArray and the
// actual array in one allocation. The amount of memory to
// allocate is equal to the class's size + the number of bytes for all
// but the first array item (because aBaseSize includes one
// item, see the private declarations)
return ::operator new(aBaseSize +
(aArrayLen - 1) * sizeof(nsCSSShadowItem));
}
explicit nsCSSShadowArray(uint32_t aArrayLen) :
mLength(aArrayLen)
{
MOZ_COUNT_CTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
// Make sure we call the constructors of each nsCSSShadowItem
// (the first one is called for us because we declared it under private)
new (&mArray[i]) nsCSSShadowItem();
}
explicit nsCSSShadowArray(uint32_t aArrayLen) :
mLength(aArrayLen)
{
MOZ_COUNT_CTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
// Make sure we call the constructors of each nsCSSShadowItem
// (the first one is called for us because we declared it under private)
new (&mArray[i]) nsCSSShadowItem();
}
}
private:
// Private destructor, to discourage deletion outside of Release():
~nsCSSShadowArray() {
MOZ_COUNT_DTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
mArray[i].~nsCSSShadowItem();
}
// Private destructor, to discourage deletion outside of Release():
~nsCSSShadowArray() {
MOZ_COUNT_DTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
mArray[i].~nsCSSShadowItem();
}
}
public:
uint32_t Length() const { return mLength; }
nsCSSShadowItem* ShadowAt(uint32_t i) {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
const nsCSSShadowItem* ShadowAt(uint32_t i) const {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
uint32_t Length() const { return mLength; }
nsCSSShadowItem* ShadowAt(uint32_t i) {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
const nsCSSShadowItem* ShadowAt(uint32_t i) const {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
bool HasShadowWithInset(bool aInset) {
for (uint32_t i = 0; i < mLength; ++i) {
if (mArray[i].mInset == aInset)
return true;
}
bool HasShadowWithInset(bool aInset) {
for (uint32_t i = 0; i < mLength; ++i) {
if (mArray[i].mInset == aInset)
return true;
}
return false;
}
bool operator==(const nsCSSShadowArray& aOther) const {
if (mLength != aOther.Length())
return false;
}
bool operator==(const nsCSSShadowArray& aOther) const {
if (mLength != aOther.Length())
for (uint32_t i = 0; i < mLength; ++i) {
if (ShadowAt(i) != aOther.ShadowAt(i))
return false;
for (uint32_t i = 0; i < mLength; ++i) {
if (ShadowAt(i) != aOther.ShadowAt(i))
return false;
}
return true;
}
NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray)
return true;
}
private:
uint32_t mLength;
nsCSSShadowItem mArray[1]; // This MUST be the last item
NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray)
private:
uint32_t mLength;
nsCSSShadowItem mArray[1]; // This MUST be the last item
};
// Border widths are rounded to the nearest-below integer number of pixels,
@ -871,7 +883,8 @@ static bool IsVisibleBorderStyle(uint8_t aStyle)
aStyle != NS_STYLE_BORDER_STYLE_HIDDEN);
}
struct nsStyleBorder {
struct nsStyleBorder
{
explicit nsStyleBorder(nsPresContext* aContext);
nsStyleBorder(const nsStyleBorder& aBorder);
~nsStyleBorder();
@ -1097,7 +1110,8 @@ private:
};
struct nsStyleOutline {
struct nsStyleOutline
{
explicit nsStyleOutline(nsPresContext* aPresContext);
nsStyleOutline(const nsStyleOutline& aOutline);
~nsStyleOutline(void) {
@ -1195,7 +1209,8 @@ protected:
};
struct nsStyleList {
struct nsStyleList
{
explicit nsStyleList(nsPresContext* aPresContext);
nsStyleList(const nsStyleList& aStyleList);
~nsStyleList(void);
@ -1261,7 +1276,8 @@ public:
nsRect mImageRegion; // [inherited] the rect to use within an image
};
struct nsStyleGridLine {
struct nsStyleGridLine
{
// http://dev.w3.org/csswg/css-grid/#typedef-grid-line
// XXXmats we could optimize memory size here
bool mHasSpan;
@ -1360,7 +1376,8 @@ struct nsStyleGridLine {
// when there is no <auto-repeat> track, i.e. when mRepeatAutoIndex == -1).
// When mIsSubgrid is true, mRepeatAutoLineNameListBefore contains the line
// names and mRepeatAutoLineNameListAfter is empty.
struct nsStyleGridTemplate {
struct nsStyleGridTemplate
{
nsTArray<nsTArray<nsString>> mLineNameLists;
nsTArray<nsStyleCoord> mMinTrackSizingFunctions;
nsTArray<nsStyleCoord> mMaxTrackSizingFunctions;
@ -1399,7 +1416,8 @@ struct nsStyleGridTemplate {
}
};
struct nsStylePosition {
struct nsStylePosition
{
nsStylePosition(void);
nsStylePosition(const nsStylePosition& aOther);
~nsStylePosition(void);
@ -1590,7 +1608,8 @@ private:
{ return aCoord.HasPercent(); }
};
struct nsStyleTextOverflowSide {
struct nsStyleTextOverflowSide
{
nsStyleTextOverflowSide() : mType(NS_STYLE_TEXT_OVERFLOW_CLIP) {}
bool operator==(const nsStyleTextOverflowSide& aOther) const {
@ -1606,7 +1625,8 @@ struct nsStyleTextOverflowSide {
uint8_t mType;
};
struct nsStyleTextOverflow {
struct nsStyleTextOverflow
{
nsStyleTextOverflow() : mLogicalDirections(true) {}
bool operator==(const nsStyleTextOverflow& aOther) const {
return mLeft == aOther.mLeft && mRight == aOther.mRight;
@ -1646,7 +1666,8 @@ struct nsStyleTextOverflow {
bool mLogicalDirections; // true when only one value was specified
};
struct nsStyleTextReset {
struct nsStyleTextReset
{
nsStyleTextReset(void);
nsStyleTextReset(const nsStyleTextReset& aOther);
~nsStyleTextReset(void);
@ -1723,7 +1744,8 @@ protected:
nscolor mTextDecorationColor; // [reset] the colors to use for a decoration lines, not used at currentColor
};
struct nsStyleText {
struct nsStyleText
{
explicit nsStyleText(nsPresContext* aPresContext);
nsStyleText(const nsStyleText& aOther);
~nsStyleText(void);
@ -1835,7 +1857,8 @@ struct nsStyleText {
mozilla::LogicalSide TextEmphasisSide(mozilla::WritingMode aWM) const;
};
struct nsStyleImageOrientation {
struct nsStyleImageOrientation
{
static nsStyleImageOrientation CreateAsAngleAndFlip(double aRadians,
bool aFlip) {
uint8_t orientation(0);
@ -1927,7 +1950,8 @@ protected:
uint8_t mOrientation;
};
struct nsStyleVisibility {
struct nsStyleVisibility
{
explicit nsStyleVisibility(nsPresContext* aPresContext);
nsStyleVisibility(const nsStyleVisibility& aVisibility);
~nsStyleVisibility() {
@ -1975,7 +1999,8 @@ struct nsStyleVisibility {
inline uint8_t GetEffectivePointerEvents(nsIFrame* aFrame) const;
};
struct nsTimingFunction {
struct nsTimingFunction
{
enum class Type {
Ease, // ease
@ -2102,7 +2127,8 @@ private:
namespace mozilla {
struct StyleTransition {
struct StyleTransition
{
StyleTransition() { /* leaves uninitialized; see also SetInitialValues */ }
explicit StyleTransition(const StyleTransition& aCopy);
@ -2156,7 +2182,8 @@ private:
// eCSSPropertyExtra_variable
};
struct StyleAnimation {
struct StyleAnimation
{
StyleAnimation() { /* leaves uninitialized; see also SetInitialValues */ }
explicit StyleAnimation(const StyleAnimation& aCopy);
@ -2203,7 +2230,8 @@ private:
} // namespace mozilla
struct nsStyleDisplay {
struct nsStyleDisplay
{
nsStyleDisplay();
nsStyleDisplay(const nsStyleDisplay& aOther);
~nsStyleDisplay() {
@ -2482,7 +2510,8 @@ struct nsStyleDisplay {
inline uint8_t PhysicalBreakType(mozilla::WritingMode aWM) const;
};
struct nsStyleTable {
struct nsStyleTable
{
nsStyleTable(void);
nsStyleTable(const nsStyleTable& aOther);
~nsStyleTable(void);
@ -2513,7 +2542,8 @@ struct nsStyleTable {
int32_t mSpan; // [reset] the number of columns spanned by a colgroup or col
};
struct nsStyleTableBorder {
struct nsStyleTableBorder
{
nsStyleTableBorder();
nsStyleTableBorder(const nsStyleTableBorder& aOther);
~nsStyleTableBorder(void);
@ -2561,7 +2591,8 @@ enum nsStyleContentType {
eStyleContentType_Uninitialized
};
struct nsStyleContentData {
struct nsStyleContentData
{
nsStyleContentType mType;
union {
char16_t *mString;
@ -2601,7 +2632,8 @@ private:
nsStyleContentData(const nsStyleContentData&); // not to be implemented
};
struct nsStyleCounterData {
struct nsStyleCounterData
{
nsString mCounter;
int32_t mValue;
};
@ -2609,7 +2641,8 @@ struct nsStyleCounterData {
#define DELETE_ARRAY_IF(array) if (array) { delete[] array; array = nullptr; }
struct nsStyleQuotes {
struct nsStyleQuotes
{
nsStyleQuotes();
nsStyleQuotes(const nsStyleQuotes& aQuotes);
~nsStyleQuotes();
@ -2691,7 +2724,8 @@ protected:
nsString* mQuotes;
};
struct nsStyleContent {
struct nsStyleContent
{
nsStyleContent(void);
nsStyleContent(const nsStyleContent& aContent);
~nsStyleContent(void);
@ -2800,7 +2834,8 @@ protected:
uint32_t mResetCount;
};
struct nsStyleUIReset {
struct nsStyleUIReset
{
nsStyleUIReset(void);
nsStyleUIReset(const nsStyleUIReset& aOther);
~nsStyleUIReset(void);
@ -2833,7 +2868,8 @@ struct nsStyleUIReset {
uint8_t mWindowShadow; // [reset]
};
struct nsCursorImage {
struct nsCursorImage
{
bool mHaveHotspot;
float mHotspotX, mHotspotY;
@ -2862,7 +2898,8 @@ private:
nsCOMPtr<imgIRequest> mImage;
};
struct nsStyleUserInterface {
struct nsStyleUserInterface
{
nsStyleUserInterface(void);
nsStyleUserInterface(const nsStyleUserInterface& aOther);
~nsStyleUserInterface(void);
@ -2909,7 +2946,8 @@ struct nsStyleUserInterface {
void CopyCursorArrayFrom(const nsStyleUserInterface& aSource);
};
struct nsStyleXUL {
struct nsStyleXUL
{
nsStyleXUL();
nsStyleXUL(const nsStyleXUL& aSource);
~nsStyleXUL();
@ -2945,7 +2983,8 @@ struct nsStyleXUL {
bool mStretchStack; // [reset] see nsStyleConsts.h
};
struct nsStyleColumn {
struct nsStyleColumn
{
explicit nsStyleColumn(nsPresContext* aPresContext);
nsStyleColumn(const nsStyleColumn& aSource);
~nsStyleColumn();
@ -3038,7 +3077,8 @@ struct nsStyleSVGPaint
}
};
struct nsStyleSVG {
struct nsStyleSVG
{
nsStyleSVG();
nsStyleSVG(const nsStyleSVG& aSource);
~nsStyleSVG();
@ -3125,7 +3165,8 @@ struct nsStyleSVG {
}
};
class nsStyleBasicShape final {
class nsStyleBasicShape final
{
public:
enum Type {
eInset,
@ -3267,7 +3308,8 @@ private:
uint8_t mSizingBox; // see NS_STYLE_CLIP_SHAPE_SIZING_* constants in nsStyleConsts.h
};
struct nsStyleFilter {
struct nsStyleFilter
{
nsStyleFilter();
nsStyleFilter(const nsStyleFilter& aSource);
~nsStyleFilter();
@ -3316,11 +3358,13 @@ private:
};
template<>
struct nsTArray_CopyChooser<nsStyleFilter> {
struct nsTArray_CopyChooser<nsStyleFilter>
{
typedef nsTArray_CopyWithConstructors<nsStyleFilter> Type;
};
struct nsStyleSVGReset {
struct nsStyleSVGReset
{
nsStyleSVGReset();
nsStyleSVGReset(const nsStyleSVGReset& aSource);
~nsStyleSVGReset();
@ -3371,7 +3415,8 @@ struct nsStyleSVGReset {
uint8_t mMaskType; // [reset] see nsStyleConsts.h
};
struct nsStyleVariables {
struct nsStyleVariables
{
nsStyleVariables();
nsStyleVariables(const nsStyleVariables& aSource);
~nsStyleVariables();

View File

@ -212,8 +212,7 @@ public:
} // namespace mozilla
/**
* Frame class for SVG <text> elements, used when the
* layout.svg.css-text.enabled is true.
* Frame class for SVG <text> elements.
*
* An SVGTextFrame manages SVG text layout, painting and interaction for
* all descendent text content elements. The frame tree will look like this:

View File

@ -1404,9 +1404,8 @@ nsTableFrame::PaintTableBorderBackground(nsDisplayListBuilder* aBuilder,
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext,
borderFlags, skipSides);
}
else {
gfxContext* ctx = aRenderingContext.ThebesContext();
} else {
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxPoint devPixelOffset =
nsLayoutUtils::PointToGfxPoint(aPt,
@ -1414,10 +1413,11 @@ nsTableFrame::PaintTableBorderBackground(nsDisplayListBuilder* aBuilder,
// XXX we should probably get rid of this translation at some stage
// But that would mean modifying PaintBCBorders, ugh
gfxContextMatrixAutoSaveRestore autoSR(ctx);
ctx->SetMatrix(ctx->CurrentMatrix().Translate(devPixelOffset));
AutoRestoreTransform autoRestoreTransform(drawTarget);
drawTarget->SetTransform(
drawTarget->GetTransform().PreTranslate(ToPoint(devPixelOffset)));
PaintBCBorders(aRenderingContext, aDirtyRect - aPt);
PaintBCBorders(*drawTarget, aDirtyRect - aPt);
}
}
@ -6230,7 +6230,7 @@ struct BCBlockDirSeg
void Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext,
DrawTarget& aDrawTarget,
BCPixelSize aInlineSegBSize);
void AdvanceOffsetB();
void IncludeCurrentBorder(BCPaintBorderIterator& aIter);
@ -6280,8 +6280,7 @@ struct BCInlineDirSeg
BCPixelSize aIStartSegISize);
void AdvanceOffsetI();
void IncludeCurrentBorder(BCPaintBorderIterator& aIter);
void Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext);
void Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget);
nscoord mOffsetI; // i-offset with respect to the table edge
nscoord mOffsetB; // b-offset with respect to the table edge
@ -6325,8 +6324,8 @@ public:
bool SetDamageArea(const nsRect& aDamageRect);
void First();
void Next();
void AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRenderingContext);
void AccumulateOrPaintBlockDirSegment(nsRenderingContext& aRenderingContext);
void AccumulateOrPaintInlineDirSegment(DrawTarget& aDrawTarget);
void AccumulateOrPaintBlockDirSegment(DrawTarget& aDrawTarget);
void ResetVerInfo();
void StoreColumnWidth(int32_t aIndex);
bool BlockDirSegmentOwnsCorner();
@ -6952,14 +6951,14 @@ BCBlockDirSeg::GetBEndCorner(BCPaintBorderIterator& aIter,
/**
* Paint the block-dir segment
* @param aIter - iterator containing the structural information
* @param aRenderingContext - the rendering context
* @param aInlineSegBSize - the width of the inline-dir segment joining the corner
* at the start
* @param aIter - iterator containing the structural information
* @param aDrawTarget - the draw target
* @param aInlineSegBSize - the width of the inline-dir segment joining the
* corner at the start
*/
void
BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext,
DrawTarget& aDrawTarget,
BCPixelSize aInlineSegBSize)
{
// get the border style, color and paint the segment
@ -7065,7 +7064,7 @@ BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter,
Swap(startBevelSide, endBevelSide);
Swap(startBevelOffset, endBevelOffset);
}
nsCSSRendering::DrawTableBorderSegment(aRenderingContext, style, color,
nsCSSRendering::DrawTableBorderSegment(aDrawTarget, style, color,
aIter.mTableBgColor, physicalRect,
appUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
@ -7167,12 +7166,11 @@ BCInlineDirSeg::GetIEndCorner(BCPaintBorderIterator& aIter,
/**
* Paint the inline-dir segment
* @param aIter - iterator containing the structural information
* @param aRenderingContext - the rendering context
* @param aIter - iterator containing the structural information
* @param aDrawTarget - the draw target
*/
void
BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext)
BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget)
{
// get the border style, color and paint the segment
LogicalSide side =
@ -7270,7 +7268,7 @@ BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter,
Swap(startBevelSide, endBevelSide);
Swap(startBevelOffset, endBevelOffset);
}
nsCSSRendering::DrawTableBorderSegment(aRenderingContext, style, color,
nsCSSRendering::DrawTableBorderSegment(aDrawTarget, style, color,
aIter.mTableBgColor, physicalRect,
appUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
@ -7329,10 +7327,10 @@ BCPaintBorderIterator::BlockDirSegmentOwnsCorner()
/**
* Paint if necessary an inline-dir segment, otherwise accumulate it
* @param aRenderingContext - the rendering context
* @param aDrawTarget - the draw target
*/
void
BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRenderingContext)
BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(DrawTarget& aDrawTarget)
{
int32_t relColIndex = GetRelativeColIndex();
@ -7365,7 +7363,7 @@ BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRe
if (mInlineSeg.mLength > 0) {
mInlineSeg.GetIEndCorner(*this, iStartSegISize);
if (mInlineSeg.mWidth > 0) {
mInlineSeg.Paint(*this, aRenderingContext);
mInlineSeg.Paint(*this, aDrawTarget);
}
mInlineSeg.AdvanceOffsetI();
}
@ -7377,10 +7375,10 @@ BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRe
}
/**
* Paint if necessary a block-dir segment, otherwise accumulate it
* @param aRenderingContext - the rendering context
* @param aDrawTarget - the draw target
*/
void
BCPaintBorderIterator::AccumulateOrPaintBlockDirSegment(nsRenderingContext& aRenderingContext)
BCPaintBorderIterator::AccumulateOrPaintBlockDirSegment(DrawTarget& aDrawTarget)
{
BCBorderOwner borderOwner = eCellOwner;
BCBorderOwner ignoreBorderOwner;
@ -7407,7 +7405,7 @@ BCPaintBorderIterator::AccumulateOrPaintBlockDirSegment(nsRenderingContext& aRen
if (blockDirSeg.mLength > 0) {
blockDirSeg.GetBEndCorner(*this, inlineSegBSize);
if (blockDirSeg.mWidth > 0) {
blockDirSeg.Paint(*this, aRenderingContext, inlineSegBSize);
blockDirSeg.Paint(*this, aDrawTarget, inlineSegBSize);
}
blockDirSeg.AdvanceOffsetB();
}
@ -7435,12 +7433,11 @@ BCPaintBorderIterator::ResetVerInfo()
/**
* Method to paint BCBorders, this does not use currently display lists although
* it will do this in future
* @param aRenderingContext - the rendering context
* @param aDirtyRect - inside this rectangle the BC Borders will redrawn
* @param aDrawTarget - the rendering context
* @param aDirtyRect - inside this rectangle the BC Borders will redrawn
*/
void
nsTableFrame::PaintBCBorders(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
nsTableFrame::PaintBCBorders(DrawTarget& aDrawTarget, const nsRect& aDirtyRect)
{
// We first transfer the aDirtyRect into cellmap coordinates to compute which
// cell borders need to be painted
@ -7459,7 +7456,7 @@ nsTableFrame::PaintBCBorders(nsRenderingContext& aRenderingContext,
// this we the now active segment with the current border. These
// segments are stored in mBlockDirInfo to be used on the next row
for (iter.First(); !iter.mAtEnd; iter.Next()) {
iter.AccumulateOrPaintBlockDirSegment(aRenderingContext);
iter.AccumulateOrPaintBlockDirSegment(aDrawTarget);
}
// Next, paint all of the inline-dir border segments from bStart to bEnd reuse
@ -7467,7 +7464,7 @@ nsTableFrame::PaintBCBorders(nsRenderingContext& aRenderingContext,
// corner calculations
iter.Reset();
for (iter.First(); !iter.mAtEnd; iter.Next()) {
iter.AccumulateOrPaintInlineDirSegment(aRenderingContext);
iter.AccumulateOrPaintInlineDirSegment(aDrawTarget);
}
}

View File

@ -312,8 +312,7 @@ public:
void AddBCDamageArea(const mozilla::TableArea& aValue);
bool BCRecalcNeeded(nsStyleContext* aOldStyleContext,
nsStyleContext* aNewStyleContext);
void PaintBCBorders(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
void PaintBCBorders(DrawTarget& aDrawTarget, const nsRect& aDirtyRect);
virtual void MarkIntrinsicISizesDirty() override;
// For border-collapse tables, the caller must not add padding and

View File

@ -521,6 +521,12 @@ function _execute_test() {
this[func] = Assert[func].bind(Assert);
}
if (_gTestHasOnly) {
_gTests = _gTests.filter(([props,]) => {
return ("_only" in props) && props._only;
});
}
try {
do_test_pending("MAIN run_test");
// Check if run_test() is defined. If defined, run it.
@ -1342,6 +1348,52 @@ function do_send_remote_message(name) {
mm[sender](name);
}
/**
* Helper function to add the _only property to add_task/add_test function when
* running it as add_task.only(...).
*
* @param addFunc
* The parent function to call, e.g. add_task or add_test.
* @param funcOrProperties
* A function to be run or an object represents test properties.
* @param func
* A function to be run only if the funcOrProperies is not a function.
*/
function _add_only(addFunc, funcOrProperties, func) {
_gTestHasOnly = true;
if (typeof funcOrProperties == "function") {
func = funcOrProperties;
funcOrProperties = {};
}
if (typeof funcOrProperties == "object") {
funcOrProperties._only = true;
}
return addFunc(funcOrProperties, func);
}
/**
* Helper function to skip the test using e.g. add_task.skip(...)
*
* @param addFunc
* The parent function to call, e.g. add_task or add_test.
* @param funcOrProperties
* A function to be run or an object represents test properties.
* @param func
* A function to be run only if the funcOrProperies is not a function.
*/
function _add_skip(addFunc, funcOrProperties, func) {
if (typeof funcOrProperties == "function") {
func = funcOrProperties;
funcOrProperties = {};
}
if (typeof funcOrProperties == "object") {
funcOrProperties.skip_if = () => true;
}
return addFunc(funcOrProperties, func);
}
/**
* Add a test function to the list of tests that are to be run asynchronously.
*
@ -1371,6 +1423,8 @@ function add_test(funcOrProperties, func) {
}
return func;
}
add_test.only = _add_only.bind(undefined, add_test);
add_test.skip = _add_skip.bind(undefined, add_test);
/**
* Add a test function which is a Task function.
@ -1437,6 +1491,9 @@ function add_task(funcOrProperties, func) {
do_throw("add_task() should take a function or an object and a function");
}
}
add_task.only = _add_only.bind(undefined, add_task);
add_task.skip = _add_skip.bind(undefined, add_task);
var _Task = Components.utils.import("resource://gre/modules/Task.jsm", {}).Task;
_Task.Debugging.maintainStack = true;
@ -1447,6 +1504,7 @@ _Task.Debugging.maintainStack = true;
var _gRunningTest = null;
var _gTestIndex = 0; // The index of the currently running test.
var _gTaskRunning = false;
var _gTestHasOnly = false;
function run_next_test()
{
if (_gTaskRunning) {

View File

@ -30,4 +30,5 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_videocontrols_standalone.html]
skip-if = android_version == '10' || android_version == '18' # bug 1075573
[test_videocontrols_video_direction.html]
skip-if = os == 'win'
[test_bug898940.html]

View File

@ -391,9 +391,9 @@ uint32_t
AndroidGraphicBuffer::GetAndroidFormat(gfxImageFormat aFormat)
{
switch (aFormat) {
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return HAL_PIXEL_FORMAT_RGBX_8888;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return HAL_PIXEL_FORMAT_RGB_565;
default:
return 0;

View File

@ -157,7 +157,7 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
CGContextScaleCTM(context, 1.0, -1.0);
newSurface = new gfxQuartzSurface(context, gfxSize(width, height));
} else {
newSurface = new gfxQuartzSurface(gfxSize((int32_t)width, (int32_t)height), gfxImageFormat::ARGB32);
newSurface = new gfxQuartzSurface(gfxSize((int32_t)width, (int32_t)height), SurfaceFormat::A8R8G8B8_UINT32);
}
if (!newSurface)

View File

@ -86,7 +86,7 @@ nsDeviceContextSpecProxy::GetSurfaceForPrinter(gfxASurface** aSurface)
RefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->
CreateOffscreenSurface(mozilla::gfx::IntSize(width, height),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
surface.forget(aSurface);
return NS_OK;

View File

@ -357,7 +357,7 @@ TaskbarPreview::UpdateTooltip() {
void
TaskbarPreview::DrawBitmap(uint32_t width, uint32_t height, bool isPreview) {
nsresult rv;
RefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(gfx::IntSize(width, height), gfxImageFormat::ARGB32);
RefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(gfx::IntSize(width, height), gfx::SurfaceFormat::A8R8G8B8_UINT32);
nsCOMPtr<nsIDocShell> shell = do_QueryReferent(mDocShell);

View File

@ -6939,7 +6939,7 @@ void nsWindow::ResizeTranslucentWindow(int32_t aNewWidth, int32_t aNewHeight, bo
return;
RefPtr<gfxWindowsSurface> newSurface =
new gfxWindowsSurface(IntSize(aNewWidth, aNewHeight), gfxImageFormat::ARGB32);
new gfxWindowsSurface(IntSize(aNewWidth, aNewHeight), SurfaceFormat::A8R8G8B8_UINT32);
mTransparentSurface = newSurface;
mMemoryDC = newSurface->GetDC();
}

View File

@ -354,7 +354,7 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel)
targetSurfaceImage = new gfxImageSurface(sSharedSurfaceData.get(),
surfaceSize,
surfaceSize.width * 4,
gfxImageFormat::RGB24);
SurfaceFormat::X8R8G8B8_UINT32);
if (targetSurfaceImage && !targetSurfaceImage->CairoStatus()) {
targetSurfaceImage->SetDeviceOffset(gfxPoint(-ps.rcPaint.left, -ps.rcPaint.top));