merge mozilla-inbound to mozilla-central a=merge
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 29 Jul 2014 15:30:09 +0200
changeset 196515 2fc48871c4593f7317f9a11c31c0ea9562130a14
parent 196508 32f22aa8d02d9a1ee54de3aa77387f8d16df15ba (current diff)
parent 196514 2047ca9ae242213f9823ae1f86c2e11239c2fb33 (diff)
child 196523 da30716e9417a10e230cf8ce8e00303cfde24285
child 196540 c949331218cdb6d3e6c1f3bd79a1f5411d75ed72
child 196601 c2642259129554293d06508009943299c571e054
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmerge
milestone34.0a1
merge mozilla-inbound to mozilla-central a=merge
--- a/configure.in
+++ b/configure.in
@@ -5641,17 +5641,16 @@ if test -n "${JAVA_BIN_PATH}" -o \
   if test -z "$KEYTOOL" -o "$KEYTOOL" = ":"; then
     AC_MSG_ERROR([The program keytool was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
   fi
 fi
 
 dnl ========================================================
 dnl = ANGLE OpenGL->D3D translator for WebGL
 dnl = * only applies to win32
-dnl = * enabled by default (shipping build); requires explicit --disable to disable
 dnl ========================================================
 
 MOZ_ANGLE_RENDERER=
 MOZ_D3D_CPU_SUFFIX=
 MOZ_HAS_WINSDK_WITH_D3D=
 MOZ_D3DCOMPILER_VISTA_DLL=
 MOZ_D3DCOMPILER_VISTA_DLL_PATH=
 MOZ_DIRECTX_SDK_PATH=
--- a/content/media/omx/MediaCodecReader.cpp
+++ b/content/media/omx/MediaCodecReader.cpp
@@ -12,16 +12,17 @@
 #include <ICrypto.h>
 
 #include <stagefright/foundation/ABuffer.h>
 #include <stagefright/foundation/ADebug.h>
 #include <stagefright/foundation/ALooper.h>
 #include <stagefright/foundation/AMessage.h>
 #include <stagefright/MediaBuffer.h>
 #include <stagefright/MediaCodec.h>
+#include <stagefright/MediaDefs.h>
 #include <stagefright/MediaExtractor.h>
 #include <stagefright/MediaSource.h>
 #include <stagefright/MetaData.h>
 #include <stagefright/Utils.h>
 
 #include "mozilla/TimeStamp.h"
 
 #include "gfx2DGlue.h"
@@ -100,25 +101,62 @@ MediaCodecReader::VideoResourceListener:
 void
 MediaCodecReader::VideoResourceListener::codecCanceled()
 {
   if (mReader != nullptr) {
     mReader->codecCanceled(mReader->mVideoTrack);
   }
 }
 
+bool MediaCodecReader::TrackInputCopier::Copy(MediaBuffer* aSourceBuffer, sp<ABuffer> aCodecBuffer)
+{
+  if (aSourceBuffer == nullptr ||
+      aCodecBuffer == nullptr ||
+      aSourceBuffer->range_length() > aCodecBuffer->capacity()) {
+    return false;
+  }
+
+  aCodecBuffer->setRange(0, aSourceBuffer->range_length());
+  memcpy(aCodecBuffer->data(), aSourceBuffer->data() + aSourceBuffer->range_offset(), aSourceBuffer->range_length());
+
+  return true;
+}
+
 MediaCodecReader::Track::Track()
   : mDurationUs(INT64_C(0))
   , mInputIndex(sInvalidInputIndex)
   , mEndOfStream(false)
   , mSeekTimeUs(sInvalidTimestampUs)
   , mFlushed(false)
 {
 }
 
+// Append the value of |kKeyValidSamples| to the end of each vorbis buffer.
+// https://github.com/mozilla-b2g/platform_frameworks_av/blob/master/media/libstagefright/OMXCodec.cpp#L3128
+// https://github.com/mozilla-b2g/platform_frameworks_av/blob/master/media/libstagefright/NuMediaExtractor.cpp#L472
+bool MediaCodecReader::VorbisInputCopier::Copy(MediaBuffer* aSourceBuffer, sp<ABuffer> aCodecBuffer)
+{
+  if (aSourceBuffer == nullptr ||
+      aCodecBuffer == nullptr ||
+      aSourceBuffer->range_length() + sizeof(int32_t) > aCodecBuffer->capacity()) {
+    return false;
+  }
+
+  int32_t numPageSamples = 0;
+  if (!aSourceBuffer->meta_data()->findInt32(kKeyValidSamples, &numPageSamples)) {
+    numPageSamples = -1;
+  }
+
+  aCodecBuffer->setRange(0, aSourceBuffer->range_length() + sizeof(int32_t));
+  memcpy(aCodecBuffer->data(), aSourceBuffer->data() + aSourceBuffer->range_offset(), aSourceBuffer->range_length());
+  memcpy(aCodecBuffer->data() + aSourceBuffer->range_length(), &numPageSamples, sizeof(numPageSamples));
+
+  return true;
+}
+
 MediaCodecReader::AudioTrack::AudioTrack()
 {
 }
 
 MediaCodecReader::VideoTrack::VideoTrack()
   : mWidth(0)
   , mHeight(0)
   , mStride(0)
@@ -673,16 +711,22 @@ MediaCodecReader::CreateMediaCodec(sp<AL
       aTrack.mCodec = MediaCodecProxy::CreateByType(aLooper, mime, false, aAsync, aListener);
     }
 
     if (aTrack.mCodec == nullptr) {
       NS_WARNING("Couldn't create MediaCodecProxy");
       return false;
     }
 
+    if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS)) {
+      aTrack.mInputCopier = new VorbisInputCopier;
+    } else {
+      aTrack.mInputCopier = new TrackInputCopier;
+    }
+
     if (!aAsync) {
       // Pending configure() and start() to codecReserved() if the creation
       // should be asynchronous.
       if (!aTrack.mCodec->allocated() || !ConfigureMediaCodec(aTrack)){
         NS_WARNING("Couldn't create and configure MediaCodec synchronously");
         aTrack.mCodec = nullptr;
         return false;
       }
@@ -994,22 +1038,19 @@ MediaCodecReader::FillCodecInputData(Tra
     // read() successes
     aTrack.mEndOfStream = false;
     aTrack.mSeekTimeUs = sInvalidTimestampUs;
 
     sp<ABuffer> input_buffer = nullptr;
     if (aTrack.mInputIndex.value() < aTrack.mInputBuffers.size()) {
       input_buffer = aTrack.mInputBuffers[aTrack.mInputIndex.value()];
     }
-    if (input_buffer != nullptr && input_buffer->capacity() >= source_buffer->range_length()) {
-      input_buffer->setRange(0, source_buffer->range_length());
-      memcpy((uint8_t *)input_buffer->data() + input_buffer->offset(),
-          (uint8_t *)source_buffer->data() + source_buffer->range_offset(),
-          source_buffer->range_length());
-
+    if (input_buffer != nullptr &&
+        aTrack.mInputCopier != nullptr &&
+        aTrack.mInputCopier->Copy(source_buffer, input_buffer)) {
       int64_t timestamp = sInvalidTimestampUs;
       sp<MetaData> codec_format = source_buffer->meta_data();
       if (codec_format != nullptr) {
         codec_format->findInt64(kKeyTime, &timestamp);
       }
 
       status = aTrack.mCodec->queueInputBuffer(
           aTrack.mInputIndex.value(), input_buffer->offset(), input_buffer->size(), timestamp, 0);
--- a/content/media/omx/MediaCodecReader.h
+++ b/content/media/omx/MediaCodecReader.h
@@ -17,16 +17,17 @@
 #include "MediaCodecProxy.h"
 #include "MediaDecoderReader.h"
 
 namespace android {
 struct ALooper;
 struct AMessage;
 
 class MOZ_EXPORT MediaExtractor;
+class MOZ_EXPORT MediaBuffer;
 struct MOZ_EXPORT MediaSource;
 struct MediaCodec;
 } // namespace android
 
 namespace mozilla {
 
 class MediaCodecReader : public MediaDecoderReader
 {
@@ -80,26 +81,34 @@ public:
   virtual nsresult Seek(int64_t aTime,
                         int64_t aStartTime,
                         int64_t aEndTime,
                         int64_t aCurrentTime);
 
   virtual bool IsMediaSeekable() MOZ_OVERRIDE;
 
 protected:
+  struct TrackInputCopier
+  {
+    virtual bool Copy(android::MediaBuffer* aSourceBuffer, android::sp<android::ABuffer> aCodecBuffer);
+  };
+
   struct Track
   {
     Track();
 
     // pipeline parameters
     android::sp<android::MediaSource> mSource;
     android::sp<android::MediaCodecProxy> mCodec;
     android::Vector<android::sp<android::ABuffer> > mInputBuffers;
     android::Vector<android::sp<android::ABuffer> > mOutputBuffers;
 
+    // pipeline copier
+    nsAutoPtr<TrackInputCopier> mInputCopier;
+
     // media parameters
     int64_t mDurationUs;
 
     // playback parameters
     CheckedUint32 mInputIndex;
     bool mEndOfStream;
     int64_t mSeekTimeUs;
     bool mFlushed; // meaningless when mSeekTimeUs is invalid.
@@ -151,16 +160,21 @@ private:
     VideoResourceListener() MOZ_DELETE;
     VideoResourceListener(const VideoResourceListener &rhs) MOZ_DELETE;
     const VideoResourceListener &operator=(const VideoResourceListener &rhs) MOZ_DELETE;
 
     MediaCodecReader *mReader;
   };
   friend class VideoResourceListener;
 
+  class VorbisInputCopier : public TrackInputCopier
+  {
+    virtual bool Copy(android::MediaBuffer* aSourceBuffer, android::sp<android::ABuffer> aCodecBuffer);
+  };
+
   struct AudioTrack : public Track
   {
     AudioTrack();
   };
 
   struct VideoTrack : public Track
   {
     VideoTrack();
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -511,16 +511,17 @@ TabChildBase::DispatchSynthesizedMouseEv
              aMsg == NS_MOUSE_BUTTON_UP || aMsg == NS_MOUSE_MOZLONGTAP);
 
   WidgetMouseEvent event(true, aMsg, nullptr,
                          WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
   event.refPoint = LayoutDeviceIntPoint(aRefPoint.x, aRefPoint.y);
   event.time = aTime;
   event.button = WidgetMouseEvent::eLeftButton;
   event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+  event.ignoreRootScrollFrame = true;
   if (aMsg != NS_MOUSE_MOVE) {
     event.clickCount = 1;
   }
   event.widget = aWidget;
 
   return DispatchWidgetEvent(event);
 }
 
@@ -1840,17 +1841,17 @@ TabChild::RecvHandleLongTap(const CSSPoi
     return true;
   }
 
   SendPendingTouchPreventedResponse(false, aGuid);
 
   bool eventHandled =
       DispatchMouseEvent(NS_LITERAL_STRING("contextmenu"),
                          APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid),
-                         2, 1, 0, false,
+                         2, 1, 0, true,
                          nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
 
   // If no one handle context menu, fire MOZLONGTAP event
   if (!eventHandled) {
     LayoutDevicePoint currentPoint =
       APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid) * mWidget->GetDefaultScale();
     int time = 0;
     nsEventStatus status =
@@ -2073,17 +2074,17 @@ TabChild::FireContextMenuEvent()
   }
 
   MOZ_ASSERT(mTapHoldTimer && mActivePointerId >= 0);
   bool defaultPrevented = DispatchMouseEvent(NS_LITERAL_STRING("contextmenu"),
                                              mGestureDownPoint / CSSToLayoutDeviceScale(scale),
                                              2 /* Right button */,
                                              1 /* Click count */,
                                              0 /* Modifiers */,
-                                             false /* Ignore root scroll frame */,
+                                             true /* Ignore root scroll frame */,
                                              nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
 
   // Fire a click event if someone didn't call preventDefault() on the context
   // menu event.
   if (defaultPrevented) {
     CancelTapTracking();
   } else if (mTapHoldTimer) {
     mTapHoldTimer->Cancel();
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -68,16 +68,19 @@ skip-if = buildapp == 'b2g' || os == 'an
 [test_peerConnection_bug822674.html]
 [test_peerConnection_bug825703.html]
 [test_peerConnection_bug827843.html]
 skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
 [test_peerConnection_bug834153.html]
 [test_peerConnection_bug835370.html]
 [test_peerConnection_bug1013809.html]
 skip-if = (toolkit == 'gonk' && debug) # b2g emulator seems to be too slow (Bug 1016498 and 1008080)
+[test_peerConnection_bug1042791.html]
+skip-if = true # disabled until we can resolve plugin installation issues
+#skip-if = toolkit == 'gonk' || toolkit == 'android' # no openh264 on b2g/android
 [test_peerConnection_close.html]
 [test_peerConnection_errorCallbacks.html]
 [test_peerConnection_offerRequiresReceiveAudio.html]
 skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
 [test_peerConnection_offerRequiresReceiveVideo.html]
 skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
 [test_peerConnection_offerRequiresReceiveVideoAudio.html]
 skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_bug1042791.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="head.js"></script>
+  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
+  <script type="application/javascript" src="pc.js"></script>
+  <script type="application/javascript" src="templates.js"></script>
+  <script type="application/javascript" src="turnConfig.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript;version=1.8">
+  createHTML({
+    bug: "1040346",
+    title: "Basic H.264 GMP video-only peer connection"
+  });
+
+  var test;
+  runNetworkTest(function (options) {
+    options = options || { };
+    options.h264 = true;
+    test = new PeerConnectionTest(options);
+    test.setMediaConstraints([{video: true}], [{video: true}]);
+    test.chain.removeAfter("PC_LOCAL_CREATE_OFFER");
+
+    test.chain.append([[
+      "PC_LOCAL_VERIFY_H264_OFFER",
+      function (test) {
+        ok(!test.pcLocal._last_offer.sdp.contains("profile-level-id=0x42e00c"),
+          "H264 offer does not contain profile-level-id=0x42e00c");
+        ok(test.pcLocal._last_offer.sdp.contains("profile-level-id=42e00c"),
+          "H264 offer contains profile-level-id=42e00c");
+        test.next();
+      }
+    ]]);
+
+    test.run();
+  });
+</script>
+</pre>
+</body>
+</html>
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -4641,20 +4641,33 @@ nsImageRenderer::Draw(nsPresContext*    
     {
       nsRefPtr<gfxDrawable> drawable = DrawableForElement(aDest,
                                                           aRenderingContext);
       if (!drawable) {
         NS_WARNING("Could not create drawable for element");
         return;
       }
 
+      gfxContext* ctx = aRenderingContext.ThebesContext();
+      gfxContext::GraphicsOperator op = ctx->CurrentOperator();
+      if (op != gfxContext::OPERATOR_OVER) {
+        ctx->PushGroup(gfxContentType::COLOR_ALPHA);
+        ctx->SetOperator(gfxContext::OPERATOR_OVER);
+      }
+
       nsCOMPtr<imgIContainer> image(ImageOps::CreateFromDrawable(drawable));
       nsLayoutUtils::DrawImage(&aRenderingContext, aPresContext, image,
                                filter, aDest, aFill, aAnchor, aDirtyRect,
                                ConvertImageRendererToDrawFlags(mFlags));
+
+      if (op != gfxContext::OPERATOR_OVER) {
+        ctx->PopGroupToSource();
+        ctx->Paint();
+      }
+
       return;
     }
     case eStyleImageType_Null:
     default:
       return;
   }
 }
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-blending/background-blending-moz-element-ref.html
@@ -0,0 +1,22 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+.c {
+    height: 10px;
+    background: rgb(0,255,0,.5);
+}
+
+</style>
+</head>
+<body>
+<div class="c"></div>
+<div class="c"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-blending/background-blending-moz-element.html
@@ -0,0 +1,29 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+div {
+	    height: 10px;
+}
+
+#b {
+	background: rgb(0,255,0,.5);
+}
+#c {
+    background: -moz-element(#b);
+    background-blend-mode: difference;
+}
+
+</style>
+</head>
+<body>
+<div id="b"></div>
+<div id="c"></div>
+</body>
+</html>
+
--- a/layout/reftests/css-blending/reftest.list
+++ b/layout/reftests/css-blending/reftest.list
@@ -77,8 +77,10 @@ pref(layout.css.background-blend-mode.en
 pref(layout.css.background-blend-mode.enabled,true) == background-blending-background-origin-content-box.html background-blending-background-origin-ref.html
 
 # Test plan 5.3.11 background-blend-mode for an element with background-attachement
 pref(layout.css.background-blend-mode.enabled,true) == background-blending-background-attachement-fixed.html background-blending-background-attachement-fixed-ref.html
 pref(layout.css.background-blend-mode.enabled,true) == background-blending-background-attachement-fixed-scroll.html background-blending-background-attachement-fixed-scroll-ref.html
 
 pref(layout.css.background-blend-mode.enabled,true) == background-blend-mode-body-image.html background-blend-mode-body-image-ref.html
 pref(layout.css.background-blend-mode.enabled,true) == background-blend-mode-body-transparent-image.html background-blend-mode-body-transparent-image-ref.html
+
+pref(layout.css.background-blend-mode.enabled,true) == background-blending-moz-element.html background-blending-moz-element-ref.html
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -95,17 +95,17 @@ GetProcSelfSmapsPrivate(int64_t* aN)
   memset(buffer, ' ', carryOver);
 
   for (;;) {
     size_t bytes = fread(buffer + carryOver, sizeof(*buffer), readSize, f);
     char* end = buffer + bytes;
     char* ptr = buffer;
     end[carryOver] = '\0';
     // We are looking for lines like "Private_{Clean,Dirty}: 4 kB".
-    while (ptr = strstr(ptr, "Private")) {
+    while ((ptr = strstr(ptr, "Private"))) {
       if (ptr >= end) {
         break;
       }
       ptr += sizeof("Private_Xxxxx:");
       amount += strtol(ptr, nullptr, 10);
     }
     if (bytes < readSize) {
       // We do not expect any match within the end of the buffer.