diff --git a/browser/components/customizableui/content/panelUI.inc.xul b/browser/components/customizableui/content/panelUI.inc.xul index 7367db011a4b..82eeb0160fd7 100644 --- a/browser/components/customizableui/content/panelUI.inc.xul +++ b/browser/components/customizableui/content/panelUI.inc.xul @@ -88,7 +88,7 @@ class="syncTabsMenuItem subviewbutton" label="&syncTabsMenu3.label;" oncommand="BrowserOpenSyncTabs();" - disabled="true"/> + hidden="true"/> GetFormat() == ImageFormat::PLANAR_YCBCR) { nsTArray data; layers::PlanarYCbCrImage* ycbcrImage = static_cast (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); diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 3927d461713d..da10628711cf 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3096,6 +3096,10 @@ nsDOMWindowUtils::ExitFullscreen() { nsCOMPtr 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; } diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index a344fd916d09..819b03015c8e 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -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 imgsurf = new gfxImageSurface(gfx::IntSize(copyWidth, copyHeight), - gfxImageFormat::ARGB32, + SurfaceFormat::A8R8G8B8_UINT32, false); if (!imgsurf || imgsurf->CairoStatus()) { return NS_ERROR_FAILURE; diff --git a/dom/html/test/browser.ini b/dom/html/test/browser.ini index 7755e4be588f..803b18936e6e 100644 --- a/dom/html/test/browser.ini +++ b/dom/html/test/browser.ini @@ -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] diff --git a/dom/html/test/browser_fullscreen-api-keys.js b/dom/html/test/browser_fullscreen-api-keys.js new file mode 100644 index 000000000000..ef55ced6ccaa --- /dev/null +++ b/dom/html/test/browser_fullscreen-api-keys.js @@ -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"); + }); + }); + } +}); diff --git a/dom/html/test/browser_fullscreen-contextmenu-esc.js b/dom/html/test/browser_fullscreen-contextmenu-esc.js new file mode 100644 index 000000000000..a4975145b093 --- /dev/null +++ b/dom/html/test/browser_fullscreen-contextmenu-esc.js @@ -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"); +}); diff --git a/dom/html/test/dummy_page.html b/dom/html/test/dummy_page.html new file mode 100644 index 000000000000..fd238954c688 --- /dev/null +++ b/dom/html/test/dummy_page.html @@ -0,0 +1,10 @@ + + + +Dummy test page + + + +

Dummy test page

+ + diff --git a/dom/html/test/file_fullscreen-api-keys.html b/dom/html/test/file_fullscreen-api-keys.html index 9925ae3a3c3a..fd604bbf1002 100644 --- a/dom/html/test/file_fullscreen-api-keys.html +++ b/dom/html/test/file_fullscreen-api-keys.html @@ -1,129 +1,32 @@ - - - + + - Test for Bug 545812 - - - + + - diff --git a/dom/html/test/file_fullscreen-esc-context-menu.html b/dom/html/test/file_fullscreen-esc-context-menu.html deleted file mode 100644 index 06c12ff5259b..000000000000 --- a/dom/html/test/file_fullscreen-esc-context-menu.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - Text for bug 910532 - - - - - - - - - diff --git a/dom/html/test/file_fullscreen-plugins.html b/dom/html/test/file_fullscreen-plugins.html index 4393dac6bc3d..89e811ec8a7d 100644 --- a/dom/html/test/file_fullscreen-plugins.html +++ b/dom/html/test/file_fullscreen-plugins.html @@ -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(); } diff --git a/dom/html/test/file_fullscreen-utils.js b/dom/html/test/file_fullscreen-utils.js index d757d191cbba..3bf7e91a6dff 100644 --- a/dom/html/test/file_fullscreen-utils.js +++ b/dom/html/test/file_fullscreen-utils.js @@ -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() { diff --git a/dom/html/test/head.js b/dom/html/test/head.js new file mode 100644 index 000000000000..7f5db315e071 --- /dev/null +++ b/dom/html/test/head.js @@ -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 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()); diff --git a/dom/html/test/mochitest.ini b/dom/html/test/mochitest.ini index dcf1e43072a3..70bd4c62ffc8 100644 --- a/dom/html/test/mochitest.ini +++ b/dom/html/test/mochitest.ini @@ -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] diff --git a/dom/html/test/test_fullscreen-api.html b/dom/html/test/test_fullscreen-api.html index 47fb034e3e1d..27b9834eec45 100644 --- a/dom/html/test/test_fullscreen-api.html +++ b/dom/html/test/test_fullscreen-api.html @@ -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", diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 29ae1fba30fa..3259c98bb776 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -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 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 audioSink = aAudioCaptured ? - mStreamSink : CreateAudioSink(); + RefPtr audioSink = aAudioCaptured + ? new DecodedStream(mTaskQueue, mAudioQueue, mVideoQueue, + mOutputStreamManager, mSameOriginMedia.Ref()) + : CreateAudioSink(); RefPtr mediaSink = new VideoSink(mTaskQueue, audioSink, mVideoQueue, diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 6596b41a4085..6bdfb8a976c5 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -1187,13 +1187,6 @@ private: // Data about MediaStreams that are being fed by the decoder. const RefPtr 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 mStreamSink; - // Media data resource from the decoder. RefPtr mResource; diff --git a/dom/media/android/AndroidMediaReader.cpp b/dom/media/android/AndroidMediaReader.cpp index a002a9c3e79f..130f024e9507 100644 --- a/dom/media/android/AndroidMediaReader.cpp +++ b/dom/media/android/AndroidMediaReader.cpp @@ -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; diff --git a/dom/media/webrtc/MediaEngineTabVideoSource.cpp b/dom/media/webrtc/MediaEngineTabVideoSource.cpp index e4c097cb57e4..ea2d9c4fb19e 100644 --- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp @@ -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(stride * size.height)) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 4d2bd485613f..d9c9019a55fe 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -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; } diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 083ac4736cd1..fcfcf7dd2841 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -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(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 diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 9ad0080e2c16..8dcbd99c4645 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -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; diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index 0d4893537e8f..3da1523b50d8 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -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) diff --git a/gfx/gl/GLReadTexImageHelper.h b/gfx/gl/GLReadTexImageHelper.h index 685afcf270c1..cfd65d8a2f57 100644 --- a/gfx/gl/GLReadTexImageHelper.h +++ b/gfx/gl/GLReadTexImageHelper.h @@ -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 diff --git a/gfx/gl/GLTextureImage.h b/gfx/gl/GLTextureImage.h index ba87f3f1a911..8db2407677aa 100644 --- a/gfx/gl/GLTextureImage.h +++ b/gfx/gl/GLTextureImage.h @@ -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 diff --git a/gfx/gl/SharedSurfaceGLX.cpp b/gfx/gl/SharedSurfaceGLX.cpp index 1636b9ec6e1c..64f9eb0559b2 100644 --- a/gfx/gl/SharedSurfaceGLX.cpp +++ b/gfx/gl/SharedSurfaceGLX.cpp @@ -29,7 +29,7 @@ SharedSurface_GLXDrawable::Create(GLContext* prodGL, UniquePtr 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 surf = gfxXlibSurface::Create(screen, visual, size); if (!deallocateClient) diff --git a/gfx/gl/TextureImageCGL.h b/gfx/gl/TextureImageCGL.h index a2b489c3a396..5bb9678d4620 100644 --- a/gfx/gl/TextureImageCGL.h +++ b/gfx/gl/TextureImageCGL.h @@ -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(); diff --git a/gfx/gl/TextureImageEGL.h b/gfx/gl/TextureImageEGL.h index 472718e2efd2..7495728d5bb3 100644 --- a/gfx/gl/TextureImageEGL.h +++ b/gfx/gl/TextureImageEGL.h @@ -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(); diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index d4508fef4534..e53eadf7cc0d 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -229,14 +229,6 @@ struct ParamTraits mozilla::layers::ScaleMode::SENTINEL> {}; -template <> -struct ParamTraits - : public ContiguousEnumSerializer< - gfxImageFormat, - gfxImageFormat::ARGB32, - gfxImageFormat::Unknown> -{}; - template <> struct ParamTraits : public ContiguousEnumSerializer< @@ -287,8 +279,8 @@ struct ParamTraits template <> struct ParamTraits : public EnumSerializer + SurfaceFormat::A8R8G8B8_UINT32, + SurfaceFormat::UNKNOWN> {}; */ diff --git a/gfx/ipc/SharedDIBSurface.cpp b/gfx/ipc/SharedDIBSurface.cpp index 656abab8fa97..696bb300cf0b 100644 --- a/gfx/ipc/SharedDIBSurface.cpp +++ b/gfx/ipc/SharedDIBSurface.cpp @@ -43,7 +43,7 @@ SharedDIBSurface::InitSurface(uint32_t aWidth, uint32_t aHeight, long stride = long(aWidth * SharedDIB::kBytesPerPixel); unsigned char* data = reinterpret_cast(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); diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 3b4f18447044..b01e3ad90955 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -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; } diff --git a/gfx/layers/ImageDataSerializer.cpp b/gfx/layers/ImageDataSerializer.cpp index bdda54671570..7e04acd38017 100644 --- a/gfx/layers/ImageDataSerializer.cpp +++ b/gfx/layers/ImageDataSerializer.cpp @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ImageDataSerializer.h" -#include // for memcpy #include "gfx2DGlue.h" // for SurfaceFormatToImageFormat #include "mozilla/gfx/Point.h" // for IntSize #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 5133b634b76f..9156f78e7aeb 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -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 aSource, aDestRect.RoundOut(); // Create a surface the size of the transformed object. - RefPtr dest = aDest->CurrentSurface(); RefPtr destImage = new gfxImageSurface(IntSize(aDestRect.width, aDestRect.height), - gfxImageFormat::ARGB32); + SurfaceFormat::A8R8G8B8_UINT32); gfxPoint offset = aDestRect.TopLeft(); // Include a translation to the correct origin. diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index facaf86beeb3..ce86a3c96f62 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -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 @@ -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; diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index 35c283cc5c13..5967f297fc61 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -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. diff --git a/gfx/layers/ipc/SharedRGBImage.cpp b/gfx/layers/ipc/SharedRGBImage.cpp index e16210d8c7d5..0e084951dee7 100644 --- a/gfx/layers/ipc/SharedRGBImage.cpp +++ b/gfx/layers/ipc/SharedRGBImage.cpp @@ -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) { diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index a68a55f4b9b9..361aa1bbf029 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -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); diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index c2cde0c452ff..61a7def3bc21 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -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 ySurface = new gfxImageSurface(IntSize(400,300), gfxImageFormat::A8); - RefPtr cbSurface = new gfxImageSurface(IntSize(200,150), gfxImageFormat::A8); - RefPtr crSurface = new gfxImageSurface(IntSize(200,150), gfxImageFormat::A8); + RefPtr ySurface = new gfxImageSurface(IntSize(400,300), SurfaceFormat::A8); + RefPtr cbSurface = new gfxImageSurface(IntSize(200,150), SurfaceFormat::A8); + RefPtr crSurface = new gfxImageSurface(IntSize(200,150), SurfaceFormat::A8); SetupSurface(ySurface.get()); SetupSurface(cbSurface.get()); SetupSurface(crSurface.get()); diff --git a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp index d874584910f4..0bbd2361d1a3 100644 --- a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp +++ b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp @@ -44,7 +44,7 @@ TestNewSurface () { int failures = 0; int destroyed = 0; - RefPtr s = new gfxImageSurface (mozilla::gfx::IntSize(10, 10), gfxImageFormat::ARGB32); + RefPtr 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); diff --git a/gfx/thebes/gfx2DGlue.h b/gfx/thebes/gfx2DGlue.h index 9bba6ef371ba..2d3267b6c024 100644 --- a/gfx/thebes/gfx2DGlue.h +++ b/gfx/thebes/gfx2DGlue.h @@ -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; } } diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index 2af66f7d4f51..03665a023fb2 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -344,7 +344,7 @@ already_AddRefed gfxASurface::GetAsReadableARGB32ImageSurface() { RefPtr 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 imgSurface = - new gfxImageSurface(size, gfxImageFormat::ARGB32); + new gfxImageSurface(size, SurfaceFormat::A8R8G8B8_UINT32); RefPtr dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height)); RefPtr 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; diff --git a/gfx/thebes/gfxAlphaRecovery.cpp b/gfx/thebes/gfxAlphaRecovery.cpp index 9f2e42300461..810fbeffa6d3 100644 --- a/gfx/thebes/gfxAlphaRecovery.cpp +++ b/gfx/thebes/gfxAlphaRecovery.cpp @@ -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 diff --git a/gfx/thebes/gfxAlphaRecoverySSE2.cpp b/gfx/thebes/gfxAlphaRecoverySSE2.cpp index 5334bafe592e..2c8987cbe8dc 100644 --- a/gfx/thebes/gfxAlphaRecoverySSE2.cpp +++ b/gfx/thebes/gfxAlphaRecoverySSE2.cpp @@ -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; diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index f4323b02b41c..6f7500007b2b 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -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 diff --git a/gfx/thebes/gfxBlur.cpp b/gfx/thebes/gfxBlur.cpp index 119af1532d1e..2f4e1fc05b7a 100644 --- a/gfx/thebes/gfxBlur.cpp +++ b/gfx/thebes/gfxBlur.cpp @@ -511,14 +511,13 @@ CreateBoxShadow(SourceSurface* aBlurMask, const Color& aShadowColor) } static already_AddRefed -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 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 boxShadow = GetBlur(destDrawTarget, + RefPtr 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 { diff --git a/gfx/thebes/gfxBlur.h b/gfx/thebes/gfxBlur.h index 27c293b44621..2210949b6749 100644 --- a/gfx/thebes/gfxBlur.h +++ b/gfx/thebes/gfxBlur.h @@ -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 DoBlur(mozilla::gfx::DrawTarget* aDT, mozilla::gfx::IntPoint* aTopLeft); + already_AddRefed + 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. diff --git a/gfx/thebes/gfxImageSurface.cpp b/gfx/thebes/gfxImageSurface.cpp index 63fa0efec2e2..9f4e62c16f10 100644 --- a/gfx/thebes/gfxImageSurface.cpp +++ b/gfx/thebes/gfxImageSurface.cpp @@ -12,6 +12,7 @@ #include "cairo.h" #include "mozilla/gfx/2D.h" +#include "mozilla/gfx/HelpersCairo.h" #include "gfx2DGlue.h" #include @@ -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 image = diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 4934169f8843..25e3664cbb12 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -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; } } diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 54d704b337f9..362c24c4aad7 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -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 diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index 50f672218fcf..a934e7d7184f 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -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) diff --git a/gfx/thebes/gfxQPainterSurface.cpp b/gfx/thebes/gfxQPainterSurface.cpp index de3f804e156d..fb0f1349db0f 100644 --- a/gfx/thebes/gfxQPainterSurface.cpp +++ b/gfx/thebes/gfxQPainterSurface.cpp @@ -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); diff --git a/gfx/thebes/gfxQtPlatform.cpp b/gfx/thebes/gfxQtPlatform.cpp index 61275adca302..c3290af2d22a 100644 --- a/gfx/thebes/gfxQtPlatform.cpp +++ b/gfx/thebes/gfxQtPlatform.cpp @@ -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); diff --git a/gfx/thebes/gfxQuartzSurface.cpp b/gfx/thebes/gfxQuartzSurface.cpp index 9614c68f733f..01bb162bcd23 100644 --- a/gfx/thebes/gfxQuartzSurface.cpp +++ b/gfx/thebes/gfxQuartzSurface.cpp @@ -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(mSize.width); unsigned int height = static_cast(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(mSize.width); unsigned int height = static_cast(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); diff --git a/gfx/thebes/gfxTypes.h b/gfx/thebes/gfxTypes.h index 64ad9e1ef6d7..e017efbe9539 100644 --- a/gfx/thebes/gfxTypes.h +++ b/gfx/thebes/gfxTypes.h @@ -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, diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index bda76a7f9f24..1a0809469426 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -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, diff --git a/gfx/thebes/gfxUtils.h b/gfx/thebes/gfxUtils.h index 595678e637ab..e538081dad65 100644 --- a/gfx/thebes/gfxUtils.h +++ b/gfx/thebes/gfxUtils.h @@ -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} diff --git a/gfx/thebes/gfxWindowsSurface.cpp b/gfx/thebes/gfxWindowsSurface.cpp index 27b165da2a27..9f83b38dccf8 100644 --- a/gfx/thebes/gfxWindowsSurface.cpp +++ b/gfx/thebes/gfxWindowsSurface.cpp @@ -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 { diff --git a/gfx/thebes/gfxWindowsSurface.h b/gfx/thebes/gfxWindowsSurface.h index 0f5e2f58b993..8600ca567ac0 100644 --- a/gfx/thebes/gfxWindowsSurface.h +++ b/gfx/thebes/gfxWindowsSurface.h @@ -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); diff --git a/gfx/thebes/gfxXlibNativeRenderer.cpp b/gfx/thebes/gfxXlibNativeRenderer.cpp index f6e3900ef31c..767f2e3b5992 100644 --- a/gfx/thebes/gfxXlibNativeRenderer.cpp +++ b/gfx/thebes/gfxXlibNativeRenderer.cpp @@ -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 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 whiteImage = - CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::RGB24); + CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::X8R8G8B8_UINT32); if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS && whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) { diff --git a/gfx/thebes/gfxXlibSurface.cpp b/gfx/thebes/gfxXlibSurface.cpp index f86c030d8abf..cdb8db7f8abe 100644 --- a/gfx/thebes/gfxXlibSurface.cpp +++ b/gfx/thebes/gfxXlibSurface.cpp @@ -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; diff --git a/gfx/ycbcr/YCbCrUtils.cpp b/gfx/ycbcr/YCbCrUtils.cpp index 024520c7880e..b4b750af361c 100644 --- a/gfx/ycbcr/YCbCrUtils.cpp +++ b/gfx/ycbcr/YCbCrUtils.cpp @@ -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, diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 0c514247134e..5f7a8a5cec2c 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -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 diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h index 2a439b4d3968..fc58668838b6 100644 --- a/layout/base/nsCSSRendering.h +++ b/layout/base/nsCSSRendering.h @@ -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, diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 3a9ace711799..0f73787f13e6 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -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 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 nsDisplayPerspective::BuildLayer(nsDisplayListBuilder *aBuilder, diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 3bfcc4a648d7..1e79452f218b 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -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 BuildLayer(nsDisplayListBuilder* aBuilder, diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index f8c9e43c0041..79383532fced 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -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; } } diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 7f779ed12c11..9f39ceb8da30 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -30,6 +30,7 @@ #include "mozilla/ToString.h" #include "nsHTMLReflowMetrics.h" #include "ImageContainer.h" +#include "gfx2DGlue.h" #include #include diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index ea4048dcd3ee..cdc22bb7a918 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -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); diff --git a/layout/reftests/transform-3d/preserve3d-6-ref.html b/layout/reftests/transform-3d/preserve3d-6-ref.html new file mode 100644 index 000000000000..f24abbe730d9 --- /dev/null +++ b/layout/reftests/transform-3d/preserve3d-6-ref.html @@ -0,0 +1,12 @@ + + + + +
+
+
+
+
+
+ + diff --git a/layout/reftests/transform-3d/preserve3d-6a.html b/layout/reftests/transform-3d/preserve3d-6a.html new file mode 100644 index 000000000000..0b604ba5d505 --- /dev/null +++ b/layout/reftests/transform-3d/preserve3d-6a.html @@ -0,0 +1,12 @@ + + + + +
+
+
+
+
+
+ + diff --git a/layout/reftests/transform-3d/reftest.list b/layout/reftests/transform-3d/reftest.list index 74eedcb3b2a1..fa9d88c60619 100644 --- a/layout/reftests/transform-3d/reftest.list +++ b/layout/reftests/transform-3d/reftest.list @@ -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 diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 3018e337d881..62c773135b3d 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -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 diff --git a/layout/style/nsCSSDataBlock.cpp b/layout/style/nsCSSDataBlock.cpp index 653a4cb01772..6431c745cc51 100644 --- a/layout/style/nsCSSDataBlock.cpp +++ b/layout/style/nsCSSDataBlock.cpp @@ -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 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 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(oldValue)); - aFromBlock.ClearPropertyBit(aProperty); - return true; + *aChanged = MoveValue(newValue, const_cast(oldValue)); + aFromBlock.ClearPropertyBit(aProperty); + return true; } nsCSSCompressedDataBlock* nsCSSCompressedDataBlock::Clone() const { - nsAutoPtr - result(new(mNumProps) nsCSSCompressedDataBlock(mNumProps)); + nsAutoPtr + 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& aOrder) { - nsAutoPtr result_normal, result_important; - uint32_t i_normal = 0, i_important = 0; + nsAutoPtr 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(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(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(PropertyAt(aProperty)); - storage = aValue; - SetPropertyBit(aProperty); + MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty), + "property out of range"); + nsCSSValue& storage = *static_cast(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 diff --git a/layout/style/nsCSSDataBlock.h b/layout/style/nsCSSDataBlock.h index 1e558b56e6af..67b53eddbc47 100644 --- a/layout/style/nsCSSDataBlock.h +++ b/layout/style/nsCSSDataBlock.h @@ -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& 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& 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__) */ diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index cdbd144c5c0d..7fd832694513 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -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 diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index e3325a674548..faab8a93faa7 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -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 nsComputedDOMStyle::DoGetPerspective() { - RefPtr val = new nsROCSSPrimitiveValue; - SetValueToCoord(val, StyleDisplay()->mChildPerspective, false); - return val.forget(); + RefPtr val = new nsROCSSPrimitiveValue; + SetValueToCoord(val, StyleDisplay()->mChildPerspective, false); + return val.forget(); } already_AddRefed nsComputedDOMStyle::DoGetBackfaceVisibility() { - RefPtr val = new nsROCSSPrimitiveValue; - val->SetIdent( - nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mBackfaceVisibility, - nsCSSProps::kBackfaceVisibilityKTable)); - return val.forget(); + RefPtr val = new nsROCSSPrimitiveValue; + val->SetIdent( + nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mBackfaceVisibility, + nsCSSProps::kBackfaceVisibilityKTable)); + return val.forget(); } already_AddRefed nsComputedDOMStyle::DoGetTransformStyle() { - RefPtr val = new nsROCSSPrimitiveValue; - val->SetIdent( - nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mTransformStyle, - nsCSSProps::kTransformStyleKTable)); - return val.forget(); + RefPtr 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. diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index b0bd03c26cc2..6f67e4d9e3bf 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -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/. */ @@ -34,34 +35,34 @@ static const nsCSSProps::KTableEntry kScanKeywords[] = { #ifdef XP_WIN struct WindowsThemeName { - LookAndFeel::WindowsTheme id; - const wchar_t* name; + LookAndFeel::WindowsTheme id; + const wchar_t* name; }; // Windows theme identities used in the -moz-windows-theme media query. const WindowsThemeName themeStrings[] = { - { LookAndFeel::eWindowsTheme_Aero, L"aero" }, - { LookAndFeel::eWindowsTheme_AeroLite, L"aero-lite" }, - { LookAndFeel::eWindowsTheme_LunaBlue, L"luna-blue" }, - { LookAndFeel::eWindowsTheme_LunaOlive, L"luna-olive" }, - { LookAndFeel::eWindowsTheme_LunaSilver, L"luna-silver" }, - { LookAndFeel::eWindowsTheme_Royale, L"royale" }, - { LookAndFeel::eWindowsTheme_Zune, L"zune" }, - { LookAndFeel::eWindowsTheme_Generic, L"generic" } + { LookAndFeel::eWindowsTheme_Aero, L"aero" }, + { LookAndFeel::eWindowsTheme_AeroLite, L"aero-lite" }, + { LookAndFeel::eWindowsTheme_LunaBlue, L"luna-blue" }, + { LookAndFeel::eWindowsTheme_LunaOlive, L"luna-olive" }, + { LookAndFeel::eWindowsTheme_LunaSilver, L"luna-silver" }, + { LookAndFeel::eWindowsTheme_Royale, L"royale" }, + { LookAndFeel::eWindowsTheme_Zune, L"zune" }, + { LookAndFeel::eWindowsTheme_Generic, L"generic" } }; struct OperatingSystemVersionInfo { - LookAndFeel::OperatingSystemVersion id; - const wchar_t* name; + LookAndFeel::OperatingSystemVersion id; + const wchar_t* name; }; // Os version identities used in the -moz-os-version media query. const OperatingSystemVersionInfo osVersionStrings[] = { - { LookAndFeel::eOperatingSystemVersion_WindowsXP, L"windows-xp" }, - { LookAndFeel::eOperatingSystemVersion_WindowsVista, L"windows-vista" }, - { LookAndFeel::eOperatingSystemVersion_Windows7, L"windows-win7" }, - { LookAndFeel::eOperatingSystemVersion_Windows8, L"windows-win8" }, - { LookAndFeel::eOperatingSystemVersion_Windows10, L"windows-win10" } + { LookAndFeel::eOperatingSystemVersion_WindowsXP, L"windows-xp" }, + { LookAndFeel::eOperatingSystemVersion_WindowsVista, L"windows-vista" }, + { LookAndFeel::eOperatingSystemVersion_Windows7, L"windows-win7" }, + { LookAndFeel::eOperatingSystemVersion_Windows8, L"windows-win8" }, + { LookAndFeel::eOperatingSystemVersion_Windows10, L"windows-win10" } }; #endif @@ -69,33 +70,33 @@ const OperatingSystemVersionInfo osVersionStrings[] = { static nsSize GetSize(nsPresContext* aPresContext) { - nsSize size; - if (aPresContext->IsRootPaginatedDocument()) - // We want the page size, including unprintable areas and margins. - size = aPresContext->GetPageSize(); - else - size = aPresContext->GetVisibleArea().Size(); - return size; + nsSize size; + if (aPresContext->IsRootPaginatedDocument()) + // We want the page size, including unprintable areas and margins. + size = aPresContext->GetPageSize(); + else + size = aPresContext->GetVisibleArea().Size(); + return size; } static nsresult GetWidth(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - nsSize size = GetSize(aPresContext); - float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width); - aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel); - return NS_OK; + nsSize size = GetSize(aPresContext); + float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width); + aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel); + return NS_OK; } static nsresult GetHeight(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - nsSize size = GetSize(aPresContext); - float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height); - aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel); - return NS_OK; + nsSize size = GetSize(aPresContext); + float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height); + aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel); + return NS_OK; } inline static nsDeviceContext* @@ -112,81 +113,81 @@ GetDeviceContextFor(nsPresContext* aPresContext) static bool ShouldResistFingerprinting(nsPresContext* aPresContext) { - return nsContentUtils::ShouldResistFingerprinting(aPresContext->GetDocShell()); + return nsContentUtils::ShouldResistFingerprinting(aPresContext->GetDocShell()); } // A helper for three features below. static nsSize GetDeviceSize(nsPresContext* aPresContext) { - nsSize size; + nsSize size; - if (ShouldResistFingerprinting(aPresContext) || aPresContext->IsDeviceSizePageSize()) { - size = GetSize(aPresContext); - } else if (aPresContext->IsRootPaginatedDocument()) { - // We want the page size, including unprintable areas and margins. - // XXX The spec actually says we want the "page sheet size", but - // how is that different? - size = aPresContext->GetPageSize(); - } else { - GetDeviceContextFor(aPresContext)-> - GetDeviceSurfaceDimensions(size.width, size.height); - } - return size; + if (ShouldResistFingerprinting(aPresContext) || aPresContext->IsDeviceSizePageSize()) { + size = GetSize(aPresContext); + } else if (aPresContext->IsRootPaginatedDocument()) { + // We want the page size, including unprintable areas and margins. + // XXX The spec actually says we want the "page sheet size", but + // how is that different? + size = aPresContext->GetPageSize(); + } else { + GetDeviceContextFor(aPresContext)-> + GetDeviceSurfaceDimensions(size.width, size.height); + } + return size; } static nsresult GetDeviceWidth(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - nsSize size = GetDeviceSize(aPresContext); - float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width); - aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel); - return NS_OK; + nsSize size = GetDeviceSize(aPresContext); + float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width); + aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel); + return NS_OK; } static nsresult GetDeviceHeight(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - nsSize size = GetDeviceSize(aPresContext); - float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height); - aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel); - return NS_OK; + nsSize size = GetDeviceSize(aPresContext); + float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height); + aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel); + return NS_OK; } static nsresult GetOrientation(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - nsSize size = GetSize(aPresContext); - int32_t orientation; - if (size.width > size.height) { - orientation = NS_STYLE_ORIENTATION_LANDSCAPE; - } else { - // Per spec, square viewports should be 'portrait' - orientation = NS_STYLE_ORIENTATION_PORTRAIT; - } + nsSize size = GetSize(aPresContext); + int32_t orientation; + if (size.width > size.height) { + orientation = NS_STYLE_ORIENTATION_LANDSCAPE; + } else { + // Per spec, square viewports should be 'portrait' + orientation = NS_STYLE_ORIENTATION_PORTRAIT; + } - aResult.SetIntValue(orientation, eCSSUnit_Enumerated); - return NS_OK; + aResult.SetIntValue(orientation, eCSSUnit_Enumerated); + return NS_OK; } static nsresult GetDeviceOrientation(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - nsSize size = GetDeviceSize(aPresContext); - int32_t orientation; - if (size.width > size.height) { - orientation = NS_STYLE_ORIENTATION_LANDSCAPE; - } else { - // Per spec, square viewports should be 'portrait' - orientation = NS_STYLE_ORIENTATION_PORTRAIT; - } + nsSize size = GetDeviceSize(aPresContext); + int32_t orientation; + if (size.width > size.height) { + orientation = NS_STYLE_ORIENTATION_LANDSCAPE; + } else { + // Per spec, square viewports should be 'portrait' + orientation = NS_STYLE_ORIENTATION_PORTRAIT; + } - aResult.SetIntValue(orientation, eCSSUnit_Enumerated); - return NS_OK; + aResult.SetIntValue(orientation, eCSSUnit_Enumerated); + return NS_OK; } static nsresult @@ -202,207 +203,207 @@ GetIsResourceDocument(nsPresContext* aPresContext, const nsMediaFeature*, static nsresult MakeArray(const nsSize& aSize, nsCSSValue& aResult) { - RefPtr a = nsCSSValue::Array::Create(2); + RefPtr a = nsCSSValue::Array::Create(2); - a->Item(0).SetIntValue(aSize.width, eCSSUnit_Integer); - a->Item(1).SetIntValue(aSize.height, eCSSUnit_Integer); + a->Item(0).SetIntValue(aSize.width, eCSSUnit_Integer); + a->Item(1).SetIntValue(aSize.height, eCSSUnit_Integer); - aResult.SetArrayValue(a, eCSSUnit_Array); - return NS_OK; + aResult.SetArrayValue(a, eCSSUnit_Array); + return NS_OK; } static nsresult GetAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - return MakeArray(GetSize(aPresContext), aResult); + return MakeArray(GetSize(aPresContext), aResult); } static nsresult GetDeviceAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - return MakeArray(GetDeviceSize(aPresContext), aResult); + return MakeArray(GetDeviceSize(aPresContext), aResult); } static nsresult GetColor(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - uint32_t depth = 24; // Use depth of 24 when resisting fingerprinting. + uint32_t depth = 24; // Use depth of 24 when resisting fingerprinting. - if (!ShouldResistFingerprinting(aPresContext)) { - // FIXME: This implementation is bogus. nsDeviceContext - // doesn't provide reliable information (should be fixed in bug - // 424386). - // FIXME: On a monochrome device, return 0! - nsDeviceContext *dx = GetDeviceContextFor(aPresContext); - dx->GetDepth(depth); - } + if (!ShouldResistFingerprinting(aPresContext)) { + // FIXME: This implementation is bogus. nsDeviceContext + // doesn't provide reliable information (should be fixed in bug + // 424386). + // FIXME: On a monochrome device, return 0! + nsDeviceContext *dx = GetDeviceContextFor(aPresContext); + dx->GetDepth(depth); + } - // The spec says to use bits *per color component*, so divide by 3, - // and round down, since the spec says to use the smallest when the - // color components differ. - depth /= 3; - aResult.SetIntValue(int32_t(depth), eCSSUnit_Integer); - return NS_OK; + // The spec says to use bits *per color component*, so divide by 3, + // and round down, since the spec says to use the smallest when the + // color components differ. + depth /= 3; + aResult.SetIntValue(int32_t(depth), eCSSUnit_Integer); + return NS_OK; } static nsresult GetColorIndex(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - // We should return zero if the device does not use a color lookup - // table. Stuart says that our handling of displays with 8-bit - // color is bad enough that we never change the lookup table to - // match what we're trying to display, so perhaps we should always - // return zero. Given that there isn't any better information - // exposed, we don't have much other choice. - aResult.SetIntValue(0, eCSSUnit_Integer); - return NS_OK; + // We should return zero if the device does not use a color lookup + // table. Stuart says that our handling of displays with 8-bit + // color is bad enough that we never change the lookup table to + // match what we're trying to display, so perhaps we should always + // return zero. Given that there isn't any better information + // exposed, we don't have much other choice. + aResult.SetIntValue(0, eCSSUnit_Integer); + return NS_OK; } static nsresult GetMonochrome(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - // For color devices we should return 0. - // FIXME: On a monochrome device, return the actual color depth, not - // 0! - aResult.SetIntValue(0, eCSSUnit_Integer); - return NS_OK; + // For color devices we should return 0. + // FIXME: On a monochrome device, return the actual color depth, not + // 0! + aResult.SetIntValue(0, eCSSUnit_Integer); + return NS_OK; } static nsresult GetResolution(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - float dpi = 96; // Use 96 when resisting fingerprinting. + float dpi = 96; // Use 96 when resisting fingerprinting. - if (!ShouldResistFingerprinting(aPresContext)) { - // Resolution measures device pixels per CSS (inch/cm/pixel). We - // return it in device pixels per CSS inches. - dpi = float(nsPresContext::AppUnitsPerCSSInch()) / - float(aPresContext->AppUnitsPerDevPixel()); - } + if (!ShouldResistFingerprinting(aPresContext)) { + // Resolution measures device pixels per CSS (inch/cm/pixel). We + // return it in device pixels per CSS inches. + dpi = float(nsPresContext::AppUnitsPerCSSInch()) / + float(aPresContext->AppUnitsPerDevPixel()); + } - aResult.SetFloatValue(dpi, eCSSUnit_Inch); - return NS_OK; + aResult.SetFloatValue(dpi, eCSSUnit_Inch); + return NS_OK; } static nsresult GetScan(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - // Since Gecko doesn't support the 'tv' media type, the 'scan' - // feature is never present. - aResult.Reset(); - return NS_OK; + // Since Gecko doesn't support the 'tv' media type, the 'scan' + // feature is never present. + aResult.Reset(); + return NS_OK; } static nsresult GetGrid(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - // Gecko doesn't support grid devices (e.g., ttys), so the 'grid' - // feature is always 0. - aResult.SetIntValue(0, eCSSUnit_Integer); - return NS_OK; + // Gecko doesn't support grid devices (e.g., ttys), so the 'grid' + // feature is always 0. + aResult.SetIntValue(0, eCSSUnit_Integer); + return NS_OK; } static nsresult GetDevicePixelRatio(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { - if (!ShouldResistFingerprinting(aPresContext)) { - float ratio = aPresContext->CSSPixelsToDevPixels(1.0f); - aResult.SetFloatValue(ratio, eCSSUnit_Number); - } else { - aResult.SetFloatValue(1.0, eCSSUnit_Number); - } - return NS_OK; + if (!ShouldResistFingerprinting(aPresContext)) { + float ratio = aPresContext->CSSPixelsToDevPixels(1.0f); + aResult.SetFloatValue(ratio, eCSSUnit_Number); + } else { + aResult.SetFloatValue(1.0, eCSSUnit_Number); + } + return NS_OK; } static nsresult GetSystemMetric(nsPresContext* aPresContext, const nsMediaFeature* aFeature, nsCSSValue& aResult) { - aResult.Reset(); - if (ShouldResistFingerprinting(aPresContext)) { - // If "privacy.resistFingerprinting" is enabled, then we simply don't - // return any system-backed media feature values. (No spoofed values returned.) - return NS_OK; - } - - MOZ_ASSERT(aFeature->mValueType == nsMediaFeature::eBoolInteger, - "unexpected type"); - nsIAtom *metricAtom = *aFeature->mData.mMetric; - bool hasMetric = nsCSSRuleProcessor::HasSystemMetric(metricAtom); - aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer); + aResult.Reset(); + if (ShouldResistFingerprinting(aPresContext)) { + // If "privacy.resistFingerprinting" is enabled, then we simply don't + // return any system-backed media feature values. (No spoofed values returned.) return NS_OK; + } + + MOZ_ASSERT(aFeature->mValueType == nsMediaFeature::eBoolInteger, + "unexpected type"); + nsIAtom *metricAtom = *aFeature->mData.mMetric; + bool hasMetric = nsCSSRuleProcessor::HasSystemMetric(metricAtom); + aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer); + return NS_OK; } static nsresult GetWindowsTheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature, nsCSSValue& aResult) { - aResult.Reset(); - if (ShouldResistFingerprinting(aPresContext)) { - return NS_OK; - } + aResult.Reset(); + if (ShouldResistFingerprinting(aPresContext)) { + return NS_OK; + } #ifdef XP_WIN - uint8_t windowsThemeId = - nsCSSRuleProcessor::GetWindowsThemeIdentifier(); + uint8_t windowsThemeId = + nsCSSRuleProcessor::GetWindowsThemeIdentifier(); - // Classic mode should fail to match. - if (windowsThemeId == LookAndFeel::eWindowsTheme_Classic) - return NS_OK; - - // Look up the appropriate theme string - for (size_t i = 0; i < ArrayLength(themeStrings); ++i) { - if (windowsThemeId == themeStrings[i].id) { - aResult.SetStringValue(nsDependentString(themeStrings[i].name), - eCSSUnit_Ident); - break; - } - } -#endif + // Classic mode should fail to match. + if (windowsThemeId == LookAndFeel::eWindowsTheme_Classic) return NS_OK; + + // Look up the appropriate theme string + for (size_t i = 0; i < ArrayLength(themeStrings); ++i) { + if (windowsThemeId == themeStrings[i].id) { + aResult.SetStringValue(nsDependentString(themeStrings[i].name), + eCSSUnit_Ident); + break; + } + } +#endif + return NS_OK; } static nsresult GetOperatingSystemVersion(nsPresContext* aPresContext, const nsMediaFeature* aFeature, nsCSSValue& aResult) { - aResult.Reset(); - if (ShouldResistFingerprinting(aPresContext)) { - return NS_OK; - } + aResult.Reset(); + if (ShouldResistFingerprinting(aPresContext)) { + return NS_OK; + } #ifdef XP_WIN - int32_t metricResult; - if (NS_SUCCEEDED( - LookAndFeel::GetInt(LookAndFeel::eIntID_OperatingSystemVersionIdentifier, - &metricResult))) { - for (size_t i = 0; i < ArrayLength(osVersionStrings); ++i) { - if (metricResult == osVersionStrings[i].id) { - aResult.SetStringValue(nsDependentString(osVersionStrings[i].name), - eCSSUnit_Ident); - break; - } - } + int32_t metricResult; + if (NS_SUCCEEDED( + LookAndFeel::GetInt(LookAndFeel::eIntID_OperatingSystemVersionIdentifier, + &metricResult))) { + for (size_t i = 0; i < ArrayLength(osVersionStrings); ++i) { + if (metricResult == osVersionStrings[i].id) { + aResult.SetStringValue(nsDependentString(osVersionStrings[i].name), + eCSSUnit_Ident); + break; + } } + } #endif - return NS_OK; + return NS_OK; } static nsresult GetIsGlyph(nsPresContext* aPresContext, const nsMediaFeature* aFeature, nsCSSValue& aResult) { - aResult.SetIntValue(aPresContext->IsGlyph() ? 1 : 0, eCSSUnit_Integer); - return NS_OK; + aResult.SetIntValue(aPresContext->IsGlyph() ? 1 : 0, eCSSUnit_Integer); + return NS_OK; } /* @@ -416,344 +417,344 @@ GetIsGlyph(nsPresContext* aPresContext, const nsMediaFeature* aFeature, /* static */ const nsMediaFeature nsMediaFeatures::features[] = { - { - &nsGkAtoms::width, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eLength, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetWidth - }, - { - &nsGkAtoms::height, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eLength, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetHeight - }, - { - &nsGkAtoms::deviceWidth, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eLength, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetDeviceWidth - }, - { - &nsGkAtoms::deviceHeight, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eLength, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetDeviceHeight - }, - { - &nsGkAtoms::orientation, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eEnumerated, - nsMediaFeature::eNoRequirements, - { kOrientationKeywords }, - GetOrientation - }, - { - &nsGkAtoms::aspectRatio, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eIntRatio, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetAspectRatio - }, - { - &nsGkAtoms::deviceAspectRatio, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eIntRatio, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetDeviceAspectRatio - }, - { - &nsGkAtoms::color, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eInteger, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetColor - }, - { - &nsGkAtoms::colorIndex, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eInteger, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetColorIndex - }, - { - &nsGkAtoms::monochrome, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eInteger, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetMonochrome - }, - { - &nsGkAtoms::resolution, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eResolution, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetResolution - }, - { - &nsGkAtoms::scan, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eEnumerated, - nsMediaFeature::eNoRequirements, - { kScanKeywords }, - GetScan - }, - { - &nsGkAtoms::grid, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetGrid - }, + { + &nsGkAtoms::width, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eLength, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetWidth + }, + { + &nsGkAtoms::height, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eLength, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetHeight + }, + { + &nsGkAtoms::deviceWidth, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eLength, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetDeviceWidth + }, + { + &nsGkAtoms::deviceHeight, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eLength, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetDeviceHeight + }, + { + &nsGkAtoms::orientation, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eEnumerated, + nsMediaFeature::eNoRequirements, + { kOrientationKeywords }, + GetOrientation + }, + { + &nsGkAtoms::aspectRatio, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eIntRatio, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetAspectRatio + }, + { + &nsGkAtoms::deviceAspectRatio, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eIntRatio, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetDeviceAspectRatio + }, + { + &nsGkAtoms::color, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetColor + }, + { + &nsGkAtoms::colorIndex, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetColorIndex + }, + { + &nsGkAtoms::monochrome, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetMonochrome + }, + { + &nsGkAtoms::resolution, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eResolution, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetResolution + }, + { + &nsGkAtoms::scan, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eEnumerated, + nsMediaFeature::eNoRequirements, + { kScanKeywords }, + GetScan + }, + { + &nsGkAtoms::grid, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetGrid + }, - // Webkit extensions that we support for de-facto web compatibility - // -webkit-{min|max}-device-pixel-ratio: - { - &nsGkAtoms::devicePixelRatio, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eFloat, - nsMediaFeature::eHasWebkitPrefix, - { nullptr }, - GetDevicePixelRatio - }, + // Webkit extensions that we support for de-facto web compatibility + // -webkit-{min|max}-device-pixel-ratio: + { + &nsGkAtoms::devicePixelRatio, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eFloat, + nsMediaFeature::eHasWebkitPrefix, + { nullptr }, + GetDevicePixelRatio + }, - // Mozilla extensions - { - &nsGkAtoms::_moz_device_pixel_ratio, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eFloat, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetDevicePixelRatio - }, - { - &nsGkAtoms::_moz_device_orientation, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eEnumerated, - nsMediaFeature::eNoRequirements, - { kOrientationKeywords }, - GetDeviceOrientation - }, - { - &nsGkAtoms::_moz_is_resource_document, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetIsResourceDocument - }, - { - &nsGkAtoms::_moz_color_picker_available, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::color_picker_available }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_scrollbar_start_backward, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::scrollbar_start_backward }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_scrollbar_start_forward, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::scrollbar_start_forward }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_scrollbar_end_backward, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::scrollbar_end_backward }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_scrollbar_end_forward, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::scrollbar_end_forward }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_scrollbar_thumb_proportional, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::scrollbar_thumb_proportional }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_images_in_menus, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::images_in_menus }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_images_in_buttons, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::images_in_buttons }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_overlay_scrollbars, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::overlay_scrollbars }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_windows_default_theme, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::windows_default_theme }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_mac_graphite_theme, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::mac_graphite_theme }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_mac_lion_theme, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::mac_lion_theme }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_mac_yosemite_theme, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::mac_yosemite_theme }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_windows_compositor, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::windows_compositor }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_windows_classic, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::windows_classic }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_windows_glass, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::windows_glass }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_touch_enabled, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::touch_enabled }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_menubar_drag, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::menubar_drag }, - GetSystemMetric - }, - { - &nsGkAtoms::_moz_windows_theme, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eIdent, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetWindowsTheme - }, - { - &nsGkAtoms::_moz_os_version, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eIdent, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetOperatingSystemVersion - }, + // Mozilla extensions + { + &nsGkAtoms::_moz_device_pixel_ratio, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eFloat, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetDevicePixelRatio + }, + { + &nsGkAtoms::_moz_device_orientation, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eEnumerated, + nsMediaFeature::eNoRequirements, + { kOrientationKeywords }, + GetDeviceOrientation + }, + { + &nsGkAtoms::_moz_is_resource_document, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetIsResourceDocument + }, + { + &nsGkAtoms::_moz_color_picker_available, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::color_picker_available }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_scrollbar_start_backward, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::scrollbar_start_backward }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_scrollbar_start_forward, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::scrollbar_start_forward }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_scrollbar_end_backward, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::scrollbar_end_backward }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_scrollbar_end_forward, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::scrollbar_end_forward }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_scrollbar_thumb_proportional, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::scrollbar_thumb_proportional }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_images_in_menus, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::images_in_menus }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_images_in_buttons, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::images_in_buttons }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_overlay_scrollbars, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::overlay_scrollbars }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_windows_default_theme, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::windows_default_theme }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_mac_graphite_theme, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::mac_graphite_theme }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_mac_lion_theme, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::mac_lion_theme }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_mac_yosemite_theme, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::mac_yosemite_theme }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_windows_compositor, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::windows_compositor }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_windows_classic, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::windows_classic }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_windows_glass, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::windows_glass }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_touch_enabled, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::touch_enabled }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_menubar_drag, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::menubar_drag }, + GetSystemMetric + }, + { + &nsGkAtoms::_moz_windows_theme, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eIdent, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetWindowsTheme + }, + { + &nsGkAtoms::_moz_os_version, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eIdent, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetOperatingSystemVersion + }, - { - &nsGkAtoms::_moz_swipe_animation_enabled, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::swipe_animation_enabled }, - GetSystemMetric - }, + { + &nsGkAtoms::_moz_swipe_animation_enabled, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::swipe_animation_enabled }, + GetSystemMetric + }, - { - &nsGkAtoms::_moz_physical_home_button, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { &nsGkAtoms::physical_home_button }, - GetSystemMetric - }, + { + &nsGkAtoms::_moz_physical_home_button, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::physical_home_button }, + GetSystemMetric + }, - // Internal -moz-is-glyph media feature: applies only inside SVG glyphs. - // Internal because it is really only useful in the user agent anyway - // and therefore not worth standardizing. - { - &nsGkAtoms::_moz_is_glyph, - nsMediaFeature::eMinMaxNotAllowed, - nsMediaFeature::eBoolInteger, - nsMediaFeature::eNoRequirements, - { nullptr }, - GetIsGlyph - }, - // Null-mName terminator: - { - nullptr, - nsMediaFeature::eMinMaxAllowed, - nsMediaFeature::eInteger, - nsMediaFeature::eNoRequirements, - { nullptr }, - nullptr - }, + // Internal -moz-is-glyph media feature: applies only inside SVG glyphs. + // Internal because it is really only useful in the user agent anyway + // and therefore not worth standardizing. + { + &nsGkAtoms::_moz_is_glyph, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetIsGlyph + }, + // Null-mName terminator: + { + nullptr, + nsMediaFeature::eMinMaxAllowed, + nsMediaFeature::eInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + nullptr + }, }; diff --git a/layout/style/nsMediaFeatures.h b/layout/style/nsMediaFeatures.h index 0d0403ea9972..edc1cc0b1d5c 100644 --- a/layout/style/nsMediaFeatures.h +++ b/layout/style/nsMediaFeatures.h @@ -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_) */ diff --git a/layout/style/nsROCSSPrimitiveValue.cpp b/layout/style/nsROCSSPrimitiveValue.cpp index 83a01651b146..7c66d0b20305 100644 --- a/layout/style/nsROCSSPrimitiveValue.cpp +++ b/layout/style/nsROCSSPrimitiveValue.cpp @@ -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 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 03f6ae315774..97f01cce9b1d 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -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); } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 3e62535d3eee..ec12f7a54fe7 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -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 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 track, i.e. when mRepeatAutoIndex == -1). // When mIsSubgrid is true, mRepeatAutoLineNameListBefore contains the line // names and mRepeatAutoLineNameListAfter is empty. -struct nsStyleGridTemplate { +struct nsStyleGridTemplate +{ nsTArray> mLineNameLists; nsTArray mMinTrackSizingFunctions; nsTArray 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 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 { +struct nsTArray_CopyChooser +{ typedef nsTArray_CopyWithConstructors 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(); diff --git a/layout/svg/SVGTextFrame.h b/layout/svg/SVGTextFrame.h index 36769eed94bb..9b423e9d16f7 100644 --- a/layout/svg/SVGTextFrame.h +++ b/layout/svg/SVGTextFrame.h @@ -212,8 +212,7 @@ public: } // namespace mozilla /** - * Frame class for SVG elements, used when the - * layout.svg.css-text.enabled is true. + * Frame class for SVG elements. * * An SVGTextFrame manages SVG text layout, painting and interaction for * all descendent text content elements. The frame tree will look like this: diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index ed2df662ce8a..6d737aefa272 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -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); } } diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 28e3d5787def..20f3848fe083 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -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 diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index 1b87ab8148fc..da78df981e28 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -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) { diff --git a/toolkit/components/telemetry/TelemetryController.jsm b/toolkit/components/telemetry/TelemetryController.jsm index c082817b27ef..c19e483c5a12 100644 --- a/toolkit/components/telemetry/TelemetryController.jsm +++ b/toolkit/components/telemetry/TelemetryController.jsm @@ -739,6 +739,7 @@ var Impl = { try { // TODO: This should probably happen after all the delayed init here. this._initialized = true; + TelemetryEnvironment.delayedInit(); yield TelemetrySend.setup(this._testMode); diff --git a/toolkit/components/telemetry/TelemetryEnvironment.jsm b/toolkit/components/telemetry/TelemetryEnvironment.jsm index 795f0e5e0df7..3fe07598c778 100644 --- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -65,6 +65,10 @@ this.TelemetryEnvironment = { return getGlobal().onInitialized(); }, + delayedInit: function() { + return getGlobal().delayedInit(); + }, + registerChangeListener: function(name, listener) { return getGlobal().registerChangeListener(name, listener); }, @@ -664,6 +668,7 @@ function EnvironmentCache() { this._log.trace("constructor"); this._shutdown = false; + this._delayedInitFinished = false; // A map of listeners that will be called on environment changes. this._changeListeners = new Map(); @@ -740,6 +745,13 @@ EnvironmentCache.prototype = { return Promise.resolve(this.currentEnvironment); }, + /** + * This gets called when the delayed init completes. + */ + delayedInit: function() { + this._delayedInitFinished = true; + }, + /** * Register a listener for environment changes. * @param name The name of the listener. If a new listener is registered @@ -1304,6 +1316,7 @@ EnvironmentCache.prototype = { // We are already skipping change events in _checkChanges if there is a pending change task running. let now = Policy.now(); if (this._lastEnvironmentChangeDate && + this._delayedInitFinished && (CHANGE_THROTTLE_INTERVAL_MS >= (now.getTime() - this._lastEnvironmentChangeDate.getTime()))) { this._log.trace("_onEnvironmentChange - throttling changes, now: " + now + @@ -1311,7 +1324,9 @@ EnvironmentCache.prototype = { return; } - this._lastEnvironmentChangeDate = now; + if(this._delayedInitFinished) { + this._lastEnvironmentChangeDate = now; + } for (let [name, listener] of this._changeListeners) { try { diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js index 68b9ea08a175..493e6d7bb41a 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js @@ -653,6 +653,7 @@ function isRejected(promise) { add_task(function* asyncSetup() { yield spoofProfileReset(); + TelemetryEnvironment.delayedInit(); }); add_task(function* test_checkEnvironment() { diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryLog.js b/toolkit/components/telemetry/tests/unit/test_TelemetryLog.js index 44d73b296d1f..4f9d3854854b 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryLog.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryLog.js @@ -24,8 +24,9 @@ function check_event(event, id, data) } } -function* run_test() +add_task(function* () { + do_get_profile(); yield TelemetrySession.setup(); TelemetryLog.log(TEST_PREFIX + "1", ["val", 123, undefined]); @@ -45,4 +46,4 @@ function* run_test() do_check_true(log[1][1] <= log[2][1]); yield TelemetrySession.shutdown(); -} +}); diff --git a/toolkit/content/tests/widgets/mochitest.ini b/toolkit/content/tests/widgets/mochitest.ini index 96d63eb6fdde..4163fc958a38 100644 --- a/toolkit/content/tests/widgets/mochitest.ini +++ b/toolkit/content/tests/widgets/mochitest.ini @@ -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] diff --git a/widget/android/AndroidGraphicBuffer.cpp b/widget/android/AndroidGraphicBuffer.cpp index c74b70c8ddef..a600b0158776 100644 --- a/widget/android/AndroidGraphicBuffer.cpp +++ b/widget/android/AndroidGraphicBuffer.cpp @@ -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; diff --git a/widget/cocoa/nsDeviceContextSpecX.mm b/widget/cocoa/nsDeviceContextSpecX.mm index 6ac66060c12f..39563da0a4bc 100644 --- a/widget/cocoa/nsDeviceContextSpecX.mm +++ b/widget/cocoa/nsDeviceContextSpecX.mm @@ -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) diff --git a/widget/nsDeviceContextSpecProxy.cpp b/widget/nsDeviceContextSpecProxy.cpp index 560816ce27bd..6d2b9c62263b 100644 --- a/widget/nsDeviceContextSpecProxy.cpp +++ b/widget/nsDeviceContextSpecProxy.cpp @@ -86,7 +86,7 @@ nsDeviceContextSpecProxy::GetSurfaceForPrinter(gfxASurface** aSurface) RefPtr surface = gfxPlatform::GetPlatform()-> CreateOffscreenSurface(mozilla::gfx::IntSize(width, height), - gfxImageFormat::ARGB32); + SurfaceFormat::A8R8G8B8_UINT32); surface.forget(aSurface); return NS_OK; diff --git a/widget/windows/TaskbarPreview.cpp b/widget/windows/TaskbarPreview.cpp index ad20f038ca80..b7cd7703700b 100644 --- a/widget/windows/TaskbarPreview.cpp +++ b/widget/windows/TaskbarPreview.cpp @@ -357,7 +357,7 @@ TaskbarPreview::UpdateTooltip() { void TaskbarPreview::DrawBitmap(uint32_t width, uint32_t height, bool isPreview) { nsresult rv; - RefPtr surface = new gfxWindowsSurface(gfx::IntSize(width, height), gfxImageFormat::ARGB32); + RefPtr surface = new gfxWindowsSurface(gfx::IntSize(width, height), gfx::SurfaceFormat::A8R8G8B8_UINT32); nsCOMPtr shell = do_QueryReferent(mDocShell); diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 8a98a056cc33..15ffabb84bdd 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -6939,7 +6939,7 @@ void nsWindow::ResizeTranslucentWindow(int32_t aNewWidth, int32_t aNewHeight, bo return; RefPtr newSurface = - new gfxWindowsSurface(IntSize(aNewWidth, aNewHeight), gfxImageFormat::ARGB32); + new gfxWindowsSurface(IntSize(aNewWidth, aNewHeight), SurfaceFormat::A8R8G8B8_UINT32); mTransparentSurface = newSurface; mMemoryDC = newSurface->GetDC(); } diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp index ecaab98ae840..e702d87fcd30 100644 --- a/widget/windows/nsWindowGfx.cpp +++ b/widget/windows/nsWindowGfx.cpp @@ -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));