From 0eb87cd8911ad5e303f687984a7bb3d6467bd3be Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Wed, 11 Sep 2013 13:54:44 -0700 Subject: [PATCH 01/69] Bug 914937: Remove nsFlexContainerFrame::GetSkipSides, now that we can inherit a useful impl from nsSplittableFrame. r=mats --- layout/generic/nsFlexContainerFrame.cpp | 20 -------------------- layout/generic/nsFlexContainerFrame.h | 1 - 2 files changed, 21 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 6139f7e094d8..be1284b6a233 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -1097,26 +1097,6 @@ nsFlexContainerFrame::GetType() const return nsGkAtoms::flexContainerFrame; } -/* virtual */ -int -nsFlexContainerFrame::GetSkipSides(const nsHTMLReflowState* aReflowState) const -{ - // (same as nsBlockFrame's GetSkipSides impl) - if (IS_TRUE_OVERFLOW_CONTAINER(this)) { - return (1 << NS_SIDE_TOP) | (1 << NS_SIDE_BOTTOM); - } - - int skip = 0; - if (GetPrevInFlow()) { - skip |= 1 << NS_SIDE_TOP; - } - nsIFrame* nif = GetNextInFlow(); - if (nif && !IS_TRUE_OVERFLOW_CONTAINER(nif)) { - skip |= 1 << NS_SIDE_BOTTOM; - } - return skip; -} - #ifdef DEBUG NS_IMETHODIMP nsFlexContainerFrame::GetFrameName(nsAString& aResult) const diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h index 2661b740bc1f..aa372f308259 100644 --- a/layout/generic/nsFlexContainerFrame.h +++ b/layout/generic/nsFlexContainerFrame.h @@ -49,7 +49,6 @@ public: GetPrefWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE; virtual nsIAtom* GetType() const MOZ_OVERRIDE; - virtual int GetSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const MOZ_OVERRIDE; #ifdef DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; #endif // DEBUG From 45b0fda320556c4bb443a1da0c5be13de2aab6c5 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Wed, 11 Sep 2013 13:54:45 -0700 Subject: [PATCH 02/69] Bug 915344: Make variables 'SAMPLES' and 'numSamplesReadFromInput' unsigned, to fix build warning in mediaconduit_unittests.cpp. r=jesup --- media/webrtc/signaling/test/mediaconduit_unittests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media/webrtc/signaling/test/mediaconduit_unittests.cpp b/media/webrtc/signaling/test/mediaconduit_unittests.cpp index eaec1423b610..16c46799651a 100644 --- a/media/webrtc/signaling/test/mediaconduit_unittests.cpp +++ b/media/webrtc/signaling/test/mediaconduit_unittests.cpp @@ -270,7 +270,7 @@ void AudioSendAndReceive::GenerateAndReadSamples() int16_t audioOutput[PLAYOUT_SAMPLE_LENGTH]; short* inbuf; int sampleLengthDecoded = 0; - int SAMPLES = (PLAYOUT_SAMPLE_FREQUENCY * 10); //10 seconds + unsigned int SAMPLES = (PLAYOUT_SAMPLE_FREQUENCY * 10); //10 seconds int CHANNELS = 1; //mono audio int sampleLengthInBytes = sizeof(audioInput); //generated audio buffer @@ -299,7 +299,7 @@ void AudioSendAndReceive::GenerateAndReadSamples() fclose(inFile); WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, outFile); - int numSamplesReadFromInput = 0; + unsigned int numSamplesReadFromInput = 0; do { if(!memcpy(audioInput, inbuf, sampleLengthInBytes)) From d0df95db1fd000405c385f242d4c67dce9b786aa Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 11 Sep 2013 14:00:19 -0700 Subject: [PATCH 03/69] Bug 913848: Attempt to fix intermittent test_unix_domain.js timeout with MOAR ASYNC. r=mayhemer This patch makes the tests avoid expecting data from the client to be available to the server immediately upon accepting a connection; instead, the server uses asyncWait to receive those first bytes. This changes both test_echo and test_connect_permission. I've pushed this through the try server twice, and it didn't hang. In either case, it adds a few more do_prints to give me more clues about the source of the problem. --- netwerk/test/unit/test_unix_domain.js | 37 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/netwerk/test/unit/test_unix_domain.js b/netwerk/test/unit/test_unix_domain.js index 230170debfdf..15c34240242b 100644 --- a/netwerk/test/unit/test_unix_domain.js +++ b/netwerk/test/unit/test_unix_domain.js @@ -91,12 +91,19 @@ function test_echo() do_check_eq(connectionPeerAddr.family, Ci.nsINetAddr.FAMILY_LOCAL); do_check_eq(connectionPeerAddr.address, ''); - let serverInput = new ScriptableInputStream(connection.openInputStream(0, 0, 0)); + let serverAsyncInput = connection.openInputStream(0, 0, 0).QueryInterface(Ci.nsIAsyncInputStream); let serverOutput = connection.openOutputStream(0, 0, 0); - // Receive data from the client, and send back a response. - do_check_eq(serverInput.readBytes(17), "Mervyn Murgatroyd"); - serverOutput.write("Ruthven Murgatroyd", 18); + serverAsyncInput.asyncWait(function (aStream) { + do_print("called test_echo's server's onInputStreamReady"); + let serverScriptableInput = new ScriptableInputStream(aStream); + + // Receive data from the client, and send back a response. + do_check_eq(serverScriptableInput.readBytes(17), "Mervyn Murgatroyd"); + do_print("server has read message from client"); + serverOutput.write("Ruthven Murgatroyd", 18); + do_print("server has written to client"); + }, 0, 0, threadManager.currentThread); }, onStopListening: function(aServ, aStatus) { @@ -120,8 +127,10 @@ function test_echo() let clientOutput = client.openOutputStream(0, 0, 0); clientOutput.write("Mervyn Murgatroyd", 17); + do_print("client has written to server"); + clientAsyncInput.asyncWait(function (aStream) { - do_print("called test_echo's onInputStreamReady"); + do_print("called test_echo's client's onInputStreamReady"); log += 'c'; do_check_eq(aStream, clientAsyncInput); @@ -138,6 +147,7 @@ function test_echo() do_check_eq(clientPeerAddr.address, socketName.path); do_check_eq(clientInput.readBytes(18), "Ruthven Murgatroyd"); + do_print("client has read message from server"); server.close(); }, 0, 0, threadManager.currentThread); @@ -359,12 +369,18 @@ function test_connect_permission() do_print("called test_connect_permission's onSocketAccepted"); log += 'a'; - let serverInput = new ScriptableInputStream(aTransport.openInputStream(0, 0, 0)); + let serverInput = aTransport.openInputStream(0, 0, 0).QueryInterface(Ci.nsIAsyncInputStream); let serverOutput = aTransport.openOutputStream(0, 0, 0); - // Receive data from the client, and send back a response. - do_check_eq(serverInput.readBytes(8), "Hanratty"); - serverOutput.write("Ferlingatti", 11); + serverInput.asyncWait(function (aStream) { + do_print("called test_connect_permission's socketAccepted's onInputStreamReady"); + log += 'i'; + + // Receive data from the client, and send back a response. + let serverScriptableInput = new ScriptableInputStream(serverInput); + do_check_eq(serverScriptableInput.readBytes(8), "Hanratty"); + serverOutput.write("Ferlingatti", 11); + }, 0, 0, threadManager.currentThread); } function client3InputStreamReady(aStream) { @@ -375,7 +391,6 @@ function test_connect_permission() do_check_eq(client3Input.readBytes(11), "Ferlingatti"); - aStream.close(); client3.close(Cr.NS_OK); server.close(); } @@ -384,7 +399,7 @@ function test_connect_permission() do_print("called test_connect_permission's server's stopListening"); log += 's'; - do_check_eq(log, '12a3s'); + do_check_eq(log, '12ai3s'); run_next_test(); } From a569ef8c45486fd50e571d1a26c1fd33c0eb693b Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Wed, 11 Sep 2013 14:42:31 +0200 Subject: [PATCH 04/69] Bug 914601 - Remove non-required, crashing-on-oom assert in GlobalObject::getIntrinsicValue. r=terrence --HG-- extra : rebase_source : cb1d3e8f40e0b0264214a1c151adf1e6aeacd622 --- js/src/vm/GlobalObject.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/src/vm/GlobalObject.h b/js/src/vm/GlobalObject.h index d36dc3a29bdb..540b23725963 100644 --- a/js/src/vm/GlobalObject.h +++ b/js/src/vm/GlobalObject.h @@ -444,9 +444,7 @@ class GlobalObject : public JSObject return true; if (!cx->runtime()->cloneSelfHostedValue(cx, name, value)) return false; - mozilla::DebugOnly ok = JS_DefinePropertyById(cx, holder, id, value, NULL, NULL, 0); - JS_ASSERT(ok); - return true; + return JS_DefinePropertyById(cx, holder, id, value, NULL, NULL, 0); } bool setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value) { From 0375e46d983b802dc81c2a4451a541e3f7e9bfce Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 11 Sep 2013 22:43:01 +0300 Subject: [PATCH 05/69] Bug 912874 - New API to enumerate mutation observers, r=peterv --HG-- extra : rebase_source : a11135f5fbf0faec36fd2cf5a3f1d348886d0bdc --- content/base/public/nsINode.h | 3 ++ content/base/src/nsDOMMutationObserver.cpp | 28 ++++++++++++++++++- content/base/src/nsDOMMutationObserver.h | 17 +++++++---- content/base/src/nsINode.cpp | 17 +++++++++++ content/base/test/test_mutationobservers.html | 26 +++++++++++++++-- dom/webidl/MutationObserver.webidl | 10 +++++++ dom/webidl/Node.webidl | 2 ++ 7 files changed, 93 insertions(+), 10 deletions(-) diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 4870ac0d2d04..e05f6e50b663 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -46,6 +46,7 @@ class nsIURI; class nsNodeSupportsWeakRefTearoff; class nsNodeWeakReference; class nsXPCClassInfo; +class nsDOMMutationObserver; namespace mozilla { namespace dom { @@ -1474,6 +1475,8 @@ public: // aObject alive anymore. void UnbindObject(nsISupports* aObject); + void GetBoundMutationObservers(nsTArray >& aResult); + /** * Returns the length of this node, as specified at * diff --git a/content/base/src/nsDOMMutationObserver.cpp b/content/base/src/nsDOMMutationObserver.cpp index f79d1836fd4e..a758cb88a918 100644 --- a/content/base/src/nsDOMMutationObserver.cpp +++ b/content/base/src/nsDOMMutationObserver.cpp @@ -66,7 +66,6 @@ NS_IMPL_RELEASE(nsMutationReceiver) NS_INTERFACE_MAP_BEGIN(nsMutationReceiver) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsIMutationObserver) - NS_INTERFACE_MAP_ENTRY(nsMutationReceiver) NS_INTERFACE_MAP_END nsMutationReceiver::nsMutationReceiver(nsINode* aTarget, @@ -321,6 +320,7 @@ void nsMutationReceiver::NodeWillBeDestroyed(const nsINode *aNode) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMMutationObserver) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_INTERFACE_MAP_ENTRY(nsDOMMutationObserver) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMMutationObserver) @@ -525,6 +525,32 @@ nsDOMMutationObserver::TakeRecords( mPendingMutations.SwapElements(aRetVal); } +void +nsDOMMutationObserver::GetObservingInfo(nsTArray >& aResult) +{ + aResult.SetCapacity(mReceivers.Count()); + for (int32_t i = 0; i < mReceivers.Count(); ++i) { + MutationObservingInfoInitializer& info = aResult.AppendElement()->SetValue(); + nsMutationReceiver* mr = mReceivers[i]; + info.mChildList = mr->ChildList(); + info.mAttributes = mr->Attributes(); + info.mCharacterData = mr->CharacterData(); + info.mSubtree = mr->Subtree(); + info.mAttributeOldValue = mr->AttributeOldValue(); + info.mCharacterDataOldValue = mr->CharacterDataOldValue(); + nsCOMArray& filters = mr->AttributeFilter(); + if (filters.Count()) { + info.mAttributeFilter.Construct(); + mozilla::dom::Sequence& filtersAsStrings = + info.mAttributeFilter.Value(); + for (int32_t j = 0; j < filters.Count(); ++j) { + filtersAsStrings.AppendElement(nsDependentAtomString(filters[j])); + } + } + info.mObservedNode = mr->Target(); + } +} + // static already_AddRefed nsDOMMutationObserver::Constructor(const mozilla::dom::GlobalObject& aGlobal, diff --git a/content/base/src/nsDOMMutationObserver.h b/content/base/src/nsDOMMutationObserver.h index ccfbed1b51d1..f12024a1b4c4 100644 --- a/content/base/src/nsDOMMutationObserver.h +++ b/content/base/src/nsDOMMutationObserver.h @@ -25,6 +25,7 @@ #include "mozilla/dom/MutationObserverBinding.h" class nsDOMMutationObserver; +using mozilla::dom::MutationObservingInfoInitializer; class nsDOMMutationRecord : public nsISupports, public nsWrapperCache @@ -267,10 +268,6 @@ private: }; -#define NS_MUTATION_OBSERVER_IID \ -{ 0xe628f313, 0x8129, 0x4f90, \ - { 0x8e, 0xc3, 0x85, 0xe8, 0x28, 0x22, 0xe7, 0xab } } - class nsMutationReceiver : public nsMutationReceiverBase { public: @@ -315,7 +312,6 @@ public: void Disconnect(bool aRemoveFromObserver); - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMUTATION_OBSERVER_IID) NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW NS_DECL_ISUPPORTS @@ -337,7 +333,9 @@ public: } }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsMutationReceiver, NS_MUTATION_OBSERVER_IID) +#define NS_DOM_MUTATION_OBSERVER_IID \ +{ 0x0c3b91f8, 0xcc3b, 0x4b08, \ + { 0x9e, 0xab, 0x07, 0x47, 0xa9, 0xe4, 0x65, 0xb4 } } class nsDOMMutationObserver : public nsISupports, public nsWrapperCache @@ -352,6 +350,7 @@ public: virtual ~nsDOMMutationObserver(); NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMMutationObserver) + NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_MUTATION_OBSERVER_IID) static already_AddRefed Constructor(const mozilla::dom::GlobalObject& aGlobal, @@ -379,6 +378,10 @@ public: void HandleMutation(); + void GetObservingInfo(nsTArray >& aResult); + + mozilla::dom::MutationCallback* MutationCallback() { return mCallback; } + // static methods static void HandleMutations() { @@ -445,6 +448,8 @@ protected: sCurrentlyHandlingObservers; }; +NS_DEFINE_STATIC_IID_ACCESSOR(nsDOMMutationObserver, NS_DOM_MUTATION_OBSERVER_IID) + class nsAutoMutationBatch { public: diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 323586daa7a0..4149128a9ac8 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -103,6 +103,7 @@ #include #include "nsDOMEvent.h" #include "nsGlobalWindow.h" +#include "nsDOMMutationObserver.h" using namespace mozilla; using namespace mozilla::dom; @@ -2144,6 +2145,22 @@ nsINode::UnbindObject(nsISupports* aObject) } } +void +nsINode::GetBoundMutationObservers(nsTArray >& aResult) +{ + nsCOMArray* objects = + static_cast*>(GetProperty(nsGkAtoms::keepobjectsalive)); + if (objects) { + for (int32_t i = 0; i < objects->Count(); ++i) { + nsCOMPtr mo = do_QueryInterface(objects->ObjectAt(i)); + if (mo) { + MOZ_ASSERT(!aResult.Contains(mo)); + aResult.AppendElement(mo.forget()); + } + } + } +} + size_t nsINode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { diff --git a/content/base/test/test_mutationobservers.html b/content/base/test/test_mutationobservers.html index 88a4e143ec9f..11019f48449f 100644 --- a/content/base/test/test_mutationobservers.html +++ b/content/base/test/test_mutationobservers.html @@ -153,7 +153,10 @@ function runTest() { then(testThisBind); m = null; }); - m.observe(div, { attributes: true}); + m.observe(div, { attributes: true, attributeFilter: ["foo"] }); + is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributes, true); + is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributeFilter.length, 1) + is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributeFilter[0], "foo") div.setAttribute("foo", "bar"); } @@ -182,6 +185,9 @@ function testThisBind() { m = null; }).bind(window)); m.observe(div, { attributes: true, attributeOldValue: true, subtree: true }); + is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributes, true) + is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributeOldValue, true) + is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].subtree, true) div.setAttribute("foo", "bar2"); div.removeAttribute("foo"); div.removeChild(child); @@ -225,6 +231,11 @@ function testCharacterData() { m3.observe(div, { characterData: true, subtree: true }); m3.observe(div, { characterData: true, subtree: false }); m4.observe(div.firstChild, { characterData: true, subtree: false }); + + is(SpecialPowers.wrap(div).getBoundMutationObservers().length, 3) + is(SpecialPowers.wrap(div).getBoundMutationObservers()[2].getObservingInfo()[0].characterData, true) + is(SpecialPowers.wrap(div).getBoundMutationObservers()[2].getObservingInfo()[0].subtree, false) + div.firstChild.data = "bar"; } @@ -278,7 +289,7 @@ function testChildList4() { var s1 = div.appendChild(document.createElement("span")); s1.textContent = "foo"; var s2 = div.appendChild(document.createElement("span")); - m = new M(function(records, observer) { + function callback(records, observer) { is(records.length, 3, "Should have got one record for removing nodes from document fragment and one record for adding them to div"); is(records[0].removedNodes.length, 2, "Should have got removedNodes"); is(records[0].removedNodes[0], t1, "Should be the 1st textnode"); @@ -294,9 +305,16 @@ function testChildList4() { observer.disconnect(); then(testChildList5); m = null; - }); + }; + m = new M(callback); m.observe(df, { childList: true, characterData: true, characterDataOldValue: true, subtree: true }); + is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].childList, true) + is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].characterData, true) + is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].characterDataOldValue, true) + is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].subtree, true) + ok(SpecialPowers.compare(SpecialPowers.wrap(df).getBoundMutationObservers()[0].mutationCallback, callback)) m.observe(div, { childList: true }); + is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo().length, 2) // Make sure transient observers aren't leaked. var leakTest = new M(function(){}); @@ -554,6 +572,8 @@ function testTakeRecords() { m = null; }); m.observe(div, { attributes: true, attributeOldValue: true }); + // Note, [0] points to a mutation observer which is there for a leak test! + ok(SpecialPowers.compare(SpecialPowers.wrap(div).getBoundMutationObservers()[1], m)); var mutationEventCount = 0; div.addEventListener("DOMAttrModified", mutationListener); div.setAttribute("foo", "bar"); diff --git a/dom/webidl/MutationObserver.webidl b/dom/webidl/MutationObserver.webidl index 6caa07ba2706..91e499d72797 100644 --- a/dom/webidl/MutationObserver.webidl +++ b/dom/webidl/MutationObserver.webidl @@ -27,6 +27,11 @@ interface MutationObserver { void observe(Node target, optional MutationObserverInit options); void disconnect(); sequence takeRecords(); + + [ChromeOnly] + sequence getObservingInfo(); + [ChromeOnly] + readonly attribute MutationCallback mutationCallback; }; callback MutationCallback = void (sequence mutations, MutationObserver observer); @@ -40,3 +45,8 @@ dictionary MutationObserverInit { boolean characterDataOldValue = false; sequence attributeFilter; }; + +dictionary MutationObservingInfo : MutationObserverInit +{ + Node? observedNode = null; +}; diff --git a/dom/webidl/Node.webidl b/dom/webidl/Node.webidl index 06f54afb0429..cddd9a47a65d 100644 --- a/dom/webidl/Node.webidl +++ b/dom/webidl/Node.webidl @@ -104,4 +104,6 @@ interface Node : EventTarget { readonly attribute Principal nodePrincipal; [ChromeOnly] readonly attribute URI? baseURIObject; + [ChromeOnly] + sequence getBoundMutationObservers(); }; From 6a944153af1620ffd722db2f6231ef97ae8521d8 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Wed, 11 Sep 2013 00:18:59 +0200 Subject: [PATCH 06/69] Bug 914498 - Minimize the #includes in accessible/src/base; r=tbsaunde --- accessible/src/atk/AccessibleWrap.cpp | 1 + accessible/src/atk/nsMaiInterfaceImage.cpp | 1 + accessible/src/atk/nsMaiInterfaceText.cpp | 1 + accessible/src/base/ARIAMap.cpp | 1 - accessible/src/base/AccEvent.cpp | 7 ------- accessible/src/base/AccGroupInfo.cpp | 1 + accessible/src/base/AccGroupInfo.h | 1 - accessible/src/base/AccIterator.cpp | 3 --- accessible/src/base/AccIterator.h | 3 ++- accessible/src/base/DocManager.cpp | 6 ++---- accessible/src/base/DocManager.h | 1 - accessible/src/base/EventQueue.cpp | 6 +++++- accessible/src/base/EventQueue.h | 2 -- accessible/src/base/FocusManager.cpp | 2 +- accessible/src/base/FocusManager.h | 5 ++++- accessible/src/base/Logging.cpp | 1 + accessible/src/base/Logging.h | 3 ++- accessible/src/base/NotificationController.cpp | 1 - accessible/src/base/NotificationController.h | 3 --- accessible/src/base/RoleAsserts.cpp | 2 -- accessible/src/base/SelectionManager.cpp | 6 ++---- accessible/src/base/TextAttrs.cpp | 3 +-- accessible/src/base/TreeWalker.h | 2 +- accessible/src/base/nsAccUtils.cpp | 7 ++----- accessible/src/base/nsAccUtils.h | 12 +++++------- accessible/src/base/nsAccessNode.cpp | 9 --------- accessible/src/base/nsAccessNode.h | 4 ---- accessible/src/base/nsAccessibilityService.cpp | 18 ++++++++++-------- accessible/src/base/nsAccessiblePivot.cpp | 5 ----- accessible/src/base/nsAccessiblePivot.h | 1 - accessible/src/base/nsCoreUtils.cpp | 9 +-------- accessible/src/base/nsCoreUtils.h | 2 +- accessible/src/base/nsTextEquivUtils.cpp | 7 +------ accessible/src/base/nsTextEquivUtils.h | 1 - accessible/src/generic/ARIAGridAccessible.cpp | 1 + accessible/src/generic/DocAccessible-inl.h | 1 + accessible/src/generic/DocAccessible.cpp | 1 + accessible/src/generic/HyperTextAccessible.cpp | 1 + accessible/src/generic/ImageAccessible.cpp | 1 + accessible/src/html/HTMLElementAccessibles.cpp | 1 + .../src/html/HTMLFormControlAccessible.cpp | 1 + accessible/src/html/HTMLTableAccessible.cpp | 1 + accessible/src/mac/mozAccessible.mm | 1 + accessible/src/mac/mozTextAccessible.mm | 1 + .../src/windows/ia2/ia2AccessibleText.cpp | 1 + accessible/src/windows/msaa/AccessibleWrap.cpp | 2 ++ accessible/src/windows/sdn/sdnAccessible.cpp | 1 + .../src/windows/sdn/sdnTextAccessible.cpp | 1 + .../src/xul/XULFormControlAccessible.cpp | 1 + accessible/src/xul/XULListboxAccessible.cpp | 1 + accessible/src/xul/XULSliderAccessible.cpp | 1 + accessible/src/xul/XULTreeAccessible.cpp | 1 + accessible/src/xul/XULTreeGridAccessible.cpp | 2 ++ 53 files changed, 66 insertions(+), 92 deletions(-) diff --git a/accessible/src/atk/AccessibleWrap.cpp b/accessible/src/atk/AccessibleWrap.cpp index 8fed8d615d12..6bb19fac6950 100644 --- a/accessible/src/atk/AccessibleWrap.cpp +++ b/accessible/src/atk/AccessibleWrap.cpp @@ -27,6 +27,7 @@ #include "mozilla/Util.h" #include "nsXPCOMStrings.h" #include "nsComponentManagerUtils.h" +#include "nsIPersistentProperties2.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/atk/nsMaiInterfaceImage.cpp b/accessible/src/atk/nsMaiInterfaceImage.cpp index f0946181184e..38f234621183 100644 --- a/accessible/src/atk/nsMaiInterfaceImage.cpp +++ b/accessible/src/atk/nsMaiInterfaceImage.cpp @@ -10,6 +10,7 @@ #include "ImageAccessible.h" #include "mozilla/Likely.h" #include "nsMai.h" +#include "nsIAccessibleTypes.h" #include "nsIURI.h" using namespace mozilla; diff --git a/accessible/src/atk/nsMaiInterfaceText.cpp b/accessible/src/atk/nsMaiInterfaceText.cpp index 52dc485bcc20..df41df047996 100644 --- a/accessible/src/atk/nsMaiInterfaceText.cpp +++ b/accessible/src/atk/nsMaiInterfaceText.cpp @@ -10,6 +10,7 @@ #include "HyperTextAccessible.h" #include "nsMai.h" +#include "nsIAccessibleTypes.h" #include "nsIPersistentProperties2.h" #include "mozilla/Likely.h" diff --git a/accessible/src/base/ARIAMap.cpp b/accessible/src/base/ARIAMap.cpp index f43fe29dd1bd..ed344e9abe78 100644 --- a/accessible/src/base/ARIAMap.cpp +++ b/accessible/src/base/ARIAMap.cpp @@ -7,7 +7,6 @@ #include "ARIAMap.h" -#include "Accessible.h" #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "Role.h" diff --git a/accessible/src/base/AccEvent.cpp b/accessible/src/base/AccEvent.cpp index 92256804ba41..4b2e97e14041 100644 --- a/accessible/src/base/AccEvent.cpp +++ b/accessible/src/base/AccEvent.cpp @@ -6,19 +6,12 @@ #include "AccEvent.h" -#include "ApplicationAccessibleWrap.h" -#include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "DocAccessible.h" -#include "nsIAccessibleText.h" #include "xpcAccEvents.h" #include "States.h" #include "nsEventStateManager.h" -#include "nsIServiceManager.h" -#ifdef MOZ_XUL -#include "nsIDOMXULMultSelectCntrlEl.h" -#endif using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/AccGroupInfo.cpp b/accessible/src/base/AccGroupInfo.cpp index 001c0d9a3735..6790a788398f 100644 --- a/accessible/src/base/AccGroupInfo.cpp +++ b/accessible/src/base/AccGroupInfo.cpp @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "AccGroupInfo.h" +#include "nsAccUtils.h" #include "Role.h" #include "States.h" diff --git a/accessible/src/base/AccGroupInfo.h b/accessible/src/base/AccGroupInfo.h index fab4af1b8377..1d32337136e2 100644 --- a/accessible/src/base/AccGroupInfo.h +++ b/accessible/src/base/AccGroupInfo.h @@ -6,7 +6,6 @@ #define AccGroupInfo_h_ #include "Accessible-inl.h" -#include "nsAccUtils.h" namespace mozilla { namespace a11y { diff --git a/accessible/src/base/AccIterator.cpp b/accessible/src/base/AccIterator.cpp index c249482565fb..bdf4b7ca3a56 100644 --- a/accessible/src/base/AccIterator.cpp +++ b/accessible/src/base/AccIterator.cpp @@ -4,15 +4,12 @@ #include "AccIterator.h" -#include "nsAccessibilityService.h" #include "AccGroupInfo.h" -#include "Accessible-inl.h" #ifdef MOZ_XUL #include "XULTreeAccessible.h" #endif #include "mozilla/dom/Element.h" -#include "nsBindingManager.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/AccIterator.h b/accessible/src/base/AccIterator.h index 85d8016d7922..79d3deebffc0 100644 --- a/accessible/src/base/AccIterator.h +++ b/accessible/src/base/AccIterator.h @@ -9,7 +9,8 @@ #include "DocAccessible.h" #include "Filters.h" -#include "nsAccessibilityService.h" + +class nsITreeView; namespace mozilla { namespace a11y { diff --git a/accessible/src/base/DocManager.cpp b/accessible/src/base/DocManager.cpp index 0911e79f6f67..f3b4e83b946d 100644 --- a/accessible/src/base/DocManager.cpp +++ b/accessible/src/base/DocManager.cpp @@ -5,14 +5,11 @@ #include "DocManager.h" -#include "Accessible-inl.h" #include "ApplicationAccessible.h" #include "ARIAMap.h" #include "DocAccessible-inl.h" #include "nsAccessibilityService.h" -#include "nsAccUtils.h" #include "RootAccessibleWrap.h" -#include "States.h" #ifdef A11Y_LOG #include "Logging.h" @@ -22,13 +19,14 @@ #include "nsDocShellLoadTypes.h" #include "nsDOMEvent.h" #include "nsIChannel.h" -#include "nsIContentViewer.h" #include "nsIDOMDocument.h" #include "nsEventListenerManager.h" #include "nsIDOMWindow.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIWebNavigation.h" #include "nsServiceManagerUtils.h" +#include "nsIWebProgress.h" +#include "nsCoreUtils.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/DocManager.h b/accessible/src/base/DocManager.h index a41779b11658..580456734364 100644 --- a/accessible/src/base/DocManager.h +++ b/accessible/src/base/DocManager.h @@ -8,7 +8,6 @@ #include "nsIDocument.h" #include "nsIDOMEventListener.h" #include "nsRefPtrHashtable.h" -#include "nsIWebProgress.h" #include "nsIWebProgressListener.h" #include "nsWeakReference.h" #include "nsIPresShell.h" diff --git a/accessible/src/base/EventQueue.cpp b/accessible/src/base/EventQueue.cpp index c9235f2c8af1..9fabc16c5d23 100644 --- a/accessible/src/base/EventQueue.cpp +++ b/accessible/src/base/EventQueue.cpp @@ -6,8 +6,12 @@ #include "EventQueue.h" #include "Accessible-inl.h" -#include "DocAccessible-inl.h" #include "nsEventShell.h" +#include "DocAccessible.h" +#include "nsAccessibilityService.h" +#ifdef A11Y_LOG +#include "Logging.h" +#endif using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/EventQueue.h b/accessible/src/base/EventQueue.h index 8cc00a716fe8..a5457d5b0a5f 100644 --- a/accessible/src/base/EventQueue.h +++ b/accessible/src/base/EventQueue.h @@ -8,8 +8,6 @@ #include "AccEvent.h" -class nsIContent; - namespace mozilla { namespace a11y { diff --git a/accessible/src/base/FocusManager.cpp b/accessible/src/base/FocusManager.cpp index e4550cc0b732..1ec9358874e1 100644 --- a/accessible/src/base/FocusManager.cpp +++ b/accessible/src/base/FocusManager.cpp @@ -10,10 +10,10 @@ #include "nsAccUtils.h" #include "nsEventShell.h" #include "Role.h" -#include "RootAccessible.h" #include "nsEventStateManager.h" #include "nsFocusManager.h" +#include "mozilla/dom/Element.h" namespace dom = mozilla::dom; using namespace mozilla::a11y; diff --git a/accessible/src/base/FocusManager.h b/accessible/src/base/FocusManager.h index 1955a84193c4..ccbbd9e9ee38 100644 --- a/accessible/src/base/FocusManager.h +++ b/accessible/src/base/FocusManager.h @@ -6,7 +6,10 @@ #define mozilla_a11y_FocusManager_h_ #include "nsAutoPtr.h" -#include "mozilla/dom/Element.h" + +class nsINode; +class nsIDocument; +class nsISupports; namespace mozilla { namespace a11y { diff --git a/accessible/src/base/Logging.cpp b/accessible/src/base/Logging.cpp index 3ab8a3ffae35..4e2e321ce8ca 100644 --- a/accessible/src/base/Logging.cpp +++ b/accessible/src/base/Logging.cpp @@ -22,6 +22,7 @@ #include "prenv.h" #include "nsIDocShellTreeItem.h" #include "nsIURI.h" +#include "mozilla/dom/Element.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/Logging.h b/accessible/src/base/Logging.h index 288d8bc394aa..35705bd90718 100644 --- a/accessible/src/base/Logging.h +++ b/accessible/src/base/Logging.h @@ -8,12 +8,13 @@ #define mozilla_a11y_logs_h__ #include "nscore.h" -#include "nsAString.h" +#include "nsStringFwd.h" class nsIDocument; class nsINode; class nsIRequest; class nsISelection; +class nsISupports; class nsIWebProgress; namespace mozilla { diff --git a/accessible/src/base/NotificationController.cpp b/accessible/src/base/NotificationController.cpp index bfebf9f6abc0..8c9f8e7fa1a9 100644 --- a/accessible/src/base/NotificationController.cpp +++ b/accessible/src/base/NotificationController.cpp @@ -5,7 +5,6 @@ #include "NotificationController.h" -#include "Accessible-inl.h" #include "DocAccessible-inl.h" #include "TextLeafAccessible.h" #include "TextUpdater.h" diff --git a/accessible/src/base/NotificationController.h b/accessible/src/base/NotificationController.h index 4b7dfbb7fb96..24ac4bfe72e5 100644 --- a/accessible/src/base/NotificationController.h +++ b/accessible/src/base/NotificationController.h @@ -15,12 +15,9 @@ #include "Logging.h" #endif -class nsIContent; - namespace mozilla { namespace a11y { -class Accessible; class DocAccessible; /** diff --git a/accessible/src/base/RoleAsserts.cpp b/accessible/src/base/RoleAsserts.cpp index 4477bc9202c2..34a9a2039414 100644 --- a/accessible/src/base/RoleAsserts.cpp +++ b/accessible/src/base/RoleAsserts.cpp @@ -7,8 +7,6 @@ #include "nsIAccessibleRole.h" #include "Role.h" -#include "mozilla/Assertions.h" - using namespace mozilla::a11y; #define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \ diff --git a/accessible/src/base/SelectionManager.cpp b/accessible/src/base/SelectionManager.cpp index 96678d522e95..c6f1ea183ea6 100644 --- a/accessible/src/base/SelectionManager.cpp +++ b/accessible/src/base/SelectionManager.cpp @@ -10,17 +10,15 @@ #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "nsIAccessibleEvent.h" -#include "RootAccessible.h" #include "nsCaret.h" +#include "nsIAccessibleTypes.h" #include "nsIDOMDocument.h" -#include "nsIDOMHTMLAnchorElement.h" -#include "nsIDOMHTMLTextAreaElement.h" #include "nsIFrame.h" #include "nsIPresShell.h" #include "nsISelectionPrivate.h" -#include "nsServiceManagerUtils.h" #include "mozilla/Selection.h" +#include "mozilla/dom/Element.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/TextAttrs.cpp b/accessible/src/base/TextAttrs.cpp index 0efb08d4879b..76d51ec48642 100644 --- a/accessible/src/base/TextAttrs.cpp +++ b/accessible/src/base/TextAttrs.cpp @@ -6,15 +6,14 @@ #include "TextAttrs.h" #include "Accessible-inl.h" -#include "HyperTextAccessibleWrap.h" #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "StyleInfo.h" #include "gfxFont.h" -#include "gfxUserFontSet.h" #include "nsFontMetrics.h" #include "nsLayoutUtils.h" +#include "HyperTextAccessible.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/TreeWalker.h b/accessible/src/base/TreeWalker.h index aa5647d4f5ec..4fa02eb87d61 100644 --- a/accessible/src/base/TreeWalker.h +++ b/accessible/src/base/TreeWalker.h @@ -6,7 +6,7 @@ #ifndef mozilla_a11y_TreeWalker_h_ #define mozilla_a11y_TreeWalker_h_ -#include "nsAutoPtr.h" +#include class nsIContent; diff --git a/accessible/src/base/nsAccUtils.cpp b/accessible/src/base/nsAccUtils.cpp index 0cd188cfd661..3be7c530e8c7 100644 --- a/accessible/src/base/nsAccUtils.cpp +++ b/accessible/src/base/nsAccUtils.cpp @@ -15,13 +15,10 @@ #include "Role.h" #include "States.h" #include "TextLeafAccessible.h" -#include "nsIMutableArray.h" #include "nsIDOMXULContainerElement.h" -#include "nsIDOMXULSelectCntrlEl.h" -#include "nsIDOMXULSelectCntrlItemEl.h" -#include "nsWhitespaceTokenizer.h" -#include "nsComponentManagerUtils.h" +#include "nsIPersistentProperties2.h" +#include "mozilla/dom/Element.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/nsAccUtils.h b/accessible/src/base/nsAccUtils.h index aad5b8826dbd..d43c99f1264c 100644 --- a/accessible/src/base/nsAccUtils.h +++ b/accessible/src/base/nsAccUtils.h @@ -7,23 +7,21 @@ #define nsAccUtils_h_ #include "mozilla/a11y/Accessible.h" -#include "nsIAccessibleText.h" #include "nsAccessibilityService.h" #include "nsCoreUtils.h" -#include "mozilla/dom/Element.h" #include "nsIDocShell.h" -#include "nsIPersistentProperties2.h" -#include "nsIPresShell.h" #include "nsPoint.h" -struct nsRoleMapEntry; - namespace mozilla { + +namespace dom { +class Element; +} + namespace a11y { -class Accessible; class HyperTextAccessible; class DocAccessible; diff --git a/accessible/src/base/nsAccessNode.cpp b/accessible/src/base/nsAccessNode.cpp index 276686f4d2ce..c333532340c3 100644 --- a/accessible/src/base/nsAccessNode.cpp +++ b/accessible/src/base/nsAccessNode.cpp @@ -5,20 +5,11 @@ #include "nsAccessNode.h" -#include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "RootAccessible.h" #include "nsIDocShell.h" -#include "nsIDOMWindow.h" -#include "nsIFrame.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsIPresShell.h" -#include "nsIServiceManager.h" -#include "nsFocusManager.h" -#include "nsPresContext.h" -#include "mozilla/Services.h" using namespace mozilla::a11y; diff --git a/accessible/src/base/nsAccessNode.h b/accessible/src/base/nsAccessNode.h index beed6774cf74..987da6afaa60 100644 --- a/accessible/src/base/nsAccessNode.h +++ b/accessible/src/base/nsAccessNode.h @@ -10,14 +10,10 @@ #ifndef _nsAccessNode_H_ #define _nsAccessNode_H_ -#include "nsIAccessibleTypes.h" #include "nsINode.h" class nsIContent; -class nsIDocShellTreeItem; class nsIFrame; -class nsIPresShell; -class nsPresContext; namespace mozilla { namespace a11y { diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index 0461fd68e12f..ac8ddc31c671 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -6,7 +6,6 @@ #include "nsAccessibilityService.h" // NOTE: alphabetically ordered -#include "Accessible-inl.h" #include "ApplicationAccessibleWrap.h" #include "ARIAGridAccessibleWrap.h" #include "ARIAMap.h" @@ -20,13 +19,18 @@ #include "HTMLSelectAccessible.h" #include "HTMLTableAccessibleWrap.h" #include "HyperTextAccessibleWrap.h" +#include "RootAccessible.h" #include "nsAccessiblePivot.h" #include "nsAccUtils.h" +#include "nsAttrName.h" #include "nsEventShell.h" +#include "nsIURI.h" #include "OuterDocAccessible.h" #include "Platform.h" #include "Role.h" +#ifdef MOZ_ACCESSIBILITY_ATK #include "RootAccessibleWrap.h" +#endif #include "States.h" #include "Statistics.h" #include "TextLeafAccessibleWrap.h" @@ -38,6 +42,7 @@ #ifdef XP_WIN #include "mozilla/a11y/Compatibility.h" #include "HTMLWin32ObjectAccessible.h" +#include "mozilla/StaticPtr.h" #endif #ifdef A11Y_LOG @@ -48,25 +53,18 @@ #include "nsExceptionHandler.h" #endif -#include "nsIDOMDocument.h" -#include "nsIDOMHTMLObjectElement.h" -#include "nsIDOMXULElement.h" #include "nsImageFrame.h" #include "nsIObserverService.h" #include "nsLayoutUtils.h" -#include "nsNPAPIPluginInstance.h" #include "nsObjectFrame.h" #include "nsSVGPathGeometryFrame.h" #include "nsTreeBodyFrame.h" #include "nsTreeColumns.h" #include "nsTreeUtils.h" -#include "nsBindingManager.h" #include "nsXBLPrototypeBinding.h" #include "nsXBLBinding.h" -#include "mozilla/dom/Element.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" -#include "mozilla/StaticPtr.h" #include "mozilla/Util.h" #include "nsDeckFrame.h" @@ -83,6 +81,10 @@ #include "XULTreeGridAccessibleWrap.h" #endif +#if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK) +#include "nsNPAPIPluginInstance.h" +#endif + using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/base/nsAccessiblePivot.cpp b/accessible/src/base/nsAccessiblePivot.cpp index 61d3a4703d91..43e1b6efb995 100644 --- a/accessible/src/base/nsAccessiblePivot.cpp +++ b/accessible/src/base/nsAccessiblePivot.cpp @@ -6,15 +6,10 @@ #include "nsAccessiblePivot.h" -#include "DocAccessible.h" #include "HyperTextAccessible.h" #include "nsAccUtils.h" #include "States.h" -#include "nsArrayUtils.h" -#include "nsComponentManagerUtils.h" -#include "nsISupportsPrimitives.h" - using namespace mozilla::a11y; diff --git a/accessible/src/base/nsAccessiblePivot.h b/accessible/src/base/nsAccessiblePivot.h index 476650a5d9d8..0c578c72a423 100644 --- a/accessible/src/base/nsAccessiblePivot.h +++ b/accessible/src/base/nsAccessiblePivot.h @@ -15,7 +15,6 @@ #include "nsCycleCollectionParticipant.h" #include "mozilla/Attributes.h" -class nsIAccessibleTraversalRule; class RuleCache; /** diff --git a/accessible/src/base/nsCoreUtils.cpp b/accessible/src/base/nsCoreUtils.cpp index cc8fb478f8b0..e1b212455e66 100644 --- a/accessible/src/base/nsCoreUtils.cpp +++ b/accessible/src/base/nsCoreUtils.cpp @@ -7,8 +7,6 @@ #include "nsIAccessibleTypes.h" -#include "nsAccessNode.h" - #include "nsIBaseWindow.h" #include "nsIDocShellTreeOwner.h" #include "nsIDocument.h" @@ -16,10 +14,9 @@ #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsRange.h" -#include "nsIDOMWindow.h" +#include "nsIBoxObject.h" #include "nsIDOMXULElement.h" #include "nsIDocShell.h" -#include "nsIContentViewer.h" #include "nsEventListenerManager.h" #include "nsIPresShell.h" #include "nsPresContext.h" @@ -27,16 +24,12 @@ #include "nsEventStateManager.h" #include "nsISelectionPrivate.h" #include "nsISelectionController.h" -#include "nsPIDOMWindow.h" #include "nsGUIEvent.h" #include "nsView.h" -#include "nsLayoutUtils.h" #include "nsGkAtoms.h" #include "nsDOMTouchEvent.h" #include "nsComponentManagerUtils.h" -#include "nsIInterfaceRequestorUtils.h" -#include "mozilla/dom/Element.h" #include "nsITreeBoxObject.h" #include "nsITreeColumns.h" diff --git a/accessible/src/base/nsCoreUtils.h b/accessible/src/base/nsCoreUtils.h index 110434389fbe..5107d4a58cc3 100644 --- a/accessible/src/base/nsCoreUtils.h +++ b/accessible/src/base/nsCoreUtils.h @@ -7,7 +7,6 @@ #define nsCoreUtils_h_ #include "nsIContent.h" -#include "nsIBoxObject.h" #include "nsIPresShell.h" #include "nsIDOMDOMStringList.h" @@ -15,6 +14,7 @@ #include "nsTArray.h" class nsRange; +class nsIBoxObject; class nsIFrame; class nsIDocShell; class nsITreeColumn; diff --git a/accessible/src/base/nsTextEquivUtils.cpp b/accessible/src/base/nsTextEquivUtils.cpp index 2d77c2d2488b..b486fa015c00 100644 --- a/accessible/src/base/nsTextEquivUtils.cpp +++ b/accessible/src/base/nsTextEquivUtils.cpp @@ -9,14 +9,9 @@ #include "Accessible-inl.h" #include "AccIterator.h" -#include "nsAccessibilityService.h" -#include "nsAccUtils.h" -#include "nsStyleStructInlines.h" - +#include "nsCoreUtils.h" #include "nsIDOMXULLabeledControlEl.h" -#include "nsArrayUtils.h" - using namespace mozilla::a11y; /** diff --git a/accessible/src/base/nsTextEquivUtils.h b/accessible/src/base/nsTextEquivUtils.h index 0615e20b4335..77ed2d39043a 100644 --- a/accessible/src/base/nsTextEquivUtils.h +++ b/accessible/src/base/nsTextEquivUtils.h @@ -9,7 +9,6 @@ #define _nsTextEquivUtils_H_ #include "Accessible.h" -#include "nsIStringBundle.h" #include "Role.h" class nsIContent; diff --git a/accessible/src/generic/ARIAGridAccessible.cpp b/accessible/src/generic/ARIAGridAccessible.cpp index 5250fa3d294a..2be1b3e2aef9 100644 --- a/accessible/src/generic/ARIAGridAccessible.cpp +++ b/accessible/src/generic/ARIAGridAccessible.cpp @@ -12,6 +12,7 @@ #include "States.h" #include "nsIMutableArray.h" +#include "nsIPersistentProperties2.h" #include "nsComponentManagerUtils.h" using namespace mozilla; diff --git a/accessible/src/generic/DocAccessible-inl.h b/accessible/src/generic/DocAccessible-inl.h index dbeeca495048..6e884863ca71 100644 --- a/accessible/src/generic/DocAccessible-inl.h +++ b/accessible/src/generic/DocAccessible-inl.h @@ -11,6 +11,7 @@ #include "nsAccessibilityService.h" #include "NotificationController.h" #include "States.h" +#include "nsIScrollableFrame.h" #ifdef A11Y_LOG #include "Logging.h" diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index 0cb1c8c76fd2..082c575525b0 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -32,6 +32,7 @@ #include "nsIFrame.h" #include "nsIInterfaceRequestorUtils.h" #include "nsINameSpaceManager.h" +#include "nsIPersistentProperties2.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" #include "nsViewManager.h" diff --git a/accessible/src/generic/HyperTextAccessible.cpp b/accessible/src/generic/HyperTextAccessible.cpp index 28c871f8a797..eea26770480b 100644 --- a/accessible/src/generic/HyperTextAccessible.cpp +++ b/accessible/src/generic/HyperTextAccessible.cpp @@ -25,6 +25,7 @@ #include "nsFrameSelection.h" #include "nsILineIterator.h" #include "nsIInterfaceRequestorUtils.h" +#include "nsIPersistentProperties2.h" #include "nsIPlaintextEditor.h" #include "nsIScrollableFrame.h" #include "nsIServiceManager.h" diff --git a/accessible/src/generic/ImageAccessible.cpp b/accessible/src/generic/ImageAccessible.cpp index 2d4cb0676eaa..341f0630e462 100644 --- a/accessible/src/generic/ImageAccessible.cpp +++ b/accessible/src/generic/ImageAccessible.cpp @@ -18,6 +18,7 @@ #include "nsIPresShell.h" #include "nsIServiceManager.h" #include "nsIDOMHTMLImageElement.h" +#include "nsIPersistentProperties2.h" #include "nsPIDOMWindow.h" #include "nsIURI.h" diff --git a/accessible/src/html/HTMLElementAccessibles.cpp b/accessible/src/html/HTMLElementAccessibles.cpp index 2a2f53d42027..e64286c05c66 100644 --- a/accessible/src/html/HTMLElementAccessibles.cpp +++ b/accessible/src/html/HTMLElementAccessibles.cpp @@ -8,6 +8,7 @@ #include "DocAccessible.h" #include "nsAccUtils.h" #include "nsIAccessibleRelation.h" +#include "nsIPersistentProperties2.h" #include "nsTextEquivUtils.h" #include "Relation.h" #include "Role.h" diff --git a/accessible/src/html/HTMLFormControlAccessible.cpp b/accessible/src/html/HTMLFormControlAccessible.cpp index 0309b77545ae..97437cf9c524 100644 --- a/accessible/src/html/HTMLFormControlAccessible.cpp +++ b/accessible/src/html/HTMLFormControlAccessible.cpp @@ -23,6 +23,7 @@ #include "nsIEditor.h" #include "nsIFormControl.h" #include "nsINameSpaceManager.h" +#include "nsIPersistentProperties2.h" #include "nsISelectionController.h" #include "jsapi.h" #include "nsIServiceManager.h" diff --git a/accessible/src/html/HTMLTableAccessible.cpp b/accessible/src/html/HTMLTableAccessible.cpp index 70e3e04b2b3a..4d78d6b778db 100644 --- a/accessible/src/html/HTMLTableAccessible.cpp +++ b/accessible/src/html/HTMLTableAccessible.cpp @@ -28,6 +28,7 @@ #include "nsIDOMHTMLCollection.h" #include "nsIDocument.h" #include "nsIMutableArray.h" +#include "nsIPersistentProperties2.h" #include "nsIPresShell.h" #include "nsITableCellLayout.h" #include "nsFrameSelection.h" diff --git a/accessible/src/mac/mozAccessible.mm b/accessible/src/mac/mozAccessible.mm index 119a1ae0d36a..97d19e1dc3cf 100644 --- a/accessible/src/mac/mozAccessible.mm +++ b/accessible/src/mac/mozAccessible.mm @@ -13,6 +13,7 @@ #include "nsIAccessibleRelation.h" #include "nsIAccessibleText.h" #include "nsIAccessibleEditableText.h" +#include "nsIPersistentProperties2.h" #include "Relation.h" #include "Role.h" #include "RootAccessible.h" diff --git a/accessible/src/mac/mozTextAccessible.mm b/accessible/src/mac/mozTextAccessible.mm index f88c3490878a..05d426e7c98f 100644 --- a/accessible/src/mac/mozTextAccessible.mm +++ b/accessible/src/mac/mozTextAccessible.mm @@ -6,6 +6,7 @@ #include "Accessible-inl.h" #include "AccessibleWrap.h" #include "TextLeafAccessible.h" +#include "nsIAccessibleTypes.h" #include "nsCocoaUtils.h" #include "nsObjCExceptions.h" diff --git a/accessible/src/windows/ia2/ia2AccessibleText.cpp b/accessible/src/windows/ia2/ia2AccessibleText.cpp index 3b9d9663dc13..5d3b8b9347e7 100644 --- a/accessible/src/windows/ia2/ia2AccessibleText.cpp +++ b/accessible/src/windows/ia2/ia2AccessibleText.cpp @@ -13,6 +13,7 @@ #include "HyperTextAccessibleWrap.h" #include "nsIPersistentProperties2.h" +#include "nsIAccessibleTypes.h" using namespace mozilla::a11y; diff --git a/accessible/src/windows/msaa/AccessibleWrap.cpp b/accessible/src/windows/msaa/AccessibleWrap.cpp index 7c08afe15db9..737f37c09ff6 100644 --- a/accessible/src/windows/msaa/AccessibleWrap.cpp +++ b/accessible/src/windows/msaa/AccessibleWrap.cpp @@ -42,6 +42,8 @@ #include "AccessibleRole.h" #include "AccessibleStates.h" #include "oleacc.h" +#include "nsIAccessibleTypes.h" +#include "nsIPersistentProperties2.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/accessible/src/windows/sdn/sdnAccessible.cpp b/accessible/src/windows/sdn/sdnAccessible.cpp index 2ecd9c611150..96357af88e90 100644 --- a/accessible/src/windows/sdn/sdnAccessible.cpp +++ b/accessible/src/windows/sdn/sdnAccessible.cpp @@ -11,6 +11,7 @@ #include "nsAttrName.h" #include "nsCoreUtils.h" +#include "nsIAccessibleTypes.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMCSSStyleDeclaration.h" #include "nsServiceManagerUtils.h" diff --git a/accessible/src/windows/sdn/sdnTextAccessible.cpp b/accessible/src/windows/sdn/sdnTextAccessible.cpp index b8b71c6afe42..30b8d092b47f 100644 --- a/accessible/src/windows/sdn/sdnTextAccessible.cpp +++ b/accessible/src/windows/sdn/sdnTextAccessible.cpp @@ -16,6 +16,7 @@ #include "nsPresContext.h" #include "nsLayoutUtils.h" #include "gfxFont.h" +#include "nsIAccessibleTypes.h" using namespace mozilla::a11y; diff --git a/accessible/src/xul/XULFormControlAccessible.cpp b/accessible/src/xul/XULFormControlAccessible.cpp index d6981e44942b..d0f5fa7fd2c6 100644 --- a/accessible/src/xul/XULFormControlAccessible.cpp +++ b/accessible/src/xul/XULFormControlAccessible.cpp @@ -28,6 +28,7 @@ #include "nsINameSpaceManager.h" #include "nsITextControlFrame.h" #include "nsMenuPopupFrame.h" +#include "mozilla/dom/Element.h" using namespace mozilla::a11y; diff --git a/accessible/src/xul/XULListboxAccessible.cpp b/accessible/src/xul/XULListboxAccessible.cpp index 6863646c219a..8ad8f85a1be6 100644 --- a/accessible/src/xul/XULListboxAccessible.cpp +++ b/accessible/src/xul/XULListboxAccessible.cpp @@ -21,6 +21,7 @@ #include "nsIDOMXULPopupElement.h" #include "nsIDOMXULSelectCntrlItemEl.h" #include "nsIMutableArray.h" +#include "nsIPersistentProperties2.h" using namespace mozilla::a11y; diff --git a/accessible/src/xul/XULSliderAccessible.cpp b/accessible/src/xul/XULSliderAccessible.cpp index 96e5f1c7032a..ec8f1028bb96 100644 --- a/accessible/src/xul/XULSliderAccessible.cpp +++ b/accessible/src/xul/XULSliderAccessible.cpp @@ -10,6 +10,7 @@ #include "States.h" #include "nsIFrame.h" +#include "mozilla/dom/Element.h" using namespace mozilla::a11y; diff --git a/accessible/src/xul/XULTreeAccessible.cpp b/accessible/src/xul/XULTreeAccessible.cpp index 019adacee4ca..e134a79a1239 100644 --- a/accessible/src/xul/XULTreeAccessible.cpp +++ b/accessible/src/xul/XULTreeAccessible.cpp @@ -21,6 +21,7 @@ #include "nsIAccessibleRelation.h" #include "nsIAutoCompleteInput.h" #include "nsIAutoCompletePopup.h" +#include "nsIBoxObject.h" #include "nsIDOMXULElement.h" #include "nsIDOMXULMenuListElement.h" #include "nsIDOMXULMultSelectCntrlEl.h" diff --git a/accessible/src/xul/XULTreeGridAccessible.cpp b/accessible/src/xul/XULTreeGridAccessible.cpp index 8a885a721951..8a578f7ac1ca 100644 --- a/accessible/src/xul/XULTreeGridAccessible.cpp +++ b/accessible/src/xul/XULTreeGridAccessible.cpp @@ -14,7 +14,9 @@ #include "Role.h" #include "States.h" +#include "nsIBoxObject.h" #include "nsIMutableArray.h" +#include "nsIPersistentProperties2.h" #include "nsITreeSelection.h" #include "nsComponentManagerUtils.h" From 5ba463915bb68ada2f707542042801ac5e9d3baa Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Wed, 11 Sep 2013 23:57:23 +0200 Subject: [PATCH 07/69] Display fill ratio when showing FPS counter (bug 915342, r=bgirard). --- gfx/layers/Compositor.h | 8 ++ gfx/layers/opengl/CompositorOGL.cpp | 117 +++++++++++--------------- gfx/layers/opengl/FPSCounter.h | 3 +- gfx/layers/opengl/LayerManagerOGL.cpp | 2 +- 4 files changed, 59 insertions(+), 71 deletions(-) diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 98010f8c3925..6b9548e0fb01 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -420,6 +420,14 @@ protected: uint32_t mCompositorID; static LayersBackend sBackend; DiagnosticTypes mDiagnosticTypes; + + /** + * We keep track of the total number of pixels filled as we composite the + * current frame. This value is an approximation and is not accurate, + * especially in the presence of transforms. + */ + size_t mPixelsPerFrame; + size_t mPixelsFilled; }; } // namespace layers diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index ef882f8c3d65..4799aeaa5cac 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -106,15 +106,11 @@ DrawWithVertexBuffer2(GLContext *aGLContext, VBOArena &aVBOs, } void -FPSState::DrawFPS(TimeStamp aNow, - GLContext* context, ShaderProgramOGL* copyprog) +FPSState::DrawCounter(float offset, + unsigned value, + GLContext* context, + ShaderProgramOGL* copyprog) { - int fps = int(mCompositionFps.AddFrameAndGetFps(aNow)); - int txnFps = int(mTransactionFps.GetFpsAt(aNow)); - - GLint viewport[4]; - context->fGetIntegerv(LOCAL_GL_VIEWPORT, viewport); - if (!mTexture) { // Bind the number of textures we need, in this case one. context->fGenTextures(1, &mTexture); @@ -144,7 +140,8 @@ FPSState::DrawFPS(TimeStamp aNow, free(buf); } - mVBOs.Reset(); + GLint viewport[4]; + context->fGetIntegerv(LOCAL_GL_VIEWPORT, viewport); struct Vertex2D { float x,y; @@ -152,49 +149,26 @@ FPSState::DrawFPS(TimeStamp aNow, float oneOverVP2 = 1.0 / viewport[2]; float oneOverVP3 = 1.0 / viewport[3]; const Vertex2D vertices[] = { - { -1.0f, 1.0f - 42.f * oneOverVP3 }, - { -1.0f, 1.0f}, - { -1.0f + 22.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 22.f * oneOverVP2, 1.0f }, + { -1.0f + (offset + 0.f) * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, + { -1.0f + (offset + 0.f) * oneOverVP2, 1.0f}, + { -1.0f + (offset + 22.f) * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, + { -1.0f + (offset + 22.f) * oneOverVP2, 1.0f }, - { -1.0f + 22.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 22.f * oneOverVP2, 1.0f }, - { -1.0f + 44.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 44.f * oneOverVP2, 1.0f }, + { -1.0f + (offset + 22.f) * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, + { -1.0f + (offset + 22.f) * oneOverVP2, 1.0f }, + { -1.0f + (offset + 44.f) * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, + { -1.0f + (offset + 44.f) * oneOverVP2, 1.0f }, - { -1.0f + 44.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 44.f * oneOverVP2, 1.0f }, - { -1.0f + 66.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 66.f * oneOverVP2, 1.0f } + { -1.0f + (offset + 44.f) * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, + { -1.0f + (offset + 44.f) * oneOverVP2, 1.0f }, + { -1.0f + (offset + 66.f) * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, + { -1.0f + (offset + 66.f) * oneOverVP2, 1.0f } }; - const Vertex2D vertices2[] = { - { -1.0f + 80.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 80.f * oneOverVP2, 1.0f }, - { -1.0f + 102.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 102.f * oneOverVP2, 1.0f }, + unsigned v1 = value % 10; + unsigned v10 = (value % 100) / 10; + unsigned v100 = (value % 1000) / 100; - { -1.0f + 102.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 102.f * oneOverVP2, 1.0f }, - { -1.0f + 124.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 124.f * oneOverVP2, 1.0f }, - - { -1.0f + 124.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 124.f * oneOverVP2, 1.0f }, - { -1.0f + 146.f * oneOverVP2, 1.0f - 42.f * oneOverVP3 }, - { -1.0f + 146.f * oneOverVP2, 1.0f }, - }; - - int v1 = fps % 10; - int v10 = (fps % 100) / 10; - int v100 = (fps % 1000) / 100; - - int txn1 = txnFps % 10; - int txn10 = (txnFps % 100) / 10; - int txn100 = (txnFps % 1000) / 100; - - // Feel free to comment these texture coordinates out and use one - // of the ones below instead, or play around with your own values. const GLfloat texCoords[] = { (v100 * 4.f) / 64, 7.f / 8, (v100 * 4.f) / 64, 0.0f, @@ -212,23 +186,6 @@ FPSState::DrawFPS(TimeStamp aNow, (v1 * 4.f + 4) / 64, 0.0f, }; - const GLfloat texCoords2[] = { - (txn100 * 4.f) / 64, 7.f / 8, - (txn100 * 4.f) / 64, 0.0f, - (txn100 * 4.f + 4) / 64, 7.f / 8, - (txn100 * 4.f + 4) / 64, 0.0f, - - (txn10 * 4.f) / 64, 7.f / 8, - (txn10 * 4.f) / 64, 0.0f, - (txn10 * 4.f + 4) / 64, 7.f / 8, - (txn10 * 4.f + 4) / 64, 0.0f, - - (txn1 * 4.f) / 64, 7.f / 8, - (txn1 * 4.f) / 64, 0.0f, - (txn1 * 4.f + 4) / 64, 7.f / 8, - (txn1 * 4.f + 4) / 64, 0.0f, - }; - // Turn necessary features on context->fEnable(LOCAL_GL_BLEND); context->fBlendFunc(LOCAL_GL_ONE, LOCAL_GL_SRC_COLOR); @@ -250,10 +207,21 @@ FPSState::DrawFPS(TimeStamp aNow, LOCAL_GL_TRIANGLE_STRIP, 12, vcattr, (GLfloat *) vertices, tcattr, (GLfloat *) texCoords); - DrawWithVertexBuffer2(context, mVBOs, - LOCAL_GL_TRIANGLE_STRIP, 12, - vcattr, (GLfloat *) vertices2, - tcattr, (GLfloat *) texCoords2); +} + +void +FPSState::DrawFPS(TimeStamp aNow, + unsigned aFillRatio, + GLContext* context, ShaderProgramOGL* copyprog) +{ + mVBOs.Reset(); + + unsigned fps = unsigned(mCompositionFps.AddFrameAndGetFps(aNow)); + unsigned txnFps = unsigned(mTransactionFps.GetFpsAt(aNow)); + + DrawCounter(0, fps, context, copyprog); + DrawCounter(80, txnFps, context, copyprog); + DrawCounter(160, aFillRatio, context, copyprog); } #ifdef CHECK_CURRENT_PROGRAM @@ -829,6 +797,9 @@ CompositorOGL::BeginFrame(const Rect *aClipRectIn, const gfxMatrix& aTransform, MakeCurrent(); } + mPixelsPerFrame = width * height; + mPixelsFilled = 0; + #if MOZ_ANDROID_OMTC TexturePoolOGL::Fill(gl()); #endif @@ -1053,6 +1024,8 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect, maskType = MaskNone; } + mPixelsFilled += aRect.width * aRect.height; + ShaderProgramType programType = GetProgramTypeForEffect(aEffectChain.mPrimaryEffect); ShaderProgramOGL *program = GetProgram(programType, maskType); program->Activate(); @@ -1314,7 +1287,13 @@ CompositorOGL::EndFrame() } if (mFPS) { - mFPS->DrawFPS(TimeStamp::Now(), mGLContext, GetProgram(Copy2DProgramType)); + double fillRatio = 0; + if (mPixelsFilled > 0.0f && mPixelsPerFrame > 0.0f) { + fillRatio = 100.0f * double(mPixelsFilled) / double(mPixelsPerFrame); + if (fillRatio > 999.0f) + fillRatio = 999.0f; + } + mFPS->DrawFPS(TimeStamp::Now(), unsigned(fillRatio), mGLContext, GetProgram(Copy2DProgramType)); } mGLContext->SwapBuffers(); diff --git a/gfx/layers/opengl/FPSCounter.h b/gfx/layers/opengl/FPSCounter.h index 95e94fe884a0..5bbbdfa235ff 100644 --- a/gfx/layers/opengl/FPSCounter.h +++ b/gfx/layers/opengl/FPSCounter.h @@ -75,7 +75,8 @@ struct FPSState { FPSState() : mTexture(0) { } - void DrawFPS(TimeStamp, gl::GLContext*, ShaderProgramOGL*); + void DrawCounter(float, unsigned, gl::GLContext*, ShaderProgramOGL*); + void DrawFPS(TimeStamp, unsigned, gl::GLContext*, ShaderProgramOGL*); void NotifyShadowTreeTransaction() { mTransactionFps.AddFrame(TimeStamp::Now()); diff --git a/gfx/layers/opengl/LayerManagerOGL.cpp b/gfx/layers/opengl/LayerManagerOGL.cpp index f44b6fa4a8b3..143e18124140 100644 --- a/gfx/layers/opengl/LayerManagerOGL.cpp +++ b/gfx/layers/opengl/LayerManagerOGL.cpp @@ -896,7 +896,7 @@ LayerManagerOGL::Render() } if (mFPS) { - mFPS->DrawFPS(TimeStamp::Now(), mGLContext, GetProgram(Copy2DProgramType)); + mFPS->DrawFPS(TimeStamp::Now(), 0, mGLContext, GetProgram(Copy2DProgramType)); } if (mGLContext->IsDoubleBuffered()) { From c3d3652f49b53669f466bf2ec4f100eb4a28e2ba Mon Sep 17 00:00:00 2001 From: "Adam Roach [:abr]" Date: Thu, 5 Sep 2013 15:11:47 -0500 Subject: [PATCH 08/69] Bug 880067 - Part 4: Video Conduit configuration for RTCP feedback r=ekr --- media/webrtc/signaling/signaling.gyp | 1 + .../signaling/src/media-conduit/CodecConfig.h | 30 ++++-- .../src/media-conduit/VideoConduit.cpp | 101 ++++++++++++++---- .../signaling/src/media/VcmSIPCCBinding.cpp | 6 +- .../signaling/src/sipcc/core/gsm/gsm_sdp.c | 24 ++--- .../webrtc/signaling/src/sipcc/core/sdp/sdp.h | 50 --------- .../signaling/src/sipcc/include/ccsdp.h | 1 + .../src/sipcc/include/ccsdp_rtcp_fb.h | 96 +++++++++++++++++ .../signaling/test/mediaconduit_unittests.cpp | 12 +-- 9 files changed, 224 insertions(+), 97 deletions(-) create mode 100644 media/webrtc/signaling/src/sipcc/include/ccsdp_rtcp_fb.h diff --git a/media/webrtc/signaling/signaling.gyp b/media/webrtc/signaling/signaling.gyp index ad53174806dd..7e0972ad0562 100644 --- a/media/webrtc/signaling/signaling.gyp +++ b/media/webrtc/signaling/signaling.gyp @@ -587,6 +587,7 @@ './src/sipcc/include/ccapi_service.h', './src/sipcc/include/ccapi_types.h', './src/sipcc/include/ccsdp.h', + './src/sipcc/include/ccsdp_rtcp_fb.h', './src/sipcc/include/config_api.h', './src/sipcc/include/dns_util.h', './src/sipcc/include/plat_api.h', diff --git a/media/webrtc/signaling/src/media-conduit/CodecConfig.h b/media/webrtc/signaling/src/media-conduit/CodecConfig.h index 6d7c894db792..9b5d7c9d8524 100755 --- a/media/webrtc/signaling/src/media-conduit/CodecConfig.h +++ b/media/webrtc/signaling/src/media-conduit/CodecConfig.h @@ -7,7 +7,7 @@ #define CODEC_CONFIG_H_ #include - +#include "ccsdp_rtcp_fb.h" namespace mozilla { @@ -56,16 +56,32 @@ struct VideoCodecConfig */ int mType; std::string mName; + uint32_t mRtcpFbTypes; - /* When we have resolution negotiation information (RFC 6236) - * it will be stored here. - */ - - VideoCodecConfig(int type, std::string name): mType(type), - mName(name) + VideoCodecConfig(int type, + std::string name, + int rtcpFbTypes): mType(type), + mName(name), + mRtcpFbTypes(rtcpFbTypes) { } + + bool RtcpFbIsSet(sdp_rtcp_fb_nack_type_e type) const + { + return mRtcpFbTypes & sdp_rtcp_fb_nack_to_bitmap(type); + } + + bool RtcpFbIsSet(sdp_rtcp_fb_ack_type_e type) const + { + return mRtcpFbTypes & sdp_rtcp_fb_ack_to_bitmap(type); + } + + bool RtcpFbIsSet(sdp_rtcp_fb_ccm_type_e type) const + { + return mRtcpFbTypes & sdp_rtcp_fb_ccm_to_bitmap(type); + } + }; } #endif diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index e18b8a12116b..b1256746e0ec 100644 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -5,6 +5,9 @@ #include "CSFLog.h" #include "nspr.h" +// For rtcp-fb constants +#include "ccsdp.h" + #include "VideoConduit.h" #include "AudioConduit.h" #include "webrtc/video_engine/include/vie_errors.h" @@ -245,22 +248,6 @@ MediaConduitErrorCode WebrtcVideoConduit::Init() mPtrViEBase->LastError()); return kMediaConduitRTCPStatusError; } - // Enable pli as key frame request method. - if(mPtrRTP->SetKeyFrameRequestMethod(mChannel, - webrtc::kViEKeyFrameRequestPliRtcp) != 0) - { - CSFLogError(logTag, "%s KeyFrameRequest Failed %d ", __FUNCTION__, - mPtrViEBase->LastError()); - return kMediaConduitKeyFrameRequestError; - } - // Enable lossless transport - // XXX Note: We may want to disable this or limit it - if (mPtrRTP->SetNACKStatus(mChannel, true) != 0) - { - CSFLogError(logTag, "%s NACKStatus Failed %d ", __FUNCTION__, - mPtrViEBase->LastError()); - return kMediaConduitNACKStatusError; - } CSFLogError(logTag, "%s Initialization Done", __FUNCTION__); return kMediaConduitNoError; } @@ -418,6 +405,16 @@ WebrtcVideoConduit::ConfigureSendMediaCodec(const VideoCodecConfig* codecConfig) mSendingWidth = 0; mSendingHeight = 0; + if(codecConfig->RtcpFbIsSet(SDP_RTCP_FB_NACK_BASIC)) { + CSFLogDebug(logTag, "Enabling NACK (send) for video stream\n"); + if (mPtrRTP->SetNACKStatus(mChannel, true) != 0) + { + CSFLogError(logTag, "%s NACKStatus Failed %d ", __FUNCTION__, + mPtrViEBase->LastError()); + return kMediaConduitNACKStatusError; + } + } + if(mPtrViEBase->StartSend(mChannel) == -1) { CSFLogError(logTag, "%s Start Send Error %d ", __FUNCTION__, @@ -428,8 +425,7 @@ WebrtcVideoConduit::ConfigureSendMediaCodec(const VideoCodecConfig* codecConfig) //Copy the applied codec for future reference delete mCurSendCodecConfig; - mCurSendCodecConfig = new VideoCodecConfig(codecConfig->mType, - codecConfig->mName); + mCurSendCodecConfig = new VideoCodecConfig(*codecConfig); mPtrRTP->SetRembStatus(mChannel, true, false); @@ -472,6 +468,9 @@ WebrtcVideoConduit::ConfigureRecvMediaCodecs( return kMediaConduitMalformedArgument; } + webrtc::ViEKeyFrameRequestMethod kf_request = webrtc::kViEKeyFrameRequestNone; + bool use_nack_basic = false; + //Try Applying the codecs in the list // we treat as success if atleast one codec was applied and reception was // started successfully. @@ -483,7 +482,25 @@ WebrtcVideoConduit::ConfigureRecvMediaCodecs( return condError; } + // Check for the keyframe request type: PLI is preferred + // over FIR, and FIR is preferred over none. + if (codecConfigList[i]->RtcpFbIsSet(SDP_RTCP_FB_NACK_PLI)) + { + kf_request = webrtc::kViEKeyFrameRequestPliRtcp; + } else if(kf_request == webrtc::kViEKeyFrameRequestNone && + codecConfigList[i]->RtcpFbIsSet(SDP_RTCP_FB_CCM_FIR)) + { + kf_request = webrtc::kViEKeyFrameRequestFirRtcp; + } + + // Check whether NACK is requested + if(codecConfigList[i]->RtcpFbIsSet(SDP_RTCP_FB_NACK_BASIC)) + { + use_nack_basic = true; + } + webrtc::VideoCodec video_codec; + mEngineReceiving = false; memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); //Retrieve pre-populated codec structure for our codec. @@ -523,6 +540,51 @@ WebrtcVideoConduit::ConfigureRecvMediaCodecs( return kMediaConduitInvalidReceiveCodec; } + // XXX Currently, we gather up all of the feedback types that the remote + // party indicated it supports for all video codecs and configure the entire + // conduit based on those capabilities. This is technically out of spec, + // as these values should be configured on a per-codec basis. However, + // the video engine only provides this API on a per-conduit basis, so that's + // how we have to do it. The approach of considering the remote capablities + // for the entire conduit to be a union of all remote codec capabilities + // (rather than the more conservative approach of using an intersection) + // is made to provide as many feedback mechanisms as are likely to be + // processed by the remote party (and should be relatively safe, since the + // remote party is required to ignore feedback types that it does not + // understand). + // + // Note that our configuration uses this union of remote capabilites as + // input to the configuration. It is not isomorphic to the configuration. + // For example, it only makes sense to have one frame request mechanism + // active at a time; so, if the remote party indicates more than one + // supported mechanism, we're only configuring the one we most prefer. + // + // See http://code.google.com/p/webrtc/issues/detail?id=2331 + + if (kf_request != webrtc::kViEKeyFrameRequestNone) + { + CSFLogDebug(logTag, "Enabling %s frame requests for video stream\n", + (kf_request == webrtc::kViEKeyFrameRequestPliRtcp ? + "PLI" : "FIR")); + if(mPtrRTP->SetKeyFrameRequestMethod(mChannel, kf_request) != 0) + { + CSFLogError(logTag, "%s KeyFrameRequest Failed %d ", __FUNCTION__, + mPtrViEBase->LastError()); + return kMediaConduitKeyFrameRequestError; + } + } + + if(use_nack_basic) + { + CSFLogDebug(logTag, "Enabling NACK (recv) for video stream\n"); + if (mPtrRTP->SetNACKStatus(mChannel, true) != 0) + { + CSFLogError(logTag, "%s NACKStatus Failed %d ", __FUNCTION__, + mPtrViEBase->LastError()); + return kMediaConduitNACKStatusError; + } + } + //Start Receive on the video engine if(mPtrViEBase->StartReceive(mChannel) == -1) { @@ -789,8 +851,7 @@ WebrtcVideoConduit::CodecConfigToWebRTCCodec(const VideoCodecConfig* codecInfo, bool WebrtcVideoConduit::CopyCodecToDB(const VideoCodecConfig* codecInfo) { - VideoCodecConfig* cdcConfig = new VideoCodecConfig(codecInfo->mType, - codecInfo->mName); + VideoCodecConfig* cdcConfig = new VideoCodecConfig(*codecInfo); mRecvCodecList.push_back(cdcConfig); return true; } diff --git a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp index 53af816c1be7..cef2fcd7ed47 100644 --- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp +++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp @@ -1486,7 +1486,8 @@ static int vcmRxStartICE_m(cc_mcapid_t mcap_id, { config_raw = new mozilla::VideoCodecConfig( payloads[i].remote_rtp_pt, - ccsdpCodecName(payloads[i].codec_type)); + ccsdpCodecName(payloads[i].codec_type), + payloads[i].video.rtcp_fb_types); configs.push_back(config_raw); } @@ -2117,7 +2118,8 @@ static int vcmTxStartICE_m(cc_mcapid_t mcap_id, mozilla::VideoCodecConfig *config_raw; config_raw = new mozilla::VideoCodecConfig( payload->remote_rtp_pt, - ccsdpCodecName(payload->codec_type)); + ccsdpCodecName(payload->codec_type), + payload->video.rtcp_fb_types); // Take possession of this pointer mozilla::ScopedDeletePtr config(config_raw); diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c index 531f2d9fc8c0..6d1abf54219d 100644 --- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c @@ -4542,21 +4542,21 @@ gsmsdp_add_rtcp_fb (int level, sdp_t *sdp_p, /* Add requested a=rtcp-fb:nack attributes */ for (j = 0; j < SDP_MAX_RTCP_FB_NACK; j++) { - if (types & SDP_RTCP_FB_NACK_TO_BITMAP(j)) { + if (types & sdp_rtcp_fb_nack_to_bitmap(j)) { gsmsdp_set_rtcp_fb_nack_attribute(level, sdp_p, pt, j); } } /* Add requested a=rtcp-fb:ack attributes */ for (j = 0; j < SDP_MAX_RTCP_FB_ACK; j++) { - if (types & SDP_RTCP_FB_ACK_TO_BITMAP(j)) { + if (types & sdp_rtcp_fb_ack_to_bitmap(j)) { gsmsdp_set_rtcp_fb_nack_attribute(level, sdp_p, pt, j); } } /* Add requested a=rtcp-fb:ccm attributes */ for (j = 0; j < SDP_MAX_RTCP_FB_CCM; j++) { - if (types & SDP_RTCP_FB_CCM_TO_BITMAP(j)) { + if (types & sdp_rtcp_fb_ccm_to_bitmap(j)) { gsmsdp_set_rtcp_fb_ccm_attribute(level, sdp_p, pt, j); } } @@ -4626,7 +4626,7 @@ gsmsdp_negotiate_rtcp_fb (cc_sdp_t *cc_sdp_p, nack_type = sdp_attr_get_rtcp_fb_nack(cc_sdp_p->dest_sdp, level, remote_pt, i); if (nack_type >= 0 && nack_type < SDP_MAX_RTCP_FB_NACK) { - fb_types |= SDP_RTCP_FB_NACK_TO_BITMAP(nack_type); + fb_types |= sdp_rtcp_fb_nack_to_bitmap(nack_type); } i++; } while (nack_type != SDP_RTCP_FB_NACK_NOT_FOUND); @@ -4637,7 +4637,7 @@ gsmsdp_negotiate_rtcp_fb (cc_sdp_t *cc_sdp_p, ack_type = sdp_attr_get_rtcp_fb_ack(cc_sdp_p->dest_sdp, level, remote_pt, i); if (ack_type >= 0 && ack_type < SDP_MAX_RTCP_FB_ACK) { - fb_types |= SDP_RTCP_FB_ACK_TO_BITMAP(ack_type); + fb_types |= sdp_rtcp_fb_ack_to_bitmap(ack_type); } i++; } while (ack_type != SDP_RTCP_FB_ACK_NOT_FOUND); @@ -4648,7 +4648,7 @@ gsmsdp_negotiate_rtcp_fb (cc_sdp_t *cc_sdp_p, ccm_type = sdp_attr_get_rtcp_fb_ccm(cc_sdp_p->dest_sdp, level, remote_pt, i); if (ccm_type >= 0 && ccm_type < SDP_MAX_RTCP_FB_CCM) { - fb_types |= SDP_RTCP_FB_CCM_TO_BITMAP(ccm_type); + fb_types |= sdp_rtcp_fb_ccm_to_bitmap(ccm_type); } i++; } while (ccm_type != SDP_RTCP_FB_CCM_NOT_FOUND); @@ -4659,9 +4659,9 @@ gsmsdp_negotiate_rtcp_fb (cc_sdp_t *cc_sdp_p, switch (codec) { case RTP_VP8: fb_types &= - SDP_RTCP_FB_NACK_TO_BITMAP(SDP_RTCP_FB_NACK_BASIC) | - SDP_RTCP_FB_NACK_TO_BITMAP(SDP_RTCP_FB_NACK_PLI) | - SDP_RTCP_FB_CCM_TO_BITMAP(SDP_RTCP_FB_CCM_FIR); + sdp_rtcp_fb_nack_to_bitmap(SDP_RTCP_FB_NACK_BASIC) | + sdp_rtcp_fb_nack_to_bitmap(SDP_RTCP_FB_NACK_PLI) | + sdp_rtcp_fb_ccm_to_bitmap(SDP_RTCP_FB_CCM_FIR); break; default: fb_types = 0; @@ -5589,9 +5589,9 @@ gsmsdp_add_media_line (fsmdef_dcb_t *dcb_p, const cc_media_cap_t *media_cap, /* Add supported rtcp-fb types */ if (media_cap->type == SDP_MEDIA_VIDEO) { gsmsdp_add_rtcp_fb (level, dcb_p->sdp->src_sdp, RTP_VP8, - SDP_RTCP_FB_NACK_TO_BITMAP(SDP_RTCP_FB_NACK_BASIC) | - SDP_RTCP_FB_NACK_TO_BITMAP(SDP_RTCP_FB_NACK_PLI) | - SDP_RTCP_FB_CCM_TO_BITMAP(SDP_RTCP_FB_CCM_FIR)); + sdp_rtcp_fb_nack_to_bitmap(SDP_RTCP_FB_NACK_BASIC) | + sdp_rtcp_fb_nack_to_bitmap(SDP_RTCP_FB_NACK_PLI) | + sdp_rtcp_fb_ccm_to_bitmap(SDP_RTCP_FB_CCM_FIR)); } /* setup and connection attributes */ diff --git a/media/webrtc/signaling/src/sipcc/core/sdp/sdp.h b/media/webrtc/signaling/src/sipcc/core/sdp/sdp.h index 3f6a1042ea9c..38d152223eb0 100644 --- a/media/webrtc/signaling/src/sipcc/core/sdp/sdp.h +++ b/media/webrtc/signaling/src/sipcc/core/sdp/sdp.h @@ -474,51 +474,6 @@ typedef enum { SDP_RTCP_UNICAST_MODE_NOT_PRESENT } sdp_rtcp_unicast_mode_e; -/* a=rtcp-fb enumerations */ - -typedef enum { - SDP_RTCP_FB_ANY = -1, - SDP_RTCP_FB_ACK = 0, - SDP_RTCP_FB_CCM, - SDP_RTCP_FB_NACK, - SDP_RTCP_FB_TRR_INT, - SDP_MAX_RTCP_FB, - SDP_RTCP_FB_UNKNOWN -} sdp_rtcp_fb_type_e; - -typedef enum { - SDP_RTCP_FB_NACK_NOT_FOUND = -1, - SDP_RTCP_FB_NACK_BASIC = 0, - SDP_RTCP_FB_NACK_SLI, - SDP_RTCP_FB_NACK_PLI, - SDP_RTCP_FB_NACK_RPSI, - SDP_RTCP_FB_NACK_APP, - SDP_RTCP_FB_NACK_RAI, - SDP_RTCP_FB_NACK_TLLEI, - SDP_RTCP_FB_NACK_PSLEI, - SDP_RTCP_FB_NACK_ECN, - SDP_MAX_RTCP_FB_NACK, - SDP_RTCP_FB_NACK_UNKNOWN -} sdp_rtcp_fb_nack_type_e; - -typedef enum { - SDP_RTCP_FB_ACK_NOT_FOUND = -1, - SDP_RTCP_FB_ACK_RPSI = 0, - SDP_RTCP_FB_ACK_APP, - SDP_MAX_RTCP_FB_ACK, - SDP_RTCP_FB_ACK_UNKNOWN -} sdp_rtcp_fb_ack_type_e; - -typedef enum { - SDP_RTCP_FB_CCM_NOT_FOUND = -1, - SDP_RTCP_FB_CCM_FIR = 0, - SDP_RTCP_FB_CCM_TMMBR, - SDP_RTCP_FB_CCM_TSTR, - SDP_RTCP_FB_CCM_VBCM, - SDP_MAX_RTCP_FB_CCM, - SDP_RTCP_FB_CCM_UNKNOWN -} sdp_rtcp_fb_ccm_type_e; - typedef enum { SDP_CONNECTION_NOT_FOUND = -1, SDP_CONNECTION_NEW = 0, @@ -527,11 +482,6 @@ typedef enum { SDP_CONNECTION_UNKNOWN } sdp_connection_type_e; -#define SDP_RTCP_FB_NACK_TO_BITMAP(type) (1 << (type)) -#define SDP_RTCP_FB_ACK_TO_BITMAP(type) (1 << (SDP_MAX_RTCP_FB_NACK + (type))) -#define SDP_RTCP_FB_CCM_TO_BITMAP(type) (1 << (SDP_MAX_RTCP_FB_NACK + \ - SDP_MAX_RTCP_FB_ACK + (type))) - /* * sdp_srtp_fec_order_t * This type defines the order in which to perform FEC diff --git a/media/webrtc/signaling/src/sipcc/include/ccsdp.h b/media/webrtc/signaling/src/sipcc/include/ccsdp.h index e424b9c1088e..1238e617c23b 100644 --- a/media/webrtc/signaling/src/sipcc/include/ccsdp.h +++ b/media/webrtc/signaling/src/sipcc/include/ccsdp.h @@ -47,6 +47,7 @@ #define __CCSDP_H__ #include "cpr_types.h" +#include "ccsdp_rtcp_fb.h" #define SIPSDP_ILBC_MODE20 20 diff --git a/media/webrtc/signaling/src/sipcc/include/ccsdp_rtcp_fb.h b/media/webrtc/signaling/src/sipcc/include/ccsdp_rtcp_fb.h new file mode 100644 index 000000000000..3a732ca4a259 --- /dev/null +++ b/media/webrtc/signaling/src/sipcc/include/ccsdp_rtcp_fb.h @@ -0,0 +1,96 @@ +/* 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 __CCSDP_RTCP_FB_H__ +#define __CCSDP_RTCP_FB_H__ + +/* a=rtcp-fb enumerations */ + +typedef enum { + SDP_RTCP_FB_ANY = -1, + SDP_RTCP_FB_ACK = 0, + SDP_RTCP_FB_CCM, + SDP_RTCP_FB_NACK, + SDP_RTCP_FB_TRR_INT, + SDP_MAX_RTCP_FB, + SDP_RTCP_FB_UNKNOWN +} sdp_rtcp_fb_type_e; + +typedef enum { + SDP_RTCP_FB_NACK_NOT_FOUND = -1, + SDP_RTCP_FB_NACK_BASIC = 0, + SDP_RTCP_FB_NACK_SLI, + SDP_RTCP_FB_NACK_PLI, + SDP_RTCP_FB_NACK_RPSI, + SDP_RTCP_FB_NACK_APP, + SDP_RTCP_FB_NACK_RAI, + SDP_RTCP_FB_NACK_TLLEI, + SDP_RTCP_FB_NACK_PSLEI, + SDP_RTCP_FB_NACK_ECN, + SDP_MAX_RTCP_FB_NACK, + SDP_RTCP_FB_NACK_UNKNOWN +} sdp_rtcp_fb_nack_type_e; + +typedef enum { + SDP_RTCP_FB_ACK_NOT_FOUND = -1, + SDP_RTCP_FB_ACK_RPSI = 0, + SDP_RTCP_FB_ACK_APP, + SDP_MAX_RTCP_FB_ACK, + SDP_RTCP_FB_ACK_UNKNOWN +} sdp_rtcp_fb_ack_type_e; + +typedef enum { + SDP_RTCP_FB_CCM_NOT_FOUND = -1, + SDP_RTCP_FB_CCM_FIR = 0, + SDP_RTCP_FB_CCM_TMMBR, + SDP_RTCP_FB_CCM_TSTR, + SDP_RTCP_FB_CCM_VBCM, + SDP_MAX_RTCP_FB_CCM, + SDP_RTCP_FB_CCM_UNKNOWN +} sdp_rtcp_fb_ccm_type_e; + +#ifdef __cplusplus +static_assert(SDP_MAX_RTCP_FB_NACK + + SDP_MAX_RTCP_FB_ACK + + SDP_MAX_RTCP_FB_CCM < 32, + "rtcp-fb Bitmap is larger than 32 bits"); +#endif + +static int32_t +sdp_rtcp_fb_nack_to_bitmap(sdp_rtcp_fb_nack_type_e type) +{ + int bitnumber = type; + + if (type < 0 || type >= SDP_MAX_RTCP_FB_NACK) { + return 0; + } + + return (1 << bitnumber); +} + +static int32_t +sdp_rtcp_fb_ack_to_bitmap(sdp_rtcp_fb_ack_type_e type) +{ + int bitnumber = type + SDP_MAX_RTCP_FB_NACK; + + if (type < 0 || type >= SDP_MAX_RTCP_FB_ACK) { + return 0; + } + + return (1 << bitnumber); +} + +static int32_t +sdp_rtcp_fb_ccm_to_bitmap(sdp_rtcp_fb_ccm_type_e type) +{ + int bitnumber = type + SDP_MAX_RTCP_FB_NACK + SDP_MAX_RTCP_FB_ACK; + + if (type < 0 || type >= SDP_MAX_RTCP_FB_CCM) { + return 0; + } + + return (1 << bitnumber); +} + +#endif diff --git a/media/webrtc/signaling/test/mediaconduit_unittests.cpp b/media/webrtc/signaling/test/mediaconduit_unittests.cpp index 16c46799651a..9de46eced66c 100644 --- a/media/webrtc/signaling/test/mediaconduit_unittests.cpp +++ b/media/webrtc/signaling/test/mediaconduit_unittests.cpp @@ -573,8 +573,8 @@ class TransportConduitTest : public ::testing::Test ASSERT_EQ(mozilla::kMediaConduitNoError, err); //configure send and recv codecs on theconduit - mozilla::VideoCodecConfig cinst1(120, "VP8"); - mozilla::VideoCodecConfig cinst2(124, "I420"); + mozilla::VideoCodecConfig cinst1(120, "VP8", 0); + mozilla::VideoCodecConfig cinst2(124, "I420", 0); std::vector rcvCodecList; @@ -637,8 +637,8 @@ class TransportConduitTest : public ::testing::Test cerr << " 1. Same Codec (VP8) Repeated Twice " << endl; cerr << " *************************************************" << endl; - mozilla::VideoCodecConfig cinst1(120, "VP8"); - mozilla::VideoCodecConfig cinst2(120, "VP8"); + mozilla::VideoCodecConfig cinst1(120, "VP8", 0); + mozilla::VideoCodecConfig cinst2(120, "VP8", 0); rcvCodecList.push_back(&cinst1); rcvCodecList.push_back(&cinst2); err = mVideoSession->ConfigureRecvMediaCodecs(rcvCodecList); @@ -654,8 +654,8 @@ class TransportConduitTest : public ::testing::Test cerr << " Setting payload 1 with name: I4201234tttttthhhyyyy89087987y76t567r7756765rr6u6676" << endl; cerr << " Setting payload 2 with name of zero length" << endl; - mozilla::VideoCodecConfig cinst3(124, "I4201234tttttthhhyyyy89087987y76t567r7756765rr6u6676"); - mozilla::VideoCodecConfig cinst4(124, ""); + mozilla::VideoCodecConfig cinst3(124, "I4201234tttttthhhyyyy89087987y76t567r7756765rr6u6676", 0); + mozilla::VideoCodecConfig cinst4(124, "", 0); rcvCodecList.push_back(&cinst3); rcvCodecList.push_back(&cinst4); From 2dd06df49034376ea694bf5b9e65aa515795d51a Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Thu, 12 Sep 2013 00:07:29 +0200 Subject: [PATCH 09/69] Follow-up fix for bug 915342 (pushed the original patch without fixing a nit). --- gfx/layers/opengl/CompositorOGL.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 4799aeaa5cac..9f83a8785cb7 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -1287,9 +1287,9 @@ CompositorOGL::EndFrame() } if (mFPS) { - double fillRatio = 0; - if (mPixelsFilled > 0.0f && mPixelsPerFrame > 0.0f) { - fillRatio = 100.0f * double(mPixelsFilled) / double(mPixelsPerFrame); + float fillRatio = 0; + if (mPixelsFilled > 0 && mPixelsPerFrame > 0) { + fillRatio = 100.0f * float(mPixelsFilled) / float(mPixelsPerFrame); if (fillRatio > 999.0f) fillRatio = 999.0f; } From d5909a2915dfd2318928a3b403426650527d6bbc Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Wed, 11 Sep 2013 15:15:45 -0700 Subject: [PATCH 10/69] Bug 914899 - Reinstate the OOL double truncation path in truncating values to int32. (r=jandem) --- js/src/jit/CodeGenerator.cpp | 53 ++++++++++++++++------ js/src/jit/IonMacroAssembler.cpp | 11 +++-- js/src/jit/IonMacroAssembler.h | 23 +++++----- js/src/jit/shared/CodeGenerator-shared.cpp | 13 +++++- js/src/jit/shared/CodeGenerator-shared.h | 1 + 5 files changed, 68 insertions(+), 33 deletions(-) diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index f88aab9dd41a..bfb1ef33df9d 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -166,20 +166,31 @@ CodeGenerator::visitValueToInt32(LValueToInt32 *lir) Label fails; if (lir->mode() == LValueToInt32::TRUNCATE) { + OutOfLineCode *oolDouble = oolTruncateDouble(temp, output); + if (!oolDouble) + return false; + // We can only handle strings in truncation contexts, like bitwise // operations. + Label *stringEntry, *stringRejoin; + Register stringReg; if (input->mightBeType(MIRType_String)) { - Register stringReg = ToRegister(lir->temp()); - OutOfLineCode *ool = oolCallVM(StringToNumberInfo, lir, (ArgList(), stringReg), - StoreFloatRegisterTo(temp)); - if (!ool) + stringReg = ToRegister(lir->temp()); + OutOfLineCode *oolString = oolCallVM(StringToNumberInfo, lir, (ArgList(), stringReg), + StoreFloatRegisterTo(temp)); + if (!oolString) return false; - - masm.truncateValueToInt32(operand, input, ool->entry(), ool->rejoin(), stringReg, - temp, output, &fails); + stringEntry = oolString->entry(); + stringRejoin = oolString->rejoin(); } else { - masm.truncateValueToInt32(operand, input, temp, output, &fails); + stringReg = InvalidReg; + stringEntry = NULL; + stringRejoin = NULL; } + + masm.truncateValueToInt32(operand, input, stringEntry, stringRejoin, oolDouble->entry(), + stringReg, temp, output, &fails); + masm.bind(oolDouble->rejoin()); } else { masm.convertValueToInt32(operand, input, temp, output, &fails, lir->mirNormal()->canBeNegativeZero()); @@ -6779,16 +6790,28 @@ CodeGenerator::visitClampVToUint8(LClampVToUint8 *lir) Register output = ToRegister(lir->output()); MDefinition *input = lir->mir()->input(); - Label fails; - if (input->mightBeType(MIRType_String)) { - OutOfLineCode *ool = oolCallVM(StringToNumberInfo, lir, (ArgList(), output), - StoreFloatRegisterTo(tempFloat)); - masm.clampValueToUint8(operand, input, ool->entry(), ool->rejoin(), output, - tempFloat, output, &fails); + OutOfLineCode *oolDouble = oolTruncateDouble(tempFloat, output); + if (!oolDouble) + return false; + Label *stringEntry, *stringRejoin; + if (input->mightBeType(MIRType_String)) { + OutOfLineCode *oolString = oolCallVM(StringToNumberInfo, lir, (ArgList(), output), + StoreFloatRegisterTo(tempFloat)); + if (!oolString) + return false; + stringEntry = oolString->entry(); + stringRejoin = oolString->rejoin(); } else { - masm.clampValueToUint8(operand, input, tempFloat, output, &fails); + stringEntry = NULL; + stringRejoin = NULL; } + + Label fails; + masm.clampValueToUint8(operand, input, + stringEntry, stringRejoin, oolDouble->entry(), + output, tempFloat, output, &fails); + if (!bailoutFrom(&fails, lir->snapshot())) return false; diff --git a/js/src/jit/IonMacroAssembler.cpp b/js/src/jit/IonMacroAssembler.cpp index d6458bece4ef..fb17f5957c7c 100644 --- a/js/src/jit/IonMacroAssembler.cpp +++ b/js/src/jit/IonMacroAssembler.cpp @@ -1535,8 +1535,8 @@ MacroAssembler::convertTypedOrValueToDouble(TypedOrValueRegister src, FloatRegis } void -MacroAssembler::convertDoubleToInt(FloatRegister src, Register output, Label *fail, - IntConversionBehavior behavior) +MacroAssembler::convertDoubleToInt(FloatRegister src, Register output, Label *truncateFail, + Label *fail, IntConversionBehavior behavior) { switch (behavior) { case IntConversion_Normal: @@ -1544,7 +1544,7 @@ MacroAssembler::convertDoubleToInt(FloatRegister src, Register output, Label *fa convertDoubleToInt32(src, output, fail, behavior == IntConversion_NegativeZeroCheck); break; case IntConversion_Truncate: - branchTruncateDouble(src, output, fail); + branchTruncateDouble(src, output, truncateFail ? truncateFail : fail); break; case IntConversion_ClampToUint8: clampDoubleToUint8(src, output); @@ -1555,6 +1555,7 @@ MacroAssembler::convertDoubleToInt(FloatRegister src, Register output, Label *fa void MacroAssembler::convertValueToInt(ValueOperand value, MDefinition *maybeInput, Label *handleStringEntry, Label *handleStringRejoin, + Label *truncateDoubleSlow, Register stringReg, FloatRegister temp, Register output, Label *fail, IntConversionBehavior behavior) { @@ -1613,7 +1614,7 @@ MacroAssembler::convertValueToInt(ValueOperand value, MDefinition *maybeInput, if (handleStrings) bind(handleStringRejoin); - convertDoubleToInt(temp, output, fail, behavior); + convertDoubleToInt(temp, output, truncateDoubleSlow, fail, behavior); jump(&done); } @@ -1724,7 +1725,7 @@ MacroAssembler::convertTypedOrValueToInt(TypedOrValueRegister src, FloatRegister move32(src.typedReg().gpr(), output); break; case MIRType_Double: - convertDoubleToInt(src.typedReg().fpu(), output, fail, behavior); + convertDoubleToInt(src.typedReg().fpu(), output, NULL, fail, behavior); break; case MIRType_String: case MIRType_Object: diff --git a/js/src/jit/IonMacroAssembler.h b/js/src/jit/IonMacroAssembler.h index cc6a7a669b5b..5fce99b1fa6e 100644 --- a/js/src/jit/IonMacroAssembler.h +++ b/js/src/jit/IonMacroAssembler.h @@ -1013,7 +1013,7 @@ class MacroAssembler : public MacroAssemblerSpecific // // Functions for converting values to int. // - void convertDoubleToInt(FloatRegister src, Register output, Label *fail, + void convertDoubleToInt(FloatRegister src, Register output, Label *truncateFail, Label *fail, IntConversionBehavior behavior); // Strings may be handled by providing labels to jump to when the behavior @@ -1022,12 +1022,13 @@ class MacroAssembler : public MacroAssemblerSpecific // double store into |temp|. void convertValueToInt(ValueOperand value, MDefinition *input, Label *handleStringEntry, Label *handleStringRejoin, + Label *truncateDoubleSlow, Register stringReg, FloatRegister temp, Register output, Label *fail, IntConversionBehavior behavior); void convertValueToInt(ValueOperand value, FloatRegister temp, Register output, Label *fail, IntConversionBehavior behavior) { - convertValueToInt(value, NULL, NULL, NULL, InvalidReg, temp, output, fail, behavior); + convertValueToInt(value, NULL, NULL, NULL, NULL, InvalidReg, temp, output, fail, behavior); } bool convertValueToInt(JSContext *cx, const Value &v, Register output, Label *fail, IntConversionBehavior behavior); @@ -1050,7 +1051,7 @@ class MacroAssembler : public MacroAssemblerSpecific FloatRegister temp, Register output, Label *fail, bool negativeZeroCheck) { - convertValueToInt(value, input, NULL, NULL, InvalidReg, temp, output, fail, + convertValueToInt(value, input, NULL, NULL, NULL, InvalidReg, temp, output, fail, negativeZeroCheck ? IntConversion_NegativeZeroCheck : IntConversion_Normal); @@ -1085,16 +1086,16 @@ class MacroAssembler : public MacroAssemblerSpecific } void truncateValueToInt32(ValueOperand value, MDefinition *input, Label *handleStringEntry, Label *handleStringRejoin, - Register stringReg, FloatRegister temp, Register output, - Label *fail) + Label *truncateDoubleSlow, + Register stringReg, FloatRegister temp, Register output, Label *fail) { - convertValueToInt(value, input, handleStringEntry, handleStringRejoin, + convertValueToInt(value, input, handleStringEntry, handleStringRejoin, truncateDoubleSlow, stringReg, temp, output, fail, IntConversion_Truncate); } void truncateValueToInt32(ValueOperand value, MDefinition *input, FloatRegister temp, Register output, Label *fail) { - convertValueToInt(value, input, NULL, NULL, InvalidReg, temp, output, fail, + convertValueToInt(value, input, NULL, NULL, NULL, InvalidReg, temp, output, fail, IntConversion_Truncate); } bool truncateValueToInt32(JSContext *cx, const Value &v, Register output, Label *fail) { @@ -1117,16 +1118,16 @@ class MacroAssembler : public MacroAssemblerSpecific } void clampValueToUint8(ValueOperand value, MDefinition *input, Label *handleStringEntry, Label *handleStringRejoin, - Register stringReg, FloatRegister temp, Register output, - Label *fail) + Label *truncateDoubleSlow, + Register stringReg, FloatRegister temp, Register output, Label *fail) { - convertValueToInt(value, input, handleStringEntry, handleStringRejoin, + convertValueToInt(value, input, handleStringEntry, handleStringRejoin, truncateDoubleSlow, stringReg, temp, output, fail, IntConversion_ClampToUint8); } void clampValueToUint8(ValueOperand value, MDefinition *input, FloatRegister temp, Register output, Label *fail) { - convertValueToInt(value, input, NULL, NULL, InvalidReg, temp, output, fail, + convertValueToInt(value, input, NULL, NULL, NULL, InvalidReg, temp, output, fail, IntConversion_ClampToUint8); } bool clampValueToUint8(JSContext *cx, const Value &v, Register output, Label *fail) { diff --git a/js/src/jit/shared/CodeGenerator-shared.cpp b/js/src/jit/shared/CodeGenerator-shared.cpp index 4e482103446f..d9bc4386ccac 100644 --- a/js/src/jit/shared/CodeGenerator-shared.cpp +++ b/js/src/jit/shared/CodeGenerator-shared.cpp @@ -675,11 +675,20 @@ class OutOfLineTruncateSlow : public OutOfLineCodeBase } }; -bool -CodeGeneratorShared::emitTruncateDouble(const FloatRegister &src, const Register &dest) +OutOfLineCode * +CodeGeneratorShared::oolTruncateDouble(const FloatRegister &src, const Register &dest) { OutOfLineTruncateSlow *ool = new OutOfLineTruncateSlow(src, dest); if (!addOutOfLineCode(ool)) + return NULL; + return ool; +} + +bool +CodeGeneratorShared::emitTruncateDouble(const FloatRegister &src, const Register &dest) +{ + OutOfLineCode *ool = oolTruncateDouble(src, dest); + if (!ool) return false; masm.branchTruncateDouble(src, dest, ool->entry()); diff --git a/js/src/jit/shared/CodeGenerator-shared.h b/js/src/jit/shared/CodeGenerator-shared.h index 39b313d08a63..16ba09a3d0cd 100644 --- a/js/src/jit/shared/CodeGenerator-shared.h +++ b/js/src/jit/shared/CodeGenerator-shared.h @@ -283,6 +283,7 @@ class CodeGeneratorShared : public LInstructionVisitor // an invalidation marker. void ensureOsiSpace(); + OutOfLineCode *oolTruncateDouble(const FloatRegister &src, const Register &dest); bool emitTruncateDouble(const FloatRegister &src, const Register &dest); void emitPreBarrier(Register base, const LAllocation *index, MIRType type); From 7b2e2a93a1016ecd6d098b3ae08bf6022a6f8afe Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 11 Sep 2013 15:24:09 -0700 Subject: [PATCH 11/69] Bug 914325 - Leave ourselves some room to make the call into chrome. r=luke --- js/xpconnect/tests/chrome/test_bug732665.xul | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/xpconnect/tests/chrome/test_bug732665.xul b/js/xpconnect/tests/chrome/test_bug732665.xul index f3884038f115..3a77918987c3 100644 --- a/js/xpconnect/tests/chrome/test_bug732665.xul +++ b/js/xpconnect/tests/chrome/test_bug732665.xul @@ -59,10 +59,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=732665 ok(chromeLimit >= contentLimit + 10, "Chrome should be able to have at least 10 heavy frames more stack than content: " + chromeLimit + ", " + contentLimit); - // Exhaust the stack space in content, and then make sure we can still get 10 heavy frames in chrome. + // Exhaust the stack space in content, and then make sure we can still get 10 + // heavy frames in chrome. + // + // Note that sometimes, if we pass |0| to nearNativeStackLimit, we can end up + // so close to the border in content that we can't even get ourselves together + // enough to make the cross-compartment call. So rather than exhausting the + // stack entirely and then checking for 10 chrome frames, we leave ourselves + // one frame's worth, and check for 11. contentSb.nnslChrome = chromeSb.nearNativeStackLimit; - var nestedLimit = Cu.evalInSandbox("nearNativeStackLimit(0, function() { nestedLimit = nnslChrome(0);}); nestedLimit;", contentSb); - ok(nestedLimit >= 10, "Chrome should be invokable from content script with an exhausted stack: " + nestedLimit); + var nestedLimit = Cu.evalInSandbox("nearNativeStackLimit(1, function() { nestedLimit = nnslChrome(0);}); nestedLimit;", contentSb); + ok(nestedLimit >= 11, "Chrome should be invokable from content script with an exhausted stack: " + nestedLimit); ]]> From 10ac32e77a36f60df3f616eca1ac3be17b2dba36 Mon Sep 17 00:00:00 2001 From: Dirk Schulze Date: Wed, 11 Sep 2013 15:24:03 -0700 Subject: [PATCH 12/69] Bug 896050 - Implement animation of CSS filter property. r=dholbert --- layout/style/nsCSSPropList.h | 2 +- layout/style/nsStyleAnimation.cpp | 325 ++++++++++++++++-- layout/style/nsStyleAnimation.h | 6 +- .../test/test_transitions_per_property.html | 230 +++++++++++++ 4 files changed, 532 insertions(+), 31 deletions(-) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 1fd3ffcc0017..e2a217225557 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -3374,7 +3374,7 @@ CSS_PROP_SVGRESET( 0, nullptr, CSS_PROP_NO_OFFSET, - eStyleAnimType_None) + eStyleAnimType_Custom) CSS_PROP_SVGRESET( flood-color, flood_color, diff --git a/layout/style/nsStyleAnimation.cpp b/layout/style/nsStyleAnimation.cpp index baa602b9bda0..66a7dc448ed6 100644 --- a/layout/style/nsStyleAnimation.cpp +++ b/layout/style/nsStyleAnimation.cpp @@ -248,6 +248,34 @@ nscoordToCSSValue(nscoord aCoord, nsCSSValue& aCSSValue) eCSSUnit_Pixel); } +static void +AppendCSSShadowValue(const nsCSSShadowItem *aShadow, + nsCSSValueList **&aResultTail) +{ + NS_ABORT_IF_FALSE(aShadow, "shadow expected"); + + // X, Y, Radius, Spread, Color, Inset + nsRefPtr arr = nsCSSValue::Array::Create(6); + nscoordToCSSValue(aShadow->mXOffset, arr->Item(0)); + nscoordToCSSValue(aShadow->mYOffset, arr->Item(1)); + nscoordToCSSValue(aShadow->mRadius, arr->Item(2)); + // NOTE: This code sometimes stores mSpread: 0 even when + // the parser would be required to leave it null. + nscoordToCSSValue(aShadow->mSpread, arr->Item(3)); + if (aShadow->mHasColor) { + arr->Item(4).SetColorValue(aShadow->mColor); + } + if (aShadow->mInset) { + arr->Item(5).SetIntValue(NS_STYLE_BOX_SHADOW_INSET, + eCSSUnit_Enumerated); + } + + nsCSSValueList *resultItem = new nsCSSValueList; + resultItem->mValue.SetArrayValue(arr, eCSSUnit_Array); + *aResultTail = resultItem; + aResultTail = &resultItem->mNext; +} + // Like nsStyleCoord::Calc, but with length in float pixels instead of nscoord. struct CalcValue { float mLength, mPercent; @@ -753,6 +781,8 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, aDistance = sqrt(squareDistance); return true; } + case eUnit_Filter: + // FIXME: Support paced animations for filter function interpolation. case eUnit_Transform: { return false; } @@ -1032,6 +1062,38 @@ AddCSSValuePixelPercentCalc(const uint32_t aValueRestrictions, return true; } +static inline float +GetNumberOrPercent(const nsCSSValue &aValue) +{ + nsCSSUnit unit = aValue.GetUnit(); + NS_ABORT_IF_FALSE(unit == eCSSUnit_Number || unit == eCSSUnit_Percent, + "unexpected unit"); + return (unit == eCSSUnit_Number) ? + aValue.GetFloatValue() : aValue.GetPercentValue(); +} + +static inline void +AddCSSValuePercentNumber(const uint32_t aValueRestrictions, + double aCoeff1, const nsCSSValue &aValue1, + double aCoeff2, const nsCSSValue &aValue2, + nsCSSValue &aResult, float aInitialVal) +{ + float n1 = GetNumberOrPercent(aValue1); + float n2 = GetNumberOrPercent(aValue2); + + // Rather than interpolating aValue1 and aValue2 directly, we + // interpolate their *distances from aInitialVal* (the initial value, + // which is either 1 or 0 for "filter" functions). This matters in + // cases where aInitialVal is nonzero and the coefficients don't add + // up to 1. For example, if initialVal is 1, aCoeff1 is 0.5, and + // aCoeff2 is 0, then we'll return the value halfway between 1 and + // aValue1, rather than the value halfway between 0 and aValue1. + // Note that we do something similar in AddTransformScale(). + float result = (n1 - aInitialVal) * aCoeff1 + (n2 - aInitialVal) * aCoeff2; + aResult.SetFloatValue(RestrictValue(aValueRestrictions, result + aInitialVal), + eCSSUnit_Number); +} + static bool AddShadowItems(double aCoeff1, const nsCSSValue &aValue1, double aCoeff2, const nsCSSValue &aValue2, @@ -1547,6 +1609,121 @@ TransformFunctionsMatch(nsCSSKeyword func1, nsCSSKeyword func2) return ToPrimitive(func1) == ToPrimitive(func2); } +static bool +AddFilterFunctionImpl(double aCoeff1, const nsCSSValueList* aList1, + double aCoeff2, const nsCSSValueList* aList2, + nsCSSValueList**& aResultTail) +{ + // AddFilterFunction should be our only caller, and it should ensure that both + // args are non-null. + NS_ABORT_IF_FALSE(aList1, "expected filter list"); + NS_ABORT_IF_FALSE(aList2, "expected filter list"); + NS_ABORT_IF_FALSE(aList1->mValue.GetUnit() == eCSSUnit_Function, + "expected function"); + NS_ABORT_IF_FALSE(aList2->mValue.GetUnit() == eCSSUnit_Function, + "expected function"); + nsRefPtr a1 = aList1->mValue.GetArrayValue(), + a2 = aList2->mValue.GetArrayValue(); + nsCSSKeyword filterFunction = a1->Item(0).GetKeywordValue(); + if (filterFunction != a2->Item(0).GetKeywordValue()) + return false; // Can't add two filters of different types. + + nsAutoPtr resultListEntry(new nsCSSValueList); + nsCSSValue::Array* result = + resultListEntry->mValue.InitFunction(filterFunction, 1); + + // "hue-rotate" is the only filter-function that accepts negative values, and + // we don't use this "restrictions" variable in its clause below. + const uint32_t restrictions = CSS_PROPERTY_VALUE_NONNEGATIVE; + const nsCSSValue& funcArg1 = a1->Item(1); + const nsCSSValue& funcArg2 = a2->Item(1); + nsCSSValue& resultArg = result->Item(1); + float initialVal = 1.0f; + switch (filterFunction) { + case eCSSKeyword_blur: { + nsCSSUnit unit; + if (funcArg1.GetUnit() == funcArg2.GetUnit()) { + unit = funcArg1.GetUnit(); + } else { + // If units differ, we'll just combine them with calc(). + unit = eCSSUnit_Calc; + } + if (!AddCSSValuePixelPercentCalc(restrictions, + unit, + aCoeff1, funcArg1, + aCoeff2, funcArg2, + resultArg)) { + return false; + } + break; + } + case eCSSKeyword_grayscale: + case eCSSKeyword_invert: + case eCSSKeyword_sepia: + initialVal = 0.0f; + case eCSSKeyword_brightness: + case eCSSKeyword_contrast: + case eCSSKeyword_opacity: + case eCSSKeyword_saturate: + AddCSSValuePercentNumber(restrictions, + aCoeff1, funcArg1, + aCoeff2, funcArg2, + resultArg, + initialVal); + break; + case eCSSKeyword_hue_rotate: + AddCSSValueAngle(aCoeff1, funcArg1, + aCoeff2, funcArg2, + resultArg); + break; + case eCSSKeyword_drop_shadow: { + nsCSSValueList* resultShadow = resultArg.SetListValue(); + nsAutoPtr shadowValue; + nsCSSValueList **shadowTail = getter_Transfers(shadowValue); + NS_ABORT_IF_FALSE(!funcArg1.GetListValue()->mNext && + !funcArg2.GetListValue()->mNext, + "drop-shadow filter func doesn't support lists"); + if (!AddShadowItems(aCoeff1, funcArg1.GetListValue()->mValue, + aCoeff2, funcArg2.GetListValue()->mValue, + shadowTail)) { + return false; + } + *resultShadow = *shadowValue; + break; + } + default: + NS_ABORT_IF_FALSE(false, "unknown filter function"); + return false; + } + + *aResultTail = resultListEntry.forget(); + aResultTail = &(*aResultTail)->mNext; + + return true; +} + +static bool +AddFilterFunction(double aCoeff1, const nsCSSValueList* aList1, + double aCoeff2, const nsCSSValueList* aList2, + nsCSSValueList**& aResultTail) +{ + NS_ABORT_IF_FALSE(aList1 || aList2, + "one function list item must not be null"); + // Note that one of our arguments could be null, indicating that + // it's the initial value. Rather than adding special null-handling + // logic, we just check for null values and replace them with + // 0 * the other value. That way, AddFilterFunctionImpl can assume + // its args are non-null. + if (!aList1) { + return AddFilterFunctionImpl(aCoeff2, aList2, 0, aList2, aResultTail); + } + if (!aList2) { + return AddFilterFunctionImpl(aCoeff1, aList1, 0, aList1, aResultTail); + } + + return AddFilterFunctionImpl(aCoeff1, aList1, aCoeff2, aList2, aResultTail); +} + static nsCSSValueList* AddTransformLists(double aCoeff1, const nsCSSValueList* aList1, double aCoeff2, const nsCSSValueList* aList2) @@ -2060,6 +2237,44 @@ nsStyleAnimation::AddWeighted(nsCSSProperty aProperty, aResultValue.SetAndAdoptCSSValueListValue(result.forget(), eUnit_Shadow); return true; } + + case eUnit_Filter: { + const nsCSSValueList *list1 = aValue1.GetCSSValueListValue(); + const nsCSSValueList *list2 = aValue2.GetCSSValueListValue(); + + nsAutoPtr result; + nsCSSValueList **resultTail = getter_Transfers(result); + while (list1 || list2) { + NS_ABORT_IF_FALSE(!*resultTail, + "resultTail isn't pointing to the tail (may leak)"); + if ((list1 && list1->mValue.GetUnit() != eCSSUnit_Function) || + (list2 && list2->mValue.GetUnit() != eCSSUnit_Function)) { + // If we don't have filter-functions, we must have filter-URLs, which + // we can't add or interpolate. + return false; + } + + if (!AddFilterFunction(aCoeff1, list1, aCoeff2, list2, resultTail)) { + // filter function mismatch + return false; + } + + // move to next list items + if (list1) { + list1 = list1->mNext; + } + if (list2) { + list2 = list2->mNext; + } + }; + NS_ABORT_IF_FALSE(!*resultTail, + "resultTail isn't pointing to the tail (may leak)"); + + aResultValue.SetAndAdoptCSSValueListValue(result.forget(), + eUnit_Filter); + return true; + } + case eUnit_Transform: { const nsCSSValueList *list1 = aValue1.GetCSSValueListValue(); const nsCSSValueList *list2 = aValue2.GetCSSValueListValue(); @@ -2432,6 +2647,7 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty, } break; case eUnit_Dasharray: case eUnit_Shadow: + case eUnit_Filter: case eUnit_Transform: case eUnit_BackgroundPosition: aSpecifiedValue. @@ -2544,12 +2760,27 @@ StyleCoordToCSSValue(const nsStyleCoord& aCoord, nsCSSValue& aCSSValue) case eStyleUnit_Coord: nscoordToCSSValue(aCoord.GetCoordValue(), aCSSValue); break; + case eStyleUnit_Factor: + aCSSValue.SetFloatValue(aCoord.GetFactorValue(), eCSSUnit_Number); + break; case eStyleUnit_Percent: aCSSValue.SetPercentValue(aCoord.GetPercentValue()); break; case eStyleUnit_Calc: SetCalcValue(aCoord.GetCalcValue(), aCSSValue); break; + case eStyleUnit_Degree: + aCSSValue.SetFloatValue(aCoord.GetAngleValue(), eCSSUnit_Degree); + break; + case eStyleUnit_Grad: + aCSSValue.SetFloatValue(aCoord.GetAngleValue(), eCSSUnit_Grad); + break; + case eStyleUnit_Radian: + aCSSValue.SetFloatValue(aCoord.GetAngleValue(), eCSSUnit_Radian); + break; + case eStyleUnit_Turn: + aCSSValue.SetFloatValue(aCoord.GetAngleValue(), eCSSUnit_Turn); + break; default: NS_ABORT_IF_FALSE(false, "unexpected unit"); return false; @@ -3012,6 +3243,63 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty, break; } + case eCSSProperty_filter: { + const nsStyleSVGReset *svgReset = + static_cast(styleStruct); + const nsTArray& filters = svgReset->mFilters; + nsAutoPtr result; + nsCSSValueList **resultTail = getter_Transfers(result); + for (uint32_t i = 0; i < filters.Length(); ++i) { + nsCSSValueList *item = new nsCSSValueList; + *resultTail = item; + resultTail = &item->mNext; + const nsStyleFilter& filter = filters[i]; + int32_t type = filter.GetType(); + if (type == NS_STYLE_FILTER_URL) { + nsIDocument* doc = aStyleContext->PresContext()->Document(); + nsRefPtr uriAsStringBuffer = + GetURIAsUtf16StringBuffer(filter.GetURL()); + nsRefPtr url = + new mozilla::css::URLValue(filter.GetURL(), + uriAsStringBuffer, + doc->GetDocumentURI(), + doc->NodePrincipal()); + item->mValue.SetURLValue(url); + } else { + nsCSSKeyword functionName = + nsCSSProps::ValueToKeywordEnum(type, + nsCSSProps::kFilterFunctionKTable); + nsCSSValue::Array* filterArray = + item->mValue.InitFunction(functionName, 1); + if (type >= NS_STYLE_FILTER_BLUR && type <= NS_STYLE_FILTER_HUE_ROTATE) { + if (!StyleCoordToCSSValue( + filter.GetFilterParameter(), + filterArray->Item(1))) { + return false; + } + } else if (type == NS_STYLE_FILTER_DROP_SHADOW) { + nsCSSValueList* shadowResult = filterArray->Item(1).SetListValue(); + nsAutoPtr tmpShadowValue; + nsCSSValueList **tmpShadowResultTail = getter_Transfers(tmpShadowValue); + nsCSSShadowArray* shadowArray = filter.GetDropShadow(); + NS_ABORT_IF_FALSE(shadowArray->Length() == 1, + "expected exactly one shadow"); + AppendCSSShadowValue(shadowArray->ShadowAt(0), tmpShadowResultTail); + *shadowResult = *tmpShadowValue; + } else { + // We checked all possible nsStyleFilter types but + // NS_STYLE_FILTER_NULL before. We should never enter this path. + NS_NOTREACHED("no other filter functions defined"); + return false; + } + } + } + + aComputedValue.SetAndAdoptCSSValueListValue(result.forget(), + eUnit_Filter); + break; + } + case eCSSProperty_transform: { const nsStyleDisplay *display = static_cast(styleStruct); @@ -3172,30 +3460,7 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty, nsAutoPtr result; nsCSSValueList **resultTail = getter_Transfers(result); for (uint32_t i = 0, i_end = shadowArray->Length(); i < i_end; ++i) { - const nsCSSShadowItem *shadow = shadowArray->ShadowAt(i); - // X, Y, Radius, Spread, Color, Inset - nsRefPtr arr = nsCSSValue::Array::Create(6); - nscoordToCSSValue(shadow->mXOffset, arr->Item(0)); - nscoordToCSSValue(shadow->mYOffset, arr->Item(1)); - nscoordToCSSValue(shadow->mRadius, arr->Item(2)); - // NOTE: This code sometimes stores mSpread: 0 even when - // the parser would be required to leave it null. - nscoordToCSSValue(shadow->mSpread, arr->Item(3)); - if (shadow->mHasColor) { - arr->Item(4).SetColorValue(shadow->mColor); - } - if (shadow->mInset) { - arr->Item(5).SetIntValue(NS_STYLE_BOX_SHADOW_INSET, - eCSSUnit_Enumerated); - } - - nsCSSValueList *resultItem = new nsCSSValueList; - if (!resultItem) { - return false; - } - resultItem->mValue.SetArrayValue(arr, eCSSUnit_Array); - *resultTail = resultItem; - resultTail = &resultItem->mNext; + AppendCSSShadowValue(shadowArray->ShadowAt(i), resultTail); } aComputedValue.SetAndAdoptCSSValueListValue(result.forget(), eUnit_Shadow); @@ -3299,12 +3564,14 @@ nsStyleAnimation::Value::operator=(const Value& aOther) mUnit = eUnit_Null; } break; + case eUnit_Filter: case eUnit_Dasharray: case eUnit_Shadow: case eUnit_Transform: case eUnit_BackgroundPosition: - NS_ABORT_IF_FALSE(mUnit == eUnit_Shadow || aOther.mValue.mCSSValueList, - "value lists other than shadows may not be null"); + NS_ABORT_IF_FALSE(mUnit == eUnit_Shadow || mUnit == eUnit_Filter || + aOther.mValue.mCSSValueList, + "value lists other than shadows and filters may not be null"); if (aOther.mValue.mCSSValueList) { mValue.mCSSValueList = aOther.mValue.mCSSValueList->Clone(); if (!mValue.mCSSValueList) { @@ -3453,8 +3720,9 @@ nsStyleAnimation::Value::SetAndAdoptCSSValueListValue( { FreeValue(); NS_ABORT_IF_FALSE(IsCSSValueListUnit(aUnit), "bad unit"); - NS_ABORT_IF_FALSE(aUnit != eUnit_Dasharray || aValueList != nullptr, - "dasharrays may not be null"); + NS_ABORT_IF_FALSE(aUnit != eUnit_Dasharray || aUnit != eUnit_Filter || + aValueList != nullptr, + "dasharrays and filters may not be null"); mUnit = aUnit; mValue.mCSSValueList = aValueList; // take ownership } @@ -3523,6 +3791,7 @@ nsStyleAnimation::Value::operator==(const Value& aOther) const case eUnit_CSSRect: return *mValue.mCSSRect == *aOther.mValue.mCSSRect; case eUnit_Dasharray: + case eUnit_Filter: case eUnit_Shadow: case eUnit_Transform: case eUnit_BackgroundPosition: diff --git a/layout/style/nsStyleAnimation.h b/layout/style/nsStyleAnimation.h index 2a5e5a69e476..6e4a61ee9807 100644 --- a/layout/style/nsStyleAnimation.h +++ b/layout/style/nsStyleAnimation.h @@ -221,6 +221,7 @@ public: eUnit_CSSValueTriplet, // nsCSSValueTriplet* (never null) eUnit_CSSRect, // nsCSSRect* (never null) eUnit_Dasharray, // nsCSSValueList* (never null) + eUnit_Filter, // nsCSSValueList* (may be null) eUnit_Shadow, // nsCSSValueList* (may be null) eUnit_Transform, // nsCSSValueList* (never null) eUnit_BackgroundPosition, // nsCSSValueList* (never null) @@ -380,8 +381,9 @@ public: return aUnit == eUnit_CSSRect; } static bool IsCSSValueListUnit(Unit aUnit) { - return aUnit == eUnit_Dasharray || aUnit == eUnit_Shadow || - aUnit == eUnit_Transform || aUnit == eUnit_BackgroundPosition; + return aUnit == eUnit_Dasharray || aUnit == eUnit_Filter || + aUnit == eUnit_Shadow || aUnit == eUnit_Transform || + aUnit == eUnit_BackgroundPosition; } static bool IsCSSValuePairListUnit(Unit aUnit) { return aUnit == eUnit_CSSValuePairList; diff --git a/layout/style/test/test_transitions_per_property.html b/layout/style/test/test_transitions_per_property.html index 05ab74279cc1..8e100f38c9a7 100644 --- a/layout/style/test/test_transitions_per_property.html +++ b/layout/style/test/test_transitions_per_property.html @@ -122,6 +122,7 @@ var supported_properties = { // opacity is clamped in computed style // (not parsing/interpolation) test_float_zeroToOne_clamped ], + "filter" : [ test_filter_transition ], "flood-color": [ test_color_transition ], "flood-opacity" : [ test_float_zeroToOne_transition, // opacity is clamped in computed style @@ -576,6 +577,156 @@ var transformTests = [ round_error_ok: true }, ]; +var filterTests = [ + { start: "none", end: "none", + expected: ["none"] }, + // function from none (number/length) + { start: "none", end: "brightness(0.5)", + expected: ["brightness", 0.875] }, + { start: "none", end: "contrast(0.5)", + expected: ["contrast", 0.875] }, + { start: "none", end: "grayscale(0.5)", + expected: ["grayscale", 0.125] }, + { start: "none", end: "invert(0.5)", + expected: ["invert", 0.125] }, + { start: "none", end: "opacity(0.5)", + expected: ["opacity", 0.875] }, + { start: "none", end: "saturate(0.5)", + expected: ["saturate", 0.875] }, + { start: "none", end: "sepia(0.5)", + expected: ["sepia", 0.125] }, + { start: "none", end: "blur(50px)", + expected: ["blur", 12.5] }, + // function to none (number/length) + { start: "brightness(0.5)", end: "none", + expected: ["brightness", 0.625] }, + { start: "contrast(0.5)", end: "none", + expected: ["contrast", 0.625] }, + { start: "grayscale(0.5)", end: "none", + expected: ["grayscale", 0.375] }, + { start: "invert(0.5)", end: "none", + expected: ["invert", 0.375] }, + { start: "opacity(0.5)", end: "none", + expected: ["opacity", 0.625] }, + { start: "saturate(0.5)", end: "none", + expected: ["saturate", 0.625] }, + { start: "sepia(0.5)", end: "none", + expected: ["sepia", 0.375] }, + { start: "blur(50px)", end: "none", + expected: ["blur", 37.5] }, + // function to same function (number/length) + { start: "brightness(0.25)", end: "brightness(0.75)", + expected: ["brightness", 0.375] }, + { start: "contrast(0.25)", end: "contrast(0.75)", + expected: ["contrast", 0.375] }, + { start: "grayscale(0.25)", end: "grayscale(0.75)", + expected: ["grayscale", 0.375] }, + { start: "invert(0.25)", end: "invert(0.75)", + expected: ["invert", 0.375] }, + { start: "opacity(0.25)", end: "opacity(0.75)", + expected: ["opacity", 0.375] }, + { start: "saturate(0.25)", end: "saturate(0.75)", + expected: ["saturate", 0.375] }, + { start: "sepia(0.25)", end: "sepia(0.75)", + expected: ["sepia", 0.375] }, + { start: "blur(25px)", end: "blur(75px)", + expected: ["blur", 37.5] }, + // function to same function (percent) + { start: "brightness(25%)", end: "brightness(75%)", + expected: ["brightness", 0.375] }, + { start: "contrast(25%)", end: "contrast(75%)", + expected: ["contrast", 0.375] }, + { start: "grayscale(25%)", end: "grayscale(75%)", + expected: ["grayscale", 0.375] }, + { start: "invert(25%)", end: "invert(75%)", + expected: ["invert", 0.375] }, + { start: "opacity(25%)", end: "opacity(75%)", + expected: ["opacity", 0.375] }, + { start: "saturate(25%)", end: "saturate(75%)", + expected: ["saturate", 0.375] }, + { start: "sepia(25%)", end: "sepia(75%)", + expected: ["sepia", 0.375] }, + // function to same function (percent, number/length) + { start: "brightness(0.25)", end: "brightness(75%)", + expected: ["brightness", 0.375] }, + { start: "contrast(25%)", end: "contrast(0.75)", + expected: ["contrast", 0.375] }, + // hue-rotate with different angle values + { start: "hue-rotate(0deg)", end: "hue-rotate(720deg)", + expected: ["hue-rotate", Math.PI.toFixed(5)] }, + { start: "hue-rotate(0rad)", end: "hue-rotate("+4*Math.PI+"rad)", + expected: ["hue-rotate", Math.PI.toFixed(5)] }, + { start: "hue-rotate(0grad)", end: "hue-rotate(800grad)", + expected: ["hue-rotate", Math.PI.toFixed(5)] }, + { start: "hue-rotate(0turn)", end: "hue-rotate(2turn)", + expected: ["hue-rotate", Math.PI.toFixed(5)] }, + { start: "hue-rotate(0deg)", end: "hue-rotate("+4*Math.PI+"rad)", + expected: ["hue-rotate", Math.PI.toFixed(5)] }, + { start: "hue-rotate(0turn)", end: "hue-rotate(800grad)", + expected: ["hue-rotate", Math.PI.toFixed(5)] }, + { start: "hue-rotate(0grad)", end: "hue-rotate("+4*Math.PI+"rad)", + expected: ["hue-rotate", Math.PI.toFixed(5)] }, + { start: "hue-rotate(0grad)", end: "hue-rotate(0turn)", + expected: ["hue-rotate", 0] }, + // multiple matching functions, same length + { start: "contrast(25%) brightness(0.25) blur(25px) sepia(75%)", + end: "contrast(75%) brightness(0.75) blur(75px) sepia(25%)", + expected: ["contrast", 0.375, "brightness", 0.375, "blur", 37.5, "sepia", 0.625] }, + { start: "invert(25%) brightness(0.25) blur(25px) invert(50%) brightness(0.5) blur(50px)", + end: "invert(75%) brightness(0.75) blur(75px)", + expected: ["invert", 0.375, "brightness", 0.375, "blur", 37.5, "invert", 0.375, "brightness", 0.625, "blur", 37.5] }, + // multiple matching functions, different length + { start: "contrast(25%) brightness(0.5) blur(50px)", + end: "contrast(75%)", + expected: ["contrast", 0.375, "brightness", 0.625, "blur", 37.5] }, + // mismatching filter functions + { start: "contrast(0%)", end: "blur(10px)", + expected: ["blur", 10] }, + // not supported interpolations + { start: "none", end: "url('#b')", + expected: ["url", "\""+document.URL+"#b\""] }, + { start: "url('#a')", end: "none", + expected: ["none"] }, + { start: "url('#a')", end: "url('#b')", + expected: ["url", "\""+document.URL+"#b\""] }, + { start: "url('#a')", end: "blur(10px)", + expected: ["blur", 10] }, + { start: "blur(10px)", end: "url('#a')", + expected: ["url", "\""+document.URL+"#a\""] }, + { start: "blur(0px) url('#a')", end: "blur(20px)", + expected: ["blur", 20] }, + { start: "blur(0px)", end: "blur(20px) url('#a')", + expected: ["blur", 20, "url", "\""+document.URL+"#a\""] }, + { start: "contrast(0.25) brightness(0.25) blur(25px)", + end: "contrast(0.75) url('#a')", + expected: ["contrast", 0.75, "url", "\""+document.URL+"#a\""] }, + { start: "contrast(0.25) brightness(0.25) blur(75px)", + end: "brightness(0.75) contrast(0.75) blur(25px)", + expected: ["brightness", 0.75, "contrast", 0.75, "blur", 25] }, + { start: "contrast(0.25) brightness(0.25) blur(25px)", + end: "contrast(0.75) brightness(0.75) contrast(0.75)", + expected: ["contrast", 0.75, "brightness", 0.75, "contrast", 0.75] }, + // drop-shadow animation + { start: "none", + end: "drop-shadow(rgb(0, 0, 0) 4px 4px 0px)", + expected: ["drop-shadow", "rgba(0, 0, 0, 0.25) 1px 1px 0px"] }, + { start: "drop-shadow(rgb(0, 0, 0) 0px 0px 0px)", + end: "drop-shadow(rgb(0, 0, 0) 4px 4px 0px)", + expected: ["drop-shadow", "rgb(0, 0, 0) 1px 1px 0px"] }, + { start: "drop-shadow(#038000 4px 4px)", + end: "drop-shadow(8px 8px 8px red)", + expected: ["drop-shadow", "rgb(66, 96, 0) 5px 5px 2px"] }, + { start: "blur(25px) drop-shadow(8px 8px)", + end: "blur(75px)", + expected: ["blur", 37.5, "drop-shadow", "rgb(0, 0, 0) 6px 6px 0px"] }, + { start: "blur(75px)", + end: "blur(25px) drop-shadow(8px 8px)", + expected: ["blur", 62.5, "drop-shadow", "rgb(0, 0, 0) 2px 2px 0px"] }, + { start: "drop-shadow(2px 2px blue)", + end: "none", + expected: ["drop-shadow", "rgba(0, 0, 255, 0.75) 1.5px 1.5px 0px"] }, +]; + var prop; for (prop in supported_properties) { // Test that prop is in the property database. @@ -995,6 +1146,85 @@ function test_border_color_transition(prop) { div.style.removeProperty("color"); } +function filter_function_list_equals(string, expectedList) +{ + // Check simple case "none" + if (string == "none" && string == expectedList[0]) { + return true; + } + // The regular expression does not filter out the last parenthesis. + // Remove last character for now. + is(string.substring(string.length - 1, string.length), ')', "Check if last character is close-paren.") + string = string.substring(0, string.length - 1); + var reg = /\)*\s*(blur|brightness|contrast|grayscale|hue\-rotate|invert|opacity|saturate|sepia|drop\-shadow|url)\(/ + var matches = string.split(reg); + // First item must be empty. All other items are of functionName, functionValue. + if (!matches || matches.shift() != "") { + ok(false, "computed style of 'filter' isn't in the format we expect"); + return false; + } + + // Odd items are the function name, even items the function value. + if (!matches.length || matches.length % 2 || + expectedList.length != matches.length) { + ok(false, "computed style of 'filter' isn't in the format we expect"); + return false; + } + for (var i = 0; i < matches.length; i += 2) { + var functionName = matches[i]; + var functionValue = matches[i+1]; + var expected = expectedList[i+1] + var tolerance = 0; + // Check if we have the expected function. + if (functionName != expectedList[i]) { + return false; + } + if (functionName == "blur") { + // Last two characters must be "px". + if (functionValue.search("px") != functionValue.length - 2) { + return false; + } + functionValue = functionValue.substring(0, functionValue.length - 2); + } else if (functionName == "hue-rotate") { + // Last two characters must be "rad". + if (functionValue.search("rad") != functionValue.length - 3) { + return false; + } + tolerance = 0.001; + functionValue = functionValue.substring(0, functionValue.length - 3); + } else if (functionName == "drop-shadow" || functionName == "url") { + if (functionValue != expected) { + return false; + } + continue; + } + // Check if string is not a number or difference is not in tolerance level. + if (isNaN(functionValue) || + Math.abs(parseFloat(functionValue) - expected) > tolerance) { + return false; + } + } + return true; +} + +function test_filter_transition(prop) { + if (!SpecialPowers.getBoolPref("layout.css.filters.enabled")) { + return; + } + for (var i in filterTests) { + var test = filterTests[i]; + div.style.setProperty("transition-property", "none", ""); + div.style.setProperty(prop, test.start, ""); + cs.getPropertyValue(prop); + div.style.setProperty("transition-property", prop, ""); + div.style.setProperty(prop, test.end, ""); + var actual = cs.getPropertyValue(prop); + ok(filter_function_list_equals(actual, test.expected), + "Filter property is " + actual + " expected values of " + + test.expected); + } +} + function test_shadow_transition(prop) { var spreadStr = (prop == "box-shadow") ? " 0px" : ""; From 9cd2fb6d368a365a5aaa8d593fcd70f91f835d73 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Wed, 11 Sep 2013 15:24:04 -0700 Subject: [PATCH 13/69] Bug 896050 followup: fix some nits in the filter animation mochitest code. (test-only, no review) --- .../style/test/test_transitions_per_property.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/layout/style/test/test_transitions_per_property.html b/layout/style/test/test_transitions_per_property.html index 8e100f38c9a7..a82393e924e5 100644 --- a/layout/style/test/test_transitions_per_property.html +++ b/layout/style/test/test_transitions_per_property.html @@ -1146,18 +1146,21 @@ function test_border_color_transition(prop) { div.style.removeProperty("color"); } -function filter_function_list_equals(string, expectedList) +function filter_function_list_equals(computedValStr, expectedList) { // Check simple case "none" - if (string == "none" && string == expectedList[0]) { + if (computedValStr == "none" && computedValStr == expectedList[0]) { return true; } + // The regular expression does not filter out the last parenthesis. // Remove last character for now. - is(string.substring(string.length - 1, string.length), ')', "Check if last character is close-paren.") - string = string.substring(0, string.length - 1); + is(computedValStr.substring(computedValStr.length - 1, computedValStr.length), + ')', "Check if last character is close-paren"); + computedValStr = computedValStr.substring(0, computedValStr.length - 1); + var reg = /\)*\s*(blur|brightness|contrast|grayscale|hue\-rotate|invert|opacity|saturate|sepia|drop\-shadow|url)\(/ - var matches = string.split(reg); + var matches = computedValStr.split(reg); // First item must be empty. All other items are of functionName, functionValue. if (!matches || matches.shift() != "") { ok(false, "computed style of 'filter' isn't in the format we expect"); From 1cd12ac2e44d58c2905740005c2dac62844e6920 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Thu, 12 Sep 2013 10:34:27 +1200 Subject: [PATCH 14/69] Bug 894497. Weaken the assertion in GetAnimationRule. r=dbaron --- layout/style/nsAnimationManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 4d87816cd740..957c82337509 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -981,7 +981,8 @@ nsAnimationManager::GetAnimationRule(mozilla::dom::Element* aElement, return nullptr; } - NS_WARN_IF_FALSE(ea->mStyleRuleRefreshTime == + NS_WARN_IF_FALSE(!ea->mNeedsRefreshes || + ea->mStyleRuleRefreshTime == mPresContext->RefreshDriver()->MostRecentRefresh(), "should already have refreshed style rule"); From 3fe447f42f66451496232265c677f0ef26780f07 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Wed, 11 Sep 2013 10:35:04 -0400 Subject: [PATCH 15/69] Bug 914944 - Move PowerManager to mozilla::dom r=Ms2ger --- dom/base/Navigator.cpp | 6 ++---- dom/base/Navigator.h | 6 ++---- dom/bindings/Bindings.conf | 2 +- dom/power/PowerManager.cpp | 5 ++--- dom/power/PowerManager.h | 2 -- dom/power/WakeLock.cpp | 1 - dom/power/moz.build | 5 ++++- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 1091c5001516..ff5cad6dec60 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -25,7 +25,7 @@ #include "mozilla/Preferences.h" #include "mozilla/Telemetry.h" #include "BatteryManager.h" -#include "PowerManager.h" +#include "mozilla/dom/PowerManager.h" #include "nsIDOMWakeLock.h" #include "nsIPowerManagerService.h" #include "mozilla/dom/MobileMessageManager.h" @@ -76,8 +76,6 @@ #include "mozilla/dom/NavigatorBinding.h" -using namespace mozilla::dom::power; - // This should not be in the namespace. DOMCI_DATA(Navigator, mozilla::dom::Navigator) @@ -1100,7 +1098,7 @@ Navigator::GetBattery(ErrorResult& aRv) return mBatteryManager; } -power::PowerManager* +PowerManager* Navigator::GetMozPower(ErrorResult& aRv) { if (!mPowerManager) { diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 3d10eb000bf6..5228bd305f44 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -97,9 +97,7 @@ class BluetoothManager; class Voicemail; #endif -namespace power { class PowerManager; -} // namespace power namespace time { class TimeManager; @@ -199,7 +197,7 @@ public: { aRv = GetBuildID(aBuildID); } - power::PowerManager* GetMozPower(ErrorResult& aRv); + PowerManager* GetMozPower(ErrorResult& aRv); bool JavaEnabled(ErrorResult& aRv); bool TaintEnabled() { @@ -327,7 +325,7 @@ private: #ifdef MOZ_B2G_FM nsRefPtr mFMRadio; #endif - nsRefPtr mPowerManager; + nsRefPtr mPowerManager; nsRefPtr mMobileMessageManager; #ifdef MOZ_B2G_RIL nsRefPtr mTelephony; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index f2d53e899d79..a194eab3872c 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -777,7 +777,7 @@ DOMInterfaces = { }, 'MozPowerManager': { - 'nativeType': 'mozilla::dom::power::PowerManager', + 'nativeType': 'mozilla::dom::PowerManager', }, 'MozStkCommandEvent' : { diff --git a/dom/power/PowerManager.cpp b/dom/power/PowerManager.cpp index fdb7a287639e..127dca5eaaf3 100644 --- a/dom/power/PowerManager.cpp +++ b/dom/power/PowerManager.cpp @@ -3,8 +3,9 @@ * 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 "mozilla/dom/PowerManager.h" + #include "mozilla/Hal.h" -#include "PowerManager.h" #include "WakeLock.h" #include "nsDOMClassInfoID.h" #include "nsIDOMWakeLockListener.h" @@ -19,7 +20,6 @@ namespace mozilla { namespace dom { -namespace power { NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PowerManager) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY @@ -205,6 +205,5 @@ PowerManager::CreateInstance(nsPIDOMWindow* aWindow) return powerManager.forget(); } -} // power } // dom } // mozilla diff --git a/dom/power/PowerManager.h b/dom/power/PowerManager.h index 492d0a889305..314236603a05 100644 --- a/dom/power/PowerManager.h +++ b/dom/power/PowerManager.h @@ -19,7 +19,6 @@ namespace mozilla { class ErrorResult; namespace dom { -namespace power { class PowerManager MOZ_FINAL : public nsIDOMMozWakeLockListener , public nsWrapperCache @@ -66,7 +65,6 @@ private: nsTArray > mListeners; }; -} // namespace power } // namespace dom } // namespace mozilla diff --git a/dom/power/WakeLock.cpp b/dom/power/WakeLock.cpp index aa27efb6b69e..93a8249655af 100644 --- a/dom/power/WakeLock.cpp +++ b/dom/power/WakeLock.cpp @@ -14,7 +14,6 @@ #include "nsIDOMWindow.h" #include "nsIDOMEvent.h" #include "nsPIDOMWindow.h" -#include "PowerManager.h" DOMCI_DATA(MozWakeLock, mozilla::dom::power::WakeLock) diff --git a/dom/power/moz.build b/dom/power/moz.build index 267c6aca3cf2..d0a447583640 100644 --- a/dom/power/moz.build +++ b/dom/power/moz.build @@ -15,8 +15,11 @@ XPIDL_SOURCES += [ XPIDL_MODULE = 'dom_power' -EXPORTS.mozilla.dom.power += [ +EXPORTS.mozilla.dom += [ 'PowerManager.h', +] + +EXPORTS.mozilla.dom.power += [ 'PowerManagerService.h', 'Types.h', ] From 0f9e2adcb1a5b0120db1b1efa2a68cf5d2d917af Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Wed, 11 Sep 2013 18:35:51 -0400 Subject: [PATCH 16/69] Bug 911575 - Convert canvas callbacks to WebIDL r=bz --- .../html/content/public/HTMLCanvasElement.h | 55 ++++- .../html/content/src/HTMLCanvasElement.cpp | 208 ++++++++---------- dom/base/nsDOMClassInfo.cpp | 8 - dom/base/nsDOMClassInfoClasses.h | 3 - dom/bindings/Bindings.conf | 8 +- dom/bindings/CallbackObject.h | 3 + .../html/nsIDOMHTMLCanvasElement.idl | 33 --- .../mochitest/general/test_interfaces.html | 1 - dom/webidl/HTMLCanvasElement.webidl | 16 +- layout/generic/nsSimplePageSequence.cpp | 5 +- layout/printing/nsPrintEngine.cpp | 6 +- 11 files changed, 164 insertions(+), 182 deletions(-) diff --git a/content/html/content/public/HTMLCanvasElement.h b/content/html/content/public/HTMLCanvasElement.h index 9a6503638493..e1e06ba84655 100644 --- a/content/html/content/public/HTMLCanvasElement.h +++ b/content/html/content/public/HTMLCanvasElement.h @@ -31,7 +31,9 @@ class LayerManager; namespace dom { +class FileCallback; class HTMLCanvasPrintState; +class PrintCallback; class HTMLCanvasElement MOZ_FINAL : public nsGenericHTMLElement, public nsICanvasElementExternal, @@ -92,16 +94,10 @@ public: aRv = ToDataURL(aType, params, aCx, aDataURL); } void ToBlob(JSContext* aCx, - nsIFileCallback* aCallback, + FileCallback& aCallback, const nsAString& aType, const Optional >& aParams, - ErrorResult& aRv) - { - JS::Value params = aParams.WasPassed() - ? aParams.Value() - : JS::UndefinedValue(); - aRv = ToBlob(aCallback, aType, params, aCx); - } + ErrorResult& aRv); bool MozOpaque() const { @@ -126,8 +122,8 @@ public: { aRv = MozFetchAsStream(aCallback, aType); } - nsIPrintCallback* GetMozPrintCallback() const; - // Using XPCOM SetMozPrintCallback. + PrintCallback* GetMozPrintCallback() const; + void SetMozPrintCallback(PrintCallback* aCallback); /** * Get the size in pixels of this canvas element @@ -244,9 +240,9 @@ protected: nsString mCurrentContextId; nsRefPtr mOriginalCanvas; - nsCOMPtr mPrintCallback; + nsRefPtr mPrintCallback; nsCOMPtr mCurrentContext; - nsCOMPtr mPrintState; + nsRefPtr mPrintState; public: // Record whether this canvas should be write-only or not. @@ -266,6 +262,41 @@ public: HTMLCanvasElement* GetOriginalCanvas(); }; +class HTMLCanvasPrintState MOZ_FINAL : public nsWrapperCache +{ +public: + HTMLCanvasPrintState(HTMLCanvasElement* aCanvas, + nsICanvasRenderingContextInternal* aContext, + nsITimerCallback* aCallback); + + nsISupports* Context() const; + + void Done(); + + void NotifyDone(); + + bool mIsDone; + + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(HTMLCanvasPrintState) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(HTMLCanvasPrintState) + + virtual JSObject* WrapObject(JSContext *cx, JS::Handle scope) MOZ_OVERRIDE; + + HTMLCanvasElement* GetParentObject() + { + return mCanvas; + } + +private: + ~HTMLCanvasPrintState(); + bool mPendingNotify; + +protected: + nsRefPtr mCanvas; + nsCOMPtr mContext; + nsCOMPtr mCallback; +}; + } // namespace dom } // namespace mozilla diff --git a/content/html/content/src/HTMLCanvasElement.cpp b/content/html/content/src/HTMLCanvasElement.cpp index 67b60a340d94..950bc8a9e59a 100644 --- a/content/html/content/src/HTMLCanvasElement.cpp +++ b/content/html/content/src/HTMLCanvasElement.cpp @@ -48,9 +48,9 @@ HTMLImageOrCanvasOrVideoElement; class ToBlobRunnable : public nsRunnable { public: - ToBlobRunnable(nsIFileCallback* aCallback, + ToBlobRunnable(mozilla::dom::FileCallback& aCallback, nsIDOMBlob* aBlob) - : mCallback(aCallback), + : mCallback(&aCallback), mBlob(aBlob) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -59,11 +59,12 @@ public: NS_IMETHOD Run() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - mCallback->Receive(mBlob); - return NS_OK; + mozilla::ErrorResult rv; + mCallback->Call(mBlob, rv); + return rv.ErrorCode(); } private: - nsCOMPtr mCallback; + nsRefPtr mCallback; nsCOMPtr mBlob; }; @@ -72,76 +73,63 @@ private: namespace mozilla { namespace dom { -class HTMLCanvasPrintState : public nsIDOMMozCanvasPrintState +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_3(HTMLCanvasPrintState, mCanvas, + mContext, mCallback) + +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(HTMLCanvasPrintState, AddRef) +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(HTMLCanvasPrintState, Release) + +HTMLCanvasPrintState::HTMLCanvasPrintState(HTMLCanvasElement* aCanvas, + nsICanvasRenderingContextInternal* aContext, + nsITimerCallback* aCallback) + : mIsDone(false), mPendingNotify(false), mCanvas(aCanvas), + mContext(aContext), mCallback(aCallback) { -public: - HTMLCanvasPrintState(HTMLCanvasElement* aCanvas, - nsICanvasRenderingContextInternal* aContext, - nsITimerCallback* aCallback) - : mIsDone(false), mPendingNotify(false), mCanvas(aCanvas), - mContext(aContext), mCallback(aCallback) - { - } + SetIsDOMBinding(); +} - NS_IMETHOD GetContext(nsISupports** aContext) - { - NS_ADDREF(*aContext = mContext); - return NS_OK; - } +HTMLCanvasPrintState::~HTMLCanvasPrintState() +{ +} - NS_IMETHOD Done() - { - if (!mPendingNotify && !mIsDone) { - // The canvas needs to be invalidated for printing reftests on linux to - // work. - if (mCanvas) { - mCanvas->InvalidateCanvas(); - } - nsRefPtr > doneEvent = - NS_NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); - if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) { - mPendingNotify = true; - } +/* virtual */ JSObject* +HTMLCanvasPrintState::WrapObject(JSContext* aCx, JS::Handle aScope) +{ + return MozCanvasPrintStateBinding::Wrap(aCx, aScope, this); +} + +nsISupports* +HTMLCanvasPrintState::Context() const +{ + return mContext; +} + +void +HTMLCanvasPrintState::Done() +{ + if (!mPendingNotify && !mIsDone) { + // The canvas needs to be invalidated for printing reftests on linux to + // work. + if (mCanvas) { + mCanvas->InvalidateCanvas(); } - return NS_OK; - } - - void NotifyDone() - { - mIsDone = true; - mPendingNotify = false; - if (mCallback) { - mCallback->Notify(nullptr); + nsRefPtr > doneEvent = + NS_NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); + if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) { + mPendingNotify = true; } } +} - bool mIsDone; - - // CC - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(HTMLCanvasPrintState) -private: - virtual ~HTMLCanvasPrintState() - { +void +HTMLCanvasPrintState::NotifyDone() +{ + mIsDone = true; + mPendingNotify = false; + if (mCallback) { + mCallback->Notify(nullptr); } - bool mPendingNotify; - -protected: - nsRefPtr mCanvas; - nsCOMPtr mContext; - nsCOMPtr mCallback; -}; - -NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLCanvasPrintState) -NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLCanvasPrintState) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HTMLCanvasPrintState) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_INTERFACE_MAP_ENTRY(nsIDOMMozCanvasPrintState) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCanvasPrintState) -NS_INTERFACE_MAP_END - -NS_IMPL_CYCLE_COLLECTION_3(HTMLCanvasPrintState, mCanvas, mContext, mCallback) +} // --------------------------------------------------------------------------- @@ -226,11 +214,9 @@ HTMLCanvasElement::HandlePrintCallback(nsPresContext::nsPresContextType aType) // print preview mode, 2) the canvas has a print callback and 3) the callback // hasn't already been called. For real printing the callback is handled in // nsSimplePageSequenceFrame::PrePrintNextPage. - nsCOMPtr printCallback; if ((aType == nsPresContext::eContext_PageLayout || aType == nsPresContext::eContext_PrintPreview) && - !mPrintState && - NS_SUCCEEDED(GetMozPrintCallback(getter_AddRefs(printCallback))) && printCallback) { + !mPrintState && GetMozPrintCallback()) { DispatchPrintCallback(nullptr); } } @@ -256,9 +242,8 @@ HTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback) void HTMLCanvasElement::CallPrintCallback() { - nsCOMPtr printCallback; - GetMozPrintCallback(getter_AddRefs(printCallback)); - printCallback->Render(mPrintState); + ErrorResult rv; + GetMozPrintCallback()->Call(*mPrintState, rv); } void @@ -386,14 +371,13 @@ HTMLCanvasElement::MozFetchAsStream(nsIInputStreamCallback *aCallback, return asyncCallback->OnInputStreamReady(asyncData); } -NS_IMETHODIMP -HTMLCanvasElement::SetMozPrintCallback(nsIPrintCallback *aCallback) +void +HTMLCanvasElement::SetMozPrintCallback(PrintCallback* aCallback) { mPrintCallback = aCallback; - return NS_OK; } -nsIPrintCallback* +PrintCallback* HTMLCanvasElement::GetMozPrintCallback() const { if (mOriginalCanvas) { @@ -402,13 +386,6 @@ HTMLCanvasElement::GetMozPrintCallback() const return mPrintCallback; } -NS_IMETHODIMP -HTMLCanvasElement::GetMozPrintCallback(nsIPrintCallback** aCallback) -{ - NS_IF_ADDREF(*aCallback = GetMozPrintCallback()); - return NS_OK; -} - nsresult HTMLCanvasElement::ExtractData(const nsAString& aType, const nsAString& aOptions, @@ -571,59 +548,70 @@ HTMLCanvasElement::ToDataURLImpl(JSContext* aCx, } // XXXkhuey the encoding should be off the main thread, but we're lazy. -NS_IMETHODIMP -HTMLCanvasElement::ToBlob(nsIFileCallback* aCallback, +void +HTMLCanvasElement::ToBlob(JSContext* aCx, + FileCallback& aCallback, const nsAString& aType, - const JS::Value& aEncoderOptions, - JSContext* aCx) + const Optional >& aParams, + ErrorResult& aRv) { // do a trust check if this is a write-only canvas if (mWriteOnly && !nsContentUtils::IsCallerChrome()) { - return NS_ERROR_DOM_SECURITY_ERR; - } - - if (!aCallback) { - return NS_ERROR_UNEXPECTED; + aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); + return; } nsAutoString type; - nsresult rv = nsContentUtils::ASCIIToLower(aType, type); - if (NS_FAILED(rv)) { - return rv; + aRv = nsContentUtils::ASCIIToLower(aType, type); + if (aRv.Failed()) { + return; } + JS::Value encoderOptions = aParams.WasPassed() + ? aParams.Value() + : JS::UndefinedValue(); + nsAutoString params; bool usingCustomParseOptions; - rv = ParseParams(aCx, type, aEncoderOptions, params, &usingCustomParseOptions); - if (NS_FAILED(rv)) { - return rv; + aRv = ParseParams(aCx, type, encoderOptions, params, &usingCustomParseOptions); + if (aRv.Failed()) { + return; } bool fallbackToPNG = false; nsCOMPtr stream; - rv = ExtractData(type, params, getter_AddRefs(stream), fallbackToPNG); + aRv = ExtractData(type, params, getter_AddRefs(stream), fallbackToPNG); // If there are unrecognized custom parse options, we should fall back to // the default values for the encoder without any options at all. - if (rv == NS_ERROR_INVALID_ARG && usingCustomParseOptions) { + if (aRv.ErrorCode() == NS_ERROR_INVALID_ARG && usingCustomParseOptions) { fallbackToPNG = false; - rv = ExtractData(type, EmptyString(), getter_AddRefs(stream), fallbackToPNG); + aRv = ExtractData(type, EmptyString(), getter_AddRefs(stream), fallbackToPNG); } - NS_ENSURE_SUCCESS(rv, rv); + if (aRv.Failed()) { + return; + } if (fallbackToPNG) { type.AssignLiteral("image/png"); } uint64_t imgSize; - rv = stream->Available(&imgSize); - NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(imgSize <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG); + aRv = stream->Available(&imgSize); + if (aRv.Failed()) { + return; + } + if (imgSize > UINT32_MAX) { + aRv.Throw(NS_ERROR_FILE_TOO_BIG); + return; + } void* imgData = nullptr; - rv = NS_ReadInputStreamToBuffer(stream, &imgData, imgSize); - NS_ENSURE_SUCCESS(rv, rv); + aRv = NS_ReadInputStreamToBuffer(stream, &imgData, imgSize); + if (aRv.Failed()) { + return; + } // The DOMFile takes ownership of the buffer nsRefPtr blob = @@ -635,7 +623,7 @@ HTMLCanvasElement::ToBlob(nsIFileCallback* aCallback, } nsRefPtr runnable = new ToBlobRunnable(aCallback, blob); - return NS_DispatchToCurrentThread(runnable); + aRv = NS_DispatchToCurrentThread(runnable); } already_AddRefed @@ -1052,5 +1040,3 @@ HTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::Grap } // namespace dom } // namespace mozilla - -DOMCI_DATA(MozCanvasPrintState, mozilla::dom::HTMLCanvasPrintState) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 4518ef9f0348..a880f6e86200 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -38,7 +38,6 @@ #include "xptcall.h" #include "nsTArray.h" #include "nsDOMEventTargetHelper.h" -#include "nsIDOMHTMLCanvasElement.h" #include "nsContentList.h" #include "nsHTMLDocument.h" #include "nsDOMBlobBuilder.h" @@ -423,9 +422,6 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(MozCanvasPrintState, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(WindowUtils, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) @@ -1233,10 +1229,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumber) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(MozCanvasPrintState, nsIDOMMozCanvasPrintState) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCanvasPrintState) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor) DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor) DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 78c08c707d22..bd8c5eb4180f 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -65,9 +65,6 @@ DOMCI_CLASS(CSSSupportsRule) DOMCI_CLASS(SVGLength) DOMCI_CLASS(SVGNumber) -// Canvas -DOMCI_CLASS(MozCanvasPrintState) - // WindowUtils DOMCI_CLASS(WindowUtils) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index a194eab3872c..2cd462a60b9c 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -758,6 +758,10 @@ DOMInterfaces = { 'nativeType': 'nsDOMMouseScrollEvent', }, +'MozCanvasPrintState': { + 'headerFile': 'mozilla/dom/HTMLCanvasElement.h', + 'nativeType': 'mozilla::dom::HTMLCanvasPrintState', +}, 'MozChannel': [ { @@ -1785,8 +1789,6 @@ addExternalIface('CSSRuleList') addExternalIface('DOMStringList') addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel') addExternalIface('File') -addExternalIface('FileCallback', nativeType='nsIFileCallback', - headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) @@ -1826,8 +1828,6 @@ addExternalIface('OutputStream', nativeType='nsIOutputStream', notflattened=True) addExternalIface('Principal', nativeType='nsIPrincipal', headerFile='nsIPrincipal.h', notflattened=True) -addExternalIface('PrintCallback', nativeType='nsIPrintCallback', - headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('Selection', nativeType='nsISelection') addExternalIface('StackFrame', nativeType='nsIStackFrame', headerFile='nsIException.h', notflattened=True) diff --git a/dom/bindings/CallbackObject.h b/dom/bindings/CallbackObject.h index 6447586fdabe..7f2d583a41da 100644 --- a/dom/bindings/CallbackObject.h +++ b/dom/bindings/CallbackObject.h @@ -104,6 +104,9 @@ private: mozilla::HoldJSObjects(this); } + CallbackObject(const CallbackObject&) MOZ_DELETE; + CallbackObject& operator =(const CallbackObject&) MOZ_DELETE; + protected: void DropCallback() { diff --git a/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl b/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl index ffd95f6fdb02..8ff6713b2296 100644 --- a/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl +++ b/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl @@ -20,27 +20,6 @@ interface nsIDOMFile; interface nsIVariant; interface nsIInputStreamCallback; -[scriptable, builtinclass, uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)] -interface nsIDOMMozCanvasPrintState : nsISupports -{ - // A canvas rendering context. - readonly attribute nsISupports context; - - // To be called when rendering to the context is done. - void done(); -}; - -[scriptable, function, uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)] -interface nsIPrintCallback : nsISupports -{ - void render(in nsIDOMMozCanvasPrintState ctx); -}; - -[scriptable, function, uuid(6e9ffb59-2067-4aef-a51c-65e65a3e0d81)] -interface nsIFileCallback : nsISupports { - void receive(in nsIDOMBlob file); -}; - [scriptable, uuid(8978d1c5-2981-4678-a1c3-b0b7bae04fbc)] interface nsIDOMHTMLCanvasElement : nsISupports { @@ -61,15 +40,6 @@ interface nsIDOMHTMLCanvasElement : nsISupports // mozGetAsFile(name, type); -- uses given type nsIDOMFile mozGetAsFile(in DOMString name, [optional] in DOMString type); - // Valid calls are: - // toBlob(); -- defaults to image/png - // toBlob(type); -- uses given type - // toBlob(type, params); -- uses given type, and any valid parameters - [implicit_jscontext] - void toBlob(in nsIFileCallback callback, - [optional] in DOMString type, - [optional] in jsval params); - // A Mozilla-only extension to get a canvas context backed by double-buffered // shared memory. Only privileged callers can call this. nsISupports MozGetIPCContext(in DOMString contextId); @@ -78,8 +48,5 @@ interface nsIDOMHTMLCanvasElement : nsISupports // stream in the desired image format. void mozFetchAsStream(in nsIInputStreamCallback callback, [optional] in DOMString type); - - // A Mozilla-only callback that is called during the printing process. - attribute nsIPrintCallback mozPrintCallback; }; diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index 46df3af911bb..4bf3f7a75c0f 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -315,7 +315,6 @@ var interfaceNamesInGlobalScope = "MouseScrollEvent", {name: "MozActivity", b2g: true}, "MozApplicationEvent", - "MozCanvasPrintState", {name: "MozCellBroadcast", b2g: true}, {name: "MozCellBroadcastEvent", b2g: true}, "MozConnection", diff --git a/dom/webidl/HTMLCanvasElement.webidl b/dom/webidl/HTMLCanvasElement.webidl index c52e5c31ab08..408fd6e34437 100644 --- a/dom/webidl/HTMLCanvasElement.webidl +++ b/dom/webidl/HTMLCanvasElement.webidl @@ -11,10 +11,8 @@ */ interface Blob; -interface FileCallback; interface nsIInputStreamCallback; interface nsISupports; -interface PrintCallback; interface Variant; interface HTMLCanvasElement : HTMLElement { @@ -47,3 +45,17 @@ partial interface HTMLCanvasElement { void mozFetchAsStream(nsIInputStreamCallback callback, optional DOMString? type = null); attribute PrintCallback? mozPrintCallback; }; + +[ChromeOnly] +interface MozCanvasPrintState +{ + // A canvas rendering context. + readonly attribute nsISupports context; + + // To be called when rendering to the context is done. + void done(); +}; + +callback PrintCallback = void(MozCanvasPrintState ctx); + +callback FileCallback = void(Blob file); diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index a1723334f2d7..79f6c41a43bd 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -465,10 +465,7 @@ GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArrayGetContent()); - nsCOMPtr printCallback; - if (canvas && - NS_SUCCEEDED(canvas->GetMozPrintCallback(getter_AddRefs(printCallback))) && - printCallback) { + if (canvas && canvas->GetMozPrintCallback()) { aArr->AppendElement(canvas); continue; } diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index aa81a12615ee..91f73ec5a3c4 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -2640,10 +2640,8 @@ DocHasPrintCallbackCanvas(nsIDocument* aDoc, void* aData) NS_LITERAL_STRING("canvas")); uint32_t canvasCount = canvases->Length(true); for (uint32_t i = 0; i < canvasCount; ++i) { - nsCOMPtr canvas = do_QueryInterface(canvases->Item(i, false)); - nsCOMPtr printCallback; - if (canvas && NS_SUCCEEDED(canvas->GetMozPrintCallback(getter_AddRefs(printCallback))) && - printCallback) { + HTMLCanvasElement* canvas = HTMLCanvasElement::FromContentOrNull(canvases->Item(i, false)); + if (canvas && canvas->GetMozPrintCallback()) { // This subdocument has a print callback. Set result and return false to // stop iteration. *static_cast(aData) = true; From 84f303b8c360262b252ad1beb4e85b46a697a7e3 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Wed, 11 Sep 2013 18:35:51 -0400 Subject: [PATCH 17/69] Bug 915248 - Convert DeviceProximityEvent to webidl-only r=smaug --- dom/interfaces/events/moz.build | 1 - .../events/nsIDOMDeviceProximityEvent.idl | 27 ------------------- dom/system/nsDeviceSensors.cpp | 22 +++++++-------- dom/system/nsDeviceSensors.h | 1 - dom/webidl/DeviceProximityEvent.webidl | 2 +- dom/webidl/moz.build | 2 +- js/xpconnect/src/event_impl_gen.conf.in | 1 - 7 files changed, 13 insertions(+), 43 deletions(-) delete mode 100644 dom/interfaces/events/nsIDOMDeviceProximityEvent.idl diff --git a/dom/interfaces/events/moz.build b/dom/interfaces/events/moz.build index 376c37482ee2..1d0ef7011e4b 100644 --- a/dom/interfaces/events/moz.build +++ b/dom/interfaces/events/moz.build @@ -18,7 +18,6 @@ XPIDL_SOURCES += [ 'nsIDOMDeviceLightEvent.idl', 'nsIDOMDeviceMotionEvent.idl', 'nsIDOMDeviceOrientationEvent.idl', - 'nsIDOMDeviceProximityEvent.idl', 'nsIDOMDragEvent.idl', 'nsIDOMElementReplaceEvent.idl', 'nsIDOMEvent.idl', diff --git a/dom/interfaces/events/nsIDOMDeviceProximityEvent.idl b/dom/interfaces/events/nsIDOMDeviceProximityEvent.idl deleted file mode 100644 index fac9da511fac..000000000000 --- a/dom/interfaces/events/nsIDOMDeviceProximityEvent.idl +++ /dev/null @@ -1,27 +0,0 @@ -/* 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/. */ - -#include "nsIDOMEvent.idl" - -[scriptable, builtinclass, uuid(86c7c396-9c2b-4d45-9c7c-b0dcda024105)] -interface nsIDOMDeviceProximityEvent : nsIDOMEvent -{ - [noscript] void initDeviceProximityEvent(in DOMString eventTypeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in double value, - in double min, - in double max); - readonly attribute double value; - readonly attribute double min; - readonly attribute double max; -}; - - -dictionary DeviceProximityEventInit : EventInit -{ - double value = Infinity; - double min = -Infinity; - double max = Infinity; -}; diff --git a/dom/system/nsDeviceSensors.cpp b/dom/system/nsDeviceSensors.cpp index b13f67aa8709..6a5fd141e700 100644 --- a/dom/system/nsDeviceSensors.cpp +++ b/dom/system/nsDeviceSensors.cpp @@ -18,6 +18,7 @@ #include "mozilla/Preferences.h" #include "mozilla/Attributes.h" #include "nsIPermissionManager.h" +#include "mozilla/dom/DeviceProximityEvent.h" using namespace mozilla; using namespace mozilla::dom; @@ -257,17 +258,16 @@ nsDeviceSensors::FireDOMProximityEvent(mozilla::dom::EventTarget* aTarget, double aMin, double aMax) { - nsCOMPtr event; - NS_NewDOMDeviceProximityEvent(getter_AddRefs(event), aTarget, nullptr, nullptr); - nsCOMPtr oe = do_QueryInterface(event); - - oe->InitDeviceProximityEvent(NS_LITERAL_STRING("deviceproximity"), - true, - false, - aValue, - aMin, - aMax); - + DeviceProximityEventInitInitializer init; + init.mBubbles = true; + init.mCancelable = false; + init.mValue = aValue; + init.mMin = aMin; + init.mMax = aMax; + nsRefPtr event = + DeviceProximityEvent::Constructor(aTarget, + NS_LITERAL_STRING("deviceproximity"), + init); event->SetTrusted(true); bool defaultActionEnabled; diff --git a/dom/system/nsDeviceSensors.h b/dom/system/nsDeviceSensors.h index 6a197064f0e6..41b7561d6ceb 100644 --- a/dom/system/nsDeviceSensors.h +++ b/dom/system/nsDeviceSensors.h @@ -13,7 +13,6 @@ #include "nsITimer.h" #include "nsIDOMDeviceLightEvent.h" #include "nsIDOMDeviceOrientationEvent.h" -#include "nsIDOMDeviceProximityEvent.h" #include "nsIDOMUserProximityEvent.h" #include "nsIDOMDeviceMotionEvent.h" #include "nsDOMDeviceMotionEvent.h" diff --git a/dom/webidl/DeviceProximityEvent.webidl b/dom/webidl/DeviceProximityEvent.webidl index 44ff14b55f8e..0d3dc1275a69 100644 --- a/dom/webidl/DeviceProximityEvent.webidl +++ b/dom/webidl/DeviceProximityEvent.webidl @@ -4,7 +4,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ -[Constructor(DOMString type, optional DeviceProximityEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +[Constructor(DOMString type, optional DeviceProximityEventInit eventInitDict)] interface DeviceProximityEvent : Event { readonly attribute double value; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 5af22081aa91..2cfb992bfa16 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -460,7 +460,6 @@ WEBIDL_FILES += [ 'CustomEvent.webidl', 'DeviceLightEvent.webidl', 'DeviceOrientationEvent.webidl', - 'DeviceProximityEvent.webidl', 'DeviceStorageChangeEvent.webidl', 'DOMTransactionEvent.webidl', 'ElementReplaceEvent.webidl', @@ -542,4 +541,5 @@ if CONFIG['MOZ_B2G']: GENERATED_EVENTS_WEBIDL_FILES = [ 'BlobEvent.webidl', + 'DeviceProximityEvent.webidl', ] diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index 0291f3565835..017790f2f09a 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -10,7 +10,6 @@ simple_events = [ 'ProgressEvent', 'StorageEvent', - 'DeviceProximityEvent', 'MozSettingsEvent', 'UserProximityEvent', 'CustomEvent', From 5e12eb5de71416c957dd4d1b99adcc016ebc8bed Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Wed, 11 Sep 2013 18:35:51 -0400 Subject: [PATCH 18/69] Bug 856373 - WebIDL-ify Gamepad events r=smaug --- dom/bindings/Codegen.py | 49 +++++++++----- dom/gamepad/GamepadService.cpp | 66 ++++++++++--------- dom/interfaces/events/moz.build | 3 - .../events/nsIDOMGamepadAxisMoveEvent.idl | 33 ---------- .../events/nsIDOMGamepadButtonEvent.idl | 26 -------- dom/interfaces/events/nsIDOMGamepadEvent.idl | 27 -------- dom/webidl/GamepadAxisMoveEvent.webidl | 3 +- dom/webidl/GamepadButtonEvent.webidl | 3 +- dom/webidl/GamepadEvent.webidl | 3 +- dom/webidl/moz.build | 16 +++-- js/xpconnect/src/event_impl_gen.conf.in | 6 -- 11 files changed, 79 insertions(+), 156 deletions(-) delete mode 100644 dom/interfaces/events/nsIDOMGamepadAxisMoveEvent.idl delete mode 100644 dom/interfaces/events/nsIDOMGamepadButtonEvent.idl delete mode 100644 dom/interfaces/events/nsIDOMGamepadEvent.idl diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 1578786e2a55..17a49d518e19 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -10743,12 +10743,15 @@ class CGEventMethod(CGNativeMember): self.args = list(self.originalArgs) members = "" holdJS = "" - for m in self.descriptorProvider.interface.members: - if m.isAttr(): - name = CGDictionary.makeMemberName(m.identifier.name) - members += "e->%s = %s.%s;\n" % (name, self.args[1].name, name) - if m.type.isAny() or m.type.isObject() or m.type.isSpiderMonkeyInterface(): - holdJS = "mozilla::HoldJSObjects(e.get());\n" + iface = self.descriptorProvider.interface + while iface.identifier.name != "Event": + for m in self.descriptorProvider.getDescriptor(iface.identifier.name).interface.members: + if m.isAttr(): + name = CGDictionary.makeMemberName(m.identifier.name) + members += "e->%s = %s.%s;\n" % (name, self.args[1].name, name) + if m.type.isAny() or m.type.isObject() or m.type.isSpiderMonkeyInterface(): + holdJS = "mozilla::HoldJSObjects(e.get());\n" + iface = iface.parent self.body = ( "nsRefPtr<${nativeType}> e = new ${nativeType}(aOwner);\n" @@ -10824,21 +10827,24 @@ class CGEventClass(CGBindingImplClass): visibility="private", body="body")) + parent = self.descriptor.interface.parent + self.parentType = self.descriptor.getDescriptor(parent.identifier.name).nativeType.split('::')[-1] baseDeclarations=( "public:\n" " NS_DECL_ISUPPORTS_INHERITED\n" - " NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(${nativeType}, nsDOMEvent)\n" + " NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(${nativeType}, ${parentType})\n" " virtual ~${nativeType}();\n" "protected:\n" " ${nativeType}(mozilla::dom::EventTarget* aOwner);\n\n") baseDeclarations = string.Template(baseDeclarations).substitute( { - "nativeType": self.descriptor.nativeType.split('::')[-1] + "nativeType": self.descriptor.nativeType.split('::')[-1], + "parentType": self.parentType }) CGClass.__init__(self, descriptor.nativeType.split('::')[-1], - bases=[ClassBase("nsDOMEvent")], + bases=[ClassBase(self.parentType)], methods=self.methodDecls, members=members, extradeclarations=baseDeclarations) @@ -10891,26 +10897,29 @@ class CGEventClass(CGBindingImplClass): if dropJS != "": dropJS += " mozilla::DropJSObjects(this);\n" # Just override CGClass and do our own thing + nativeType = self.descriptor.nativeType.split('::')[-1] + ctorParams = ("aOwner, nullptr, nullptr" if self.parentType == "nsDOMEvent" + else "aOwner") classImpl = """ NS_IMPL_CYCLE_COLLECTION_CLASS(${nativeType}) -NS_IMPL_ADDREF_INHERITED(${nativeType}, nsDOMEvent) -NS_IMPL_RELEASE_INHERITED(${nativeType}, nsDOMEvent) +NS_IMPL_ADDREF_INHERITED(${nativeType}, ${parentType}) +NS_IMPL_RELEASE_INHERITED(${nativeType}, ${parentType}) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(${nativeType}, nsDOMEvent) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(${nativeType}, ${parentType}) ${traverse}NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(${nativeType}, nsDOMEvent) +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(${nativeType}, ${parentType}) ${trace}NS_IMPL_CYCLE_COLLECTION_TRACE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(${nativeType}, nsDOMEvent) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(${nativeType}, ${parentType}) ${unlink}NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(${nativeType}) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent) +NS_INTERFACE_MAP_END_INHERITING(${parentType}) ${nativeType}::${nativeType}(mozilla::dom::EventTarget* aOwner) - : nsDOMEvent(aOwner, nullptr, nullptr) + : ${parentType}(${ctorParams}) { } @@ -10921,7 +10930,9 @@ ${dropJS}} """ return string.Template(classImpl).substitute( { "ifaceName": self.descriptor.name, - "nativeType": self.descriptor.nativeType.split('::')[-1], + "nativeType": nativeType, + "ctorParams": ctorParams, + "parentType": self.parentType, "traverse": self.implTraverse(), "unlink": self.implUnlink(), "trace": self.implTrace(), @@ -10942,9 +10953,11 @@ class CGEventRoot(CGThing): self.root = CGList([CGClassForwardDeclare("JSContext", isStruct=True), self.root], "\n") + parent = descriptor.interface.parent.identifier.name + # Throw in our #includes self.root = CGHeaders([descriptor], [], [], [], - [ "nsDOMEvent.h", + [ config.getDescriptor(parent, False).headerFile, "mozilla/Attributes.h", "mozilla/ErrorResult.h" , "mozilla/dom/%sBinding.h" % interfaceName, diff --git a/dom/gamepad/GamepadService.cpp b/dom/gamepad/GamepadService.cpp index dfa934cec0b8..dfe45dffb2a8 100644 --- a/dom/gamepad/GamepadService.cpp +++ b/dom/gamepad/GamepadService.cpp @@ -12,9 +12,6 @@ #include "nsAutoPtr.h" #include "nsIDOMEvent.h" #include "nsIDOMDocument.h" -#include "nsIDOMGamepadButtonEvent.h" -#include "nsIDOMGamepadAxisMoveEvent.h" -#include "nsIDOMGamepadEvent.h" #include "GeneratedEvents.h" #include "nsIDOMWindow.h" #include "nsIObserver.h" @@ -24,6 +21,10 @@ #include "nsThreadUtils.h" #include "mozilla/Services.h" +#include "mozilla/dom/GamepadAxisMoveEvent.h" +#include "mozilla/dom/GamepadButtonEvent.h" +#include "mozilla/dom/GamepadEvent.h" + #include namespace mozilla { @@ -241,18 +242,19 @@ GamepadService::FireButtonEvent(EventTarget* aTarget, uint32_t aButton, double aValue) { - nsCOMPtr event; - bool defaultActionEnabled = true; - NS_NewDOMGamepadButtonEvent(getter_AddRefs(event), aTarget, nullptr, nullptr); - nsCOMPtr je = do_QueryInterface(event); - MOZ_ASSERT(je, "QI should not fail"); - - nsString name = aValue == 1.0L ? NS_LITERAL_STRING("gamepadbuttondown") : NS_LITERAL_STRING("gamepadbuttonup"); - je->InitGamepadButtonEvent(name, false, false, aGamepad, aButton); - je->SetTrusted(true); + GamepadButtonEventInitInitializer init; + init.mBubbles = false; + init.mCancelable = false; + init.mGamepad = aGamepad; + init.mButton = aButton; + nsRefPtr event = + GamepadButtonEvent::Constructor(aTarget, name, init); + event->SetTrusted(true); + + bool defaultActionEnabled = true; aTarget->DispatchEvent(event, &defaultActionEnabled); } @@ -305,17 +307,20 @@ GamepadService::FireAxisMoveEvent(EventTarget* aTarget, uint32_t aAxis, double aValue) { - nsCOMPtr event; + GamepadAxisMoveEventInitInitializer init; + init.mBubbles = false; + init.mCancelable = false; + init.mGamepad = aGamepad; + init.mAxis = aAxis; + init.mValue = aValue; + nsRefPtr event = + GamepadAxisMoveEvent::Constructor(aTarget, + NS_LITERAL_STRING("gamepadaxismove"), + init); + + event->SetTrusted(true); + bool defaultActionEnabled = true; - NS_NewDOMGamepadAxisMoveEvent(getter_AddRefs(event), aTarget, nullptr, - nullptr); - nsCOMPtr je = do_QueryInterface(event); - MOZ_ASSERT(je, "QI should not fail"); - - je->InitGamepadAxisMoveEvent(NS_LITERAL_STRING("gamepadaxismove"), - false, false, aGamepad, aAxis, aValue); - je->SetTrusted(true); - aTarget->DispatchEvent(event, &defaultActionEnabled); } @@ -381,17 +386,18 @@ GamepadService::FireConnectionEvent(EventTarget* aTarget, Gamepad* aGamepad, bool aConnected) { - nsCOMPtr event; - bool defaultActionEnabled = true; - NS_NewDOMGamepadEvent(getter_AddRefs(event), aTarget, nullptr, nullptr); - nsCOMPtr je = do_QueryInterface(event); - MOZ_ASSERT(je, "QI should not fail"); - nsString name = aConnected ? NS_LITERAL_STRING("gamepadconnected") : NS_LITERAL_STRING("gamepaddisconnected"); - je->InitGamepadEvent(name, false, false, aGamepad); - je->SetTrusted(true); + GamepadEventInitInitializer init; + init.mBubbles = false; + init.mCancelable = false; + init.mGamepad = aGamepad; + nsRefPtr event = + GamepadEvent::Constructor(aTarget, name, init); + event->SetTrusted(true); + + bool defaultActionEnabled = true; aTarget->DispatchEvent(event, &defaultActionEnabled); } diff --git a/dom/interfaces/events/moz.build b/dom/interfaces/events/moz.build index 1d0ef7011e4b..f53bc997221e 100644 --- a/dom/interfaces/events/moz.build +++ b/dom/interfaces/events/moz.build @@ -24,9 +24,6 @@ XPIDL_SOURCES += [ 'nsIDOMEventListener.idl', 'nsIDOMEventTarget.idl', 'nsIDOMFocusEvent.idl', - 'nsIDOMGamepadAxisMoveEvent.idl', - 'nsIDOMGamepadButtonEvent.idl', - 'nsIDOMGamepadEvent.idl', 'nsIDOMHashChangeEvent.idl', 'nsIDOMKeyEvent.idl', 'nsIDOMMessageEvent.idl', diff --git a/dom/interfaces/events/nsIDOMGamepadAxisMoveEvent.idl b/dom/interfaces/events/nsIDOMGamepadAxisMoveEvent.idl deleted file mode 100644 index 2ebb5e9888df..000000000000 --- a/dom/interfaces/events/nsIDOMGamepadAxisMoveEvent.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* 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/. */ - -#include "nsIDOMGamepadEvent.idl" - -[builtinclass, scriptable, uuid(bd09eef8-8e07-4baf-8d39-4f92003dbca8)] -interface nsIDOMGamepadAxisMoveEvent : nsIDOMGamepadEvent -{ - /** - * Index in gamepad.axes of the axis that was moved. - */ - readonly attribute unsigned long axis; - - /** - * Position of the axis in the range -1.0...1.0. - */ - readonly attribute double value; - - [noscript] - void initGamepadAxisMoveEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in nsIDOMGamepad gamepad, - in unsigned long axis, - in double value); -}; - -dictionary GamepadAxisMoveEventInit : GamepadEventInit -{ - unsigned long axis; - double value; -}; diff --git a/dom/interfaces/events/nsIDOMGamepadButtonEvent.idl b/dom/interfaces/events/nsIDOMGamepadButtonEvent.idl deleted file mode 100644 index 7a8a0ea00c34..000000000000 --- a/dom/interfaces/events/nsIDOMGamepadButtonEvent.idl +++ /dev/null @@ -1,26 +0,0 @@ -/* 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/. */ - -#include "nsIDOMGamepadEvent.idl" - -[builtinclass, scriptable, uuid(d75d4d2b-e7b4-4b93-ac35-2e70b57d9b28)] -interface nsIDOMGamepadButtonEvent : nsIDOMGamepadEvent -{ - /** - * Index in gamepad.buttons of the button that was pressed or released. - */ - readonly attribute unsigned long button; - - [noscript] - void initGamepadButtonEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in nsIDOMGamepad gamepad, - in unsigned long button); -}; - -dictionary GamepadButtonEventInit : GamepadEventInit -{ - unsigned long button; -}; diff --git a/dom/interfaces/events/nsIDOMGamepadEvent.idl b/dom/interfaces/events/nsIDOMGamepadEvent.idl deleted file mode 100644 index d38bfc5a6aa5..000000000000 --- a/dom/interfaces/events/nsIDOMGamepadEvent.idl +++ /dev/null @@ -1,27 +0,0 @@ -/* 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/. */ - -#include "nsIDOMEvent.idl" - -interface nsIDOMGamepad; - -[builtinclass, scriptable, uuid(93b048d6-2aef-46a9-b0f4-06d7f00d8ef2)] -interface nsIDOMGamepadEvent : nsIDOMEvent -{ - /** - * The device that generated this event. - */ - readonly attribute nsIDOMGamepad gamepad; - - [noscript] - void initGamepadEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in nsIDOMGamepad gamepad); -}; - -dictionary GamepadEventInit : EventInit -{ - nsIDOMGamepad gamepad; -}; diff --git a/dom/webidl/GamepadAxisMoveEvent.webidl b/dom/webidl/GamepadAxisMoveEvent.webidl index 4bc9d3bae5f2..7699674b453f 100644 --- a/dom/webidl/GamepadAxisMoveEvent.webidl +++ b/dom/webidl/GamepadAxisMoveEvent.webidl @@ -5,8 +5,7 @@ */ [Pref="dom.gamepad.non_standard_events.enabled", - Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict), - HeaderFile="GeneratedEventClasses.h"] + Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict)] interface GamepadAxisMoveEvent : GamepadEvent { readonly attribute unsigned long axis; diff --git a/dom/webidl/GamepadButtonEvent.webidl b/dom/webidl/GamepadButtonEvent.webidl index 24e5e0a7cf8d..b8a9e086bfc7 100644 --- a/dom/webidl/GamepadButtonEvent.webidl +++ b/dom/webidl/GamepadButtonEvent.webidl @@ -5,8 +5,7 @@ */ [Pref="dom.gamepad.non_standard_events.enabled", - Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict), - HeaderFile="GeneratedEventClasses.h"] + Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict)] interface GamepadButtonEvent : GamepadEvent { readonly attribute unsigned long button; diff --git a/dom/webidl/GamepadEvent.webidl b/dom/webidl/GamepadEvent.webidl index 15b2209f6578..f4c3092ac1b2 100644 --- a/dom/webidl/GamepadEvent.webidl +++ b/dom/webidl/GamepadEvent.webidl @@ -5,8 +5,7 @@ */ [Pref="dom.gamepad.enabled", - Constructor(DOMString type, optional GamepadEventInit eventInitDict), - HeaderFile="GeneratedEventClasses.h"] + Constructor(DOMString type, optional GamepadEventInit eventInitDict)] interface GamepadEvent : Event { readonly attribute Gamepad? gamepad; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 2cfb992bfa16..11f34a1fe6f2 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -506,13 +506,6 @@ if CONFIG['MOZ_B2G_RIL']: 'USSDReceivedEvent.webidl', ] -if CONFIG['MOZ_GAMEPAD']: - WEBIDL_FILES += [ - 'GamepadAxisMoveEvent.webidl', - 'GamepadButtonEvent.webidl', - 'GamepadEvent.webidl', - ] - if CONFIG['MOZ_WEBSPEECH']: WEBIDL_FILES += [ 'SpeechRecognitionError.webidl', @@ -543,3 +536,12 @@ GENERATED_EVENTS_WEBIDL_FILES = [ 'BlobEvent.webidl', 'DeviceProximityEvent.webidl', ] + +if CONFIG['MOZ_GAMEPAD']: + GENERATED_EVENTS_WEBIDL_FILES += [ + 'GamepadAxisMoveEvent.webidl', + 'GamepadButtonEvent.webidl', + 'GamepadEvent.webidl', + ] + + diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index 017790f2f09a..f29344b0a653 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -51,11 +51,6 @@ simple_events = [ 'DeviceStorageChangeEvent', 'PopupBlockedEvent', 'RecordErrorEvent', -#ifdef MOZ_GAMEPAD - 'GamepadEvent', - 'GamepadButtonEvent', - 'GamepadAxisMoveEvent', -#endif #ifdef MOZ_WEBSPEECH 'SpeechRecognitionEvent', #endif @@ -81,6 +76,5 @@ xpidl_to_native = [ ['nsIDOMDocument', 'nsIDocument', 'nsIDocument'], ['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'], ['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'], - ['nsIDOMGamepad', 'Gamepad', 'nsIDOMGamepad'] ] From ad0a9b13e9a5722aff30eadcbc690b0fb3885e95 Mon Sep 17 00:00:00 2001 From: Eric Rescorla Date: Wed, 11 Sep 2013 15:43:09 -0700 Subject: [PATCH 19/69] Bug 915420 - Use foundation address instead of relay address to determine priority r=bwc --- media/mtransport/third_party/nICEr/src/ice/ice_candidate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c index 8d6bcae41f0f..9d8fbe51796e 100644 --- a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c +++ b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c @@ -60,6 +60,7 @@ static char *RCSSTRING __UNUSED__="$Id: ice_candidate.c,v 1.2 2008/04/28 17:59:0 #include "ice_reg.h" #include "ice_util.h" #include "nr_socket_turn.h" +#include "nr_socket.h" static int next_automatic_preference = 224; @@ -382,8 +383,12 @@ int nr_ice_candidate_compute_priority(nr_ice_candidate *cand) } else { char key_of_interface[MAXIFNAME + 41]; + nr_transport_addr addr; - if(r=nr_transport_addr_fmt_ifname_addr_string(&cand->base,key_of_interface, + if(r=nr_socket_getaddr(cand->isock->sock, &addr)) + ABORT(r); + + if(r=nr_transport_addr_fmt_ifname_addr_string(&addr,key_of_interface, sizeof(key_of_interface))) { ABORT(r); } From 39e605be494efff48eef0ab2394e07e348727efd Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Thu, 12 Sep 2013 09:14:34 +1000 Subject: [PATCH 20/69] Bug 914902 - remove printf as child process closes. r=cjones --- ipc/glue/AsyncChannel.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ipc/glue/AsyncChannel.cpp b/ipc/glue/AsyncChannel.cpp index 7c524f3a2537..ee7adb8b74ad 100644 --- a/ipc/glue/AsyncChannel.cpp +++ b/ipc/glue/AsyncChannel.cpp @@ -913,9 +913,6 @@ AsyncChannel::ProcessGoodbyeMessage() // TODO sort out Close() on this side racing with Close() on the // other side mChannelState = ChannelClosing; - - printf("NOTE: %s process received `Goodbye', closing down\n", - mChild ? "child" : "parent"); } From 0e0ef4f37573b7b16970a3d2b2cccdb1d80d5a99 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 12 Sep 2013 08:14:44 +0900 Subject: [PATCH 21/69] Bug 914935 - Fix pymake handling of colon in includedep files. r=gps --- build/pymake/pymake/parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/pymake/pymake/parser.py b/build/pymake/pymake/parser.py index 49521122d867..fee1b23160b7 100644 --- a/build/pymake/pymake/parser.py +++ b/build/pymake/pymake/parser.py @@ -372,6 +372,9 @@ def parsefile(pathname): pathname = os.path.realpath(pathname) return _parsecache.get(pathname) +# colon followed by anything except a slash (Windows path detection) +_depfilesplitter = re.compile(r':(?![\\/])') + def parsedepfile(pathname): """ Parse a filename listing only depencencies into a parserdata.StatementList. @@ -394,7 +397,7 @@ def parsedepfile(pathname): pathname = os.path.realpath(pathname) stmts = parserdata.StatementList() for line in continuation_iter(open(pathname).readlines()): - target, deps = line.split(":", 1) + target, deps = _depfilesplitter.split(line, 1) stmts.append(parserdata.Rule(data.StringExpansion(target, None), data.StringExpansion(deps, None), False)) return stmts From 4a50b88b69665ca5607bb39fa42200fa98f38367 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 12 Sep 2013 08:14:52 +0900 Subject: [PATCH 22/69] Bug 914482 - Allow overrides from the command line for variables defined in moz.build. r=gps --- config/rules.mk | 4 ++-- js/src/config/rules.mk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 3655fc46f258..14f99dd1a89e 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -54,11 +54,11 @@ ifndef EXTERNALLY_MANAGED_MAKE_FILE # scenarios. _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST)) -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $($(var)),\ +$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\ )) -$(foreach var,$(_DEPRECATED_VARIABLES),$(if $($(var)),\ +$(foreach var,$(_DEPRECATED_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build)\ )) diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 3655fc46f258..14f99dd1a89e 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -54,11 +54,11 @@ ifndef EXTERNALLY_MANAGED_MAKE_FILE # scenarios. _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST)) -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $($(var)),\ +$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\ )) -$(foreach var,$(_DEPRECATED_VARIABLES),$(if $($(var)),\ +$(foreach var,$(_DEPRECATED_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build)\ )) From 2ea4e685fd0e731fdaa2c6f2be93aa488a7cef00 Mon Sep 17 00:00:00 2001 From: Joey Armstrong Date: Wed, 11 Sep 2013 19:20:34 -0400 Subject: [PATCH 23/69] bug 882908: move OS_LIBS to mozbuild (logic). r=gps --- python/mozbuild/mozbuild/frontend/emitter.py | 1 + python/mozbuild/mozbuild/frontend/sandbox_symbols.py | 6 ++++++ .../mozbuild/test/backend/data/variable_passthru/moz.build | 2 ++ python/mozbuild/mozbuild/test/backend/test_recursivemake.py | 5 +++++ .../mozbuild/test/frontend/data/variable-passthru/moz.build | 2 ++ python/mozbuild/mozbuild/test/frontend/test_emitter.py | 1 + 6 files changed, 17 insertions(+) diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 0959204a3b4c..43dbbbaefba4 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -146,6 +146,7 @@ class TreeMetadataEmitter(LoggingMixin): MODULE='MODULE', MSVC_ENABLE_PGO='MSVC_ENABLE_PGO', NO_DIST_INSTALL='NO_DIST_INSTALL', + OS_LIBS='OS_LIBS', SDK_LIBRARY='SDK_LIBRARY', SHARED_LIBRARY_LIBS='SHARED_LIBRARY_LIBS', SIMPLE_PROGRAMS='SIMPLE_PROGRAMS', diff --git a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py index 997a67cc2d09..1af13d85892e 100644 --- a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py +++ b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py @@ -239,6 +239,12 @@ VARIABLES = { """Whether profile-guided optimization is enabled in this directory. """), + 'OS_LIBS': (list, list, [], + """System link libraries. + + This variable contains a list of system libaries to link against. + """), + 'SDK_LIBRARY': (StrictOrderingOnAppendList, list, [], """Elements of the distributed SDK. diff --git a/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build b/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build index 3f4270c0c3d9..ae8f64171f8c 100644 --- a/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build +++ b/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build @@ -28,6 +28,8 @@ HOST_LIBRARY_NAME = 'host_bar' LIBRARY_NAME = 'lib_name' LIBS = ['bar.lib', 'foo.lib'] +OS_LIBS = ['foo.so', '-l123', 'bar.a'] + SDK_LIBRARY = ['bar.sdk', 'foo.sdk'] SHARED_LIBRARY_LIBS += ['bar.sll', 'foo.sll'] diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py index 15671828a175..f97a51dd400a 100644 --- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -212,6 +212,11 @@ class TestRecursiveMakeBackend(BackendTester): 'MSVC_ENABLE_PGO': [ 'MSVC_ENABLE_PGO := 1', ], + 'OS_LIBS': [ + 'OS_LIBS += foo.so', + 'OS_LIBS += -l123', + 'OS_LIBS += bar.a', + ], 'SDK_LIBRARY': [ 'SDK_LIBRARY += bar.sdk', 'SDK_LIBRARY += foo.sdk', diff --git a/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build b/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build index 2dd7f0fd5a1f..9739c2a4121f 100644 --- a/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build +++ b/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build @@ -28,6 +28,8 @@ HOST_LIBRARY_NAME = 'host_fans' LIBRARY_NAME = 'lib_name' LIBS += ['fans.lib', 'tans.lib'] +OS_LIBS += ['foo.so', '-l123', 'aaa.a'] + SDK_LIBRARY += ['fans.sdk', 'tans.sdk'] SHARED_LIBRARY_LIBS += ['fans.sll', 'tans.sll'] diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py index 85e64a4541d0..f3ee90aaa12e 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -154,6 +154,7 @@ class TestEmitterBasic(unittest.TestCase): MSVC_ENABLE_PGO=True, NO_DIST_INSTALL=True, MODULE='module_name', + OS_LIBS=['foo.so', '-l123', 'aaa.a'], SDK_LIBRARY=['fans.sdk', 'tans.sdk'], SHARED_LIBRARY_LIBS=['fans.sll', 'tans.sll'], SIMPLE_PROGRAMS=['fans.x', 'tans.x'], From 35cf2c710f04f347170a25465671eed775410508 Mon Sep 17 00:00:00 2001 From: Edwin Flores Date: Thu, 12 Sep 2013 11:23:06 +1200 Subject: [PATCH 24/69] Bug 899420 - Re-enable test_seek, test_buffered, test_bug493187, test_playback_rate, test_bug465498, test_played on Linux r=cpearce --- content/media/test/Makefile.in | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in index 1a801d956a00..3521fe1f6490 100644 --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -89,7 +89,6 @@ MOCHITEST_FILES = \ test_paused_after_ended.html \ test_play_events.html \ test_play_events_2.html \ - $(filter disabled-temporarily--bug-751539, test_played.html) \ test_playback_errors.html \ test_seekable1.html \ test_preload_actions.html \ @@ -165,7 +164,7 @@ endif # Disabled since we don't play Wave files standalone, for now # test_audioDocumentTitle.html -# The below tests are disabled due to frequent timeouts. +# The below tests are disabled on Windows due to frequent timeouts. # Bug 832768 and Bug 864682: # test_buffered.html # test_bug465498.html @@ -175,6 +174,18 @@ endif # test_seek.html # Bug 832768, bug 814533, bug 840742 # test_playback_rate.html +# Bug 751539 +# test_played.html +ifneq ($(OS_ARCH), WINNT) +MOCHITEST_FILES += \ + test_buffered.html \ + test_bug465498.html \ + test_bug493187.html \ + test_seek.html \ + test_playback_rate.html \ + test_played.html \ + $(NULL) +endif # sample files MOCHITEST_FILES += \ From 0d94a7625136ed08827dccc7ec30c3500a2a566f Mon Sep 17 00:00:00 2001 From: Edwin Flores Date: Thu, 12 Sep 2013 11:23:12 +1200 Subject: [PATCH 25/69] Bug 886181 - Pref on gstreamer backend r=cpearce --- modules/libpref/src/init/all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 7a1c509bde92..af7514bb4236 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -205,7 +205,7 @@ pref("media.webm.enabled", true); pref("media.dash.enabled", false); #endif #ifdef MOZ_GSTREAMER -pref("media.gstreamer.enabled", false); +pref("media.gstreamer.enabled", true); #endif #ifdef MOZ_WEBRTC pref("media.navigator.enabled", true); From 540afa6b4d960e9726a7e9ba554c40c33533dc58 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Wed, 11 Sep 2013 16:27:41 -0700 Subject: [PATCH 26/69] Bug 913965 - Don't use build-dep for installing dependencies; install modern Mercurial on Ubuntu; r=glandium DONTBUILD (NPOTB) --- python/mozboot/mozboot/debian.py | 54 ++++++++++++++++++++----------- python/mozboot/mozboot/ubuntu.py | 55 ++++++++++++++++---------------- 2 files changed, 63 insertions(+), 46 deletions(-) diff --git a/python/mozboot/mozboot/debian.py b/python/mozboot/mozboot/debian.py index 0249a00b57e0..bd2f47ba6cf4 100644 --- a/python/mozboot/mozboot/debian.py +++ b/python/mozboot/mozboot/debian.py @@ -1,12 +1,40 @@ # 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/. - -import os +# 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/. from mozboot.base import BaseBootstrapper class DebianBootstrapper(BaseBootstrapper): + # These are common packages for all Debian-derived distros (such as + # Ubuntu). + COMMON_PACKAGES = [ + 'autoconf2.13', + 'build-essential', + 'ccache', + 'libasound2-dev', + 'libcurl4-openssl-dev', + 'libdbus-1-dev', + 'libdbus-glib-1-dev', + 'libgconf2-dev', + 'libgstreamer0.10-dev', + 'libgstreamer-plugins-base0.10-dev', + 'libgtk2.0-dev', + 'libiw-dev', + 'libnotify-dev', + 'libxt-dev', + 'mercurial', + 'mesa-common-dev', + 'python-dev', + 'unzip', + 'uuid', + 'yasm', + 'xvfb', + 'zip', + ] + + # Subclasses can add packages to this variable to have them installed. + DISTRO_PACKAGES = [] + def __init__(self, version, dist_id): BaseBootstrapper.__init__(self) @@ -14,18 +42,8 @@ class DebianBootstrapper(BaseBootstrapper): self.dist_id = dist_id def install_system_packages(self): - self.run_as_root(['apt-get', 'build-dep', 'iceweasel']) + packages = self.COMMON_PACKAGES + self.DISTRO_PACKAGES + self.apt_install(*packages) - self.apt_install( - 'autoconf2.13', - 'libasound2-dev', - 'libcurl4-openssl-dev', - 'libgstreamer0.10-dev', - 'libgstreamer-plugins-base0.10-dev', - 'libiw-dev', - 'libnotify-dev', - 'libxt-dev', - 'mercurial', - 'mesa-common-dev', - 'uuid', - 'yasm') + def _update_package_manager(self): + self.run_as_root(['apt-get', 'update']) diff --git a/python/mozboot/mozboot/ubuntu.py b/python/mozboot/mozboot/ubuntu.py index 2a814ebb802b..b8a6e2b33cf7 100644 --- a/python/mozboot/mozboot/ubuntu.py +++ b/python/mozboot/mozboot/ubuntu.py @@ -1,39 +1,38 @@ # 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/. +# 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/. import os -from mozboot.base import BaseBootstrapper +from mozboot.debian import DebianBootstrapper -class UbuntuBootstrapper(BaseBootstrapper): - def __init__(self, version, dist_id): - BaseBootstrapper.__init__(self) - self.version = version - self.dist_id = dist_id +MERCURIAL_PPA = ''' +Ubuntu does not provide a modern Mercurial in its package repository. So, +we will install a PPA that does. +'''.strip() - def install_system_packages(self): - self.run_as_root(['apt-get', 'build-dep', 'firefox']) - - self.apt_install( - 'autoconf2.13', - 'libasound2-dev', - 'libcurl4-openssl-dev', - 'libgstreamer0.10-dev', - 'libgstreamer-plugins-base0.10-dev', - 'libiw-dev', - 'libnotify-dev', - 'libxt-dev', - 'mercurial', - 'mesa-common-dev', - 'uuid', - 'yasm') - - def _update_package_manager(self): - self.run_as_root(['apt-get', 'update']) +# Ubuntu shares much logic with Debian, so it inherits from it. +class UbuntuBootstrapper(DebianBootstrapper): + DISTRO_PACKAGES = [ + # This contains add-apt-repository. + 'software-properties-common', + ] def upgrade_mercurial(self, current): - self._ensure_package_manager_updated() + # Ubuntu releases up through at least 13.04 don't ship a modern + # Mercurial. So we hook up a PPA that provides one. + self._add_ppa('mercurial-ppa/releases') + self._update_package_manager() self.apt_install('mercurial') + def _add_ppa(self, ppa): + # Detect PPAs that have already been added. Sadly add-apt-repository + # doesn't do this for us and will import keys, etc every time. This + # incurs a user prompt and is annoying, so we try to prevent it. + list_file = ppa.replace('/', '-') + for source in os.listdir('/etc/apt/sources.list.d'): + if source.startswith(list_file) and source.endswith('.list'): + return + + self.run_as_root(['add-apt-repository', 'ppa:%s' % ppa]) From 50b241c8d888a8653db3c75cd7f7a7202c5090d4 Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Wed, 11 Sep 2013 17:42:09 -0600 Subject: [PATCH 27/69] Bug 906371 - Use off thread JS parsing when loading async scripts, r=bz,billm. --- content/base/src/nsScriptLoader.cpp | 183 ++++++++++++++++++++++++---- content/base/src/nsScriptLoader.h | 20 ++- dom/base/nsIScriptContext.h | 5 +- dom/base/nsJSEnvironment.cpp | 6 +- dom/base/nsJSEnvironment.h | 3 +- dom/base/nsJSUtils.cpp | 20 ++- dom/base/nsJSUtils.h | 3 +- js/src/jsapi.cpp | 11 ++ js/src/jsapi.h | 2 +- js/src/jsatom.cpp | 9 +- js/src/jscntxt.h | 5 +- js/src/jscntxtinlines.h | 4 +- js/src/jsopcode.cpp | 11 +- js/src/jsopcode.h | 6 +- js/src/jsstr.h | 2 +- js/src/jsworkers.cpp | 22 +++- 16 files changed, 251 insertions(+), 61 deletions(-) diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index e23aab5d2df7..20d04f5def4a 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -17,6 +17,7 @@ #include "mozilla/dom/Element.h" #include "nsGkAtoms.h" #include "nsNetUtil.h" +#include "nsIJSRuntimeService.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptContext.h" #include "nsIScriptSecurityManager.h" @@ -98,6 +99,7 @@ public: uint32_t mJSVersion; nsCOMPtr mURI; nsCOMPtr mOriginPrincipal; + nsAutoCString mURL; // Keep the URI's filename alive during off thread parsing. int32_t mLineNo; const CORSMode mCORSMode; }; @@ -691,12 +693,122 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) return ProcessRequest(request) == NS_ERROR_HTMLPARSER_BLOCK; } +namespace { + +class NotifyOffThreadScriptLoadCompletedRunnable : public nsRunnable +{ + nsRefPtr mLoader; + void *mToken; + +public: + NotifyOffThreadScriptLoadCompletedRunnable(already_AddRefed aLoader, + void *aToken) + : mLoader(aLoader), mToken(aToken) + {} + + NS_DECL_NSIRUNNABLE +}; + +} /* anonymous namespace */ + nsresult -nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest) +nsScriptLoader::ProcessOffThreadRequest(void **aOffThreadToken) +{ + nsCOMPtr request = mOffThreadScriptRequest; + mOffThreadScriptRequest = nullptr; + mDocument->UnblockOnload(false); + + return ProcessRequest(request, aOffThreadToken); +} + +NS_IMETHODIMP +NotifyOffThreadScriptLoadCompletedRunnable::Run() +{ + MOZ_ASSERT(NS_IsMainThread()); + + nsresult rv = mLoader->ProcessOffThreadRequest(&mToken); + + if (mToken) { + // The result of the off thread parse was not actually needed to process + // the request (disappearing window, some other error, ...). Finish the + // request to avoid leaks in the JS engine. + nsCOMPtr svc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1"); + NS_ENSURE_TRUE(svc, NS_ERROR_FAILURE); + JSRuntime *rt; + svc->GetRuntime(&rt); + NS_ENSURE_TRUE(rt, NS_ERROR_FAILURE); + JS::FinishOffThreadScript(nullptr, rt, mToken); + } + + return rv; +} + +static void +OffThreadScriptLoaderCallback(void *aToken, void *aCallbackData) +{ + // Be careful not to adjust the refcount on the loader, as this callback + // may be invoked off the main thread. + nsScriptLoader* aLoader = static_cast(aCallbackData); + nsRefPtr notify = + new NotifyOffThreadScriptLoadCompletedRunnable( + already_AddRefed(aLoader), aToken); + NS_DispatchToMainThread(notify); +} + +nsresult +nsScriptLoader::AttemptAsyncScriptParse(nsScriptLoadRequest* aRequest) +{ + if (!aRequest->mElement->GetScriptAsync() || aRequest->mIsInline) { + return NS_ERROR_FAILURE; + } + + if (mOffThreadScriptRequest) { + return NS_ERROR_FAILURE; + } + + JSObject *unrootedGlobal; + nsCOMPtr context = GetScriptContext(&unrootedGlobal); + if (!context) { + return NS_ERROR_FAILURE; + } + AutoPushJSContext cx(context->GetNativeContext()); + JS::Rooted global(cx, unrootedGlobal); + + JS::CompileOptions options(cx); + FillCompileOptionsForRequest(aRequest, &options); + + if (!JS::CanCompileOffThread(cx, options)) { + return NS_ERROR_FAILURE; + } + + mOffThreadScriptRequest = aRequest; + if (!JS::CompileOffThread(cx, global, options, + aRequest->mScriptText.get(), aRequest->mScriptText.Length(), + OffThreadScriptLoaderCallback, + static_cast(this))) { + return NS_ERROR_OUT_OF_MEMORY; + } + + // This reference will be consumed by the NotifyOffThreadScriptLoadCompletedRunnable. + NS_ADDREF(this); + + mDocument->BlockOnload(); + + return NS_OK; +} + +nsresult +nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest, void **aOffThreadToken) { NS_ASSERTION(nsContentUtils::IsSafeToRunScript(), "Processing requests when running scripts is unsafe."); + if (!aOffThreadToken) { + nsresult rv = AttemptAsyncScriptParse(aRequest); + if (rv != NS_ERROR_FAILURE) + return rv; + } + NS_ENSURE_ARG(aRequest); nsAFlatString* script; nsAutoString textData; @@ -751,7 +863,7 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest) doc->BeginEvaluatingExternalScript(); } aRequest->mElement->BeginEvaluating(); - rv = EvaluateScript(aRequest, *script); + rv = EvaluateScript(aRequest, *script, aOffThreadToken); aRequest->mElement->EndEvaluating(); if (doc) { doc->EndEvaluatingExternalScript(); @@ -799,9 +911,44 @@ nsScriptLoader::FireScriptEvaluated(nsresult aResult, aRequest->FireScriptEvaluated(aResult); } +nsIScriptContext * +nsScriptLoader::GetScriptContext(JSObject **aGlobal) +{ + nsPIDOMWindow *pwin = mDocument->GetInnerWindow(); + NS_ASSERTION(pwin, "shouldn't be called with a null inner window"); + + nsCOMPtr globalObject = do_QueryInterface(pwin); + NS_ASSERTION(globalObject, "windows must be global objects"); + + // and make sure we are setup for this type of script. + nsresult rv = globalObject->EnsureScriptEnvironment(); + if (NS_FAILED(rv)) { + return nullptr; + } + + *aGlobal = globalObject->GetGlobalJSObject(); + return globalObject->GetScriptContext(); +} + +void +nsScriptLoader::FillCompileOptionsForRequest(nsScriptLoadRequest *aRequest, + JS::CompileOptions *aOptions) +{ + // It's very important to use aRequest->mURI, not the final URI of the channel + // aRequest ended up getting script data from, as the script filename. + nsContentUtils::GetWrapperSafeScriptFilename(mDocument, aRequest->mURI, aRequest->mURL); + + aOptions->setFileAndLine(aRequest->mURL.get(), aRequest->mLineNo); + aOptions->setVersion(JSVersion(aRequest->mJSVersion)); + if (aRequest->mOriginPrincipal) { + aOptions->setOriginPrincipals(nsJSPrincipals::get(aRequest->mOriginPrincipal)); + } +} + nsresult nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, - const nsAFlatString& aScript) + const nsAFlatString& aScript, + void** aOffThreadToken) { nsresult rv = NS_OK; @@ -817,28 +964,19 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, return NS_ERROR_FAILURE; } - nsPIDOMWindow *pwin = mDocument->GetInnerWindow(); - NS_ASSERTION(pwin, "shouldn't be called with a null inner window"); - - nsCOMPtr globalObject = do_QueryInterface(pwin); - NS_ASSERTION(globalObject, "windows must be global objects"); - // Get the script-type to be used by this element. NS_ASSERTION(scriptContent, "no content - what is default script-type?"); - // and make sure we are setup for this type of script. - rv = globalObject->EnsureScriptEnvironment(); - if (NS_FAILED(rv)) - return rv; - // Make sure context is a strong reference since we access it after // we've executed a script, which may cause all other references to // the context to go away. - nsCOMPtr context = globalObject->GetScriptContext(); + JSObject *unrootedGlobal; + nsCOMPtr context = GetScriptContext(&unrootedGlobal); if (!context) { return NS_ERROR_FAILURE; } AutoPushJSContext cx(context->GetNativeContext()); + JS::Rooted global(cx, unrootedGlobal); bool oldProcessingScriptTag = context->GetProcessingScriptTag(); context->SetProcessingScriptTag(true); @@ -847,22 +985,13 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, nsCOMPtr oldCurrent = mCurrentScript; mCurrentScript = aRequest->mElement; - // It's very important to use aRequest->mURI, not the final URI of the channel - // aRequest ended up getting script data from, as the script filename. - nsAutoCString url; - nsContentUtils::GetWrapperSafeScriptFilename(mDocument, aRequest->mURI, url); - JSVersion version = JSVersion(aRequest->mJSVersion); if (version != JSVERSION_UNKNOWN) { JS::CompileOptions options(cx); - options.setFileAndLine(url.get(), aRequest->mLineNo) - .setVersion(JSVersion(aRequest->mJSVersion)); - if (aRequest->mOriginPrincipal) { - options.setOriginPrincipals(nsJSPrincipals::get(aRequest->mOriginPrincipal)); - } - JS::Rooted global(cx, globalObject->GetGlobalJSObject()); + FillCompileOptionsForRequest(aRequest, &options); rv = context->EvaluateString(aScript, global, - options, /* aCoerceToString = */ false, nullptr); + options, /* aCoerceToString = */ false, nullptr, + aOffThreadToken); } // Put the old script back in case it wants to do anything else. diff --git a/content/base/src/nsScriptLoader.h b/content/base/src/nsScriptLoader.h index 7c8193db321c..ab2860560712 100644 --- a/content/base/src/nsScriptLoader.h +++ b/content/base/src/nsScriptLoader.h @@ -207,6 +207,12 @@ public: const nsAString &aCrossOrigin, bool aScriptFromHead); + /** + * Process a request that was deferred so that the script could be compiled + * off thread. + */ + nsresult ProcessOffThreadRequest(void **aOffThreadToken); + private: /** * Unblocks the creator parser of the parser-blocking scripts. @@ -261,14 +267,21 @@ private: bool AddPendingChildLoader(nsScriptLoader* aChild) { return mPendingChildLoaders.AppendElement(aChild) != nullptr; } - - nsresult ProcessRequest(nsScriptLoadRequest* aRequest); + + nsresult AttemptAsyncScriptParse(nsScriptLoadRequest* aRequest); + nsresult ProcessRequest(nsScriptLoadRequest* aRequest, + void **aOffThreadToken = nullptr); void FireScriptAvailable(nsresult aResult, nsScriptLoadRequest* aRequest); void FireScriptEvaluated(nsresult aResult, nsScriptLoadRequest* aRequest); nsresult EvaluateScript(nsScriptLoadRequest* aRequest, - const nsAFlatString& aScript); + const nsAFlatString& aScript, + void **aOffThreadToken); + + nsIScriptContext *GetScriptContext(JSObject **aGlobal); + void FillCompileOptionsForRequest(nsScriptLoadRequest *aRequest, + JS::CompileOptions *aOptions); nsresult PrepareLoadedRequest(nsScriptLoadRequest* aRequest, nsIStreamLoader* aLoader, @@ -302,6 +315,7 @@ private: }; nsTArray mPreloads; + nsCOMPtr mOffThreadScriptRequest; nsCOMPtr mCurrentScript; nsCOMPtr mCurrentParserInsertedScript; // XXXbz do we want to cycle-collect these or something? Not sure. diff --git a/dom/base/nsIScriptContext.h b/dom/base/nsIScriptContext.h index 931867a6e757..7f95e785aef0 100644 --- a/dom/base/nsIScriptContext.h +++ b/dom/base/nsIScriptContext.h @@ -58,12 +58,15 @@ public: * @param aRetValue the result of executing the script. Pass null if you * don't care about the result. Note that asking for a * result will deoptimize your script somewhat in many cases. + * @param aOffThreadToken if specified, the result of compiling the script + * on another thread. */ virtual nsresult EvaluateString(const nsAString& aScript, JS::Handle aScopeObject, JS::CompileOptions& aOptions, bool aCoerceToString, - JS::Value* aRetValue) = 0; + JS::Value* aRetValue, + void **aOffThreadToken = nullptr) = 0; /** * Bind an already-compiled event handler function to the given diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index dfe1939c6897..9611e3728ac1 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -980,7 +980,8 @@ nsJSContext::EvaluateString(const nsAString& aScript, JS::Handle aScopeObject, JS::CompileOptions& aCompileOptions, bool aCoerceToString, - JS::Value* aRetValue) + JS::Value* aRetValue, + void **aOffThreadToken) { NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_NOT_INITIALIZED); if (!mScriptsEnabled) { @@ -991,7 +992,8 @@ nsJSContext::EvaluateString(const nsAString& aScript, nsJSUtils::EvaluateOptions evalOptions; evalOptions.setCoerceToString(aCoerceToString); return nsJSUtils::EvaluateString(mContext, aScript, aScopeObject, - aCompileOptions, evalOptions, aRetValue); + aCompileOptions, evalOptions, aRetValue, + aOffThreadToken); } #ifdef DEBUG diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 090663241faa..238cff61a651 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -44,7 +44,8 @@ public: JS::Handle aScopeObject, JS::CompileOptions &aOptions, bool aCoerceToString, - JS::Value* aRetValue) MOZ_OVERRIDE; + JS::Value* aRetValue, + void **aOffThreadToken = nullptr) MOZ_OVERRIDE; virtual nsresult BindCompiledEventHandler(nsISupports *aTarget, JS::Handle aScope, diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp index 5782998b0e7e..a4928fee22b5 100644 --- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -223,7 +223,8 @@ nsJSUtils::EvaluateString(JSContext* aCx, JS::Handle aScopeObject, JS::CompileOptions& aCompileOptions, EvaluateOptions& aEvaluateOptions, - JS::Value* aRetValue) + JS::Value* aRetValue, + void **aOffThreadToken) { PROFILER_LABEL("JS", "EvaluateString"); MOZ_ASSERT_IF(aCompileOptions.versionSet, @@ -265,9 +266,20 @@ nsJSUtils::EvaluateString(JSContext* aCx, JSAutoCompartment ac(aCx, aScopeObject); JS::RootedObject rootedScope(aCx, aScopeObject); - ok = JS::Evaluate(aCx, rootedScope, aCompileOptions, - PromiseFlatString(aScript).get(), - aScript.Length(), aRetValue); + if (aOffThreadToken) { + JSScript *script = JS::FinishOffThreadScript(aCx, JS_GetRuntime(aCx), *aOffThreadToken); + *aOffThreadToken = nullptr; // Mark the token as having been finished. + if (script) { + ok = JS_ExecuteScript(aCx, rootedScope, script, aRetValue); + } else { + ok = false; + } + } else { + ok = JS::Evaluate(aCx, rootedScope, aCompileOptions, + PromiseFlatString(aScript).get(), + aScript.Length(), aRetValue); + } + if (ok && aEvaluateOptions.coerceToString && !aRetValue->isUndefined()) { JSString* str = JS_ValueToString(aCx, *aRetValue); ok = !!str; diff --git a/dom/base/nsJSUtils.h b/dom/base/nsJSUtils.h index 5b9627a2b587..65c1c5b8cd0b 100644 --- a/dom/base/nsJSUtils.h +++ b/dom/base/nsJSUtils.h @@ -85,7 +85,8 @@ public: JS::Handle aScopeObject, JS::CompileOptions &aCompileOptions, EvaluateOptions& aEvaluateOptions, - JS::Value* aRetValue); + JS::Value* aRetValue, + void **aOffThreadToken = nullptr); }; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 53862b56a0e7..d7a3341acc7f 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -6337,3 +6337,14 @@ JS_PreventExtensions(JSContext *cx, JS::HandleObject obj) return true; return JSObject::preventExtensions(cx, obj); } + +char * +JSAutoByteString::encodeLatin1(ExclusiveContext *cx, JSString *str) +{ + JSLinearString *linear = str->ensureLinear(cx); + if (!linear) + return NULL; + + mBytes = LossyTwoByteCharsToNewLatin1CharsZ(cx, linear->range()).c_str(); + return mBytes; +} diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 3753b9a850a8..7e184b7dcf24 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3849,7 +3849,7 @@ class JSAutoByteString return mBytes; } - char *encodeLatin1(js::ContextFriendFields *cx, JSString *str); + char *encodeLatin1(js::ExclusiveContext *cx, JSString *str); char *encodeUtf8(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); diff --git a/js/src/jsatom.cpp b/js/src/jsatom.cpp index 2a655f8b7bb0..a90af045b0c0 100644 --- a/js/src/jsatom.cpp +++ b/js/src/jsatom.cpp @@ -38,11 +38,10 @@ using mozilla::RangedPtr; const char * js::AtomToPrintableString(ExclusiveContext *cx, JSAtom *atom, JSAutoByteString *bytes) { - // The only uses for this method when running off the main thread are for - // parse errors/warnings, which will not actually be reported in such cases. - if (!cx->isJSContext()) - return ""; - return js_ValueToPrintable(cx->asJSContext(), StringValue(atom), bytes); + JSString *str = js_QuoteString(cx, atom, 0); + if (!str) + return NULL; + return bytes->encodeLatin1(cx, str); } const char * const js::TypeStrings[] = { diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index c71f796e31ae..005c2aab6a25 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -294,13 +294,13 @@ class ExclusiveContext : public ThreadSafeContext friend class jit::IonContext; // The worker on which this context is running, if this is not a JSContext. - WorkerThread *workerThread; + WorkerThread *workerThread_; public: ExclusiveContext(JSRuntime *rt, PerThreadData *pt, ContextKind kind) : ThreadSafeContext(rt, pt, kind), - workerThread(NULL), + workerThread_(NULL), enterCompartmentDepth_(0) {} @@ -336,6 +336,7 @@ class ExclusiveContext : public ThreadSafeContext inline void leaveCompartment(JSCompartment *oldCompartment); void setWorkerThread(WorkerThread *workerThread); + WorkerThread *workerThread() const { return workerThread_; } // If required, pause this thread until notified to continue by the main thread. inline void maybePause() const; diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index 19ca63009919..e7b7b3cd7796 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -352,8 +352,8 @@ inline void ExclusiveContext::maybePause() const { #ifdef JS_WORKER_THREADS - if (workerThread) - workerThread->maybePause(); + if (workerThread()) + workerThread()->maybePause(); #endif } diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index be06e685a478..a53771244159 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -732,7 +732,7 @@ Sprinter::realloc_(size_t newSize) return true; } -Sprinter::Sprinter(JSContext *cx) +Sprinter::Sprinter(ExclusiveContext *cx) : context(cx), #ifdef DEBUG initialized(false), @@ -867,7 +867,7 @@ Sprinter::putString(JSString *s) char *buffer = reserve(size); if (!buffer) return -1; - DeflateStringToBuffer(context, chars, length, buffer, &size); + DeflateStringToBuffer(NULL, chars, length, buffer, &size); buffer[size] = 0; return oldOffset; @@ -1023,14 +1023,15 @@ QuoteString(Sprinter *sp, JSString *str, uint32_t quote) } JSString * -js_QuoteString(JSContext *cx, JSString *str, jschar quote) +js_QuoteString(ExclusiveContext *cx, JSString *str, jschar quote) { Sprinter sprinter(cx); if (!sprinter.init()) return NULL; char *bytes = QuoteString(&sprinter, str, quote); - JSString *escstr = bytes ? JS_NewStringCopyZ(cx, bytes) : NULL; - return escstr; + if (!bytes) + return NULL; + return js_NewStringCopyZ(cx, bytes); } /************************************************************************/ diff --git a/js/src/jsopcode.h b/js/src/jsopcode.h index b2b2791645e0..af2a30b00c35 100644 --- a/js/src/jsopcode.h +++ b/js/src/jsopcode.h @@ -233,7 +233,7 @@ extern const char js_EscapeMap[]; * with the quote character at the beginning and end of the result string. */ extern JSString * -js_QuoteString(JSContext *cx, JSString *str, jschar quote); +js_QuoteString(js::ExclusiveContext *cx, JSString *str, jschar quote); namespace js { @@ -422,7 +422,7 @@ class Sprinter } }; - JSContext *context; /* context executing the decompiler */ + ExclusiveContext *context; /* context executing the decompiler */ private: static const size_t DefaultSize; @@ -437,7 +437,7 @@ class Sprinter bool realloc_(size_t newSize); public: - explicit Sprinter(JSContext *cx); + explicit Sprinter(ExclusiveContext *cx); ~Sprinter(); /* Initialize this sprinter, returns false on error */ diff --git a/js/src/jsstr.h b/js/src/jsstr.h index 458c1603fe5a..30003f5943fa 100644 --- a/js/src/jsstr.h +++ b/js/src/jsstr.h @@ -266,7 +266,7 @@ InflateStringToBuffer(JSContext *maybecx, const char *bytes, size_t length, * number of copied bytes. */ extern bool -DeflateStringToBuffer(JSContext *cx, const jschar *chars, +DeflateStringToBuffer(JSContext *maybecx, const jschar *chars, size_t charsLength, char *bytes, size_t *length); /* diff --git a/js/src/jsworkers.cpp b/js/src/jsworkers.cpp index 09ebbe990ff0..5ab294fee147 100644 --- a/js/src/jsworkers.cpp +++ b/js/src/jsworkers.cpp @@ -721,8 +721,8 @@ WorkerThread::handleIonWorkload(WorkerThreadState &state) void ExclusiveContext::setWorkerThread(WorkerThread *workerThread) { - this->workerThread = workerThread; - this->perThreadData = workerThread->threadData.addr(); + workerThread_ = workerThread; + perThreadData = workerThread->threadData.addr(); } frontend::CompileError & @@ -731,7 +731,7 @@ ExclusiveContext::addPendingCompileError() frontend::CompileError *error = js_new(); if (!error) MOZ_CRASH(); - if (!workerThread->parseTask->errors.append(error)) + if (!workerThread()->parseTask->errors.append(error)) MOZ_CRASH(); return *error; } @@ -829,9 +829,25 @@ SourceCompressionTask::complete() WorkerThreadState &state = *cx->workerThreadState(); AutoLockWorkerThreadState lock(state); + // If this compression task is itself being completed on a worker + // thread, treat the thread as paused while waiting for the completion. + // Otherwise we will not wake up and mark this as paused due to the + // loop in AutoPauseWorkersForGC. + if (cx->workerThread()) { + state.numPaused++; + if (state.numPaused == state.numThreads) + state.notify(WorkerThreadState::MAIN); + } + while (state.compressionInProgress(this)) state.wait(WorkerThreadState::MAIN); + if (cx->workerThread()) { + state.numPaused--; + if (state.shouldPause) + cx->workerThread()->pause(); + } + ss->ready_ = true; // Update memory accounting. From bf554d6584f0af5e9bfde3266af847b8ffbf2555 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 12 Sep 2013 08:52:36 +0900 Subject: [PATCH 28/69] Backout changeset 237c32279481 (bug 914482) for bustage --- config/rules.mk | 4 ++-- js/src/config/rules.mk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 14f99dd1a89e..3655fc46f258 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -54,11 +54,11 @@ ifndef EXTERNALLY_MANAGED_MAKE_FILE # scenarios. _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST)) -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ +$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $($(var)),\ $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\ )) -$(foreach var,$(_DEPRECATED_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ +$(foreach var,$(_DEPRECATED_VARIABLES),$(if $($(var)),\ $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build)\ )) diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 14f99dd1a89e..3655fc46f258 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -54,11 +54,11 @@ ifndef EXTERNALLY_MANAGED_MAKE_FILE # scenarios. _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST)) -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ +$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $($(var)),\ $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\ )) -$(foreach var,$(_DEPRECATED_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ +$(foreach var,$(_DEPRECATED_VARIABLES),$(if $($(var)),\ $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build)\ )) From 69dfe6599118b003ed672cf72fc7f5302d1e81b6 Mon Sep 17 00:00:00 2001 From: Seth Fowler Date: Wed, 11 Sep 2013 17:01:59 -0700 Subject: [PATCH 29/69] Bug 912514 - Don't release nsIURIs off-main-thread. r=jdm --- image/src/Image.cpp | 8 +++++++- image/src/Image.h | 20 +++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/image/src/Image.cpp b/image/src/Image.cpp index f29132703ae5..054c3f7a3829 100644 --- a/image/src/Image.cpp +++ b/image/src/Image.cpp @@ -10,9 +10,15 @@ namespace mozilla { namespace image { +#ifdef DEBUG_imagelib +static const bool allowOMTURIAccess = true; +#else +static const bool allowOMTURIAccess = false; +#endif + // Constructor ImageResource::ImageResource(imgStatusTracker* aStatusTracker, nsIURI* aURI) : - mURI(aURI), + mURI(new nsMainThreadPtrHolder(aURI, allowOMTURIAccess)), mInnerWindowId(0), mAnimationConsumers(0), mAnimationMode(kNormalAnimMode), diff --git a/image/src/Image.h b/image/src/Image.h index ec6ce68f82b7..664ae4681198 100644 --- a/image/src/Image.h +++ b/image/src/Image.h @@ -10,6 +10,7 @@ #include "imgIContainer.h" #include "imgStatusTracker.h" #include "nsIURI.h" +#include "nsProxyRelease.h" // for nsMainThreadPtrHolder and nsMainThreadPtrHandle class nsIRequest; class nsIInputStream; @@ -156,8 +157,9 @@ public: /* * Returns a non-AddRefed pointer to the URI associated with this image. + * Illegal to use off-main-thread. */ - virtual nsIURI* GetURI() MOZ_OVERRIDE { return mURI; } + virtual nsIURI* GetURI() MOZ_OVERRIDE { return mURI.get(); } protected: ImageResource(imgStatusTracker* aStatusTracker, nsIURI* aURI); @@ -185,14 +187,14 @@ protected: virtual nsresult StopAnimation() = 0; // Member data shared by all implementations of this abstract class - nsRefPtr mStatusTracker; - nsCOMPtr mURI; - uint64_t mInnerWindowId; - uint32_t mAnimationConsumers; - uint16_t mAnimationMode; // Enum values in imgIContainer - bool mInitialized:1; // Have we been initalized? - bool mAnimating:1; // Are we currently animating? - bool mError:1; // Error handling + nsRefPtr mStatusTracker; + nsMainThreadPtrHandle mURI; + uint64_t mInnerWindowId; + uint32_t mAnimationConsumers; + uint16_t mAnimationMode; // Enum values in imgIContainer + bool mInitialized:1; // Have we been initalized? + bool mAnimating:1; // Are we currently animating? + bool mError:1; // Error handling }; } // namespace image From e69ef9ae7264c27ac81bdbae83736f3c855f44b0 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 11 Sep 2013 17:06:22 -0700 Subject: [PATCH 30/69] Bug 791916 - Make label tag a label accessible regardless of frame type. r=surkov --- accessible/src/base/AccTypes.h | 1 - accessible/src/base/nsAccessibilityService.cpp | 9 ++++++--- layout/generic/nsInlineFrame.cpp | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/accessible/src/base/AccTypes.h b/accessible/src/base/AccTypes.h index e11bd0555a10..7edcf6f649d7 100644 --- a/accessible/src/base/AccTypes.h +++ b/accessible/src/base/AccTypes.h @@ -29,7 +29,6 @@ enum AccType { eHTMLGroupboxType, eHTMLHRType, eHTMLImageMapType, - eHTMLLabelType, eHTMLLiType, eHTMLSelectListType, eHTMLMediaType, diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index ac8ddc31c671..0093a5b632f6 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -1435,6 +1435,12 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame, return accessible.forget(); } + if (tag == nsGkAtoms::label) { + nsRefPtr accessible = + new HTMLLabelAccessible(aContent, document); + return accessible.forget(); + } + if (tag == nsGkAtoms::output) { nsRefPtr accessible = new HTMLOutputAccessible(aContent, document); @@ -1494,9 +1500,6 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame, case eHTMLImageMapType: newAcc = new HTMLImageMapAccessible(aContent, document); break; - case eHTMLLabelType: - newAcc = new HTMLLabelAccessible(aContent, document); - break; case eHTMLLiType: if (aContext->IsList() && aContext->GetContent() == aContent->GetParent()) { diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index ef40aba27374..62b86701db8d 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -916,8 +916,6 @@ nsInlineFrame::AccessibleType() return a11y::eHTMLButtonType; if (tagAtom == nsGkAtoms::img) // Create accessible for broken return a11y::eHyperTextType; - if (tagAtom == nsGkAtoms::label) // Creat accessible for