diff --git a/browser/base/content/content.js b/browser/base/content/content.js index e734f4b1867..36f5e70d536 100644 --- a/browser/base/content/content.js +++ b/browser/base/content/content.js @@ -16,18 +16,6 @@ XPCOMUtils.defineLazyModuleGetter(this, XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); -// Bug 671101 - directly using webNavigation in this context -// causes docshells to leak -this.__defineGetter__("webNavigation", function () { - return docShell.QueryInterface(Ci.nsIWebNavigation); -}); - -addMessageListener("WebNavigation:LoadURI", function (message) { - let flags = message.json.flags || webNavigation.LOAD_FLAGS_NONE; - - webNavigation.loadURI(message.json.uri, flags, null, null, null); -}); - addMessageListener("Browser:HideSessionRestoreButton", function (message) { // Hide session restore button on about:home let doc = content.document; diff --git a/caps/idl/nsIPrincipal.idl b/caps/idl/nsIPrincipal.idl index 9cea30c1b9a..9fa2d91b957 100644 --- a/caps/idl/nsIPrincipal.idl +++ b/caps/idl/nsIPrincipal.idl @@ -8,7 +8,6 @@ #include "nsISerializable.idl" %{C++ -struct JSContext; struct JSPrincipals; #include "nsCOMPtr.h" #include "nsTArray.h" diff --git a/caps/include/nsScriptSecurityManager.h b/caps/include/nsScriptSecurityManager.h index c559d93e4c6..46e7563266d 100644 --- a/caps/include/nsScriptSecurityManager.h +++ b/caps/include/nsScriptSecurityManager.h @@ -18,13 +18,10 @@ #include "pldhash.h" #include "plstr.h" #include "nsIScriptExternalNameSet.h" +#include "js/TypeDecls.h" #include -namespace JS { -template class Handle; -template class MutableHandle; -} class nsIDocShell; class nsString; class nsIClassInfo; diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index ba1c3dd27d1..41fb068846c 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -18,6 +18,7 @@ #include #endif +#include "js/TypeDecls.h" #include "js/RootingAPI.h" #include "mozilla/Assertions.h" #include "mozilla/GuardObjects.h" @@ -92,7 +93,6 @@ class nsTextFragment; class nsViewportInfo; class nsWrapperCache; -struct JSContext; struct JSPropertyDescriptor; struct JSRuntime; struct nsIntMargin; @@ -103,10 +103,6 @@ template class nsDataHashtable; template class nsRefPtrHashtable; template class nsReadingIterator; -namespace JS { -class Value; -} // namespace JS - namespace mozilla { class ErrorResult; class Selection; diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index c853a5b5429..abde6c3bf8f 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -19,6 +19,7 @@ #include "mozilla/ErrorResult.h" #include "mozilla/MemoryReporting.h" #include "mozilla/dom/EventTarget.h" // for base class +#include "js/TypeDecls.h" // for Handle, Value, JSObject, JSContext // Including 'windows.h' will #define GetClassInfo to something else. #ifdef XP_WIN @@ -67,11 +68,6 @@ template class Optional; } // namespace dom } // namespace mozilla -namespace JS { -class Value; -template class Handle; -} - #define NODE_FLAG_BIT(n_) (1U << (WRAPPER_CACHE_FLAGS_BITS_USED + (n_))) enum { diff --git a/content/base/src/nsFrameMessageManager.h b/content/base/src/nsFrameMessageManager.h index 55b2acc6211..5d57da54eae 100644 --- a/content/base/src/nsFrameMessageManager.h +++ b/content/base/src/nsFrameMessageManager.h @@ -108,8 +108,6 @@ StructuredCloneData UnpackClonedMessageDataForChild(const ClonedMessageData& aDa } // namespace mozilla class nsAXPCNativeCallContext; -struct JSContext; -class JSObject; struct nsMessageListenerInfo { diff --git a/content/base/src/nsNodeUtils.h b/content/base/src/nsNodeUtils.h index f3df33763a7..d02d75d9e29 100644 --- a/content/base/src/nsNodeUtils.h +++ b/content/base/src/nsNodeUtils.h @@ -8,10 +8,9 @@ #include "nsIContent.h" // for use in inline function (ParentChainChanged) #include "nsIMutationObserver.h" // for use in inline function (ParentChainChanged) +#include "js/TypeDecls.h" struct CharacterDataChangeInfo; -struct JSContext; -class JSObject; class nsIVariant; class nsIDOMNode; class nsIDOMUserDataHandler; diff --git a/content/canvas/src/WebGLActiveInfo.h b/content/canvas/src/WebGLActiveInfo.h index fe24079669f..54625c26e84 100644 --- a/content/canvas/src/WebGLActiveInfo.h +++ b/content/canvas/src/WebGLActiveInfo.h @@ -9,12 +9,7 @@ #include "WebGLTypes.h" #include "nsISupports.h" #include "nsString.h" - -struct JSContext; -class JSObject; -namespace JS { -template class Handle; -} +#include "js/TypeDecls.h" namespace mozilla { diff --git a/content/events/src/nsDOMEvent.h b/content/events/src/nsDOMEvent.h index d307a1158f7..7d9da1107af 100644 --- a/content/events/src/nsDOMEvent.h +++ b/content/events/src/nsDOMEvent.h @@ -18,12 +18,11 @@ #include "mozilla/dom/EventBinding.h" #include "nsIScriptGlobalObject.h" #include "Units.h" +#include "js/TypeDecls.h" class nsIContent; class nsIDOMEventTarget; class nsPresContext; -struct JSContext; -class JSObject; namespace mozilla { namespace dom { diff --git a/content/events/src/nsDOMUIEvent.cpp b/content/events/src/nsDOMUIEvent.cpp index faed83e1601..6ea59d31ecd 100644 --- a/content/events/src/nsDOMUIEvent.cpp +++ b/content/events/src/nsDOMUIEvent.cpp @@ -348,7 +348,7 @@ nsDOMUIEvent::IsChar() const case NS_KEY_EVENT: return static_cast(mEvent)->isChar; case NS_TEXT_EVENT: - return static_cast(mEvent)->isChar; + return static_cast(mEvent)->isChar; default: return false; } diff --git a/content/html/content/public/nsIHTMLCollection.h b/content/html/content/public/nsIHTMLCollection.h index 99e9e4baec9..76e5afac1bd 100644 --- a/content/html/content/public/nsIHTMLCollection.h +++ b/content/html/content/public/nsIHTMLCollection.h @@ -8,9 +8,8 @@ #include "nsIDOMHTMLCollection.h" #include "nsWrapperCache.h" +#include "js/TypeDecls.h" -struct JSContext; -class JSObject; class nsINode; class nsString; template class nsTArray; diff --git a/content/html/content/src/HTMLCanvasElement.cpp b/content/html/content/src/HTMLCanvasElement.cpp index 21eee4079c8..7312b86edc1 100644 --- a/content/html/content/src/HTMLCanvasElement.cpp +++ b/content/html/content/src/HTMLCanvasElement.cpp @@ -5,7 +5,7 @@ #include "mozilla/dom/HTMLCanvasElement.h" -#include "BasicLayers.h" +#include "Layers.h" #include "imgIEncoder.h" #include "jsapi.h" #include "jsfriendapi.h" diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp index 7de7d8586d7..9a0d5c9184e 100644 --- a/content/html/content/src/HTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -54,7 +54,7 @@ #include "nsICachingChannel.h" #include "nsLayoutUtils.h" #include "nsVideoFrame.h" -#include "BasicLayers.h" +#include "Layers.h" #include #include "nsIAsyncVerifyRedirectCallback.h" #include "nsIAppShell.h" diff --git a/content/html/content/src/ValidityState.h b/content/html/content/src/ValidityState.h index 1756741d76f..28711be86b3 100644 --- a/content/html/content/src/ValidityState.h +++ b/content/html/content/src/ValidityState.h @@ -9,9 +9,7 @@ #include "nsIDOMValidityState.h" #include "nsIConstraintValidation.h" #include "nsWrapperCache.h" - -class JSObject; -struct JSContext; +#include "js/TypeDecls.h" namespace mozilla { namespace dom { diff --git a/content/media/AudioNodeEngineNEON.cpp b/content/media/AudioNodeEngineNEON.cpp index 28a61ac3cdc..61138eb3fe4 100644 --- a/content/media/AudioNodeEngineNEON.cpp +++ b/content/media/AudioNodeEngineNEON.cpp @@ -174,77 +174,53 @@ AudioBlockPanStereoToStereo_NEON(const float aInputL[WEBAUDIO_BLOCK_SIZE], ASSERT_ALIGNED(aOutputL); ASSERT_ALIGNED(aOutputR); - float32x4_t vinL0, vinL1, vinL2, vinL3; - float32x4_t vinR0, vinR1, vinR2, vinR3; - float32x4_t voutL0, voutL1, voutL2, voutL3; - float32x4_t voutR0, voutR1, voutR2, voutR3; + float32x4_t vinL0, vinL1; + float32x4_t vinR0, vinR1; + float32x4_t voutL0, voutL1; + float32x4_t voutR0, voutR1; float32x4_t vscaleL = vmovq_n_f32(aGainL); float32x4_t vscaleR = vmovq_n_f32(aGainR); if (aIsOnTheLeft) { - for (uint32_t i = 0; i < WEBAUDIO_BLOCK_SIZE; i+=16) { + for (uint32_t i = 0; i < WEBAUDIO_BLOCK_SIZE; i+=8) { vinL0 = vld1q_f32(ADDRESS_OF(aInputL, i)); vinL1 = vld1q_f32(ADDRESS_OF(aInputL, i+4)); - vinL2 = vld1q_f32(ADDRESS_OF(aInputL, i+8)); - vinL3 = vld1q_f32(ADDRESS_OF(aInputL, i+12)); vinR0 = vld1q_f32(ADDRESS_OF(aInputR, i)); vinR1 = vld1q_f32(ADDRESS_OF(aInputR, i+4)); - vinR2 = vld1q_f32(ADDRESS_OF(aInputR, i+8)); - vinR3 = vld1q_f32(ADDRESS_OF(aInputR, i+12)); voutL0 = vmlaq_f32(vinL0, vinR0, vscaleL); voutL1 = vmlaq_f32(vinL1, vinR1, vscaleL); - voutL2 = vmlaq_f32(vinL2, vinR2, vscaleL); - voutL3 = vmlaq_f32(vinL3, vinR3, vscaleL); vst1q_f32(ADDRESS_OF(aOutputL, i), voutL0); vst1q_f32(ADDRESS_OF(aOutputL, i+4), voutL1); - vst1q_f32(ADDRESS_OF(aOutputL, i+8), voutL2); - vst1q_f32(ADDRESS_OF(aOutputL, i+12), voutL3); voutR0 = vmulq_f32(vinR0, vscaleR); voutR1 = vmulq_f32(vinR1, vscaleR); - voutR2 = vmulq_f32(vinR2, vscaleR); - voutR3 = vmulq_f32(vinR3, vscaleR); vst1q_f32(ADDRESS_OF(aOutputR, i), voutR0); vst1q_f32(ADDRESS_OF(aOutputR, i+4), voutR1); - vst1q_f32(ADDRESS_OF(aOutputR, i+8), voutR2); - vst1q_f32(ADDRESS_OF(aOutputR, i+12), voutR3); } } else { - for (uint32_t i = 0; i < WEBAUDIO_BLOCK_SIZE; i+=16) { + for (uint32_t i = 0; i < WEBAUDIO_BLOCK_SIZE; i+=8) { vinL0 = vld1q_f32(ADDRESS_OF(aInputL, i)); vinL1 = vld1q_f32(ADDRESS_OF(aInputL, i+4)); - vinL2 = vld1q_f32(ADDRESS_OF(aInputL, i+8)); - vinL3 = vld1q_f32(ADDRESS_OF(aInputL, i+12)); vinR0 = vld1q_f32(ADDRESS_OF(aInputR, i)); vinR1 = vld1q_f32(ADDRESS_OF(aInputR, i+4)); - vinR2 = vld1q_f32(ADDRESS_OF(aInputR, i+8)); - vinR3 = vld1q_f32(ADDRESS_OF(aInputR, i+12)); voutL0 = vmulq_f32(vinL0, vscaleL); voutL1 = vmulq_f32(vinL1, vscaleL); - voutL2 = vmulq_f32(vinL2, vscaleL); - voutL3 = vmulq_f32(vinL3, vscaleL); vst1q_f32(ADDRESS_OF(aOutputL, i), voutL0); vst1q_f32(ADDRESS_OF(aOutputL, i+4), voutL1); - vst1q_f32(ADDRESS_OF(aOutputL, i+8), voutL2); - vst1q_f32(ADDRESS_OF(aOutputL, i+12), voutL3); voutR0 = vmlaq_f32(vinR0, vinL0, vscaleR); voutR1 = vmlaq_f32(vinR1, vinL1, vscaleR); - voutR2 = vmlaq_f32(vinR2, vinL2, vscaleR); - voutR3 = vmlaq_f32(vinR3, vinL3, vscaleR); vst1q_f32(ADDRESS_OF(aOutputR, i), voutR0); vst1q_f32(ADDRESS_OF(aOutputR, i+4), voutR1); - vst1q_f32(ADDRESS_OF(aOutputR, i+8), voutR2); - vst1q_f32(ADDRESS_OF(aOutputR, i+12), voutR3); } } } -} \ No newline at end of file +} diff --git a/content/media/webaudio/AudioBuffer.h b/content/media/webaudio/AudioBuffer.h index 18b02c63b8d..5c999c84661 100644 --- a/content/media/webaudio/AudioBuffer.h +++ b/content/media/webaudio/AudioBuffer.h @@ -14,9 +14,7 @@ #include "nsAutoPtr.h" #include "nsTArray.h" #include "AudioContext.h" - -struct JSContext; -class JSObject; +#include "js/TypeDecls.h" namespace mozilla { diff --git a/content/media/webaudio/AudioContext.h b/content/media/webaudio/AudioContext.h index 8773a272f0d..a3e518c10f8 100644 --- a/content/media/webaudio/AudioContext.h +++ b/content/media/webaudio/AudioContext.h @@ -17,6 +17,7 @@ #include "nsDOMEventTargetHelper.h" #include "nsHashKeys.h" #include "nsTHashtable.h" +#include "js/TypeDecls.h" // X11 has a #define for CurrentTime. Unbelievable :-(. // See content/media/DOMMediaStream.h for more fun! @@ -24,8 +25,6 @@ #undef CurrentTime #endif -struct JSContext; -class JSObject; class nsPIDOMWindow; namespace mozilla { diff --git a/content/media/webaudio/AudioListener.h b/content/media/webaudio/AudioListener.h index 48c9bd17223..91bd4733529 100644 --- a/content/media/webaudio/AudioListener.h +++ b/content/media/webaudio/AudioListener.h @@ -16,8 +16,7 @@ #include "AudioContext.h" #include "PannerNode.h" #include "WebAudioUtils.h" - -struct JSContext; +#include "js/TypeDecls.h" namespace mozilla { diff --git a/content/media/webaudio/AudioParam.h b/content/media/webaudio/AudioParam.h index 353aa96c466..877ee4a01f9 100644 --- a/content/media/webaudio/AudioParam.h +++ b/content/media/webaudio/AudioParam.h @@ -15,8 +15,7 @@ #include "AudioNode.h" #include "mozilla/dom/TypedArray.h" #include "WebAudioUtils.h" - -struct JSContext; +#include "js/TypeDecls.h" namespace mozilla { diff --git a/content/media/webaudio/DelayProcessor.cpp b/content/media/webaudio/DelayProcessor.cpp index e20dace1b16..e1805d56d82 100644 --- a/content/media/webaudio/DelayProcessor.cpp +++ b/content/media/webaudio/DelayProcessor.cpp @@ -38,9 +38,7 @@ DelayProcessor::Process(const double *aPerFrameDelays, 0.0, static_cast(mMaxDelayFrames)); // Write the input sample to the correct location in our buffer - if (input) { - buffer[writeIndex] = input[i]; - } + buffer[writeIndex] = input ? input[i] : 0.0f; // Now, determine the correct read position. We adjust the read position to be // from currentDelayFrames frames in the past. We also interpolate the two input @@ -109,7 +107,10 @@ DelayProcessor::EnsureBuffer(uint32_t aNumberOfChannels) if (!mBuffer.SetLength(aNumberOfChannels)) { return false; } - const int numFrames = mMaxDelayFrames; + // The length of the buffer is one greater than the maximum delay so that + // writing an input frame does not overwrite the frame that would + // subsequently be read at maximum delay. + const int numFrames = mMaxDelayFrames + 1; for (uint32_t channel = 0; channel < aNumberOfChannels; ++channel) { if (!mBuffer[channel].SetLength(numFrames)) { return false; diff --git a/content/media/webaudio/test/Makefile.in b/content/media/webaudio/test/Makefile.in index 4193c446a7d..abd4d27ddac 100644 --- a/content/media/webaudio/test/Makefile.in +++ b/content/media/webaudio/test/Makefile.in @@ -57,9 +57,11 @@ MOCHITEST_FILES := \ test_channelSplitterNode.html \ test_channelSplitterNodeWithVolume.html \ test_convolverNode.html \ + test_convolverNodeWithGain.html \ test_convolverNode_mono_mono.html \ test_currentTime.html \ test_delayNode.html \ + test_delayNodeAtMax.html \ test_delayNodeSmallMaxDelay.html \ test_delayNodeWithGain.html \ test_dynamicsCompressorNode.html \ diff --git a/content/media/webaudio/test/test_convolverNodeWithGain.html b/content/media/webaudio/test/test_convolverNodeWithGain.html new file mode 100644 index 00000000000..7bbe240890b --- /dev/null +++ b/content/media/webaudio/test/test_convolverNodeWithGain.html @@ -0,0 +1,62 @@ + + + + Test ConvolverNode after a GainNode - Bug 891254 + + + + +
+
+
+
+ + diff --git a/content/media/webaudio/test/test_delayNodeAtMax.html b/content/media/webaudio/test/test_delayNodeAtMax.html new file mode 100644 index 00000000000..6c7dde3d18c --- /dev/null +++ b/content/media/webaudio/test/test_delayNodeAtMax.html @@ -0,0 +1,53 @@ + + + + Test DelayNode with maxDelayTime delay - bug 890528 + + + + +
+
+
+
+ + diff --git a/content/media/webaudio/test/webaudio.js b/content/media/webaudio/test/webaudio.js index 77d9366c92e..e722ca0ae9a 100644 --- a/content/media/webaudio/test/webaudio.js +++ b/content/media/webaudio/test/webaudio.js @@ -68,8 +68,6 @@ function getEmptyBuffer(context, length) { * This function assumes that the test file defines a single gTest variable with * the following properties and methods: * - * + length: mandatory property equal to the total number of frames which we - * are waiting to see in the output. * + numberOfChannels: optional property which specifies the number of channels * in the output. The default value is 2. * + createGraph: mandatory method which takes a context object and does @@ -84,9 +82,17 @@ function getEmptyBuffer(context, length) { * returns either one expected buffer or an array of * them, designating what is expected to be observed * in the output. If omitted, the output is expected - * to be silence. The sum of the length of the expected - * buffers should be equal to gTest.length. This - * function is guaranteed to be called before createGraph. + * to be silence. All buffers must have the same + * length, which must be a bufferSize supported by + * ScriptProcessorNode. This function is guaranteed + * to be called before createGraph. + * + length: property equal to the total number of frames which we are waiting + * to see in the output, mandatory if createExpectedBuffers is not + * provided, in which case it must be a bufferSize supported by + * ScriptProcessorNode (256, 512, 1024, 2048, 4096, 8192, or 16384). + * If createExpectedBuffers is provided then this must be equal to + * the number of expected buffers * the expected buffer length. + * * + skipOfflineContextTests: optional. when true, skips running tests on an offline * context by circumventing testOnOfflineContext. */ @@ -120,7 +126,9 @@ function runTest() "Correct number of channels for expected buffer " + i); expectedFrames += expectedBuffers[i].length; } - is(expectedFrames, gTest.length, "Correct number of expected frames"); + if (gTest.length && gTest.createExpectedBuffers) { + is(expectedFrames, gTest.length, "Correct number of expected frames"); + } if (gTest.createGraphAsync) { gTest.createGraphAsync(context, function(nodeToInspect) { diff --git a/content/media/webspeech/recognition/SpeechGrammar.h b/content/media/webspeech/recognition/SpeechGrammar.h index 15d3f8ddcf1..d1ccbbc3126 100644 --- a/content/media/webspeech/recognition/SpeechGrammar.h +++ b/content/media/webspeech/recognition/SpeechGrammar.h @@ -10,14 +10,13 @@ #include "nsCycleCollectionParticipant.h" #include "nsString.h" #include "nsWrapperCache.h" +#include "js/TypeDecls.h" #include "mozilla/Attributes.h" #include "mozilla/ErrorResult.h" #include "EnableWebSpeechRecognitionCheck.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/content/media/webspeech/recognition/SpeechGrammarList.h b/content/media/webspeech/recognition/SpeechGrammarList.h index 75c2681cda1..8771f4b595c 100644 --- a/content/media/webspeech/recognition/SpeechGrammarList.h +++ b/content/media/webspeech/recognition/SpeechGrammarList.h @@ -9,6 +9,7 @@ #include "nsCOMPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" +#include "js/TypeDecls.h" #include "mozilla/Attributes.h" #include "mozilla/dom/BindingUtils.h" @@ -16,8 +17,6 @@ #include "EnableWebSpeechRecognitionCheck.h" #include "SpeechGrammar.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/content/media/webspeech/recognition/SpeechRecognition.h b/content/media/webspeech/recognition/SpeechRecognition.h index 27ca1128d90..1480fdc428c 100644 --- a/content/media/webspeech/recognition/SpeechRecognition.h +++ b/content/media/webspeech/recognition/SpeechRecognition.h @@ -12,6 +12,7 @@ #include "nsString.h" #include "nsWrapperCache.h" #include "nsTArray.h" +#include "js/TypeDecls.h" #include "nsIDOMNavigatorUserMedia.h" #include "nsITimer.h" @@ -30,7 +31,6 @@ #include "mozilla/dom/SpeechRecognitionError.h" -struct JSContext; class nsIDOMWindow; namespace mozilla { diff --git a/content/media/webspeech/recognition/SpeechRecognitionAlternative.h b/content/media/webspeech/recognition/SpeechRecognitionAlternative.h index d99490b733b..b85702bd94f 100644 --- a/content/media/webspeech/recognition/SpeechRecognitionAlternative.h +++ b/content/media/webspeech/recognition/SpeechRecognitionAlternative.h @@ -10,13 +10,12 @@ #include "nsString.h" #include "nsWrapperCache.h" #include "nsAutoPtr.h" +#include "js/TypeDecls.h" #include "mozilla/Attributes.h" #include "EnableWebSpeechRecognitionCheck.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/content/media/webspeech/recognition/SpeechRecognitionResult.h b/content/media/webspeech/recognition/SpeechRecognitionResult.h index d1152feae7c..678a0e7877d 100644 --- a/content/media/webspeech/recognition/SpeechRecognitionResult.h +++ b/content/media/webspeech/recognition/SpeechRecognitionResult.h @@ -11,14 +11,13 @@ #include "nsWrapperCache.h" #include "nsAutoPtr.h" #include "nsTArray.h" +#include "js/TypeDecls.h" #include "mozilla/Attributes.h" #include "EnableWebSpeechRecognitionCheck.h" #include "SpeechRecognitionAlternative.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/content/media/webspeech/recognition/SpeechRecognitionResultList.h b/content/media/webspeech/recognition/SpeechRecognitionResultList.h index 034b06ef2d3..ccdf310ddde 100644 --- a/content/media/webspeech/recognition/SpeechRecognitionResultList.h +++ b/content/media/webspeech/recognition/SpeechRecognitionResultList.h @@ -10,14 +10,13 @@ #include "nsWrapperCache.h" #include "nsAutoPtr.h" #include "nsTArray.h" +#include "js/TypeDecls.h" #include "mozilla/Attributes.h" #include "EnableWebSpeechRecognitionCheck.h" #include "SpeechRecognitionResult.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/content/media/webspeech/synth/SpeechSynthesis.h b/content/media/webspeech/synth/SpeechSynthesis.h index 35fadeaf718..bfa450ea92b 100644 --- a/content/media/webspeech/synth/SpeechSynthesis.h +++ b/content/media/webspeech/synth/SpeechSynthesis.h @@ -10,12 +10,12 @@ #include "nsString.h" #include "nsWrapperCache.h" #include "nsRefPtrHashtable.h" +#include "js/TypeDecls.h" #include "EnableSpeechSynthesisCheck.h" #include "SpeechSynthesisUtterance.h" #include "SpeechSynthesisVoice.h" -struct JSContext; class nsIDOMWindow; namespace mozilla { diff --git a/content/media/webspeech/synth/SpeechSynthesisUtterance.h b/content/media/webspeech/synth/SpeechSynthesisUtterance.h index b2497eb758b..d7fea62ae31 100644 --- a/content/media/webspeech/synth/SpeechSynthesisUtterance.h +++ b/content/media/webspeech/synth/SpeechSynthesisUtterance.h @@ -9,12 +9,11 @@ #include "nsCOMPtr.h" #include "nsDOMEventTargetHelper.h" #include "nsString.h" +#include "js/TypeDecls.h" #include "EnableSpeechSynthesisCheck.h" #include "nsSpeechTask.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/content/media/webspeech/synth/SpeechSynthesisVoice.h b/content/media/webspeech/synth/SpeechSynthesisVoice.h index ba5ea42f180..d036fab94d3 100644 --- a/content/media/webspeech/synth/SpeechSynthesisVoice.h +++ b/content/media/webspeech/synth/SpeechSynthesisVoice.h @@ -9,12 +9,11 @@ #include "nsCOMPtr.h" #include "nsString.h" #include "nsWrapperCache.h" +#include "js/TypeDecls.h" #include "EnableSpeechSynthesisCheck.h" #include "nsISpeechService.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/content/xbl/src/nsXBLBinding.h b/content/xbl/src/nsXBLBinding.h index 28f3897ad3f..534535ecf7e 100644 --- a/content/xbl/src/nsXBLBinding.h +++ b/content/xbl/src/nsXBLBinding.h @@ -15,6 +15,7 @@ #include "nsTArray.h" #include "nsCycleCollectionParticipant.h" #include "nsISupportsImpl.h" +#include "js/TypeDecls.h" class nsXBLPrototypeBinding; class nsIContent; @@ -31,8 +32,6 @@ class XBLChildrenElement; } class nsAnonymousContentList; -struct JSContext; -class JSObject; // *********************************************************************/ // The XBLBinding class diff --git a/content/xbl/src/nsXBLPrototypeHandler.h b/content/xbl/src/nsXBLPrototypeHandler.h index 80b93f09364..be6d0a49899 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.h +++ b/content/xbl/src/nsXBLPrototypeHandler.h @@ -15,8 +15,8 @@ #include "nsIWeakReference.h" #include "nsIScriptGlobalObject.h" #include "nsCycleCollectionParticipant.h" +#include "js/TypeDecls.h" -class JSObject; class nsIDOMEvent; class nsIContent; class nsIDOMUIEvent; @@ -26,10 +26,6 @@ class nsIObjectInputStream; class nsIObjectOutputStream; class nsXBLPrototypeBinding; -namespace JS { -template class MutableHandle; -} - namespace mozilla { namespace dom { class EventTarget; diff --git a/content/xbl/src/nsXBLSerialize.h b/content/xbl/src/nsXBLSerialize.h index 847c9b7d2c8..45f56266f99 100644 --- a/content/xbl/src/nsXBLSerialize.h +++ b/content/xbl/src/nsXBLSerialize.h @@ -9,11 +9,7 @@ #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" #include "nsINameSpaceManager.h" - -namespace JS { -template class Handle; -template class MutableHandle; -} +#include "js/TypeDecls.h" typedef uint8_t XBLBindingSerializeDetails; diff --git a/content/xul/document/src/XULDocument.h b/content/xul/document/src/XULDocument.h index 0462d273864..c417f53a8a2 100644 --- a/content/xul/document/src/XULDocument.h +++ b/content/xul/document/src/XULDocument.h @@ -25,6 +25,8 @@ #include "mozilla/Attributes.h" +#include "js/TypeDecls.h" + class nsIRDFResource; class nsIRDFService; class nsPIWindowRoot; @@ -40,7 +42,6 @@ class nsIXULPrototypeScript; #include "nsURIHashKey.h" #include "nsInterfaceHashtable.h" -class JSObject; struct JSTracer; struct PRLogModuleInfo; diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 61829c5aaad..24b512d7114 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -9,9 +9,9 @@ #include "nsIAtom.idl" %{ C++ +#include "js/TypeDecls.h" class nsPresContext; class nsIPresShell; -struct JSContext; %} /** diff --git a/dom/base/nsIGlobalObject.h b/dom/base/nsIGlobalObject.h index f9ec31995ee..e088386c803 100644 --- a/dom/base/nsIGlobalObject.h +++ b/dom/base/nsIGlobalObject.h @@ -8,8 +8,7 @@ #include "nsISupports.h" #include "nsIScriptObjectPrincipal.h" - -class JSObject; +#include "js/TypeDecls.h" #define NS_IGLOBALOBJECT_IID \ { 0x8503e9a9, 0x530, 0x4b26, \ diff --git a/dom/base/nsIScriptGlobalObject.h b/dom/base/nsIScriptGlobalObject.h index 0e6c9733153..c7620937a3c 100644 --- a/dom/base/nsIScriptGlobalObject.h +++ b/dom/base/nsIScriptGlobalObject.h @@ -10,11 +10,11 @@ #include "nsISupports.h" #include "nsEvent.h" #include "nsIGlobalObject.h" +#include "js/TypeDecls.h" class nsIScriptContext; class nsScriptErrorEvent; class nsIScriptGlobalObject; -class JSObject; // A helper function for nsIScriptGlobalObject implementations to use // when handling a script error. Generally called by the global when a context diff --git a/dom/base/nsIScriptTimeoutHandler.h b/dom/base/nsIScriptTimeoutHandler.h index b19f4fc2e21..db03a38ad6a 100644 --- a/dom/base/nsIScriptTimeoutHandler.h +++ b/dom/base/nsIScriptTimeoutHandler.h @@ -7,10 +7,8 @@ #define nsIScriptTimeoutHandler_h___ #include "nsTArray.h" +#include "js/TypeDecls.h" -namespace JS { -class Value; -} // namespace JS namespace mozilla { namespace dom { class Function; diff --git a/dom/base/nsLocation.h b/dom/base/nsLocation.h index 082e261c3e4..615c67b49a6 100644 --- a/dom/base/nsLocation.h +++ b/dom/base/nsLocation.h @@ -12,10 +12,10 @@ #include "nsIWeakReferenceUtils.h" #include "nsWrapperCache.h" #include "nsCycleCollectionParticipant.h" +#include "js/TypeDecls.h" class nsIURI; class nsIDocShell; -struct JSContext; class nsIDocShellLoadInfo; //***************************************************************************** diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 095327e843e..4058a9822b1 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -14,12 +14,12 @@ #include "nsAutoPtr.h" #include "nsTArray.h" #include "mozilla/dom/EventTarget.h" +#include "js/TypeDecls.h" #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed" #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen" #define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed" -class JSObject; class nsIArray; class nsIContent; class nsIDocShell; @@ -33,10 +33,6 @@ class nsPIWindowRoot; class nsXBLPrototypeHandler; struct nsTimeout; -namespace JS { -template class Handle; -} - namespace mozilla { namespace dom { class AudioContext; diff --git a/dom/base/nsPIWindowRoot.h b/dom/base/nsPIWindowRoot.h index 57acdeac9a3..36450f623cf 100644 --- a/dom/base/nsPIWindowRoot.h +++ b/dom/base/nsPIWindowRoot.h @@ -13,7 +13,6 @@ class nsPIDOMWindow; class nsIControllers; class nsIController; -struct JSContext; #define NS_IWINDOWROOT_IID \ { 0x3f71f50c, 0xa7e0, 0x43bc, \ diff --git a/dom/base/nsPerformance.h b/dom/base/nsPerformance.h index 15c50e88ef0..aedc3e188fa 100644 --- a/dom/base/nsPerformance.h +++ b/dom/base/nsPerformance.h @@ -12,11 +12,10 @@ #include "nsDOMNavigationTiming.h" #include "nsContentUtils.h" #include "nsIDOMWindow.h" +#include "js/TypeDecls.h" class nsITimedChannel; class nsPerformance; -class JSObject; -struct JSContext; // Script "performance.timing" object class nsPerformanceTiming MOZ_FINAL : public nsWrapperCache diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h index 76a5973f828..4af57d3d9e5 100644 --- a/dom/base/nsWrapperCache.h +++ b/dom/base/nsWrapperCache.h @@ -13,8 +13,6 @@ #include "js/RootingAPI.h" struct JSTracer; -class JSObject; -struct JSContext; class XPCWrappedNativeScope; namespace mozilla { diff --git a/dom/bindings/BindingDeclarations.h b/dom/bindings/BindingDeclarations.h index 660a3a565f6..1f82a1d592a 100644 --- a/dom/bindings/BindingDeclarations.h +++ b/dom/bindings/BindingDeclarations.h @@ -23,8 +23,6 @@ #include "nsTArray.h" #include "nsAutoPtr.h" // for nsRefPtr member variables -struct JSContext; -class JSObject; class nsWrapperCache; // nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't diff --git a/dom/bindings/Date.h b/dom/bindings/Date.h index 26448e077b1..da7b2c7af4d 100644 --- a/dom/bindings/Date.h +++ b/dom/bindings/Date.h @@ -9,13 +9,7 @@ #ifndef mozilla_dom_Date_h #define mozilla_dom_Date_h -class JSObject; -struct JSContext; - -namespace JS { -class Value; -template class MutableHandle; -} // namespace JS +#include "js/TypeDecls.h" namespace mozilla { namespace dom { diff --git a/dom/bindings/ErrorResult.h b/dom/bindings/ErrorResult.h index d32a7a719a0..51b10eb3f83 100644 --- a/dom/bindings/ErrorResult.h +++ b/dom/bindings/ErrorResult.h @@ -18,8 +18,6 @@ #include "nsStringGlue.h" #include "mozilla/Assertions.h" -struct JSContext; - namespace mozilla { namespace dom { diff --git a/dom/bluetooth/BluetoothUtils.h b/dom/bluetooth/BluetoothUtils.h index f10fa8edcfe..2156207f1d4 100644 --- a/dom/bluetooth/BluetoothUtils.h +++ b/dom/bluetooth/BluetoothUtils.h @@ -8,9 +8,7 @@ #define mozilla_dom_bluetooth_bluetoothutils_h__ #include "BluetoothCommon.h" - -struct JSContext; -class JSObject; +#include "js/TypeDecls.h" BEGIN_BLUETOOTH_NAMESPACE diff --git a/dom/cellbroadcast/src/CellBroadcast.h b/dom/cellbroadcast/src/CellBroadcast.h index 34d5ff7e461..7ee1f73ad96 100644 --- a/dom/cellbroadcast/src/CellBroadcast.h +++ b/dom/cellbroadcast/src/CellBroadcast.h @@ -10,9 +10,7 @@ #include "mozilla/ErrorResult.h" #include "nsDOMEventTargetHelper.h" #include "nsICellBroadcastProvider.h" - -class JSObject; -struct JSContext; +#include "js/TypeDecls.h" class nsPIDOMWindow; diff --git a/dom/interfaces/base/nsIDOMHistory.idl b/dom/interfaces/base/nsIDOMHistory.idl index 080e9dc3172..d2804240afe 100644 --- a/dom/interfaces/base/nsIDOMHistory.idl +++ b/dom/interfaces/base/nsIDOMHistory.idl @@ -5,10 +5,6 @@ #include "domstubs.idl" -%{ C++ -struct JSContext; -%} - [scriptable, uuid(55226663-fe68-48ba-addf-08e32eaab569)] interface nsIDOMHistory : nsISupports { diff --git a/dom/interfaces/base/nsIStructuredCloneContainer.idl b/dom/interfaces/base/nsIStructuredCloneContainer.idl index 4d7dac47015..d1df5d50df3 100644 --- a/dom/interfaces/base/nsIStructuredCloneContainer.idl +++ b/dom/interfaces/base/nsIStructuredCloneContainer.idl @@ -11,7 +11,7 @@ interface nsIVariant; interface nsIDocument; %{C++ -struct JSContext; +#include "js/TypeDecls.h" %} /** diff --git a/dom/interfaces/events/nsIDOMEventTarget.idl b/dom/interfaces/events/nsIDOMEventTarget.idl index 4b848bfde1a..bb00563295d 100644 --- a/dom/interfaces/events/nsIDOMEventTarget.idl +++ b/dom/interfaces/events/nsIDOMEventTarget.idl @@ -8,6 +8,7 @@ %{C++ #include "nsEvent.h" #include "mozilla/dom/Nullable.h" +#include "js/TypeDecls.h" using mozilla::dom::Nullable; @@ -20,7 +21,6 @@ class EventTarget; class nsPresContext; class nsEventChainPreVisitor; class nsEventChainPostVisitor; -struct JSContext; class nsEventListenerManager; %} diff --git a/dom/interfaces/json/nsIJSON.idl b/dom/interfaces/json/nsIJSON.idl index 41ac516e76a..b09e4e069f0 100644 --- a/dom/interfaces/json/nsIJSON.idl +++ b/dom/interfaces/json/nsIJSON.idl @@ -13,7 +13,7 @@ interface nsIScriptGlobalObject; [ptr] native JSContext(JSContext); %{C++ -namespace JS { class Value; } +#include "js/TypeDecls.h" %} /** diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 51e9cac0859..2d0fe89a6c1 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -8,7 +8,7 @@ #include "TabChild.h" -#include "BasicLayers.h" +#include "Layers.h" #include "Blob.h" #include "ContentChild.h" #include "IndexedDBChild.h" diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 480395b1d4f..e2c93bc1511 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -22,10 +22,9 @@ #include "nsITabParent.h" #include "nsWeakReference.h" #include "Units.h" +#include "js/TypeDecls.h" struct gfxMatrix; -struct JSContext; -class JSObject; class mozIApplication; class nsFrameLoader; class nsIURI; diff --git a/dom/network/src/TCPServerSocketChild.h b/dom/network/src/TCPServerSocketChild.h index 05026ba47f2..bbbfdd26298 100644 --- a/dom/network/src/TCPServerSocketChild.h +++ b/dom/network/src/TCPServerSocketChild.h @@ -11,8 +11,6 @@ { 0x41a77ec8, 0xfd86, 0x409e, { 0xae, 0xa9, 0xaf, 0x2c, 0xa4, 0x07, 0xef, 0x8e } } class nsITCPServerSocketInternal; -struct JSContext; -struct JSObject; namespace mozilla { namespace dom { diff --git a/dom/network/src/TCPServerSocketParent.h b/dom/network/src/TCPServerSocketParent.h index 881bb2a8797..1bc621b066c 100644 --- a/dom/network/src/TCPServerSocketParent.h +++ b/dom/network/src/TCPServerSocketParent.h @@ -10,9 +10,6 @@ #include "nsCOMPtr.h" #include "nsIDOMTCPSocket.h" -struct JSContext; -struct JSObject; - namespace mozilla { namespace dom { diff --git a/dom/network/src/TCPSocketChild.h b/dom/network/src/TCPSocketChild.h index d2949600122..966f49a6fd4 100644 --- a/dom/network/src/TCPSocketChild.h +++ b/dom/network/src/TCPSocketChild.h @@ -6,13 +6,12 @@ #include "nsITCPSocketChild.h" #include "nsCycleCollectionParticipant.h" #include "nsCOMPtr.h" +#include "js/TypeDecls.h" #define TCPSOCKETCHILD_CID \ { 0xa589d96f, 0x7e09, 0x4edf, { 0xa0, 0x1a, 0xeb, 0x49, 0x51, 0xf4, 0x2f, 0x37 } } class nsITCPSocketInternal; -struct JSContext; -class JSObject; namespace mozilla { namespace dom { diff --git a/dom/network/src/TCPSocketParent.h b/dom/network/src/TCPSocketParent.h index cbe6c319f22..d3ad9fd3128 100644 --- a/dom/network/src/TCPSocketParent.h +++ b/dom/network/src/TCPSocketParent.h @@ -7,9 +7,7 @@ #include "nsCycleCollectionParticipant.h" #include "nsCOMPtr.h" #include "nsIDOMTCPSocket.h" - -struct JSContext; -class JSObject; +#include "js/TypeDecls.h" #define TCPSOCKETPARENT_CID \ { 0x4e7246c6, 0xa8b3, 0x426d, { 0x9c, 0x17, 0x76, 0xda, 0xb1, 0xe1, 0xe1, 0x4a } } diff --git a/dom/plugins/base/nsNPAPIPluginInstance.h b/dom/plugins/base/nsNPAPIPluginInstance.h index 9e3beeebd9c..490f00bc343 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.h +++ b/dom/plugins/base/nsNPAPIPluginInstance.h @@ -16,6 +16,7 @@ #include "nsInterfaceHashtable.h" #include "nsHashKeys.h" #include +#include "js/TypeDecls.h" #ifdef MOZ_WIDGET_ANDROID #include "nsAutoPtr.h" #include "nsIRunnable.h" @@ -30,8 +31,6 @@ class SharedPluginTexture; #include "mozilla/TimeStamp.h" #include "mozilla/PluginLibrary.h" -class JSObject; - class nsPluginStreamListenerPeer; // browser-initiated stream class class nsNPAPIPluginStreamListener; // plugin-initiated stream class class nsIPluginInstanceOwner; diff --git a/dom/promise/Promise.h b/dom/promise/Promise.h index d8617815929..1ef7c6500af 100644 --- a/dom/promise/Promise.h +++ b/dom/promise/Promise.h @@ -15,8 +15,7 @@ #include "nsWrapperCache.h" #include "nsAutoPtr.h" #include "nsPIDOMWindow.h" - -struct JSContext; +#include "js/TypeDecls.h" namespace mozilla { namespace dom { diff --git a/dom/promise/PromiseResolver.h b/dom/promise/PromiseResolver.h index fcd9e949b6e..f6b8975964c 100644 --- a/dom/promise/PromiseResolver.h +++ b/dom/promise/PromiseResolver.h @@ -12,8 +12,7 @@ #include "mozilla/dom/BindingDeclarations.h" #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" - -struct JSContext; +#include "js/TypeDecls.h" namespace mozilla { namespace dom { diff --git a/dom/src/geolocation/nsGeoPosition.h b/dom/src/geolocation/nsGeoPosition.h index 457e95a4c38..375826a3cff 100644 --- a/dom/src/geolocation/nsGeoPosition.h +++ b/dom/src/geolocation/nsGeoPosition.h @@ -14,8 +14,7 @@ #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" #include "mozilla/dom/Nullable.h" - -struct JSContext; +#include "js/TypeDecls.h" //////////////////////////////////////////////////// // nsGeoPositionCoords diff --git a/dom/workers/test/Makefile.in b/dom/workers/test/Makefile.in index a0b504a4edb..f62f30d1b9b 100644 --- a/dom/workers/test/Makefile.in +++ b/dom/workers/test/Makefile.in @@ -93,7 +93,6 @@ MOCHITEST_FILES = \ test_xhr_parameters.js \ test_xhr_system.html \ test_xhr_system.js \ - test_xhr_timeout.html \ test_blobConstructor.html \ test_csp.html \ test_csp.js \ @@ -109,6 +108,13 @@ MOCHITEST_FILES = \ url_worker.js \ $(NULL) +# Bug 842386 - Disabled on OSX due to intermittent failures. +ifneq ($(OS_ARCH), Darwin) +MOCHITEST_FILES += \ + test_xhr_timeout.html \ + $(NULL) +endif + MOCHITEST_CHROME_FILES = \ test_chromeWorker.xul \ test_chromeWorkerJSM.xul \ diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.h b/embedding/components/windowwatcher/src/nsWindowWatcher.h index 78ee962dce8..205afbe94f6 100644 --- a/embedding/components/windowwatcher/src/nsWindowWatcher.h +++ b/embedding/components/windowwatcher/src/nsWindowWatcher.h @@ -17,6 +17,7 @@ #include "nsIPromptFactory.h" #include "nsPIWindowWatcher.h" #include "nsTArray.h" +#include "js/TypeDecls.h" class nsIURI; class nsIDocShellTreeItem; @@ -26,8 +27,6 @@ class nsString; class nsWatcherWindowEnumerator; class nsIScriptContext; class nsPromptService; -struct JSContext; -class JSObject; struct nsWatcherWindowEntry; struct SizeSpec; diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index fdba9778dd5..7f1ca633b42 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -712,6 +712,121 @@ ContainerLayer::ContainerLayer(LayerManager* aManager, void* aImplData) ContainerLayer::~ContainerLayer() {} +void +ContainerLayer::InsertAfter(Layer* aChild, Layer* aAfter) +{ + NS_ASSERTION(aChild->Manager() == Manager(), + "Child has wrong manager"); + NS_ASSERTION(!aChild->GetParent(), + "aChild already in the tree"); + NS_ASSERTION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(), + "aChild already has siblings?"); + NS_ASSERTION(!aAfter || + (aAfter->Manager() == Manager() && + aAfter->GetParent() == this), + "aAfter is not our child"); + + aChild->SetParent(this); + if (aAfter == mLastChild) { + mLastChild = aChild; + } + if (!aAfter) { + aChild->SetNextSibling(mFirstChild); + if (mFirstChild) { + mFirstChild->SetPrevSibling(aChild); + } + mFirstChild = aChild; + NS_ADDREF(aChild); + DidInsertChild(aChild); + return; + } + + Layer* next = aAfter->GetNextSibling(); + aChild->SetNextSibling(next); + aChild->SetPrevSibling(aAfter); + if (next) { + next->SetPrevSibling(aChild); + } + aAfter->SetNextSibling(aChild); + NS_ADDREF(aChild); + DidInsertChild(aChild); +} + +void +ContainerLayer::RemoveChild(Layer *aChild) +{ + NS_ASSERTION(aChild->Manager() == Manager(), + "Child has wrong manager"); + NS_ASSERTION(aChild->GetParent() == this, + "aChild not our child"); + + Layer* prev = aChild->GetPrevSibling(); + Layer* next = aChild->GetNextSibling(); + if (prev) { + prev->SetNextSibling(next); + } else { + this->mFirstChild = next; + } + if (next) { + next->SetPrevSibling(prev); + } else { + this->mLastChild = prev; + } + + aChild->SetNextSibling(nullptr); + aChild->SetPrevSibling(nullptr); + aChild->SetParent(nullptr); + + this->DidRemoveChild(aChild); + NS_RELEASE(aChild); +} + + +void +ContainerLayer::RepositionChild(Layer* aChild, Layer* aAfter) +{ + NS_ASSERTION(aChild->Manager() == Manager(), + "Child has wrong manager"); + NS_ASSERTION(aChild->GetParent() == this, + "aChild not our child"); + NS_ASSERTION(!aAfter || + (aAfter->Manager() == Manager() && + aAfter->GetParent() == this), + "aAfter is not our child"); + + Layer* prev = aChild->GetPrevSibling(); + Layer* next = aChild->GetNextSibling(); + if (prev == aAfter) { + // aChild is already in the correct position, nothing to do. + return; + } + if (prev) { + prev->SetNextSibling(next); + } + if (next) { + next->SetPrevSibling(prev); + } + if (!aAfter) { + aChild->SetPrevSibling(nullptr); + aChild->SetNextSibling(mFirstChild); + if (mFirstChild) { + mFirstChild->SetPrevSibling(aChild); + } + mFirstChild = aChild; + return; + } + + Layer* afterNext = aAfter->GetNextSibling(); + if (afterNext) { + afterNext->SetPrevSibling(aChild); + } else { + mLastChild = aChild; + } + aAfter->SetNextSibling(aChild); + aChild->SetPrevSibling(aAfter); + aChild->SetNextSibling(afterNext); +} + void ContainerLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs) { @@ -827,6 +942,16 @@ ContainerLayer::ComputeEffectiveTransformsForChildren(const gfx3DMatrix& aTransf } } +/* static */ bool +ContainerLayer::HasOpaqueAncestorLayer(Layer* aLayer) +{ + for (Layer* l = aLayer->GetParent(); l; l = l->GetParent()) { + if (l->GetContentFlags() & Layer::CONTENT_OPAQUE) + return true; + } + return false; +} + void ContainerLayer::DidRemoveChild(Layer* aLayer) { diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 002055d1fd2..fa29819997a 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1411,13 +1411,13 @@ public: * If aAfter is non-null, it must be a child of this container and * we insert after that layer. If it's null we insert at the start. */ - virtual void InsertAfter(Layer* aChild, Layer* aAfter) = 0; + virtual void InsertAfter(Layer* aChild, Layer* aAfter); /** * CONSTRUCTION PHASE ONLY * Remove aChild from the child list of this container. aChild must * be a child of this container. */ - virtual void RemoveChild(Layer* aChild) = 0; + virtual void RemoveChild(Layer* aChild); /** * CONSTRUCTION PHASE ONLY * Reposition aChild from the child list of this container. aChild must @@ -1425,7 +1425,7 @@ public: * If aAfter is non-null, it must be a child of this container and we * reposition after that layer. If it's null, we reposition at the start. */ - virtual void RepositionChild(Layer* aChild, Layer* aAfter) = 0; + virtual void RepositionChild(Layer* aChild, Layer* aAfter); /** * CONSTRUCTION PHASE ONLY @@ -1530,6 +1530,8 @@ public: protected: friend class ReadbackProcessor; + static bool HasOpaqueAncestorLayer(Layer* aLayer); + void DidInsertChild(Layer* aLayer); void DidRemoveChild(Layer* aLayer); diff --git a/gfx/layers/basic/BasicContainerLayer.cpp b/gfx/layers/basic/BasicContainerLayer.cpp index 9b9fbd9af08..6973aad37f0 100644 --- a/gfx/layers/basic/BasicContainerLayer.cpp +++ b/gfx/layers/basic/BasicContainerLayer.cpp @@ -15,6 +15,9 @@ #include "nsISupportsImpl.h" // for Layer::AddRef, etc #include "nsPoint.h" // for nsIntPoint #include "nsRect.h" // for nsIntRect +#include "gfx3DMatrix.h" // for gfx3DMatrix +#include "gfxMatrix.h" // for gfxMatrix +#include "nsRegion.h" // for nsIntRegion using namespace mozilla::gfx; @@ -24,12 +27,48 @@ namespace layers { BasicContainerLayer::~BasicContainerLayer() { while (mFirstChild) { - ContainerRemoveChild(mFirstChild, this); + ContainerLayer::RemoveChild(mFirstChild); } MOZ_COUNT_DTOR(BasicContainerLayer); } +void +BasicContainerLayer::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) +{ + // We push groups for container layers if we need to, which always + // are aligned in device space, so it doesn't really matter how we snap + // containers. + gfxMatrix residual; + gfx3DMatrix idealTransform = GetLocalTransform()*aTransformToSurface; + idealTransform.ProjectTo2D(); + + if (!idealTransform.CanDraw2D()) { + mEffectiveTransform = idealTransform; + ComputeEffectiveTransformsForChildren(gfx3DMatrix()); + ComputeEffectiveTransformForMaskLayer(gfx3DMatrix()); + mUseIntermediateSurface = true; + return; + } + + mEffectiveTransform = SnapTransformTranslation(idealTransform, &residual); + // We always pass the ideal matrix down to our children, so there is no + // need to apply any compensation using the residual from SnapTransformTranslation. + ComputeEffectiveTransformsForChildren(idealTransform); + + ComputeEffectiveTransformForMaskLayer(aTransformToSurface); + + /* If we have a single child, it can just inherit our opacity, + * otherwise we need a PushGroup and we need to mark ourselves as using + * an intermediate surface so our children don't inherit our opacity + * via GetEffectiveOpacity. + * Having a mask layer always forces our own push group + */ + mUseIntermediateSurface = + GetMaskLayer() || (GetEffectiveOpacity() != 1.0 && + HasMultipleChildren()); +} + bool BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect) { diff --git a/gfx/layers/basic/BasicContainerLayer.h b/gfx/layers/basic/BasicContainerLayer.h index d444b30b533..7673e28253a 100644 --- a/gfx/layers/basic/BasicContainerLayer.h +++ b/gfx/layers/basic/BasicContainerLayer.h @@ -9,181 +9,15 @@ #include "BasicImplData.h" // for BasicImplData #include "BasicLayers.h" // for BasicLayerManager #include "Layers.h" // for Layer, ContainerLayer -#include "gfx3DMatrix.h" // for gfx3DMatrix -#include "gfxMatrix.h" // for gfxMatrix #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE -#include "nsRegion.h" // for nsIntRegion #include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR struct nsIntRect; namespace mozilla { namespace layers { -template void -ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(!aChild->GetParent(), - "aChild already in the tree"); - NS_ASSERTION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(), - "aChild already has siblings?"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - aChild->SetParent(aContainer); - if (aAfter == aContainer->mLastChild) { - aContainer->mLastChild = aChild; - } - if (!aAfter) { - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); - return; - } - - Layer* next = aAfter->GetNextSibling(); - aChild->SetNextSibling(next); - aChild->SetPrevSibling(aAfter); - if (next) { - next->SetPrevSibling(aChild); - } - aAfter->SetNextSibling(aChild); - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); -} - -template void -ContainerRemoveChild(Layer* aChild, Container* aContainer) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev) { - prev->SetNextSibling(next); - } else { - aContainer->mFirstChild = next; - } - if (next) { - next->SetPrevSibling(prev); - } else { - aContainer->mLastChild = prev; - } - - aChild->SetNextSibling(nullptr); - aChild->SetPrevSibling(nullptr); - aChild->SetParent(nullptr); - - aContainer->DidRemoveChild(aChild); - NS_RELEASE(aChild); -} - -template void -ContainerRepositionChild(Layer* aChild, Layer* aAfter, Container* aContainer) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev == aAfter) { - // aChild is already in the correct position, nothing to do. - return; - } - if (prev) { - prev->SetNextSibling(next); - } - if (next) { - next->SetPrevSibling(prev); - } - if (!aAfter) { - aChild->SetPrevSibling(nullptr); - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - return; - } - - Layer* afterNext = aAfter->GetNextSibling(); - if (afterNext) { - afterNext->SetPrevSibling(aChild); - } else { - aContainer->mLastChild = aChild; - } - aAfter->SetNextSibling(aChild); - aChild->SetPrevSibling(aAfter); - aChild->SetNextSibling(afterNext); -} - -template -static void -ContainerComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface, - Container* aContainer) -{ - // We push groups for container layers if we need to, which always - // are aligned in device space, so it doesn't really matter how we snap - // containers. - gfxMatrix residual; - gfx3DMatrix idealTransform = aContainer->GetLocalTransform()*aTransformToSurface; - idealTransform.ProjectTo2D(); - - if (!idealTransform.CanDraw2D()) { - aContainer->mEffectiveTransform = idealTransform; - aContainer->ComputeEffectiveTransformsForChildren(gfx3DMatrix()); - aContainer->ComputeEffectiveTransformForMaskLayer(gfx3DMatrix()); - aContainer->mUseIntermediateSurface = true; - return; - } - - aContainer->mEffectiveTransform = - aContainer->SnapTransformTranslation(idealTransform, &residual); - // We always pass the ideal matrix down to our children, so there is no - // need to apply any compensation using the residual from SnapTransformTranslation. - aContainer->ComputeEffectiveTransformsForChildren(idealTransform); - - aContainer->ComputeEffectiveTransformForMaskLayer(aTransformToSurface); - - /* If we have a single child, it can just inherit our opacity, - * otherwise we need a PushGroup and we need to mark ourselves as using - * an intermediate surface so our children don't inherit our opacity - * via GetEffectiveOpacity. - * Having a mask layer always forces our own push group - */ - aContainer->mUseIntermediateSurface = - aContainer->GetMaskLayer() || (aContainer->GetEffectiveOpacity() != 1.0 && - aContainer->HasMultipleChildren()); -} - class BasicContainerLayer : public ContainerLayer, public BasicImplData { - template - friend void ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer); - template - friend void ContainerRemoveChild(Layer* aChild, Container* aContainer); - template - friend void ContainerRepositionChild(Layer* aChild, Layer* aAfter, Container* aContainer); - template - friend void ContainerComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface, - Container* aContainer); - public: BasicContainerLayer(BasicLayerManager* aManager) : ContainerLayer(aManager, @@ -204,27 +38,24 @@ public: { NS_ASSERTION(BasicManager()->InConstruction(), "Can only set properties in construction phase"); - ContainerInsertAfter(aChild, aAfter, this); + ContainerLayer::InsertAfter(aChild, aAfter); } virtual void RemoveChild(Layer* aChild) { NS_ASSERTION(BasicManager()->InConstruction(), "Can only set properties in construction phase"); - ContainerRemoveChild(aChild, this); + ContainerLayer::RemoveChild(aChild); } virtual void RepositionChild(Layer* aChild, Layer* aAfter) { NS_ASSERTION(BasicManager()->InConstruction(), "Can only set properties in construction phase"); - ContainerRepositionChild(aChild, aAfter, this); + ContainerLayer::RepositionChild(aChild, aAfter); } - virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) - { - ContainerComputeEffectiveTransforms(aTransformToSurface, this); - } + virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface); /** * Returns true when: diff --git a/gfx/layers/client/ClientContainerLayer.h b/gfx/layers/client/ClientContainerLayer.h index cecfa628de3..20df9320f5f 100644 --- a/gfx/layers/client/ClientContainerLayer.h +++ b/gfx/layers/client/ClientContainerLayer.h @@ -23,140 +23,9 @@ namespace layers { class ShadowableLayer; -template void -ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(!aChild->GetParent(), - "aChild already in the tree"); - NS_ASSERTION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(), - "aChild already has siblings?"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - aChild->SetParent(aContainer); - if (aAfter == aContainer->mLastChild) { - aContainer->mLastChild = aChild; - } - if (!aAfter) { - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); - return; - } - - Layer* next = aAfter->GetNextSibling(); - aChild->SetNextSibling(next); - aChild->SetPrevSibling(aAfter); - if (next) { - next->SetPrevSibling(aChild); - } - aAfter->SetNextSibling(aChild); - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); -} - -template void -ContainerRemoveChild(Layer* aChild, Container* aContainer) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev) { - prev->SetNextSibling(next); - } else { - aContainer->mFirstChild = next; - } - if (next) { - next->SetPrevSibling(prev); - } else { - aContainer->mLastChild = prev; - } - - aChild->SetNextSibling(nullptr); - aChild->SetPrevSibling(nullptr); - aChild->SetParent(nullptr); - - aContainer->DidRemoveChild(aChild); - NS_RELEASE(aChild); -} - -template void -ContainerRepositionChild(Layer* aChild, Layer* aAfter, Container* aContainer) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev == aAfter) { - // aChild is already in the correct position, nothing to do. - return; - } - if (prev) { - prev->SetNextSibling(next); - } - if (next) { - next->SetPrevSibling(prev); - } - if (!aAfter) { - aChild->SetPrevSibling(nullptr); - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - return; - } - - Layer* afterNext = aAfter->GetNextSibling(); - if (afterNext) { - afterNext->SetPrevSibling(aChild); - } else { - aContainer->mLastChild = aChild; - } - aAfter->SetNextSibling(aChild); - aChild->SetPrevSibling(aAfter); - aChild->SetNextSibling(afterNext); -} - -static bool -HasOpaqueAncestorLayer(Layer* aLayer) -{ - for (Layer* l = aLayer->GetParent(); l; l = l->GetParent()) { - if (l->GetContentFlags() & Layer::CONTENT_OPAQUE) - return true; - } - return false; -} - class ClientContainerLayer : public ContainerLayer, public ClientLayer { - template - friend void ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer); - template - friend void ContainerRemoveChild(Layer* aChild, Container* aContainer); - template - friend void ContainerRepositionChild(Layer* aChild, Layer* aAfter, Container* aContainer); - public: ClientContainerLayer(ClientLayerManager* aManager) : ContainerLayer(aManager, @@ -168,7 +37,7 @@ public: virtual ~ClientContainerLayer() { while (mFirstChild) { - ContainerRemoveChild(mFirstChild, this); + ContainerLayer::RemoveChild(mFirstChild); } MOZ_COUNT_DTOR(ClientContainerLayer); @@ -219,33 +88,33 @@ public: "Can only set properties in construction phase"); ContainerLayer::SetVisibleRegion(aRegion); } - virtual void InsertAfter(Layer* aChild, Layer* aAfter) + virtual void InsertAfter(Layer* aChild, Layer* aAfter) MOZ_OVERRIDE { NS_ASSERTION(ClientManager()->InConstruction(), "Can only set properties in construction phase"); ClientManager()->InsertAfter(ClientManager()->Hold(this), ClientManager()->Hold(aChild), aAfter ? ClientManager()->Hold(aAfter) : nullptr); - ContainerInsertAfter(aChild, aAfter, this); + ContainerLayer::InsertAfter(aChild, aAfter); } - virtual void RemoveChild(Layer* aChild) + virtual void RemoveChild(Layer* aChild) MOZ_OVERRIDE { NS_ASSERTION(ClientManager()->InConstruction(), "Can only set properties in construction phase"); ClientManager()->RemoveChild(ClientManager()->Hold(this), ClientManager()->Hold(aChild)); - ContainerRemoveChild(aChild, this); + ContainerLayer::RemoveChild(aChild); } - virtual void RepositionChild(Layer* aChild, Layer* aAfter) + virtual void RepositionChild(Layer* aChild, Layer* aAfter) MOZ_OVERRIDE { NS_ASSERTION(ClientManager()->InConstruction(), "Can only set properties in construction phase"); ClientManager()->RepositionChild(ClientManager()->Hold(this), ClientManager()->Hold(aChild), aAfter ? ClientManager()->Hold(aAfter) : nullptr); - ContainerRepositionChild(aChild, aAfter, this); + ContainerLayer::RepositionChild(aChild, aAfter); } virtual Layer* AsLayer() { return this; } diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 3ffa7d15835..b1de280e951 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -116,6 +116,11 @@ ContainerRender(ContainerT* aContainer, } else { surface = compositor->CreateRenderTarget(surfaceRect, mode); } + + if (!surface) { + return; + } + compositor->SetRenderTarget(surface); childOffset.x = visibleRect.x; childOffset.y = visibleRect.y; @@ -216,75 +221,6 @@ ContainerLayerComposite::~ContainerLayerComposite() } } -void -ContainerLayerComposite::InsertAfter(Layer* aChild, Layer* aAfter) -{ - NS_ASSERTION(aChild->Manager() == Manager(), - "Child has wrong manager"); - NS_ASSERTION(!aChild->GetParent(), - "aChild already in the tree"); - NS_ASSERTION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(), - "aChild already has siblings?"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == Manager() && - aAfter->GetParent() == this), - "aAfter is not our child"); - - aChild->SetParent(this); - if (aAfter == mLastChild) { - mLastChild = aChild; - } - if (!aAfter) { - aChild->SetNextSibling(mFirstChild); - if (mFirstChild) { - mFirstChild->SetPrevSibling(aChild); - } - mFirstChild = aChild; - NS_ADDREF(aChild); - DidInsertChild(aChild); - return; - } - - Layer* next = aAfter->GetNextSibling(); - aChild->SetNextSibling(next); - aChild->SetPrevSibling(aAfter); - if (next) { - next->SetPrevSibling(aChild); - } - aAfter->SetNextSibling(aChild); - NS_ADDREF(aChild); - DidInsertChild(aChild); -} - -void -ContainerLayerComposite::RemoveChild(Layer *aChild) -{ - NS_ASSERTION(aChild->Manager() == Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == this, - "aChild not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev) { - prev->SetNextSibling(next); - } else { - this->mFirstChild = next; - } - if (next) { - next->SetPrevSibling(prev); - } else { - this->mLastChild = prev; - } - - aChild->SetNextSibling(nullptr); - aChild->SetPrevSibling(nullptr); - aChild->SetParent(nullptr); - - this->DidRemoveChild(aChild); - NS_RELEASE(aChild); -} - void ContainerLayerComposite::Destroy() { @@ -306,51 +242,6 @@ ContainerLayerComposite::GetFirstChildComposite() return static_cast(mFirstChild->ImplData()); } -void -ContainerLayerComposite::RepositionChild(Layer* aChild, Layer* aAfter) -{ - NS_ASSERTION(aChild->Manager() == Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == this, - "aChild not our child"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == Manager() && - aAfter->GetParent() == this), - "aAfter is not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev == aAfter) { - // aChild is already in the correct position, nothing to do. - return; - } - if (prev) { - prev->SetNextSibling(next); - } - if (next) { - next->SetPrevSibling(prev); - } - if (!aAfter) { - aChild->SetPrevSibling(nullptr); - aChild->SetNextSibling(mFirstChild); - if (mFirstChild) { - mFirstChild->SetPrevSibling(aChild); - } - mFirstChild = aChild; - return; - } - - Layer* afterNext = aAfter->GetNextSibling(); - if (afterNext) { - afterNext->SetPrevSibling(aChild); - } else { - mLastChild = aChild; - } - aAfter->SetNextSibling(aChild); - aChild->SetPrevSibling(aAfter); - aChild->SetNextSibling(afterNext); -} - void ContainerLayerComposite::RenderLayer(const nsIntPoint& aOffset, const nsIntRect& aClipRect) diff --git a/gfx/layers/composite/ContainerLayerComposite.h b/gfx/layers/composite/ContainerLayerComposite.h index 1b587a4e2ec..8b7f7dfc1be 100644 --- a/gfx/layers/composite/ContainerLayerComposite.h +++ b/gfx/layers/composite/ContainerLayerComposite.h @@ -33,12 +33,6 @@ public: ~ContainerLayerComposite(); - void InsertAfter(Layer* aChild, Layer* aAfter); - - void RemoveChild(Layer* aChild); - - void RepositionChild(Layer* aChild, Layer* aAfter); - // LayerComposite Implementation virtual Layer* GetLayer() MOZ_OVERRIDE { return this; } diff --git a/gfx/layers/d3d10/ContainerLayerD3D10.cpp b/gfx/layers/d3d10/ContainerLayerD3D10.cpp index a8af6dda593..dfd913581e1 100644 --- a/gfx/layers/d3d10/ContainerLayerD3D10.cpp +++ b/gfx/layers/d3d10/ContainerLayerD3D10.cpp @@ -28,140 +28,6 @@ ContainerLayerD3D10::~ContainerLayerD3D10() RemoveChild(mFirstChild); } } -template -static void -ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(!aChild->GetParent(), - "aChild already in the tree"); - NS_ASSERTION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(), - "aChild already has siblings?"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - aChild->SetParent(aContainer); - if (aAfter == aContainer->mLastChild) { - aContainer->mLastChild = aChild; - } - if (!aAfter) { - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); - return; - } - - Layer* next = aAfter->GetNextSibling(); - aChild->SetNextSibling(next); - aChild->SetPrevSibling(aAfter); - if (next) { - next->SetPrevSibling(aChild); - } - aAfter->SetNextSibling(aChild); - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); -} - -template -static void -ContainerRemoveChild(Container* aContainer, Layer* aChild) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev) { - prev->SetNextSibling(next); - } else { - aContainer->mFirstChild = next; - } - if (next) { - next->SetPrevSibling(prev); - } else { - aContainer->mLastChild = prev; - } - - aChild->SetNextSibling(nullptr); - aChild->SetPrevSibling(nullptr); - aChild->SetParent(nullptr); - - aContainer->DidRemoveChild(aChild); - NS_RELEASE(aChild); -} - -template -static void -ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev == aAfter) { - // aChild is already in the correct position, nothing to do. - return; - } - if (prev) { - prev->SetNextSibling(next); - } - if (next) { - next->SetPrevSibling(prev); - } - if (!aAfter) { - aChild->SetPrevSibling(nullptr); - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - return; - } - - Layer* afterNext = aAfter->GetNextSibling(); - if (afterNext) { - afterNext->SetPrevSibling(aChild); - } else { - aContainer->mLastChild = aChild; - } - aAfter->SetNextSibling(aChild); - aChild->SetPrevSibling(aAfter); - aChild->SetNextSibling(afterNext); -} - -void -ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter) -{ - ContainerInsertAfter(this, aChild, aAfter); -} - -void -ContainerLayerD3D10::RemoveChild(Layer *aChild) -{ - ContainerRemoveChild(this, aChild); -} - -void -ContainerLayerD3D10::RepositionChild(Layer* aChild, Layer* aAfter) -{ - ContainerRepositionChild(this, aChild, aAfter); -} Layer* ContainerLayerD3D10::GetLayer() diff --git a/gfx/layers/d3d10/ContainerLayerD3D10.h b/gfx/layers/d3d10/ContainerLayerD3D10.h index 40d3948a251..2a136afb0ce 100644 --- a/gfx/layers/d3d10/ContainerLayerD3D10.h +++ b/gfx/layers/d3d10/ContainerLayerD3D10.h @@ -11,35 +11,15 @@ namespace mozilla { namespace layers { -template -static void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); -template -static void ContainerRemoveChild(Container* aContainer, Layer* aChild); -template -static void ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter); - class ContainerLayerD3D10 : public ContainerLayer, public LayerD3D10 { - template - friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); - template - friend void ContainerRemoveChild(Container* aContainer, Layer* aChild); - template - friend void ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter); public: ContainerLayerD3D10(LayerManagerD3D10 *aManager); ~ContainerLayerD3D10(); nsIntRect GetVisibleRect() { return mVisibleRegion.GetBounds(); } - /* ContainerLayer implementation */ - virtual void InsertAfter(Layer* aChild, Layer* aAfter); - - virtual void RemoveChild(Layer* aChild); - - virtual void RepositionChild(Layer* aChild, Layer* aAfter); - /* LayerD3D10 implementation */ virtual Layer* GetLayer(); diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index d973ee8365f..eb8a03ed4ec 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -371,6 +371,10 @@ CompositorD3D11::CreateRenderTarget(const gfx::IntRect& aRect, RefPtr texture; mDevice->CreateTexture2D(&desc, nullptr, byRef(texture)); + NS_ASSERTION(texture, "Could not create texture"); + if (!texture) { + return nullptr; + } RefPtr rt = new CompositingRenderTargetD3D11(texture); rt->SetSize(IntSize(aRect.width, aRect.height)); @@ -393,6 +397,10 @@ CompositorD3D11::CreateRenderTargetFromSource(const gfx::IntRect &aRect, RefPtr texture; mDevice->CreateTexture2D(&desc, nullptr, byRef(texture)); + NS_ASSERTION(texture, "Could not create texture"); + if (!texture) { + return nullptr; + } if (aSource) { const CompositingRenderTargetD3D11* sourceD3D11 = diff --git a/gfx/layers/d3d9/ContainerLayerD3D9.cpp b/gfx/layers/d3d9/ContainerLayerD3D9.cpp index c00a87e1055..8c654b843c3 100644 --- a/gfx/layers/d3d9/ContainerLayerD3D9.cpp +++ b/gfx/layers/d3d9/ContainerLayerD3D9.cpp @@ -12,155 +12,37 @@ namespace mozilla { namespace layers { -template -static void -ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter) +ContainerLayerD3D9::ContainerLayerD3D9(LayerManagerD3D9 *aManager) + : ContainerLayer(aManager, nullptr) + , LayerD3D9(aManager) { - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(!aChild->GetParent(), - "aChild already in the tree"); - NS_ASSERTION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(), - "aChild already has siblings?"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - aChild->SetParent(aContainer); - if (aAfter == aContainer->mLastChild) { - aContainer->mLastChild = aChild; - } - if (!aAfter) { - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); - return; - } - - Layer* next = aAfter->GetNextSibling(); - aChild->SetNextSibling(next); - aChild->SetPrevSibling(aAfter); - if (next) { - next->SetPrevSibling(aChild); - } - aAfter->SetNextSibling(aChild); - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); + mImplData = static_cast(this); } -template -static void -ContainerRemoveChild(Container* aContainer, Layer* aChild) +ContainerLayerD3D9::~ContainerLayerD3D9() { - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev) { - prev->SetNextSibling(next); - } else { - aContainer->mFirstChild = next; + while (mFirstChild) { + RemoveChild(mFirstChild); } - if (next) { - next->SetPrevSibling(prev); - } else { - aContainer->mLastChild = prev; - } - - aChild->SetNextSibling(nullptr); - aChild->SetPrevSibling(nullptr); - aChild->SetParent(nullptr); - - aContainer->DidRemoveChild(aChild); - NS_RELEASE(aChild); } -template -static void -ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter) +Layer* +ContainerLayerD3D9::GetLayer() { - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev == aAfter) { - // aChild is already in the correct position, nothing to do. - return; - } - if (prev) { - prev->SetNextSibling(next); - } - if (next) { - next->SetPrevSibling(prev); - } - if (!aAfter) { - aChild->SetPrevSibling(nullptr); - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - return; - } - - Layer* afterNext = aAfter->GetNextSibling(); - if (afterNext) { - afterNext->SetPrevSibling(aChild); - } else { - aContainer->mLastChild = aChild; - } - aAfter->SetNextSibling(aChild); - aChild->SetPrevSibling(aAfter); - aChild->SetNextSibling(afterNext); + return this; } -static inline LayerD3D9* -GetNextSibling(LayerD3D9* aLayer) +LayerD3D9* +ContainerLayerD3D9::GetFirstChildD3D9() { - Layer* layer = aLayer->GetLayer()->GetNextSibling(); - return layer ? static_cast(layer-> - ImplData()) - : nullptr; -} - -static bool -HasOpaqueAncestorLayer(Layer* aLayer) -{ - for (Layer* l = aLayer->GetParent(); l; l = l->GetParent()) { - if (l->GetContentFlags() & Layer::CONTENT_OPAQUE) - return true; + if (!mFirstChild) { + return nullptr; } - return false; + return static_cast(mFirstChild->ImplData()); } -static inline LayerD3D9* -GetNextSiblingD3D9(LayerD3D9* aLayer) -{ - Layer* layer = aLayer->GetLayer()->GetNextSibling(); - return layer ? static_cast(layer-> - ImplData()) - : nullptr; -} - -template -static void -ContainerRender(Container* aContainer, - LayerManagerD3D9* aManager) +void +ContainerLayerD3D9::RenderLayer() { nsRefPtr previousRenderTarget; nsRefPtr renderTexture; @@ -169,7 +51,7 @@ ContainerRender(Container* aContainer, float oldViewMatrix[4][4]; RECT containerD3D9ClipRect; - aManager->device()->GetScissorRect(&containerD3D9ClipRect); + device()->GetScissorRect(&containerD3D9ClipRect); // Convert scissor to an nsIntRect. RECT's are exclusive on the bottom and // right values. nsIntRect oldScissor(containerD3D9ClipRect.left, @@ -178,44 +60,44 @@ ContainerRender(Container* aContainer, containerD3D9ClipRect.bottom - containerD3D9ClipRect.top); ReadbackProcessor readback; - readback.BuildUpdates(aContainer); + readback.BuildUpdates(this); - nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); - bool useIntermediate = aContainer->UseIntermediateSurface(); + nsIntRect visibleRect = GetEffectiveVisibleRegion().GetBounds(); + bool useIntermediate = UseIntermediateSurface(); - aContainer->mSupportsComponentAlphaChildren = false; + mSupportsComponentAlphaChildren = false; if (useIntermediate) { nsRefPtr renderSurface; - if (!aManager->CompositingDisabled()) { - aManager->device()->GetRenderTarget(0, getter_AddRefs(previousRenderTarget)); - HRESULT hr = aManager->device()->CreateTexture(visibleRect.width, visibleRect.height, 1, - D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, - D3DPOOL_DEFAULT, getter_AddRefs(renderTexture), - nullptr); + if (!mD3DManager->CompositingDisabled()) { + device()->GetRenderTarget(0, getter_AddRefs(previousRenderTarget)); + HRESULT hr = device()->CreateTexture(visibleRect.width, visibleRect.height, 1, + D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, + D3DPOOL_DEFAULT, getter_AddRefs(renderTexture), + nullptr); if (FAILED(hr)) { - aManager->ReportFailure(NS_LITERAL_CSTRING("ContainerLayerD3D9::ContainerRender(): Failed to create texture"), + ReportFailure(NS_LITERAL_CSTRING("ContainerLayerD3D9::ContainerRender(): Failed to create texture"), hr); return; } nsRefPtr renderSurface; renderTexture->GetSurfaceLevel(0, getter_AddRefs(renderSurface)); - aManager->device()->SetRenderTarget(0, renderSurface); + device()->SetRenderTarget(0, renderSurface); } - if (aContainer->mVisibleRegion.GetNumRects() == 1 && - (aContainer->GetContentFlags() & aContainer->CONTENT_OPAQUE)) { + if (mVisibleRegion.GetNumRects() == 1 && + (GetContentFlags() & CONTENT_OPAQUE)) { // don't need a background, we're going to paint all opaque stuff - aContainer->mSupportsComponentAlphaChildren = true; + mSupportsComponentAlphaChildren = true; } else { - const gfx3DMatrix& transform3D = aContainer->GetEffectiveTransform(); + const gfx3DMatrix& transform3D = GetEffectiveTransform(); gfxMatrix transform; // If we have an opaque ancestor layer, then we can be sure that // all the pixels we draw into are either opaque already or will be // covered by something opaque. Otherwise copying up the background is // not safe. HRESULT hr = E_FAIL; - if (HasOpaqueAncestorLayer(aContainer) && + if (HasOpaqueAncestorLayer(this) && transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) { // Copy background up from below RECT dest = { 0, 0, visibleRect.width, visibleRect.height }; @@ -223,24 +105,24 @@ ContainerRender(Container* aContainer, ::OffsetRect(&src, visibleRect.x + int32_t(transform.x0), visibleRect.y + int32_t(transform.y0)); - if (!aManager->CompositingDisabled()) { - hr = aManager->device()-> + if (!mD3DManager->CompositingDisabled()) { + hr = device()-> StretchRect(previousRenderTarget, &src, renderSurface, &dest, D3DTEXF_NONE); } } if (hr == S_OK) { - aContainer->mSupportsComponentAlphaChildren = true; - } else if (!aManager->CompositingDisabled()) { - aManager->device()-> + mSupportsComponentAlphaChildren = true; + } else if (!mD3DManager->CompositingDisabled()) { + device()-> Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 0), 0, 0); } } - aManager->device()-> + device()-> GetVertexShaderConstantF(CBvRenderTargetOffset, previousRenderTargetOffset, 1); renderTargetOffset[0] = (float)visibleRect.x; renderTargetOffset[1] = (float)visibleRect.y; - aManager->device()-> + device()-> SetVertexShaderConstantF(CBvRenderTargetOffset, renderTargetOffset, 1); gfx3DMatrix viewMatrix; @@ -253,19 +135,19 @@ ContainerRender(Container* aContainer, viewMatrix._41 = -1.0f; viewMatrix._42 = 1.0f; - aManager->device()-> + device()-> GetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4); - aManager->device()-> + device()-> SetVertexShaderConstantF(CBmProjection, &viewMatrix._11, 4); } else { - aContainer->mSupportsComponentAlphaChildren = - (aContainer->GetContentFlags() & aContainer->CONTENT_OPAQUE) || - (aContainer->mParent && - aContainer->mParent->SupportsComponentAlphaChildren()); + mSupportsComponentAlphaChildren = + (GetContentFlags() & CONTENT_OPAQUE) || + (mParent && + mParent->SupportsComponentAlphaChildren()); } nsAutoTArray children; - aContainer->SortChildrenBy3DZOrder(children); + SortChildrenBy3DZOrder(children); /* * Render this container's contents. @@ -288,94 +170,40 @@ ContainerRender(Container* aContainer, d3drect.top = scissorRect.y; d3drect.right = scissorRect.x + scissorRect.width; d3drect.bottom = scissorRect.y + scissorRect.height; - aManager->device()->SetScissorRect(&d3drect); + device()->SetScissorRect(&d3drect); - if (layerToRender->GetLayer()->GetType() == aContainer->TYPE_THEBES) { + if (layerToRender->GetLayer()->GetType() == TYPE_THEBES) { static_cast(layerToRender)->RenderThebesLayer(&readback); } else { layerToRender->RenderLayer(); } } - if (useIntermediate && !aManager->CompositingDisabled()) { - aManager->device()->SetRenderTarget(0, previousRenderTarget); - aManager->device()->SetVertexShaderConstantF(CBvRenderTargetOffset, previousRenderTargetOffset, 1); - aManager->device()->SetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4); + if (useIntermediate && !mD3DManager->CompositingDisabled()) { + device()->SetRenderTarget(0, previousRenderTarget); + device()->SetVertexShaderConstantF(CBvRenderTargetOffset, previousRenderTargetOffset, 1); + device()->SetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4); - aManager->device()->SetVertexShaderConstantF(CBvLayerQuad, + device()->SetVertexShaderConstantF(CBvLayerQuad, ShaderConstantRect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height), 1); - aContainer->SetShaderTransformAndOpacity(); - aManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER, - aContainer->GetMaskLayer(), - aContainer->GetTransform().CanDraw2D()); + SetShaderTransformAndOpacity(); + mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER, + GetMaskLayer(), + GetTransform().CanDraw2D()); - aManager->device()->SetTexture(0, renderTexture); - aManager->device()->SetScissorRect(&containerD3D9ClipRect); - aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); + device()->SetTexture(0, renderTexture); + device()->SetScissorRect(&containerD3D9ClipRect); + device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); } else { - aManager->device()->SetScissorRect(&containerD3D9ClipRect); + device()->SetScissorRect(&containerD3D9ClipRect); } } - -ContainerLayerD3D9::ContainerLayerD3D9(LayerManagerD3D9 *aManager) - : ContainerLayer(aManager, nullptr) - , LayerD3D9(aManager) -{ - mImplData = static_cast(this); -} - -ContainerLayerD3D9::~ContainerLayerD3D9() -{ - while (mFirstChild) { - RemoveChild(mFirstChild); - } -} - -void -ContainerLayerD3D9::InsertAfter(Layer* aChild, Layer* aAfter) -{ - ContainerInsertAfter(this, aChild, aAfter); -} - -void -ContainerLayerD3D9::RemoveChild(Layer *aChild) -{ - ContainerRemoveChild(this, aChild); -} - -void -ContainerLayerD3D9::RepositionChild(Layer* aChild, Layer* aAfter) -{ - ContainerRepositionChild(this, aChild, aAfter); -} - -Layer* -ContainerLayerD3D9::GetLayer() -{ - return this; -} - -LayerD3D9* -ContainerLayerD3D9::GetFirstChildD3D9() -{ - if (!mFirstChild) { - return nullptr; - } - return static_cast(mFirstChild->ImplData()); -} - -void -ContainerLayerD3D9::RenderLayer() -{ - ContainerRender(this, mD3DManager); -} - void ContainerLayerD3D9::LayerManagerDestroyed() { diff --git a/gfx/layers/d3d9/ContainerLayerD3D9.h b/gfx/layers/d3d9/ContainerLayerD3D9.h index 099e69f30d8..b7d94829b38 100644 --- a/gfx/layers/d3d9/ContainerLayerD3D9.h +++ b/gfx/layers/d3d9/ContainerLayerD3D9.h @@ -12,40 +12,15 @@ namespace mozilla { namespace layers { -template -static void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); -template -static void ContainerRemoveChild(Container* aContainer, Layer* aChild); -template -static void ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter); -template -static void ContainerRender(Container* aContainer, LayerManagerD3D9* aManager); - class ContainerLayerD3D9 : public ContainerLayer, public LayerD3D9 { - template - friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); - template - friend void ContainerRemoveChild(Container* aContainer, Layer* aChild); - template - friend void ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter); - template - friend void ContainerRender(Container* aContainer, LayerManagerD3D9* aManager); - public: ContainerLayerD3D9(LayerManagerD3D9 *aManager); ~ContainerLayerD3D9(); nsIntRect GetVisibleRect() { return mVisibleRegion.GetBounds(); } - /* ContainerLayer implementation */ - virtual void InsertAfter(Layer* aChild, Layer* aAfter); - - virtual void RemoveChild(Layer* aChild); - - virtual void RepositionChild(Layer* aChild, Layer* aAfter); - /* LayerD3D9 implementation */ Layer* GetLayer(); diff --git a/gfx/layers/opengl/ContainerLayerOGL.cpp b/gfx/layers/opengl/ContainerLayerOGL.cpp index 0e0cbcf407a..6b02dead09b 100644 --- a/gfx/layers/opengl/ContainerLayerOGL.cpp +++ b/gfx/layers/opengl/ContainerLayerOGL.cpp @@ -28,146 +28,6 @@ class gfxImageSurface; namespace mozilla { namespace layers { -template -static void -ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(!aChild->GetParent(), - "aChild already in the tree"); - NS_ASSERTION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(), - "aChild already has siblings?"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - aChild->SetParent(aContainer); - if (aAfter == aContainer->mLastChild) { - aContainer->mLastChild = aChild; - } - if (!aAfter) { - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); - return; - } - - Layer* next = aAfter->GetNextSibling(); - aChild->SetNextSibling(next); - aChild->SetPrevSibling(aAfter); - if (next) { - next->SetPrevSibling(aChild); - } - aAfter->SetNextSibling(aChild); - NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); -} - -template -static void -ContainerRemoveChild(Container* aContainer, Layer* aChild) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev) { - prev->SetNextSibling(next); - } else { - aContainer->mFirstChild = next; - } - if (next) { - next->SetPrevSibling(prev); - } else { - aContainer->mLastChild = prev; - } - - aChild->SetNextSibling(nullptr); - aChild->SetPrevSibling(nullptr); - aChild->SetParent(nullptr); - - aContainer->DidRemoveChild(aChild); - NS_RELEASE(aChild); -} - -template -static void -ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter) -{ - NS_ASSERTION(aChild->Manager() == aContainer->Manager(), - "Child has wrong manager"); - NS_ASSERTION(aChild->GetParent() == aContainer, - "aChild not our child"); - NS_ASSERTION(!aAfter || - (aAfter->Manager() == aContainer->Manager() && - aAfter->GetParent() == aContainer), - "aAfter is not our child"); - - Layer* prev = aChild->GetPrevSibling(); - Layer* next = aChild->GetNextSibling(); - if (prev == aAfter) { - // aChild is already in the correct position, nothing to do. - return; - } - if (prev) { - prev->SetNextSibling(next); - } - if (next) { - next->SetPrevSibling(prev); - } - if (!aAfter) { - aChild->SetPrevSibling(nullptr); - aChild->SetNextSibling(aContainer->mFirstChild); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(aChild); - } - aContainer->mFirstChild = aChild; - return; - } - - Layer* afterNext = aAfter->GetNextSibling(); - if (afterNext) { - afterNext->SetPrevSibling(aChild); - } else { - aContainer->mLastChild = aChild; - } - aAfter->SetNextSibling(aChild); - aChild->SetPrevSibling(aAfter); - aChild->SetNextSibling(afterNext); -} - -template -static void -ContainerDestroy(Container* aContainer) - { - if (!aContainer->mDestroyed) { - while (aContainer->mFirstChild) { - aContainer->GetFirstChildOGL()->Destroy(); - aContainer->RemoveChild(aContainer->mFirstChild); - } - aContainer->mDestroyed = true; - } -} - -template -static void -ContainerCleanupResources(Container* aContainer) -{ - for (Layer* l = aContainer->GetFirstChild(); l; l = l->GetNextSibling()) { - LayerOGL* layerToRender = static_cast(l->ImplData()); - layerToRender->CleanupResources(); - } -} - static inline LayerOGL* GetNextSibling(LayerOGL* aLayer) { @@ -177,195 +37,9 @@ GetNextSibling(LayerOGL* aLayer) : nullptr; } -static bool -HasOpaqueAncestorLayer(Layer* aLayer) -{ - for (Layer* l = aLayer->GetParent(); l; l = l->GetParent()) { - if (l->GetContentFlags() & Layer::CONTENT_OPAQUE) - return true; - } - return false; -} - -template -static void -ContainerRender(Container* aContainer, - int aPreviousFrameBuffer, - const nsIntPoint& aOffset, - LayerManagerOGL* aManager) -{ - /** - * Setup our temporary texture for rendering the contents of this container. - */ - GLuint containerSurface; - GLuint frameBuffer; - - nsIntPoint childOffset(aOffset); - nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); - - nsIntRect cachedScissor = aContainer->gl()->ScissorRect(); - aContainer->gl()->PushScissorRect(); - aContainer->mSupportsComponentAlphaChildren = false; - - float opacity = aContainer->GetEffectiveOpacity(); - const gfx3DMatrix& transform = aContainer->GetEffectiveTransform(); - bool needsFramebuffer = aContainer->UseIntermediateSurface(); - if (needsFramebuffer) { - nsIntRect framebufferRect = visibleRect; - // we're about to create a framebuffer backed by textures to use as an intermediate - // surface. What to do if its size (as given by framebufferRect) would exceed the - // maximum texture size supported by the GL? The present code chooses the compromise - // of just clamping the framebuffer's size to the max supported size. - // This gives us a lower resolution rendering of the intermediate surface (children layers). - // See bug 827170 for a discussion. - GLint maxTexSize; - aContainer->gl()->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &maxTexSize); - framebufferRect.width = std::min(framebufferRect.width, maxTexSize); - framebufferRect.height = std::min(framebufferRect.height, maxTexSize); - - LayerManagerOGL::InitMode mode = LayerManagerOGL::InitModeClear; - if (aContainer->GetEffectiveVisibleRegion().GetNumRects() == 1 && - (aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE)) - { - // don't need a background, we're going to paint all opaque stuff - aContainer->mSupportsComponentAlphaChildren = true; - mode = LayerManagerOGL::InitModeNone; - } else { - const gfx3DMatrix& transform3D = aContainer->GetEffectiveTransform(); - gfxMatrix transform; - // If we have an opaque ancestor layer, then we can be sure that - // all the pixels we draw into are either opaque already or will be - // covered by something opaque. Otherwise copying up the background is - // not safe. - if (HasOpaqueAncestorLayer(aContainer) && - transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) { - mode = gfxPlatform::ComponentAlphaEnabled() ? - LayerManagerOGL::InitModeCopy : - LayerManagerOGL::InitModeClear; - framebufferRect.x += transform.x0; - framebufferRect.y += transform.y0; - aContainer->mSupportsComponentAlphaChildren = gfxPlatform::ComponentAlphaEnabled(); - } - } - - aContainer->gl()->PushViewportRect(); - framebufferRect -= childOffset; - if (!aManager->CompositingDisabled()) { - if (!aManager->CreateFBOWithTexture(framebufferRect, - mode, - aPreviousFrameBuffer, - &frameBuffer, - &containerSurface)) { - aContainer->gl()->PopViewportRect(); - aContainer->gl()->PopScissorRect(); - aContainer->gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer); - return; - } - } - childOffset.x = visibleRect.x; - childOffset.y = visibleRect.y; - } else { - frameBuffer = aPreviousFrameBuffer; - aContainer->mSupportsComponentAlphaChildren = (aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE) || - (aContainer->GetParent() && aContainer->GetParent()->SupportsComponentAlphaChildren()); - } - - nsAutoTArray children; - aContainer->SortChildrenBy3DZOrder(children); - - /** - * Render this container's contents. - */ - for (uint32_t i = 0; i < children.Length(); i++) { - LayerOGL* layerToRender = static_cast(children.ElementAt(i)->ImplData()); - - if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) { - continue; - } - - nsIntRect scissorRect = layerToRender->GetLayer()-> - CalculateScissorRect(cachedScissor, &aManager->GetWorldTransform()); - if (scissorRect.IsEmpty()) { - continue; - } - - aContainer->gl()->fScissor(scissorRect.x, - scissorRect.y, - scissorRect.width, - scissorRect.height); - - layerToRender->RenderLayer(frameBuffer, childOffset); - aContainer->gl()->MakeCurrent(); - } - - - if (needsFramebuffer) { - // Unbind the current framebuffer and rebind the previous one. -#ifdef MOZ_DUMP_PAINTING - if (gfxUtils::sDumpPainting) { - nsRefPtr surf = - aContainer->gl()->GetTexImage(containerSurface, true, aManager->GetFBOTextureFormat()); - - WriteSnapshotToDumpFile(aContainer, surf); - } -#endif - - // Restore the viewport - aContainer->gl()->PopViewportRect(); - nsIntRect viewport = aContainer->gl()->ViewportRect(); - aManager->SetupPipeline(viewport.width, viewport.height, - LayerManagerOGL::ApplyWorldTransform); - aContainer->gl()->PopScissorRect(); - - if (!aManager->CompositingDisabled()) { - aContainer->gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer); - aContainer->gl()->fDeleteFramebuffers(1, &frameBuffer); - - aContainer->gl()->fActiveTexture(LOCAL_GL_TEXTURE0); - - aContainer->gl()->fBindTexture(aManager->FBOTextureTarget(), containerSurface); - - MaskType maskType = MaskNone; - if (aContainer->GetMaskLayer()) { - if (!aContainer->GetTransform().CanDraw2D()) { - maskType = Mask3d; - } else { - maskType = Mask2d; - } - } - ShaderProgramOGL *rgb = - aManager->GetFBOLayerProgram(maskType); - - rgb->Activate(); - rgb->SetLayerQuadRect(visibleRect); - rgb->SetLayerTransform(transform); - rgb->SetTextureTransform(gfx3DMatrix()); - rgb->SetLayerOpacity(opacity); - rgb->SetRenderOffset(aOffset); - rgb->SetTextureUnit(0); - rgb->LoadMask(aContainer->GetMaskLayer()); - - if (rgb->GetTexCoordMultiplierUniformLocation() != -1) { - // 2DRect case, get the multiplier right for a sampler2DRect - rgb->SetTexCoordMultiplier(visibleRect.width, visibleRect.height); - } - - // Drawing is always flipped, but when copying between surfaces we want to avoid - // this. Pass true for the flip parameter to introduce a second flip - // that cancels the other one out. - aManager->BindAndDrawQuad(rgb, true); - - // Clean up resources. This also unbinds the texture. - aContainer->gl()->fDeleteTextures(1, &containerSurface); - } - } else { - aContainer->gl()->PopScissorRect(); - } -} - -ContainerLayerOGL::ContainerLayerOGL(LayerManagerOGL *aManager) - : ContainerLayer(aManager, nullptr) - , LayerOGL(aManager) +ContainerLayerOGL::ContainerLayerOGL(LayerManagerOGL *mOGLManager) + : ContainerLayer(mOGLManager, nullptr) + , LayerOGL(mOGLManager) { mImplData = static_cast(this); } @@ -375,28 +49,16 @@ ContainerLayerOGL::~ContainerLayerOGL() Destroy(); } -void -ContainerLayerOGL::InsertAfter(Layer* aChild, Layer* aAfter) -{ - ContainerInsertAfter(this, aChild, aAfter); -} - -void -ContainerLayerOGL::RemoveChild(Layer *aChild) -{ - ContainerRemoveChild(this, aChild); -} - -void -ContainerLayerOGL::RepositionChild(Layer* aChild, Layer* aAfter) -{ - ContainerRepositionChild(this, aChild, aAfter); -} - void ContainerLayerOGL::Destroy() { - ContainerDestroy(this); + if (!mDestroyed) { + while (mFirstChild) { + GetFirstChildOGL()->Destroy(); + RemoveChild(mFirstChild); + } + mDestroyed = true; + } } LayerOGL* @@ -412,13 +74,182 @@ void ContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer, const nsIntPoint& aOffset) { - ContainerRender(this, aPreviousFrameBuffer, aOffset, mOGLManager); + /** + * Setup our temporary texture for rendering the contents of this container. + */ + GLuint containerSurface; + GLuint frameBuffer; + + nsIntPoint childOffset(aOffset); + nsIntRect visibleRect = GetEffectiveVisibleRegion().GetBounds(); + + nsIntRect cachedScissor = gl()->ScissorRect(); + gl()->PushScissorRect(); + mSupportsComponentAlphaChildren = false; + + float opacity = GetEffectiveOpacity(); + const gfx3DMatrix& transform = GetEffectiveTransform(); + bool needsFramebuffer = UseIntermediateSurface(); + if (needsFramebuffer) { + nsIntRect framebufferRect = visibleRect; + // we're about to create a framebuffer backed by textures to use as an intermediate + // surface. What to do if its size (as given by framebufferRect) would exceed the + // maximum texture size supported by the GL? The present code chooses the compromise + // of just clamping the framebuffer's size to the max supported size. + // This gives us a lower resolution rendering of the intermediate surface (children layers). + // See bug 827170 for a discussion. + GLint maxTexSize; + gl()->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &maxTexSize); + framebufferRect.width = std::min(framebufferRect.width, maxTexSize); + framebufferRect.height = std::min(framebufferRect.height, maxTexSize); + + LayerManagerOGL::InitMode mode = LayerManagerOGL::InitModeClear; + if (GetEffectiveVisibleRegion().GetNumRects() == 1 && + (GetContentFlags() & Layer::CONTENT_OPAQUE)) + { + // don't need a background, we're going to paint all opaque stuff + mSupportsComponentAlphaChildren = true; + mode = LayerManagerOGL::InitModeNone; + } else { + const gfx3DMatrix& transform3D = GetEffectiveTransform(); + gfxMatrix transform; + // If we have an opaque ancestor layer, then we can be sure that + // all the pixels we draw into are either opaque already or will be + // covered by something opaque. Otherwise copying up the background is + // not safe. + if (HasOpaqueAncestorLayer(this) && + transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) { + mode = gfxPlatform::ComponentAlphaEnabled() ? + LayerManagerOGL::InitModeCopy : + LayerManagerOGL::InitModeClear; + framebufferRect.x += transform.x0; + framebufferRect.y += transform.y0; + mSupportsComponentAlphaChildren = gfxPlatform::ComponentAlphaEnabled(); + } + } + + gl()->PushViewportRect(); + framebufferRect -= childOffset; + if (!mOGLManager->CompositingDisabled()) { + if (!mOGLManager->CreateFBOWithTexture(framebufferRect, + mode, + aPreviousFrameBuffer, + &frameBuffer, + &containerSurface)) { + gl()->PopViewportRect(); + gl()->PopScissorRect(); + gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer); + return; + } + } + childOffset.x = visibleRect.x; + childOffset.y = visibleRect.y; + } else { + frameBuffer = aPreviousFrameBuffer; + mSupportsComponentAlphaChildren = (GetContentFlags() & Layer::CONTENT_OPAQUE) || + (GetParent() && GetParent()->SupportsComponentAlphaChildren()); + } + + nsAutoTArray children; + SortChildrenBy3DZOrder(children); + + /** + * Render this container's contents. + */ + for (uint32_t i = 0; i < children.Length(); i++) { + LayerOGL* layerToRender = static_cast(children.ElementAt(i)->ImplData()); + + if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) { + continue; + } + + nsIntRect scissorRect = layerToRender->GetLayer()-> + CalculateScissorRect(cachedScissor, &mOGLManager->GetWorldTransform()); + if (scissorRect.IsEmpty()) { + continue; + } + + gl()->fScissor(scissorRect.x, + scissorRect.y, + scissorRect.width, + scissorRect.height); + + layerToRender->RenderLayer(frameBuffer, childOffset); + gl()->MakeCurrent(); + } + + + if (needsFramebuffer) { + // Unbind the current framebuffer and rebind the previous one. +#ifdef MOZ_DUMP_PAINTING + if (gfxUtils::sDumpPainting) { + nsRefPtr surf = + gl()->GetTexImage(containerSurface, true, mOGLManager->GetFBOTextureFormat()); + + WriteSnapshotToDumpFile(this, surf); + } +#endif + + // Restore the viewport + gl()->PopViewportRect(); + nsIntRect viewport = gl()->ViewportRect(); + mOGLManager->SetupPipeline(viewport.width, viewport.height, + LayerManagerOGL::ApplyWorldTransform); + gl()->PopScissorRect(); + + if (!mOGLManager->CompositingDisabled()) { + gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer); + gl()->fDeleteFramebuffers(1, &frameBuffer); + + gl()->fActiveTexture(LOCAL_GL_TEXTURE0); + + gl()->fBindTexture(mOGLManager->FBOTextureTarget(), containerSurface); + + MaskType maskType = MaskNone; + if (GetMaskLayer()) { + if (!GetTransform().CanDraw2D()) { + maskType = Mask3d; + } else { + maskType = Mask2d; + } + } + ShaderProgramOGL *rgb = + mOGLManager->GetFBOLayerProgram(maskType); + + rgb->Activate(); + rgb->SetLayerQuadRect(visibleRect); + rgb->SetLayerTransform(transform); + rgb->SetTextureTransform(gfx3DMatrix()); + rgb->SetLayerOpacity(opacity); + rgb->SetRenderOffset(aOffset); + rgb->SetTextureUnit(0); + rgb->LoadMask(GetMaskLayer()); + + if (rgb->GetTexCoordMultiplierUniformLocation() != -1) { + // 2DRect case, get the multiplier right for a sampler2DRect + rgb->SetTexCoordMultiplier(visibleRect.width, visibleRect.height); + } + + // Drawing is always flipped, but when copying between surfaces we want to avoid + // this. Pass true for the flip parameter to introduce a second flip + // that cancels the other one out. + mOGLManager->BindAndDrawQuad(rgb, true); + + // Clean up resources. This also unbinds the texture. + gl()->fDeleteTextures(1, &containerSurface); + } + } else { + gl()->PopScissorRect(); + } } void ContainerLayerOGL::CleanupResources() { - ContainerCleanupResources(this); + for (Layer* l = GetFirstChild(); l; l = l->GetNextSibling()) { + LayerOGL* layerToRender = static_cast(l->ImplData()); + layerToRender->CleanupResources(); + } } } /* layers */ diff --git a/gfx/layers/opengl/ContainerLayerOGL.h b/gfx/layers/opengl/ContainerLayerOGL.h index 84d1bbf32aa..1e80d23d58d 100644 --- a/gfx/layers/opengl/ContainerLayerOGL.h +++ b/gfx/layers/opengl/ContainerLayerOGL.h @@ -14,47 +14,13 @@ struct nsIntPoint; namespace mozilla { namespace layers { -template -static void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); -template -static void ContainerRemoveChild(Container* aContainer, Layer* aChild); -template -static void ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter); -template -static void ContainerDestroy(Container* aContainer); -template -static void ContainerRender(Container* aContainer, - int aPreviousFrameBuffer, - const nsIntPoint& aOffset, - LayerManagerOGL* aManager); - class ContainerLayerOGL : public ContainerLayer, public LayerOGL { - template - friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); - template - friend void ContainerRemoveChild(Container* aContainer, Layer* aChild); - template - friend void ContainerRepositionChild(Container* aContainer, Layer* aChild, Layer* aAfter); - template - friend void ContainerDestroy(Container* aContainer); - template - friend void ContainerRender(Container* aContainer, - int aPreviousFrameBuffer, - const nsIntPoint& aOffset, - LayerManagerOGL* aManager); - public: ContainerLayerOGL(LayerManagerOGL *aManager); ~ContainerLayerOGL(); - void InsertAfter(Layer* aChild, Layer* aAfter); - - void RemoveChild(Layer* aChild); - - void RepositionChild(Layer* aChild, Layer* aAfter); - /** LayerOGL implementation */ Layer* GetLayer() { return this; } diff --git a/gfx/src/X11Util.cpp b/gfx/src/X11Util.cpp index 912f269f90e..ac9c2595824 100644 --- a/gfx/src/X11Util.cpp +++ b/gfx/src/X11Util.cpp @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "X11Util.h" +#include "nsDebug.h" // for NS_ASSERTION, etc namespace mozilla { diff --git a/gfx/src/X11Util.h b/gfx/src/X11Util.h index 9659a0004b2..a4501fba2f6 100644 --- a/gfx/src/X11Util.h +++ b/gfx/src/X11Util.h @@ -21,10 +21,9 @@ # error Unknown toolkit #endif -#include "mozilla/Scoped.h" - -#include "gfxCore.h" -#include "nsDebug.h" +#include // for memset +#include "gfxCore.h" // for NS_GFX +#include "mozilla/Scoped.h" // for SCOPED_TEMPLATE namespace mozilla { diff --git a/gfx/src/gfxCrashReporterUtils.cpp b/gfx/src/gfxCrashReporterUtils.cpp index e04f8c93a81..d5658c062c1 100644 --- a/gfx/src/gfxCrashReporterUtils.cpp +++ b/gfx/src/gfxCrashReporterUtils.cpp @@ -10,15 +10,25 @@ #endif #ifdef MOZ_GFXFEATUREREPORTER -#include "nsExceptionHandler.h" -#include "nsString.h" -#include "nsTArray.h" -#include "nsIObserverService.h" -#include "nsIObserver.h" -#include "nsAutoPtr.h" -#include "nsServiceManagerUtils.h" -#include "mozilla/Services.h" -#include "nsThreadUtils.h" +#include "gfxCrashReporterUtils.h" +#include // for strcmp +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 +#include "mozilla/Services.h" // for GetObserverService +#include "mozilla/mozalloc.h" // for operator new, etc +#include "nsAutoPtr.h" // for nsRefPtr +#include "nsCOMPtr.h" // for nsCOMPtr +#include "nsError.h" // for NS_OK, NS_FAILED, nsresult +#include "nsExceptionHandler.h" // for AppendAppNotesToCrashReport +#include "nsID.h" +#include "nsIEventTarget.h" // for NS_DISPATCH_NORMAL +#include "nsIObserver.h" // for nsIObserver, etc +#include "nsIObserverService.h" // for nsIObserverService +#include "nsIRunnable.h" // for nsIRunnable +#include "nsISupports.h" +#include "nsStringGlue.h" // for nsAutoCString, nsCString, etc +#include "nsTArray.h" // for nsTArray +#include "nsThreadUtils.h" // for NS_DispatchToMainThread, etc +#include "nscore.h" // for NS_IMETHOD, NS_IMETHODIMP, etc namespace mozilla { diff --git a/gfx/src/nsColor.cpp b/gfx/src/nsColor.cpp index 2881f52fe64..4f0b009655b 100644 --- a/gfx/src/nsColor.cpp +++ b/gfx/src/nsColor.cpp @@ -5,17 +5,15 @@ #include "mozilla/Util.h" -#include "plstr.h" #include "nsColor.h" -#include "nsColorNames.h" -#include "nsString.h" -#include "nscore.h" -#include "nsCoord.h" -#include "nsCOMPtr.h" -#include "nsIServiceManager.h" -#include -#include "prprf.h" +#include // for int32_t +#include "mozilla/Util.h" // for ArrayLength +#include "mozilla/mozalloc.h" // for operator delete, etc +#include "nsColorNames.h" // for nsColorNames +#include "nsDebug.h" // for NS_ASSERTION, etc #include "nsStaticNameTable.h" +#include "nsStringGlue.h" // for nsAutoCString, nsString, etc +#include "nscore.h" // for nsAString, etc using namespace mozilla; diff --git a/gfx/src/nsColor.h b/gfx/src/nsColor.h index 0ac5feefdab..bcae9761f1a 100644 --- a/gfx/src/nsColor.h +++ b/gfx/src/nsColor.h @@ -6,8 +6,11 @@ #ifndef nsColor_h___ #define nsColor_h___ -#include "gfxCore.h" -#include "nscore.h" +#include // for size_t +#include // for uint8_t, uint32_t +#include "gfxCore.h" // for NS_GFX_ +#include "nscore.h" // for nsAString +#include "prtypes.h" // for PR_BEGIN_MACRO, etc class nsAString; class nsString; diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index 4aae268beea..ba51a677310 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -4,24 +4,36 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsDeviceContext.h" - -#include - -#include "gfxImageSurface.h" -#include "mozilla/Attributes.h" -#include "mozilla/Preferences.h" -#include "mozilla/Services.h" -#include "nsCRT.h" -#include "nsFontMetrics.h" -#include "nsIDeviceContextSpec.h" -#include "nsILanguageAtomService.h" -#include "nsIObserver.h" -#include "nsIObserverService.h" -#include "nsIScreen.h" -#include "nsIScreenManager.h" -#include "nsIServiceManager.h" -#include "nsIWidget.h" -#include "nsRenderingContext.h" +#include // for max +#include "gfxASurface.h" // for gfxASurface, etc +#include "gfxFont.h" // for gfxFontGroup +#include "gfxImageSurface.h" // for gfxImageSurface +#include "gfxPoint.h" // for gfxSize +#include "mozilla/Attributes.h" // for MOZ_FINAL +#include "mozilla/Preferences.h" // for Preferences +#include "mozilla/Services.h" // for GetObserverService +#include "mozilla/mozalloc.h" // for operator new +#include "nsCRT.h" // for nsCRT +#include "nsDebug.h" // for NS_NOTREACHED, NS_ASSERTION, etc +#include "nsFont.h" // for nsFont +#include "nsFontMetrics.h" // for nsFontMetrics +#include "nsIAtom.h" // for nsIAtom, do_GetAtom +#include "nsID.h" +#include "nsIDeviceContextSpec.h" // for nsIDeviceContextSpec +#include "nsILanguageAtomService.h" // for nsILanguageAtomService, etc +#include "nsIObserver.h" // for nsIObserver, etc +#include "nsIObserverService.h" // for nsIObserverService +#include "nsIScreen.h" // for nsIScreen +#include "nsIScreenManager.h" // for nsIScreenManager +#include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE +#include "nsIWidget.h" // for nsIWidget, NS_NATIVE_WINDOW +#include "nsRect.h" // for nsRect +#include "nsRenderingContext.h" // for nsRenderingContext +#include "nsServiceManagerUtils.h" // for do_GetService +#include "nsStringGlue.h" // for nsDependentString +#include "nsTArray.h" // for nsTArray, nsTArray_Impl +#include "nsThreadUtils.h" // for NS_IsMainThread +#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc #if !XP_MACOSX #include "gfxPDFSurface.h" diff --git a/gfx/src/nsDeviceContext.h b/gfx/src/nsDeviceContext.h index 6eb3e57d98d..e07e33698b8 100644 --- a/gfx/src/nsDeviceContext.h +++ b/gfx/src/nsDeviceContext.h @@ -6,11 +6,17 @@ #ifndef _NS_DEVICECONTEXT_H_ #define _NS_DEVICECONTEXT_H_ -#include "gfxTypes.h" -#include "nsAutoPtr.h" -#include "nsCOMPtr.h" -#include "nsCoord.h" -#include "nsMathUtils.h" +#include // for uint32_t +#include // for int32_t +#include "gfxTypes.h" // for gfxFloat +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 +#include "nsAutoPtr.h" // for nsRefPtr +#include "nsCOMPtr.h" // for nsCOMPtr +#include "nsCoord.h" // for nscoord +#include "nsError.h" // for nsresult +#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING +#include "nsMathUtils.h" // for NS_round +#include "nscore.h" // for PRUnichar, nsAString class gfxASurface; class gfxUserFontSet; diff --git a/gfx/src/nsFont.cpp b/gfx/src/nsFont.cpp index 985e3080e41..9f187f8398b 100644 --- a/gfx/src/nsFont.cpp +++ b/gfx/src/nsFont.cpp @@ -4,10 +4,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsFont.h" -#include "nsString.h" +#include "gfxFont.h" // for gfxFontStyle +#include "gfxFontConstants.h" // for NS_FONT_KERNING_AUTO, etc +#include "gfxFontFeatures.h" // for gfxFontFeature, etc +#include "gfxFontUtils.h" // for TRUETYPE_TAG +#include "nsCRT.h" // for nsCRT +#include "nsDebug.h" // for NS_ASSERTION +#include "nsISupports.h" +#include "nsMemory.h" // for NS_ARRAY_LENGTH #include "nsUnicharUtils.h" -#include "nsCRT.h" -#include "gfxFont.h" +#include "nscore.h" // for PRUnichar +#include "prtypes.h" // for PR_STATIC_ASSERT nsFont::nsFont(const char* aName, uint8_t aStyle, uint8_t aVariant, uint16_t aWeight, int16_t aStretch, uint8_t aDecoration, diff --git a/gfx/src/nsFont.h b/gfx/src/nsFont.h index 6667d4a8eb9..9459dcc6498 100644 --- a/gfx/src/nsFont.h +++ b/gfx/src/nsFont.h @@ -6,13 +6,17 @@ #ifndef nsFont_h___ #define nsFont_h___ -#include "gfxCore.h" -#include "nsCoord.h" -#include "nsStringGlue.h" -#include "nsTArray.h" -#include "gfxFontConstants.h" +#include // for uint8_t, uint16_t +#include // for int16_t +#include "gfxCore.h" // for NS_GFX #include "gfxFontFeatures.h" -#include "nsAutoPtr.h" +#include "nsAutoPtr.h" // for nsRefPtr +#include "nsCoord.h" // for nscoord +#include "nsStringFwd.h" // for nsSubstring +#include "nsStringGlue.h" // for nsString +#include "nsTArray.h" // for nsTArray + +struct gfxFontStyle; // XXX we need a method to enumerate all of the possible fonts on the // system across family, weight, style, size, etc. But not here! @@ -34,8 +38,6 @@ const uint8_t kGenericFont_monospace = 0x08; const uint8_t kGenericFont_cursive = 0x10; const uint8_t kGenericFont_fantasy = 0x20; -struct gfxFontStyle; - // Font structure. struct NS_GFX nsFont { // The family name of the font diff --git a/gfx/src/nsFontMetrics.cpp b/gfx/src/nsFontMetrics.cpp index fbbcdabd7ad..479e7849e47 100644 --- a/gfx/src/nsFontMetrics.cpp +++ b/gfx/src/nsFontMetrics.cpp @@ -4,11 +4,22 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsFontMetrics.h" -#include "nsBoundingMetrics.h" -#include "nsRenderingContext.h" -#include "nsDeviceContext.h" -#include "nsStyleConsts.h" -#include +#include // for floor, ceil +#include // for max +#include "gfxPlatform.h" // for gfxPlatform +#include "gfxPoint.h" // for gfxPoint +#include "gfxRect.h" // for gfxRect +#include "gfxTypes.h" // for gfxFloat +#include "nsBoundingMetrics.h" // for nsBoundingMetrics +#include "nsDebug.h" // for NS_ERROR, NS_ABORT_IF_FALSE +#include "nsDeviceContext.h" // for nsDeviceContext +#include "nsIAtom.h" // for nsIAtom +#include "nsMathUtils.h" // for NS_round +#include "nsRenderingContext.h" // for nsRenderingContext +#include "nsStringGlue.h" // for nsString +#include "nsStyleConsts.h" // for NS_STYLE_HYPHENS_NONE + +class gfxUserFontSet; namespace { diff --git a/gfx/src/nsFontMetrics.h b/gfx/src/nsFontMetrics.h index 628f6e40bf2..c4bdc72032e 100644 --- a/gfx/src/nsFontMetrics.h +++ b/gfx/src/nsFontMetrics.h @@ -6,13 +6,21 @@ #ifndef NSFONTMETRICS__H__ #define NSFONTMETRICS__H__ -#include "nsCOMPtr.h" -#include "nsCoord.h" -#include "nsFont.h" -#include "gfxFont.h" +#include // for uint32_t +#include // for int32_t +#include "gfxFont.h" // for gfxFont, gfxFontGroup +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 +#include "nsAutoPtr.h" // for nsRefPtr +#include "nsCOMPtr.h" // for nsCOMPtr +#include "nsCoord.h" // for nscoord +#include "nsError.h" // for nsresult +#include "nsFont.h" // for nsFont +#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING +#include "nscore.h" // for PRUnichar -class nsIAtom; +class gfxUserFontSet; class nsDeviceContext; +class nsIAtom; class nsRenderingContext; struct nsBoundingMetrics; diff --git a/gfx/src/nsRect.cpp b/gfx/src/nsRect.cpp index 6b1ab2cb994..ffbb7001385 100644 --- a/gfx/src/nsRect.cpp +++ b/gfx/src/nsRect.cpp @@ -4,9 +4,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsRect.h" -#include "nsString.h" -#include "nsDeviceContext.h" -#include "prlog.h" +#include "mozilla/gfx/Types.h" // for NS_SIDE_BOTTOM, etc +#include "nsDeviceContext.h" // for nsDeviceContext +#include "nsStringGlue.h" // for nsAutoString, etc +#include "prtypes.h" // for PR_STATIC_ASSERT // the mozilla::css::Side sequence must match the nsMargin nscoord sequence PR_STATIC_ASSERT((NS_SIDE_TOP == 0) && (NS_SIDE_RIGHT == 1) && (NS_SIDE_BOTTOM == 2) && (NS_SIDE_LEFT == 3)); diff --git a/gfx/src/nsRect.h b/gfx/src/nsRect.h index 0609f64c877..244ee127238 100644 --- a/gfx/src/nsRect.h +++ b/gfx/src/nsRect.h @@ -7,17 +7,20 @@ #ifndef NSRECT_H #define NSRECT_H -#include -#include "nsCoord.h" -#include "nsPoint.h" -#include "nsSize.h" -#include "nsMargin.h" -#include "gfxCore.h" -#include "nsTraceRefcnt.h" -#include "mozilla/gfx/BaseRect.h" -#include "mozilla/Likely.h" -#include -#include +#include // for FILE +#include // for int32_t, int64_t +#include // for max, min +#include // for INT_MAX +#include "gfxCore.h" // for NS_GFX +#include "mozilla/Likely.h" // for MOZ_UNLIKELY +#include "mozilla/gfx/BaseRect.h" // for BaseRect +#include "nsCoord.h" // for nscoord, etc +#include "nsDebug.h" // for NS_WARNING +#include "nsMargin.h" // for nsMargin, etc +#include "nsPoint.h" // for nsIntPoint, nsPoint +#include "nsSize.h" // for nsIntSize, nsSize +#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc +#include "nscore.h" // for NS_BUILD_REFCNT_LOGGING struct nsIntRect; diff --git a/gfx/src/nsRegion.cpp b/gfx/src/nsRegion.cpp index 5e8e3ec2b2a..c984de9e908 100644 --- a/gfx/src/nsRegion.cpp +++ b/gfx/src/nsRegion.cpp @@ -3,11 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsRegion.h" -#include "nsISupportsImpl.h" -#include "nsTArray.h" -#include "mozilla/ThreadLocal.h" -#include "nsPrintfCString.h" -#include +#include // for max, min +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2, etc +#include "mozilla/ThreadLocal.h" // for ThreadLocal +#include "mozilla/mozalloc.h" // for operator delete, etc +#include "nsDebug.h" // for NS_ASSERTION, NS_ERROR +#include "nsISupports.h" // for NS_ASSERT_OWNINGTHREAD, etc +#include "nsPrintfCString.h" // for nsPrintfCString +#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc /* * The SENTINEL values below guaranties that a < or > diff --git a/gfx/src/nsRegion.h b/gfx/src/nsRegion.h index 8c811d6a074..a6b9354e76a 100644 --- a/gfx/src/nsRegion.h +++ b/gfx/src/nsRegion.h @@ -6,9 +6,16 @@ #ifndef nsRegion_h__ #define nsRegion_h__ -#include "nsRect.h" -#include "nsPoint.h" -#include "nsString.h" +#include // for size_t +#include // for uint32_t, uint64_t +#include // for int32_t +#include "gfxCore.h" // for NS_GFX +#include "nsCoord.h" // for nscoord +#include "nsError.h" // for nsresult +#include "nsPoint.h" // for nsIntPoint, nsPoint +#include "nsRect.h" // for nsIntRect, nsRect +#include "nsStringGlue.h" // for nsCString +#include "xpcom-config.h" // for CPP_THROW_NEW class nsIntRegion; diff --git a/gfx/src/nsRenderingContext.cpp b/gfx/src/nsRenderingContext.cpp index 4aa5ecc09c3..4f47b3bb1d0 100644 --- a/gfx/src/nsRenderingContext.cpp +++ b/gfx/src/nsRenderingContext.cpp @@ -4,9 +4,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsRenderingContext.h" -#include "nsBoundingMetrics.h" -#include "nsRegion.h" -#include +#include // for strlen +#include // for min +#include "gfxColor.h" // for gfxRGBA +#include "gfxMatrix.h" // for gfxMatrix +#include "gfxPoint.h" // for gfxPoint, gfxSize +#include "gfxRect.h" // for gfxRect +#include "gfxTypes.h" // for gfxFloat +#include "mozilla/gfx/BasePoint.h" // for BasePoint +#include "mozilla/mozalloc.h" // for operator delete[], etc +#include "nsBoundingMetrics.h" // for nsBoundingMetrics +#include "nsCharTraits.h" // for NS_IS_LOW_SURROGATE +#include "nsDebug.h" // for NS_ERROR +#include "nsPoint.h" // for nsPoint +#include "nsRect.h" // for nsRect, nsIntRect +#include "nsRegion.h" // for nsIntRegionRectIterator, etc + +class gfxASurface; // XXXTodo: rename FORM_TWIPS to FROM_APPUNITS #define FROM_TWIPS(_x) ((gfxFloat)((_x)/(mP2A))) diff --git a/gfx/src/nsRenderingContext.h b/gfx/src/nsRenderingContext.h index 1127e91f0e6..0545abcd2fa 100644 --- a/gfx/src/nsRenderingContext.h +++ b/gfx/src/nsRenderingContext.h @@ -6,16 +6,25 @@ #ifndef NSRENDERINGCONTEXT__H__ #define NSRENDERINGCONTEXT__H__ -#include "nsAutoPtr.h" -#include "nsDeviceContext.h" -#include "nsFontMetrics.h" -#include "nsColor.h" -#include "nsCoord.h" -#include "gfxContext.h" -#include "mozilla/gfx/UserData.h" +#include // for uint32_t +#include // for int32_t +#include "gfxContext.h" // for gfxContext +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 +#include "mozilla/gfx/UserData.h" // for UserData, UserDataKey +#include "nsAutoPtr.h" // for nsRefPtr +#include "nsBoundingMetrics.h" // for nsBoundingMetrics +#include "nsColor.h" // for nscolor +#include "nsCoord.h" // for nscoord, NSToIntRound +#include "nsDeviceContext.h" // for nsDeviceContext +#include "nsFontMetrics.h" // for nsFontMetrics +#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING, etc +#include "nsStringGlue.h" // for nsString +#include "nscore.h" // for PRUnichar -struct nsPoint; +class gfxASurface; class nsIntRegion; +struct nsPoint; +struct nsRect; typedef enum { nsLineStyle_kNone = 0, diff --git a/gfx/src/nsScriptableRegion.cpp b/gfx/src/nsScriptableRegion.cpp index 889f652204f..f88ae4eb227 100644 --- a/gfx/src/nsScriptableRegion.cpp +++ b/gfx/src/nsScriptableRegion.cpp @@ -5,10 +5,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsScriptableRegion.h" -#include "nsCOMPtr.h" -#include "nsIXPConnect.h" -#include "nsServiceManagerUtils.h" -#include "jsapi.h" +#include // for uint32_t +#include // for int32_t +#include "js/RootingAPI.h" // for Rooted +#include "js/Value.h" // for INT_TO_JSVAL, etc +#include "jsapi.h" // for JS_DefineElement, etc +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 +#include "nsError.h" // for NS_OK, NS_ERROR_FAILURE, etc +#include "nsID.h" +#include "nsRect.h" // for nsIntRect +#include "nscore.h" // for NS_IMETHODIMP + +class JSObject; +struct JSContext; nsScriptableRegion::nsScriptableRegion() { diff --git a/gfx/src/nsThebesFontEnumerator.cpp b/gfx/src/nsThebesFontEnumerator.cpp index f81e1e2e711..eff36fc6197 100644 --- a/gfx/src/nsThebesFontEnumerator.cpp +++ b/gfx/src/nsThebesFontEnumerator.cpp @@ -4,12 +4,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsThebesFontEnumerator.h" - -#include "nsMemory.h" - -#include "gfxPlatform.h" -#include "nsTArray.h" -#include "nsIAtom.h" +#include // for uint32_t +#include "gfxPlatform.h" // for gfxPlatform +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 +#include "nsCOMPtr.h" // for nsCOMPtr +#include "nsDebug.h" // for NS_ENSURE_ARG_POINTER +#include "nsError.h" // for NS_OK, NS_FAILED, nsresult +#include "nsIAtom.h" // for nsIAtom, do_GetAtom +#include "nsID.h" +#include "nsMemory.h" // for nsMemory +#include "nsStringGlue.h" // for nsAutoCString, nsAutoString, etc +#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc +#include "nscore.h" // for PRUnichar, NS_IMETHODIMP NS_IMPL_ISUPPORTS1(nsThebesFontEnumerator, nsIFontEnumerator) diff --git a/gfx/src/nsThebesFontEnumerator.h b/gfx/src/nsThebesFontEnumerator.h index f1808fcd02f..664f6e9d7e5 100644 --- a/gfx/src/nsThebesFontEnumerator.h +++ b/gfx/src/nsThebesFontEnumerator.h @@ -6,8 +6,9 @@ #ifndef _NSTHEBESFONTENUMERATOR_H_ #define _NSTHEBESFONTENUMERATOR_H_ -#include "nsIFontEnumerator.h" -#include "mozilla/Attributes.h" +#include "mozilla/Attributes.h" // for MOZ_FINAL +#include "nsIFontEnumerator.h" // for NS_DECL_NSIFONTENUMERATOR, etc +#include "nsISupports.h" // for NS_DECL_ISUPPORTS class nsThebesFontEnumerator MOZ_FINAL : public nsIFontEnumerator { diff --git a/gfx/src/nsThebesGfxFactory.cpp b/gfx/src/nsThebesGfxFactory.cpp index bf1bcd76745..13720f9a5cd 100644 --- a/gfx/src/nsThebesGfxFactory.cpp +++ b/gfx/src/nsThebesGfxFactory.cpp @@ -3,15 +3,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "gfxPlatform.h" // for gfxPlatform +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 +#include "mozilla/Attributes.h" // for MOZ_FINAL +#include "mozilla/Module.h" // for Module, Module::CIDEntry, etc #include "mozilla/ModuleUtils.h" -#include "mozilla/Attributes.h" -#include "nsCOMPtr.h" -#include "nsGfxCIID.h" - -#include "nsThebesFontEnumerator.h" -#include "nsScriptableRegion.h" - -#include "gfxPlatform.h" +#include "mozilla/mozalloc.h" // for operator new +#include "nsCOMPtr.h" // for nsCOMPtr +#include "nsError.h" // for NS_ERROR_NO_AGGREGATION, etc +#include "nsGfxCIID.h" // for NS_FONT_ENUMERATOR_CID, etc +#include "nsID.h" // for NS_DEFINE_NAMED_CID, etc +#include "nsIScriptableRegion.h" // for nsIScriptableRegion +#include "nsISupports.h" // for NS_DECL_ISUPPORTS, etc +#include "nsScriptableRegion.h" // for nsScriptableRegion +#include "nsThebesFontEnumerator.h" // for nsThebesFontEnumerator // This class doesn't do anything; its only purpose is to give // gfxPlatform::Init a way to force this component to be registered, diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index 37fa78aba4f..539bf86249f 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -523,7 +523,7 @@ gfxASurface::MovePixels(const nsIntRect& aSourceRect, // CreateSimilarSurface can return nullptr if the current surface is // in an error state. This isn't good, but its better to carry // on with the error surface instead of crashing. - NS_ASSERTION(tmp, "Must have temporary surface to move pixels!"); + NS_WARN_IF_FALSE(tmp, "Must have temporary surface to move pixels!"); if (!tmp) { return; } diff --git a/ipc/chromium/src/base/dir_reader_bsd.h b/ipc/chromium/src/base/dir_reader_bsd.h index f579af96991..f8962c36cee 100644 --- a/ipc/chromium/src/base/dir_reader_bsd.h +++ b/ipc/chromium/src/base/dir_reader_bsd.h @@ -59,19 +59,11 @@ class DirReaderBSD { if (offset_ != size_) return true; -#ifdef OS_OPENBSD - const int r = getdirentries(fd_, buf_, sizeof(buf_), basep_); -#else const int r = getdents(fd_, buf_, sizeof(buf_)); -#endif if (r == 0) return false; if (r == -1) { -#ifdef OS_OPENBSD - DLOG(ERROR) << "getdirentries returned an error: " << errno; -#else DLOG(ERROR) << "getdents returned an error: " << errno; -#endif return false; } size_ = r; @@ -99,9 +91,6 @@ class DirReaderBSD { private: const int fd_; char buf_[512]; -#ifdef OS_OPENBSD - off_t *basep_; -#endif size_t offset_, size_; DISALLOW_COPY_AND_ASSIGN(DirReaderBSD); diff --git a/ipc/testshell/TestShellParent.h b/ipc/testshell/TestShellParent.h index 77d66284ba2..2fad6f731b3 100644 --- a/ipc/testshell/TestShellParent.h +++ b/ipc/testshell/TestShellParent.h @@ -11,12 +11,10 @@ #include "mozilla/ipc/PTestShellParent.h" #include "mozilla/ipc/PTestShellCommandParent.h" +#include "js/TypeDecls.h" #include "nsAutoJSValHolder.h" #include "nsStringGlue.h" -struct JSContext; -class JSObject; - namespace mozilla { namespace ipc { diff --git a/ipc/testshell/XPCShellEnvironment.h b/ipc/testshell/XPCShellEnvironment.h index 8c4aaf73d14..3abe42d72a8 100644 --- a/ipc/testshell/XPCShellEnvironment.h +++ b/ipc/testshell/XPCShellEnvironment.h @@ -16,9 +16,8 @@ #include "nsStringGlue.h" #include "nsJSPrincipals.h" #include "nsContentUtils.h" +#include "js/TypeDecls.h" -struct JSContext; -class JSObject; struct JSPrincipals; namespace mozilla { diff --git a/js/public/Anchor.h b/js/public/Anchor.h index 0d458e6fb6c..c2324fb2e91 100644 --- a/js/public/Anchor.h +++ b/js/public/Anchor.h @@ -11,12 +11,7 @@ #include "mozilla/Attributes.h" -class JSFunction; -class JSObject; -class JSScript; -class JSString; - -namespace JS { class Value; } +#include "js/TypeDecls.h" namespace JS { diff --git a/js/public/CallArgs.h b/js/public/CallArgs.h index 31557905633..ad5c9b6d2de 100644 --- a/js/public/CallArgs.h +++ b/js/public/CallArgs.h @@ -38,9 +38,6 @@ #include "js/RootingAPI.h" #include "js/Value.h" -struct JSContext; -class JSObject; - /* Typedef for native functions called by the JS VM. */ typedef bool (* JSNative)(JSContext *cx, unsigned argc, JS::Value *vp); diff --git a/js/public/Class.h b/js/public/Class.h index e17a46c9ec4..08f72b0a3f8 100644 --- a/js/public/Class.h +++ b/js/public/Class.h @@ -9,11 +9,11 @@ #ifndef js_Class_h #define js_Class_h -#include "jspubtd.h" #include "jstypes.h" #include "js/CallArgs.h" #include "js/Id.h" +#include "js/TypeDecls.h" /* * A JSClass acts as a vtable for JS objects that allows JSAPI clients to @@ -24,18 +24,6 @@ class JSFreeOp; -namespace JS { -template class Handle; -template class MutableHandle; -class Value; - -typedef JS::Handle HandleObject; -typedef JS::Handle HandleId; -typedef JS::Handle HandleValue; -typedef JS::MutableHandle MutableHandleObject; -typedef JS::MutableHandle MutableHandleValue; -} - namespace js { class Class; diff --git a/js/public/Id.h b/js/public/Id.h index 0ba3e1c5b76..b4bacbf0aa7 100644 --- a/js/public/Id.h +++ b/js/public/Id.h @@ -7,14 +7,24 @@ #ifndef js_Id_h #define js_Id_h +// A jsid is an identifier for a property or method of an object which is +// either a 31-bit signed integer, interned string or object. +// +// Also, there is an additional jsid value, JSID_VOID, which does not occur in +// JS scripts but may be used to indicate the absence of a valid jsid. A void +// jsid is not a valid id and only arises as an exceptional API return value, +// such as in JS_NextProperty. Embeddings must not pass JSID_VOID into JSAPI +// entry points expecting a jsid and do not need to handle JSID_VOID in hooks +// receiving a jsid except when explicitly noted in the API contract. +// +// A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or +// JS_IdToValue must be used instead. + #include "jstypes.h" -#include "js/IdForward.h" +#include "js/TypeDecls.h" #include "js/Utility.h" -class JSObject; -class JSString; - #ifdef JS_USE_JSID_STRUCT_TYPES struct jsid { diff --git a/js/public/IdForward.h b/js/public/IdForward.h deleted file mode 100644 index f300406c9b5..00000000000 --- a/js/public/IdForward.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_IdForward_h -#define js_IdForward_h - -#include - -// A jsid is an identifier for a property or method of an object which is -// either a 31-bit signed integer, interned string or object. -// -// Also, there is an additional jsid value, JSID_VOID, which does not occur in -// JS scripts but may be used to indicate the absence of a valid jsid. A void -// jsid is not a valid id and only arises as an exceptional API return value, -// such as in JS_NextProperty. Embeddings must not pass JSID_VOID into JSAPI -// entry points expecting a jsid and do not need to handle JSID_VOID in hooks -// receiving a jsid except when explicitly noted in the API contract. -// -// A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or -// JS_IdToValue must be used instead. -// -// In release builds, jsid is defined to be an integral type. This -// prevents many bugs from being caught at compile time. E.g.: -// -// jsid id = ... -// if (id) // error -// ... -// -// size_t n = id; // error -// -// To catch more errors, jsid is given a struct type in C++ debug builds. -// Struct assignment and (in C++) operator== allow correct code to be mostly -// oblivious to the change. This feature can be explicitly disabled in debug -// builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES. -// -// Note: if jsid was always a struct, we could just forward declare it in -// places where its declaration is needed. But the fact that it's a typedef in -// non-debug builds prevents that. So we have this file, which is morally -// equivalent to a forward declaration, and should be included by any file that -// uses jsid but doesn't need its definition. - -#if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES) -# define JS_USE_JSID_STRUCT_TYPES -#endif - -#ifdef JS_USE_JSID_STRUCT_TYPES -struct jsid; -#else -typedef ptrdiff_t jsid; -#endif - -#endif /* js_IdForward_h */ diff --git a/js/public/OldDebugAPI.h b/js/public/OldDebugAPI.h index 0835274ef5a..91142819407 100644 --- a/js/public/OldDebugAPI.h +++ b/js/public/OldDebugAPI.h @@ -14,7 +14,7 @@ #include "jsbytecode.h" #include "js/CallArgs.h" -#include "js/IdForward.h" +#include "js/TypeDecls.h" class JSAtom; class JSFreeOp; diff --git a/js/public/ProfilingStack.h b/js/public/ProfilingStack.h index 36af5969034..49b0ce995cc 100644 --- a/js/public/ProfilingStack.h +++ b/js/public/ProfilingStack.h @@ -13,7 +13,6 @@ #include "js/Utility.h" struct JSRuntime; -class JSScript; namespace js { diff --git a/js/public/PropertyKey.h b/js/public/PropertyKey.h index 24640e143a1..1f90653b402 100644 --- a/js/public/PropertyKey.h +++ b/js/public/PropertyKey.h @@ -9,10 +9,9 @@ #ifndef js_PropertyKey_h #define js_PropertyKey_h +#include "js/TypeDecls.h" #include "js/Value.h" -struct JSContext; - namespace JS { class PropertyKey; diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index 31948d28e3b..82d4961ab69 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -12,7 +12,7 @@ #include "jspubtd.h" -#include "js/IdForward.h" +#include "js/TypeDecls.h" #include "js/Utility.h" /* @@ -98,7 +98,6 @@ namespace js { -class Module; class ScriptSourceObject; template @@ -144,9 +143,6 @@ namespace JS { template class Rooted; -template class Handle; -template class MutableHandle; - /* This is exposing internal state of the GC for inlining purposes. */ JS_FRIEND_API(bool) isGCEnabled(); @@ -467,15 +463,6 @@ class MOZ_NONHEAP_CLASS Handle : public js::HandleBase void operator=(S v) MOZ_DELETE; }; -typedef Handle HandleObject; -typedef Handle HandleModule; -typedef Handle HandleScriptSource; -typedef Handle HandleFunction; -typedef Handle HandleScript; -typedef Handle HandleString; -typedef Handle HandleId; -typedef Handle HandleValue; - /* * Similar to a handle, but the underlying storage can be changed. This is * useful for outparams. @@ -527,13 +514,6 @@ class MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase void operator=(MutableHandle other) MOZ_DELETE; }; -typedef MutableHandle MutableHandleObject; -typedef MutableHandle MutableHandleFunction; -typedef MutableHandle MutableHandleScript; -typedef MutableHandle MutableHandleString; -typedef MutableHandle MutableHandleId; -typedef MutableHandle MutableHandleValue; - #ifdef JSGC_GENERATIONAL JS_PUBLIC_API(void) HeapCellPostBarrier(js::gc::Cell **cellp); JS_PUBLIC_API(void) HeapCellRelocate(js::gc::Cell **cellp); @@ -803,8 +783,6 @@ class Rooted; #endif typedef Rooted RootedObject; -typedef Rooted RootedModule; -typedef Rooted RootedScriptSource; typedef Rooted RootedFunction; typedef Rooted RootedScript; typedef Rooted RootedString; diff --git a/js/public/StructuredClone.h b/js/public/StructuredClone.h index 22084596e73..fa7d91d53c1 100644 --- a/js/public/StructuredClone.h +++ b/js/public/StructuredClone.h @@ -11,17 +11,12 @@ #include "jstypes.h" -struct JSContext; -class JSObject; +#include "js/TypeDecls.h" + struct JSRuntime; struct JSStructuredCloneReader; struct JSStructuredCloneWriter; -namespace JS { -template class Handle; -class Value; -} - // API for the HTML5 internal structured cloning algorithm. // Read structured data from the reader r. This hook is used to read a value diff --git a/js/public/TypeDecls.h b/js/public/TypeDecls.h new file mode 100644 index 00000000000..7274be8bc78 --- /dev/null +++ b/js/public/TypeDecls.h @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sts=4 et sw=4 tw=99: + * 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/. */ + +// This file contains public type declarations that are used *frequently*. If +// it doesn't occur at least 10 times in Gecko, it probably shouldn't be in +// here. +// +// It includes only: +// - forward declarations of structs and classes; +// - typedefs; +// - enums (maybe). +// It does *not* contain any struct or class definitions. + +#ifndef js_TypeDecls_h +#define js_TypeDecls_h + +#include +#include + +struct JSContext; +class JSFunction; +class JSObject; +class JSScript; +class JSString; + +// In release builds, jsid is defined to be an integral type. This +// prevents many bugs from being caught at compile time. E.g.: +// +// jsid id = ... +// if (id) // error +// ... +// +// size_t n = id; // error +// +// To catch more errors, jsid is given a struct type in C++ debug builds. +// Struct assignment and (in C++) operator== allow correct code to be mostly +// oblivious to the change. This feature can be explicitly disabled in debug +// builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES. +// +#if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES) +# define JS_USE_JSID_STRUCT_TYPES +#endif + +#ifdef JS_USE_JSID_STRUCT_TYPES +struct jsid; +#else +typedef ptrdiff_t jsid; +#endif + +#ifdef WIN32 +typedef wchar_t jschar; +#else +typedef uint16_t jschar; +#endif + +namespace JS { + +class Value; +template class Handle; +template class MutableHandle; + +typedef Handle HandleFunction; +typedef Handle HandleId; +typedef Handle HandleObject; +typedef Handle HandleScript; +typedef Handle HandleString; +typedef Handle HandleValue; + +typedef MutableHandle MutableHandleFunction; +typedef MutableHandle MutableHandleId; +typedef MutableHandle MutableHandleObject; +typedef MutableHandle MutableHandleScript; +typedef MutableHandle MutableHandleString; +typedef MutableHandle MutableHandleValue; + +} // namespace JS + +#endif /* js_TypeDecls_h */ diff --git a/js/src/TraceLogging.h b/js/src/TraceLogging.h index 6b79fcff1bb..64ae5a8df23 100644 --- a/js/src/TraceLogging.h +++ b/js/src/TraceLogging.h @@ -10,8 +10,6 @@ #include #include -class JSScript; - namespace JS { class CompileOptions; } diff --git a/js/src/builtin/Intl.h b/js/src/builtin/Intl.h index 68c6e67913f..149fd666082 100644 --- a/js/src/builtin/Intl.h +++ b/js/src/builtin/Intl.h @@ -11,9 +11,6 @@ #include "js/RootingAPI.h" -struct JSContext; -class JSObject; - /* * The Intl module specified by standard ECMA-402, * ECMAScript Internationalization API Specification. @@ -26,7 +23,6 @@ class JSObject; extern JSObject * js_InitIntlClass(JSContext *cx, js::HandleObject obj); - namespace js { /* diff --git a/js/src/builtin/Module.cpp b/js/src/builtin/Module.cpp index 561deec8525..157440e60ce 100644 --- a/js/src/builtin/Module.cpp +++ b/js/src/builtin/Module.cpp @@ -10,6 +10,10 @@ using namespace js; +namespace js { +typedef Rooted RootedModule; +} + Class Module::class_ = { "Module", JSCLASS_HAS_RESERVED_SLOTS(2) | JSCLASS_IS_ANONYMOUS, diff --git a/js/src/ds/LifoAlloc.cpp b/js/src/ds/LifoAlloc.cpp index 5a759cef1db..2a785019d1f 100644 --- a/js/src/ds/LifoAlloc.cpp +++ b/js/src/ds/LifoAlloc.cpp @@ -124,14 +124,16 @@ void LifoAlloc::transferFrom(LifoAlloc *other) { JS_ASSERT(!markCount); - JS_ASSERT(latest == first); JS_ASSERT(!other->markCount); if (!other->first) return; incrementCurSize(other->curSize_); - append(other->first, other->last); + if (other->isEmpty()) + appendUnused(other->first, other->last); + else + appendUsed(other->first, other->latest, other->last); other->first = other->last = other->latest = NULL; other->curSize_ = 0; } @@ -161,7 +163,7 @@ LifoAlloc::transferUnusedFrom(LifoAlloc *other) } } - append(other->latest->next(), other->last); + appendUnused(other->latest->next(), other->last); other->latest->setNext(NULL); other->last = other->latest; } diff --git a/js/src/ds/LifoAlloc.h b/js/src/ds/LifoAlloc.h index d8da17e85a3..48e3a16a80c 100644 --- a/js/src/ds/LifoAlloc.h +++ b/js/src/ds/LifoAlloc.h @@ -187,7 +187,8 @@ class LifoAlloc curSize_ = 0; } - void append(BumpChunk *start, BumpChunk *end) { + // Append unused chunks to the end of this LifoAlloc. + void appendUnused(BumpChunk *start, BumpChunk *end) { JS_ASSERT(start && end); if (last) last->setNext(start); @@ -196,6 +197,18 @@ class LifoAlloc last = end; } + // Append used chunks to the end of this LifoAlloc. We act as if all the + // chunks in |this| are used, even if they're not, so memory may be wasted. + void appendUsed(BumpChunk *start, BumpChunk *latest, BumpChunk *end) { + JS_ASSERT(start && latest && end); + if (last) + last->setNext(start); + else + first = latest = start; + last = end; + this->latest = latest; + } + void incrementCurSize(size_t size) { curSize_ += size; if (curSize_ > peakSize_) diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index a60046bc183..f6767646ba9 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -188,7 +188,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco if (options.filename && !ss->setFilename(cx, options.filename)) return NULL; - JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss)); + RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss)); if (!sourceObject) return NULL; @@ -416,7 +416,7 @@ frontend::CompileLazyFunction(JSContext *cx, LazyScript *lazy, const jschar *cha return false; RootedObject enclosingScope(cx, lazy->enclosingScope()); - JS::RootedScriptSource sourceObject(cx, lazy->sourceObject()); + RootedScriptSource sourceObject(cx, lazy->sourceObject()); JS_ASSERT(sourceObject); Rooted script(cx, JSScript::Create(cx, enclosingScope, false, @@ -468,7 +468,7 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileOptions opt return false; if (options.filename && !ss->setFilename(cx, options.filename)) return false; - JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss)); + RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss)); if (!sourceObject) return false; SourceCompressionTask sct(cx); diff --git a/js/src/frontend/NameFunctions.h b/js/src/frontend/NameFunctions.h index bfefd4cf27c..c6845c4cbfa 100644 --- a/js/src/frontend/NameFunctions.h +++ b/js/src/frontend/NameFunctions.h @@ -7,7 +7,7 @@ #ifndef frontend_NameFunctions_h #define frontend_NameFunctions_h -struct JSContext; +#include "js/TypeDecls.h" namespace js { namespace frontend { diff --git a/js/src/gc/Marking.h b/js/src/gc/Marking.h index 51835dbe7ab..c8f190e180f 100644 --- a/js/src/gc/Marking.h +++ b/js/src/gc/Marking.h @@ -9,13 +9,7 @@ #include "gc/Barrier.h" #include "jit/IonCode.h" - -extern "C" { -struct JSContext; -class JSFunction; -class JSObject; -class JSScript; -} +#include "js/TypeDecls.h" class JSAtom; class JSLinearString; diff --git a/js/src/gc/Rooting.h b/js/src/gc/Rooting.h index 6c45e82b9a4..bf94a6591cf 100644 --- a/js/src/gc/Rooting.h +++ b/js/src/gc/Rooting.h @@ -24,6 +24,7 @@ typedef JS::Handle HandleShape; typedef JS::Handle HandleTypeObject; typedef JS::Handle HandleAtom; typedef JS::Handle HandlePropertyName; +typedef JS::Handle HandleScriptSource; typedef JS::MutableHandle MutableHandleShape; typedef JS::MutableHandle MutableHandleAtom; @@ -32,6 +33,7 @@ typedef JS::Rooted RootedShape; typedef JS::Rooted RootedTypeObject; typedef JS::Rooted RootedAtom; typedef JS::Rooted RootedPropertyName; +typedef Rooted RootedScriptSource; } /* namespace js */ diff --git a/js/src/jit/IonCaches.h b/js/src/jit/IonCaches.h index 09462808ab7..885f7fc0214 100644 --- a/js/src/jit/IonCaches.h +++ b/js/src/jit/IonCaches.h @@ -14,9 +14,6 @@ #include "jit/Registers.h" #include "jit/shared/Assembler-shared.h" -class JSFunction; -class JSScript; - namespace js { class LockedJSContext; diff --git a/js/src/jit/IonCode.h b/js/src/jit/IonCode.h index c3d8d19b56b..8c7d3efca5c 100644 --- a/js/src/jit/IonCode.h +++ b/js/src/jit/IonCode.h @@ -19,8 +19,6 @@ namespace JSC { class ExecutablePool; } -class JSScript; - namespace js { class AsmJSModule; diff --git a/js/src/jit/IonFrames.h b/js/src/jit/IonFrames.h index 87d3417cdd2..c0be812a7ff 100644 --- a/js/src/jit/IonFrames.h +++ b/js/src/jit/IonFrames.h @@ -20,9 +20,6 @@ #include "jit/IonFrameIterator.h" #include "jit/Registers.h" -class JSFunction; -class JSScript; - namespace js { namespace jit { diff --git a/js/src/jit/JSONSpewer.h b/js/src/jit/JSONSpewer.h index fa00562fab4..486bf7945c7 100644 --- a/js/src/jit/JSONSpewer.h +++ b/js/src/jit/JSONSpewer.h @@ -9,7 +9,7 @@ #include -class JSScript; +#include "js/TypeDecls.h" namespace js { namespace jit { diff --git a/js/src/jit/PerfSpewer.h b/js/src/jit/PerfSpewer.h index e5a9845ef39..aa747a02904 100644 --- a/js/src/jit/PerfSpewer.h +++ b/js/src/jit/PerfSpewer.h @@ -11,8 +11,6 @@ #include "jit/IonMacroAssembler.h" -class JSScript; - namespace js { namespace jit { diff --git a/js/src/jsalloc.h b/js/src/jsalloc.h index 17c6c52253f..451ee3e745e 100644 --- a/js/src/jsalloc.h +++ b/js/src/jsalloc.h @@ -9,10 +9,9 @@ #ifndef jsalloc_h #define jsalloc_h +#include "js/TypeDecls.h" #include "js/Utility.h" -struct JSContext; - namespace js { class ContextFriendFields; diff --git a/js/src/jsanalyze.h b/js/src/jsanalyze.h index de1c78650e8..5e127e5fa26 100644 --- a/js/src/jsanalyze.h +++ b/js/src/jsanalyze.h @@ -11,8 +11,6 @@ #include "jscompartment.h" -class JSScript; - namespace js { namespace analyze { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 1206314a769..7e805fcca88 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -4637,7 +4637,6 @@ using JS::CallNonGenericMethod; using JS::Rooted; using JS::RootedObject; -using JS::RootedModule; using JS::RootedFunction; using JS::RootedScript; using JS::RootedString; @@ -4646,7 +4645,6 @@ using JS::RootedValue; using JS::Handle; using JS::HandleObject; -using JS::HandleModule; using JS::HandleFunction; using JS::HandleScript; using JS::HandleString; diff --git a/js/src/jsdate.h b/js/src/jsdate.h index 819869db295..028e64794e4 100644 --- a/js/src/jsdate.h +++ b/js/src/jsdate.h @@ -14,15 +14,7 @@ #include "jstypes.h" #include "js/RootingAPI.h" - -extern "C" { -class JSObject; -struct JSContext; -} - -namespace JS { -class Value; -} +#include "js/TypeDecls.h" extern JSObject * js_InitDateClass(JSContext *cx, JS::HandleObject obj); diff --git a/js/src/jsgc.h b/js/src/jsgc.h index ca977a80220..08c32263e77 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -21,7 +21,6 @@ class JSAtom; struct JSCompartment; -class JSFunction; class JSFlatString; class JSLinearString; diff --git a/js/src/jsinfer.h b/js/src/jsinfer.h index fd84125d409..884e2d38c04 100644 --- a/js/src/jsinfer.h +++ b/js/src/jsinfer.h @@ -18,8 +18,6 @@ #include "gc/Barrier.h" #include "js/Utility.h" -class JSScript; - namespace js { class TypeRepresentation; diff --git a/js/src/jsnum.h b/js/src/jsnum.h index 693770471c0..20fabea50d1 100644 --- a/js/src/jsnum.h +++ b/js/src/jsnum.h @@ -42,8 +42,6 @@ extern const char js_isFinite_str[]; extern const char js_parseFloat_str[]; extern const char js_parseInt_str[]; -class JSString; - /* * When base == 10, this function implements ToString() as specified by * ECMA-262-5 section 9.8.1; but note that it handles integers specially for diff --git a/js/src/jspubtd.h b/js/src/jspubtd.h index fba410c24b3..1d5d7277d08 100644 --- a/js/src/jspubtd.h +++ b/js/src/jspubtd.h @@ -15,9 +15,8 @@ #include "jsprototypes.h" #include "jstypes.h" -#include "jsversion.h" // #include here so it's seen everywhere -#include "js/IdForward.h" +#include "js/TypeDecls.h" #if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) || defined(DEBUG) # define JSGC_TRACK_EXACT_ROOTS @@ -25,12 +24,6 @@ namespace JS { -/* - * Allow headers to reference JS::Value without #including the whole jsapi.h. - * Unfortunately, typedefs (hence jsval) cannot be declared. - */ -class Value; - class AutoIdVector; class CallArgs; @@ -46,12 +39,6 @@ struct Zone; } /* namespace JS */ -#ifdef WIN32 -typedef wchar_t jschar; -#else -typedef uint16_t jschar; -#endif - /* * Run-time version enumeration. For compile-time version checking, please use * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION, @@ -150,7 +137,6 @@ typedef enum { typedef struct JSClass JSClass; typedef struct JSCompartment JSCompartment; typedef struct JSConstDoubleSpec JSConstDoubleSpec; -typedef struct JSContext JSContext; typedef struct JSCrossCompartmentCall JSCrossCompartmentCall; typedef struct JSErrorReport JSErrorReport; typedef struct JSExceptionState JSExceptionState; @@ -170,11 +156,7 @@ typedef struct JSStructuredCloneWriter JSStructuredCloneWriter; typedef struct JSTracer JSTracer; class JSFlatString; -class JSFunction; -class JSObject; -class JSScript; class JSStableString; // long story -class JSString; #ifdef JS_THREADSAFE typedef struct PRCallOnceType JSCallOnceType; diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 04a612ac6fb..7ebffce2cde 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -546,7 +546,7 @@ js::XDRScript(XDRState *xdr, HandleObject enclosingScope, HandleScript enc options.setVersion(version_) .setNoScriptRval(!!(scriptBits & (1 << NoScriptRval))) .setSelfHostingMode(!!(scriptBits & (1 << SelfHosted))); - JS::RootedScriptSource sourceObject(cx); + RootedScriptSource sourceObject(cx); if (scriptBits & (1 << OwnSource)) { ScriptSource *ss = cx->new_(xdr->originPrincipals()); if (!ss) @@ -962,7 +962,7 @@ ScriptSourceObject::create(ExclusiveContext *cx, ScriptSource *source) RootedObject object(cx, NewObjectWithGivenProto(cx, &class_, NULL, cx->global())); if (!object) return NULL; - JS::RootedScriptSource sourceObject(cx, &object->as()); + RootedScriptSource sourceObject(cx, &object->as()); sourceObject->setSlot(SOURCE_SLOT, PrivateValue(source)); source->incref(); return sourceObject; @@ -1610,7 +1610,7 @@ JSScript::initCompartment(ExclusiveContext *cx) JSScript * JSScript::Create(ExclusiveContext *cx, HandleObject enclosingScope, bool savedCallerFun, const CompileOptions &options, unsigned staticLevel, - JS::HandleScriptSource sourceObject, uint32_t bufStart, uint32_t bufEnd) + HandleScriptSource sourceObject, uint32_t bufStart, uint32_t bufEnd) { JS_ASSERT(bufStart <= bufEnd); @@ -2291,7 +2291,7 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun, .setVersion(src->getVersion()); /* Make sure we clone the script source object with the script */ - JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, src->scriptSource())); + RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, src->scriptSource())); if (!sourceObject) return NULL; diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 5ec61a9ae55..eb3d5d55533 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -20,6 +20,7 @@ #include "jsopcode.h" #include "gc/Barrier.h" +#include "gc/Rooting.h" #include "vm/Shape.h" namespace js { @@ -630,7 +631,7 @@ class JSScript : public js::gc::Cell static JSScript *Create(js::ExclusiveContext *cx, js::HandleObject enclosingScope, bool savedCallerFun, const JS::CompileOptions &options, unsigned staticLevel, - JS::HandleScriptSource sourceObject, uint32_t sourceStart, + js::HandleScriptSource sourceObject, uint32_t sourceStart, uint32_t sourceEnd); void initCompartment(js::ExclusiveContext *cx); diff --git a/js/src/jsutil.h b/js/src/jsutil.h index 6f14f8b5f4c..77e867da764 100644 --- a/js/src/jsutil.h +++ b/js/src/jsutil.h @@ -20,9 +20,6 @@ #include "js/Utility.h" -/* Forward declarations. */ -struct JSContext; - static JS_ALWAYS_INLINE void * js_memcpy(void *dst_, const void *src_, size_t len) { diff --git a/js/src/moz.build b/js/src/moz.build index 0652198c5d9..850f778eb49 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -68,7 +68,6 @@ EXPORTS.js += [ '../public/HashTable.h', '../public/HeapAPI.h', '../public/Id.h', - '../public/IdForward.h', '../public/LegacyIntTypes.h', '../public/MemoryMetrics.h', '../public/OldDebugAPI.h', @@ -77,6 +76,7 @@ EXPORTS.js += [ '../public/RequiredDefines.h', '../public/RootingAPI.h', '../public/StructuredClone.h', + '../public/TypeDecls.h', '../public/Utility.h', '../public/Value.h', '../public/Vector.h', diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index bef3bcf9fa6..cd28205957c 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -2859,7 +2859,7 @@ DebuggerScript_getSource(JSContext *cx, unsigned argc, Value *vp) THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "(get source)", args, obj, script); Debugger *dbg = Debugger::fromChildJSObject(obj); - JS::RootedScriptSource source(cx, script->sourceObject()); + RootedScriptSource source(cx, script->sourceObject()); RootedObject sourceObject(cx, dbg->wrapSource(cx, source)); if (!sourceObject) return false; @@ -3624,7 +3624,7 @@ Class DebuggerSource_class = { }; JSObject * -Debugger::newDebuggerSource(JSContext *cx, JS::HandleScriptSource source) +Debugger::newDebuggerSource(JSContext *cx, HandleScriptSource source) { assertSameCompartment(cx, object.get()); @@ -3640,7 +3640,7 @@ Debugger::newDebuggerSource(JSContext *cx, JS::HandleScriptSource source) } JSObject * -Debugger::wrapSource(JSContext *cx, JS::HandleScriptSource source) +Debugger::wrapSource(JSContext *cx, HandleScriptSource source) { assertSameCompartment(cx, object.get()); JS_ASSERT(cx->compartment() != source->compartment()); @@ -3704,7 +3704,7 @@ DebuggerSource_checkThis(JSContext *cx, const CallArgs &args, const char *fnname RootedObject obj(cx, DebuggerSource_checkThis(cx, args, fnname)); \ if (!obj) \ return false; \ - JS::RootedScriptSource sourceObject(cx, GetSourceReferent(obj)); \ + RootedScriptSource sourceObject(cx, GetSourceReferent(obj)); \ if (!sourceObject) \ return false; diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h index 4e36ddfd72f..4c9c1abb691 100644 --- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -365,7 +365,7 @@ class Debugger : private mozilla::LinkedListElement * Allocate and initialize a Debugger.Source instance whose referent is * |source|. */ - JSObject *newDebuggerSource(JSContext *cx, JS::HandleScriptSource source); + JSObject *newDebuggerSource(JSContext *cx, js::HandleScriptSource source); /* * Receive a "new script" event from the engine. A new script was compiled @@ -528,7 +528,7 @@ class Debugger : private mozilla::LinkedListElement * needed. The context |cx| must be in the debugger compartment; |source| * must be a script source object in a debuggee compartment. */ - JSObject *wrapSource(JSContext *cx, JS::HandleScriptSource source); + JSObject *wrapSource(JSContext *cx, js::HandleScriptSource source); private: Debugger(const Debugger &) MOZ_DELETE; diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 9e9ec9f1132..a15c64b21ca 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -232,7 +232,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx) js_free(source); return NULL; } - JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss)); + RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss)); if (!sourceObject) return NULL; ss->setSource(source, sourceLen); diff --git a/js/src/vm/SPSProfiler.h b/js/src/vm/SPSProfiler.h index 224cd558da3..37322e6c873 100644 --- a/js/src/vm/SPSProfiler.h +++ b/js/src/vm/SPSProfiler.h @@ -103,8 +103,6 @@ * from a signal handler when the JIT code is executing. */ -class JSFunction; - namespace js { class ProfileEntry; diff --git a/js/src/vm/Shape.h b/js/src/vm/Shape.h index a23e0ee8d83..6a1564fe1fa 100644 --- a/js/src/vm/Shape.h +++ b/js/src/vm/Shape.h @@ -93,8 +93,6 @@ * a single BaseShape. */ -class JSObject; - namespace js { class Bindings; diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index 0dd6c530b11..59ea0b47824 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -18,7 +18,6 @@ #endif #include "js/OldDebugAPI.h" -struct JSContext; struct JSCompartment; struct JSGenerator; diff --git a/js/src/vm/String.h b/js/src/vm/String.h index 1ad659ffd0f..83dbd7ca029 100644 --- a/js/src/vm/String.h +++ b/js/src/vm/String.h @@ -25,7 +25,6 @@ class JSExtensibleString; class JSExternalString; class JSInlineString; class JSStableString; -class JSString; class JSRope; namespace js { diff --git a/js/src/vm/ThreadPool.h b/js/src/vm/ThreadPool.h index 66f34e034da..8af87545f04 100644 --- a/js/src/vm/ThreadPool.h +++ b/js/src/vm/ThreadPool.h @@ -20,10 +20,8 @@ #include "js/Vector.h" -struct JSContext; struct JSRuntime; struct JSCompartment; -class JSScript; namespace js { diff --git a/js/xpconnect/idl/nsIXPConnect.idl b/js/xpconnect/idl/nsIXPConnect.idl index aef0342600a..85dd06151f3 100644 --- a/js/xpconnect/idl/nsIXPConnect.idl +++ b/js/xpconnect/idl/nsIXPConnect.idl @@ -20,16 +20,12 @@ %{ C++ #include "jspubtd.h" +#include "js/TypeDecls.h" #include "xptinfo.h" #include "nsAXPCNativeCallContext.h" struct JSFreeOp; -namespace JS { -template class Handle; -template class MutableHandle; -} - class nsWrapperCache; %} diff --git a/js/xpconnect/idl/xpcIJSModuleLoader.idl b/js/xpconnect/idl/xpcIJSModuleLoader.idl index 9d7f2ebeea3..02d820b4e36 100644 --- a/js/xpconnect/idl/xpcIJSModuleLoader.idl +++ b/js/xpconnect/idl/xpcIJSModuleLoader.idl @@ -8,7 +8,7 @@ [ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext); %{C++ -class JSObject; +#include "js/TypeDecls.h" %} [ptr] native JSObjectPtr(JSObject); diff --git a/js/xpconnect/idl/xpcexception.idl b/js/xpconnect/idl/xpcexception.idl index 4806f18d39e..6c31e424b83 100644 --- a/js/xpconnect/idl/xpcexception.idl +++ b/js/xpconnect/idl/xpcexception.idl @@ -8,10 +8,7 @@ #include "nsIException.idl" %{ C++ -struct JSContext; -namespace JS { -class Value; -} +#include "js/TypeDecls.h" %} [ptr] native xpcexJSContextPtr(JSContext); diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 3c3b6d8a679..98be9767240 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -16,6 +16,7 @@ #include "nsRect.h" #include "nsDeviceContext.h" #include "nsFont.h" +#include "gfxFontConstants.h" #include "nsIAtom.h" #include "nsIObserver.h" #include "nsITimer.h" diff --git a/netwerk/base/src/ProxyAutoConfig.h b/netwerk/base/src/ProxyAutoConfig.h index 92e0c66099d..2e322c73358 100644 --- a/netwerk/base/src/ProxyAutoConfig.h +++ b/netwerk/base/src/ProxyAutoConfig.h @@ -12,10 +12,7 @@ #include "nsITimer.h" #include "nsAutoPtr.h" #include "mozilla/net/DNS.h" - -namespace JS { -class Value; -} +#include "js/TypeDecls.h" namespace mozilla { namespace net { diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py index 6acf2a589a3..40399cb33fb 100644 --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -164,11 +164,12 @@ class MozbuildObject(ProcessExecutionMixin): # not another one. This prevents accidental usage of the wrong objdir # when the current objdir is ambiguous. if topobjdir and config_topobjdir \ - and not samepath(topobjdir, config_topobjdir): + and not samepath(topobjdir, config_topobjdir) \ + and not samepath(topobjdir, os.path.join(config_topobjdir, "mozilla")): raise ObjdirMismatchException(topobjdir, config_topobjdir) - topobjdir = config_topobjdir or topobjdir + topobjdir = topobjdir or config_topobjdir if topobjdir: topobjdir = os.path.normpath(topobjdir) diff --git a/storage/src/mozStoragePrivateHelpers.h b/storage/src/mozStoragePrivateHelpers.h index a82a5c4d8f4..2f8253b4c0d 100644 --- a/storage/src/mozStoragePrivateHelpers.h +++ b/storage/src/mozStoragePrivateHelpers.h @@ -15,16 +15,13 @@ #include "nsIVariant.h" #include "nsError.h" #include "nsAutoPtr.h" +#include "js/TypeDecls.h" class mozIStorageCompletionCallback; class mozIStorageBaseStatement; class mozIStorageBindingParams; class nsIRunnable; -namespace JS { -class Value; -} - namespace mozilla { namespace storage { diff --git a/tools/profiler/GeckoProfiler.h b/tools/profiler/GeckoProfiler.h index 9dbc43253d0..8cc8594621f 100644 --- a/tools/profiler/GeckoProfiler.h +++ b/tools/profiler/GeckoProfiler.h @@ -50,6 +50,7 @@ #define SAMPLER_H #include "mozilla/NullPtr.h" +#include "js/TypeDecls.h" namespace mozilla { class TimeStamp; @@ -59,9 +60,6 @@ class TimeStamp; #include -struct JSContext; -class JSObject; - // Insert a RAII in this scope to active a pseudo label. Any samples collected // in this scope will contain this annotation. For dynamic strings use // PROFILER_LABEL_PRINTF. Arguments must be string literals. diff --git a/tools/profiler/GeckoProfilerFunc.h b/tools/profiler/GeckoProfilerFunc.h index 56e1410cfeb..d145169db18 100644 --- a/tools/profiler/GeckoProfilerFunc.h +++ b/tools/profiler/GeckoProfilerFunc.h @@ -7,6 +7,7 @@ #define PROFILER_FUNCS_H #include "mozilla/NullPtr.h" +#include "js/TypeDecls.h" #include namespace mozilla { @@ -17,9 +18,6 @@ class TimeStamp; using mozilla::TimeStamp; using mozilla::TimeDuration; -struct JSContext; -class JSObject; - // Returns a handle to pass on exit. This can check that we are popping the // correct callstack. inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress = NULL, diff --git a/tools/profiler/JSObjectBuilder.h b/tools/profiler/JSObjectBuilder.h index 3f597d742c7..6be8da1a98d 100644 --- a/tools/profiler/JSObjectBuilder.h +++ b/tools/profiler/JSObjectBuilder.h @@ -7,11 +7,10 @@ #define JSOBJECTBUILDER_H #include "JSAObjectBuilder.h" +#include "js/TypeDecls.h" class JSCustomObject; class JSCustomObjectBuilder; -struct JSContext; -class JSObject; class nsAString; /* this is handy wrapper around JSAPI to make it more pleasant to use. diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 8fb77d115aa..389861765c6 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -37,7 +37,6 @@ using mozilla::unused; #include "gfxContext.h" #include "Layers.h" -#include "BasicLayers.h" #include "LayerManagerOGL.h" #include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/AsyncCompositionManager.h" diff --git a/widget/gtk2/nsWindow.cpp b/widget/gtk2/nsWindow.cpp index 7aef5ad26be..d944c5f0070 100644 --- a/widget/gtk2/nsWindow.cpp +++ b/widget/gtk2/nsWindow.cpp @@ -90,7 +90,6 @@ using namespace mozilla::widget; #include "nsImageToPixbuf.h" #include "nsIInterfaceRequestorUtils.h" #include "nsAutoPtr.h" -#include "BasicLayers.h" #include "ClientLayerManager.h" extern "C" { @@ -6128,8 +6127,7 @@ nsWindow::ClearCachedResources() { if (mLayerManager && mLayerManager->GetBackendType() == mozilla::layers::LAYERS_BASIC) { - static_cast (mLayerManager.get())-> - ClearCachedResources(); + mLayerManager->ClearCachedResources(); } GList* children = gdk_window_peek_children(mGdkWindow); diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index 02d57ea8d77..1791e343abc 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -95,7 +95,6 @@ using namespace QtMobility; #include "gfxUtils.h" #include "Layers.h" #include "GLContextProvider.h" -#include "BasicLayers.h" #include "LayerManagerOGL.h" #include "nsFastStartupQt.h" @@ -441,8 +440,7 @@ nsWindow::ClearCachedResources() { if (mLayerManager && mLayerManager->GetBackendType() == mozilla::layers::LAYERS_BASIC) { - static_cast (mLayerManager.get())-> - ClearCachedResources(); + statimLayerManager->ClearCachedResources(); } for (nsIWidget* kid = mFirstChild; kid; ) { nsIWidget* next = kid->GetNextSibling(); diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 751b95d42c5..8c1bbbbfb2e 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -134,7 +134,6 @@ #include "LayerManagerOGL.h" #include "nsIGfxInfo.h" -#include "BasicLayers.h" #include "nsUXThemeConstants.h" #include "KeyboardLayout.h" #include "nsNativeDragTarget.h" @@ -7176,8 +7175,7 @@ nsWindow::ClearCachedResources() #endif if (mLayerManager && mLayerManager->GetBackendType() == LAYERS_BASIC) { - static_cast(mLayerManager.get())-> - ClearCachedResources(); + mLayerManager->ClearCachedResources(); } ::EnumChildWindows(mWnd, nsWindow::ClearResourcesCallback, 0); } diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp index 8095475f57e..1c6535bc4c5 100644 --- a/widget/windows/nsWindowGfx.cpp +++ b/widget/windows/nsWindowGfx.cpp @@ -38,7 +38,6 @@ using mozilla::plugins::PluginInstanceParent; #include "mozilla/unused.h" #include "LayerManagerOGL.h" -#include "BasicLayers.h" #ifdef MOZ_ENABLE_D3D9_LAYER #include "LayerManagerD3D9.h" #endif diff --git a/widget/xpwidgets/nsBaseWidget.cpp b/widget/xpwidgets/nsBaseWidget.cpp index ee2d3b6ca82..ccab14b5552 100644 --- a/widget/xpwidgets/nsBaseWidget.cpp +++ b/widget/xpwidgets/nsBaseWidget.cpp @@ -1050,7 +1050,7 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayerTransactionChild* aShadowManag return usedLayerManager; } -BasicLayerManager* nsBaseWidget::CreateBasicLayerManager() +LayerManager* nsBaseWidget::CreateBasicLayerManager() { return new BasicLayerManager(this); } diff --git a/widget/xpwidgets/nsBaseWidget.h b/widget/xpwidgets/nsBaseWidget.h index 292a10cb6c2..354874152e0 100644 --- a/widget/xpwidgets/nsBaseWidget.h +++ b/widget/xpwidgets/nsBaseWidget.h @@ -332,7 +332,7 @@ protected: return widget.forget(); } - BasicLayerManager* CreateBasicLayerManager(); + LayerManager* CreateBasicLayerManager(); nsPopupType PopupType() const { return mPopupType; } diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 590a5738080..783ff202652 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -12,6 +12,7 @@ #include "nsISupports.h" #include "prlog.h" #include "nsXREAppData.h" +#include "js/TypeDecls.h" #include "mozilla/Assertions.h" @@ -426,15 +427,10 @@ XRE_API(void, XRE_API(MessageLoop*, XRE_GetIOMessageLoop, ()) -struct JSContext; -class JSString; - XRE_API(bool, XRE_SendTestShellCommand, (JSContext* aCx, JSString* aCommand, void* aCallback)) -class JSObject; - XRE_API(bool, XRE_ShutdownTestShell, ()) diff --git a/xpcom/ds/nsStaticNameTable.h b/xpcom/ds/nsStaticNameTable.h index 379b7712cb7..6616c770e6b 100644 --- a/xpcom/ds/nsStaticNameTable.h +++ b/xpcom/ds/nsStaticNameTable.h @@ -10,6 +10,8 @@ #define nsStaticNameTable_h___ #include "pldhash.h" +#include "nsString.h" + /* This class supports case insensitive lookup. * * It differs from atom tables: diff --git a/xpfe/appshell/public/nsIAppShellService.idl b/xpfe/appshell/public/nsIAppShellService.idl index c29483c2cc2..7a2fa8c6749 100644 --- a/xpfe/appshell/public/nsIAppShellService.idl +++ b/xpfe/appshell/public/nsIAppShellService.idl @@ -14,7 +14,7 @@ interface nsIAppShell; [ptr] native JSContext(JSContext); %{C++ -struct JSContext; +#include "js/TypeDecls.h" %} [scriptable, uuid(5c19ab54-67bf-46d0-ac5b-21abd9050c3b)]