From ff12d6de33ab312694c28e288bd635f1008312e2 Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Sun, 30 Jun 2013 18:26:39 +0200 Subject: [PATCH 01/28] Bug 798914 (part 6) - Followup: move MemoryReporting.h include after the cpp's own header include. r=njn. --- caps/src/nsNullPrincipalURI.cpp | 4 +++- content/base/src/nsAttrAndChildArray.cpp | 4 +++- content/base/src/nsPropertyTable.cpp | 4 +++- content/html/content/src/HTMLAnchorElement.cpp | 3 ++- content/html/content/src/HTMLAreaElement.cpp | 3 ++- content/html/content/src/HTMLLinkElement.cpp | 2 +- gfx/thebes/gfxDWriteFonts.cpp | 4 +++- gfx/thebes/gfxGDIFont.cpp | 4 +++- gfx/thebes/gfxMacFont.cpp | 4 +++- image/src/ImageWrapper.cpp | 3 ++- layout/base/FramePropertyTable.cpp | 4 +++- layout/base/StackArena.cpp | 3 ++- layout/generic/nsTextRunTransformations.cpp | 3 ++- layout/style/StyleRule.cpp | 3 ++- layout/style/nsAnimationManager.cpp | 4 +++- xpcom/glue/nsCOMArray.cpp | 4 +++- 16 files changed, 40 insertions(+), 16 deletions(-) diff --git a/caps/src/nsNullPrincipalURI.cpp b/caps/src/nsNullPrincipalURI.cpp index bf52ecab7eb..28d7ff5ddf6 100644 --- a/caps/src/nsNullPrincipalURI.cpp +++ b/caps/src/nsNullPrincipalURI.cpp @@ -4,8 +4,10 @@ * 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/MemoryReporting.h" #include "nsNullPrincipalURI.h" + +#include "mozilla/MemoryReporting.h" + #include "nsNetUtil.h" #include "nsEscape.h" #include "nsCRT.h" diff --git a/content/base/src/nsAttrAndChildArray.cpp b/content/base/src/nsAttrAndChildArray.cpp index cb9ff3786ba..4275cd9eda8 100644 --- a/content/base/src/nsAttrAndChildArray.cpp +++ b/content/base/src/nsAttrAndChildArray.cpp @@ -8,8 +8,10 @@ * the two is unified to minimize footprint. */ -#include "mozilla/MemoryReporting.h" #include "nsAttrAndChildArray.h" + +#include "mozilla/MemoryReporting.h" + #include "nsMappedAttributeElement.h" #include "prbit.h" #include "nsString.h" diff --git a/content/base/src/nsPropertyTable.cpp b/content/base/src/nsPropertyTable.cpp index af4b504f919..9808ddd7efb 100644 --- a/content/base/src/nsPropertyTable.cpp +++ b/content/base/src/nsPropertyTable.cpp @@ -20,8 +20,10 @@ * nsIAtom pointers, and the values are void pointers. */ -#include "mozilla/MemoryReporting.h" #include "nsPropertyTable.h" + +#include "mozilla/MemoryReporting.h" + #include "pldhash.h" #include "nsError.h" #include "nsIAtom.h" diff --git a/content/html/content/src/HTMLAnchorElement.cpp b/content/html/content/src/HTMLAnchorElement.cpp index d2d7515de3c..e60f47b312c 100644 --- a/content/html/content/src/HTMLAnchorElement.cpp +++ b/content/html/content/src/HTMLAnchorElement.cpp @@ -4,8 +4,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/MemoryReporting.h" #include "mozilla/dom/HTMLAnchorElement.h" + +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/HTMLAnchorElementBinding.h" #include "nsCOMPtr.h" diff --git a/content/html/content/src/HTMLAreaElement.cpp b/content/html/content/src/HTMLAreaElement.cpp index b5df88361c3..c6530fabe8c 100644 --- a/content/html/content/src/HTMLAreaElement.cpp +++ b/content/html/content/src/HTMLAreaElement.cpp @@ -4,8 +4,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/MemoryReporting.h" #include "mozilla/dom/HTMLAreaElement.h" + +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/HTMLAreaElementBinding.h" #include "base/compiler_specific.h" diff --git a/content/html/content/src/HTMLLinkElement.cpp b/content/html/content/src/HTMLLinkElement.cpp index 320b6894f31..a5baa1c471f 100644 --- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -3,9 +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/MemoryReporting.h" #include "mozilla/dom/HTMLLinkElement.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/HTMLLinkElementBinding.h" #include "base/compiler_specific.h" #include "nsGenericHTMLElement.h" diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 47fb0363128..094a98aa71e 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -3,8 +3,10 @@ * 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/MemoryReporting.h" #include "gfxDWriteFonts.h" + +#include "mozilla/MemoryReporting.h" + #include "gfxDWriteShaper.h" #include "gfxHarfBuzzShaper.h" #include diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 2550823bbe4..9a2428285be 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -3,8 +3,10 @@ * 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/MemoryReporting.h" #include "gfxGDIFont.h" + +#include "mozilla/MemoryReporting.h" + #include "gfxGDIShaper.h" #include "gfxUniscribeShaper.h" #include "gfxHarfBuzzShaper.h" diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 7bae46d125a..80c863c6787 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -3,8 +3,10 @@ * 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/MemoryReporting.h" #include "gfxMacFont.h" + +#include "mozilla/MemoryReporting.h" + #include "gfxCoreTextShaper.h" #include "gfxHarfBuzzShaper.h" #include diff --git a/image/src/ImageWrapper.cpp b/image/src/ImageWrapper.cpp index 332a7f8e831..5055b278468 100644 --- a/image/src/ImageWrapper.cpp +++ b/image/src/ImageWrapper.cpp @@ -3,9 +3,10 @@ * 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/MemoryReporting.h" #include "ImageWrapper.h" +#include "mozilla/MemoryReporting.h" + using mozilla::layers::LayerManager; using mozilla::layers::ImageContainer; diff --git a/layout/base/FramePropertyTable.cpp b/layout/base/FramePropertyTable.cpp index b387ce9769d..ffe6c765850 100644 --- a/layout/base/FramePropertyTable.cpp +++ b/layout/base/FramePropertyTable.cpp @@ -3,8 +3,10 @@ * 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/MemoryReporting.h" #include "FramePropertyTable.h" + +#include "mozilla/MemoryReporting.h" + #include "prlog.h" namespace mozilla { diff --git a/layout/base/StackArena.cpp b/layout/base/StackArena.cpp index c709538d21d..55aa3d8e335 100644 --- a/layout/base/StackArena.cpp +++ b/layout/base/StackArena.cpp @@ -2,9 +2,10 @@ * 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/MemoryReporting.h" #include "StackArena.h" +#include "mozilla/MemoryReporting.h" + namespace mozilla { #define STACK_ARENA_MARK_INCREMENT 50 diff --git a/layout/generic/nsTextRunTransformations.cpp b/layout/generic/nsTextRunTransformations.cpp index f684f7d2554..1932ed51e55 100644 --- a/layout/generic/nsTextRunTransformations.cpp +++ b/layout/generic/nsTextRunTransformations.cpp @@ -3,9 +3,10 @@ * 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/MemoryReporting.h" #include "nsTextRunTransformations.h" +#include "mozilla/MemoryReporting.h" + #include "nsTextFrameUtils.h" #include "gfxSkipChars.h" #include "nsGkAtoms.h" diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index 680096a027d..441f8e808c2 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -9,8 +9,9 @@ * declarations */ -#include "mozilla/MemoryReporting.h" #include "mozilla/css/StyleRule.h" + +#include "mozilla/MemoryReporting.h" #include "mozilla/css/GroupRule.h" #include "mozilla/css/Declaration.h" #include "nsCSSStyleSheet.h" diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index af7d55a3de8..1a69db2cd47 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -3,8 +3,10 @@ * 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/MemoryReporting.h" #include "nsAnimationManager.h" + +#include "mozilla/MemoryReporting.h" + #include "nsPresContext.h" #include "nsRuleProcessorData.h" #include "nsStyleSet.h" diff --git a/xpcom/glue/nsCOMArray.cpp b/xpcom/glue/nsCOMArray.cpp index 35bf7ee8a80..99b1b5e481a 100644 --- a/xpcom/glue/nsCOMArray.cpp +++ b/xpcom/glue/nsCOMArray.cpp @@ -3,8 +3,10 @@ * 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/MemoryReporting.h" #include "nsCOMArray.h" + +#include "mozilla/MemoryReporting.h" + #include "nsCOMPtr.h" // This specialization is private to nsCOMArray. From 231fc777d37b7de4ae1fe6f75565100237b33945 Mon Sep 17 00:00:00 2001 From: Gian-Carlo Pascutto Date: Mon, 1 Jul 2013 08:01:57 +0200 Subject: [PATCH 02/28] Bug 877248 - Use a TextureView and setAlpha to make preview invisible. r=blassey --- .../videoengine/VideoCaptureAndroid.java | 60 +++++++++++++++++-- mobile/android/base/GeckoApp.java | 28 +++++++-- mobile/android/base/GeckoAppShell.java | 17 ++++-- .../base/resources/layout/gecko_app.xml | 7 +++ 4 files changed, 97 insertions(+), 15 deletions(-) diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java index ceb79192560..57f659f2439 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java @@ -20,6 +20,7 @@ import org.webrtc.videoengine.VideoCaptureDeviceInfoAndroid.AndroidVideoCaptureD import android.graphics.ImageFormat; import android.graphics.PixelFormat; import android.graphics.Rect; +import android.graphics.SurfaceTexture; import android.graphics.YuvImage; import android.hardware.Camera; import android.hardware.Camera.PreviewCallback; @@ -27,6 +28,10 @@ import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback; +import android.view.SurfaceView; +import android.view.TextureView; +import android.view.TextureView.SurfaceTextureListener; +import android.view.View; import org.mozilla.gecko.GeckoApp; import org.mozilla.gecko.GeckoAppShell; @@ -50,6 +55,7 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { private boolean isCaptureRunning = false; private boolean isSurfaceReady = false; private SurfaceHolder surfaceHolder = null; + private SurfaceTexture surfaceTexture = null; private final int numCaptureBuffers = 3; private int expectedFrameSize = 0; @@ -67,6 +73,38 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { private AppStateListener mAppStateListener = null; + public class MySurfaceTextureListener implements TextureView.SurfaceTextureListener { + public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { + Log.d(TAG, "VideoCaptureAndroid::onSurfaceTextureAvailable"); + + captureLock.lock(); + isSurfaceReady = true; + surfaceTexture = surface; + + tryStartCapture(mCaptureWidth, mCaptureHeight, mCaptureFPS); + captureLock.unlock(); + } + + public void onSurfaceTextureSizeChanged(SurfaceTexture surface, + int width, int height) { + // Ignored, Camera does all the work for us + // Note that for a TextureView we start on onSurfaceTextureAvailable, + // for a SurfaceView we start on surfaceChanged. TextureView + // will not give out an onSurfaceTextureSizeChanged during creation. + } + + public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { + Log.d(TAG, "VideoCaptureAndroid::onSurfaceTextureDestroyed"); + isSurfaceReady = false; + DetachCamera(); + return true; + } + + public void onSurfaceTextureUpdated(SurfaceTexture surface) { + // Invoked every time there's a new Camera preview frame + } + } + public static void DeleteVideoCaptureAndroid(VideoCaptureAndroid captureAndroid) { Log.d(TAG, "DeleteVideoCaptureAndroid"); @@ -78,8 +116,13 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { captureAndroid.camera = null; captureAndroid.context = 0; - GeckoAppShell.getGeckoInterface().getCameraView().getHolder(). - removeCallback(captureAndroid); + View cameraView = GeckoAppShell.getGeckoInterface().getCameraView(); + if (cameraView instanceof SurfaceView) { + ((SurfaceView)cameraView).getHolder().removeCallback(captureAndroid); + } else if (cameraView instanceof TextureView) { + // No need to explicitly remove the Listener: + // i.e. ((SurfaceView)cameraView).setSurfaceTextureListener(null); + } ThreadUtils.getUiHandler().post(new Runnable() { @Override public void run() { @@ -104,7 +147,13 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { currentDevice = in_device; try { - GeckoAppShell.getGeckoInterface().getCameraView().getHolder().addCallback(this); + View cameraView = GeckoAppShell.getGeckoInterface().getCameraView(); + if (cameraView instanceof SurfaceView) { + ((SurfaceView)cameraView).getHolder().addCallback(this); + } else if (cameraView instanceof TextureView) { + MySurfaceTextureListener listener = new MySurfaceTextureListener(); + ((TextureView)cameraView).setSurfaceTextureListener(listener); + } ThreadUtils.getUiHandler().post(new Runnable() { @Override public void run() { @@ -190,7 +239,10 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { } try { - camera.setPreviewDisplay(surfaceHolder); + if (surfaceHolder != null) + camera.setPreviewDisplay(surfaceHolder); + if (surfaceTexture != null) + camera.setPreviewTexture(surfaceTexture); CaptureCapabilityAndroid currentCapability = new CaptureCapabilityAndroid(); diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 1fa2265d102..a75fd27ff3f 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -83,6 +83,7 @@ import android.view.MotionEvent; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; +import android.view.TextureView; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -163,7 +164,7 @@ abstract public class GeckoApp protected RelativeLayout mMainLayout; protected RelativeLayout mGeckoLayout; public View getView() { return mGeckoLayout; } - public SurfaceView mCameraView; + private View mCameraView; public List mAppStateListeners; private static GeckoApp sAppContext; protected MenuPanel mMenuPanel; @@ -257,7 +258,7 @@ abstract public class GeckoApp return GeckoApp.sAppContext.getSharedPreferences(PREFS_NAME, 0); } - public SurfaceView getCameraView() { + public View getCameraView() { return mCameraView; } @@ -1303,8 +1304,12 @@ abstract public class GeckoApp mFormAssistPopup = (FormAssistPopup) findViewById(R.id.form_assist_popup); if (mCameraView == null) { - mCameraView = new SurfaceView(this); - mCameraView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + mCameraView = new SurfaceView(this); + ((SurfaceView)mCameraView).getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + } else { + mCameraView = new TextureView(this); + } } if (mLayerView == null) { @@ -1688,12 +1693,23 @@ abstract public class GeckoApp } public void enableCameraView() { + if (mCameraView instanceof SurfaceView) { + // Try to make it fully transparent. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + mCameraView.setAlpha(0.0f); + } + } else if (mCameraView instanceof TextureView) { + mCameraView.setAlpha(0.0f); + } + RelativeLayout mCameraLayout = (RelativeLayout) findViewById(R.id.camera_layout); // Some phones (eg. nexus S) need at least a 8x16 preview size - mMainLayout.addView(mCameraView, new AbsoluteLayout.LayoutParams(8, 16, 0, 0)); + mCameraLayout.addView(mCameraView, + new AbsoluteLayout.LayoutParams(8, 16, 0, 0)); } public void disableCameraView() { - mMainLayout.removeView(mCameraView); + RelativeLayout mCameraLayout = (RelativeLayout) findViewById(R.id.camera_layout); + mCameraLayout.removeView(mCameraView); } public String getDefaultUAString() { diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 82723fbde86..1c672814caa 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -69,6 +69,7 @@ import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; import android.view.Surface; import android.view.SurfaceView; +import android.view.TextureView; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.webkit.MimeTypeMap; @@ -1981,7 +1982,7 @@ public class GeckoAppShell public void disableCameraView(); public void addAppStateListener(AppStateListener listener); public void removeAppStateListener(AppStateListener listener); - public SurfaceView getCameraView(); + public View getCameraView(); public void notifyWakeLockChanged(String topic, String state); public FormAssistPopup getFormAssistPopup(); public boolean areTabsShown(); @@ -2070,12 +2071,18 @@ public class GeckoAppShell } try { - if (getGeckoInterface() != null) - sCamera.setPreviewDisplay(getGeckoInterface().getCameraView().getHolder()); + if (getGeckoInterface() != null) { + View cameraView = getGeckoInterface().getCameraView(); + if (cameraView instanceof SurfaceView) { + sCamera.setPreviewDisplay(((SurfaceView)cameraView).getHolder()); + } else if (cameraView instanceof TextureView) { + sCamera.setPreviewTexture(((TextureView)cameraView).getSurfaceTexture()); + } + } } catch(IOException e) { - Log.w(LOGTAG, "Error setPreviewDisplay:", e); + Log.w(LOGTAG, "Error setPreviewXXX:", e); } catch(RuntimeException e) { - Log.w(LOGTAG, "Error setPreviewDisplay:", e); + Log.w(LOGTAG, "Error setPreviewXXX:", e); } sCamera.setParameters(params); diff --git a/mobile/android/base/resources/layout/gecko_app.xml b/mobile/android/base/resources/layout/gecko_app.xml index 15fdf896820..5d293bb790e 100644 --- a/mobile/android/base/resources/layout/gecko_app.xml +++ b/mobile/android/base/resources/layout/gecko_app.xml @@ -35,6 +35,13 @@ style="@style/FindBar" android:visibility="gone"/> + + + Date: Mon, 1 Jul 2013 08:03:33 +0200 Subject: [PATCH 03/28] Bug 874569 - Adjust rotation amount if the Android device is rotated. r=blassey --- .../videoengine/VideoCaptureAndroid.java | 52 ++------ .../android/video_capture_android.cc | 112 ++++-------------- .../android/video_capture_android.h | 4 +- mobile/android/base/GeckoApp.java | 6 + mobile/android/base/GeckoAppShell.java | 1 + 5 files changed, 40 insertions(+), 135 deletions(-) diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java index 57f659f2439..44692f4a65f 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java @@ -70,6 +70,7 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { private int mCaptureWidth = -1; private int mCaptureHeight = -1; private int mCaptureFPS = -1; + private int mCaptureRotation = 0; private AppStateListener mAppStateListener = null; @@ -145,6 +146,7 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { camera = in_camera; cameraId = in_cameraId; currentDevice = in_device; + mCaptureRotation = GetRotateAmount(); try { View cameraView = GeckoAppShell.getGeckoInterface().getCameraView(); @@ -194,6 +196,10 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { tryStartCapture(mCaptureWidth, mCaptureHeight, mCaptureFPS); captureLock.unlock(); } + @Override + public void onConfigurationChanged() { + mCaptureRotation = GetRotateAmount(); + } }; GeckoAppShell.getGeckoInterface().addAppStateListener(mAppStateListener); @@ -320,7 +326,8 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { return DetachCamera(); } - native void ProvideCameraFrame(byte[] data, int length, long captureObject); + native void ProvideCameraFrame(byte[] data, int length, int rotation, + long captureObject); public void onPreviewFrame(byte[] data, Camera camera) { previewBufferLock.lock(); @@ -332,7 +339,8 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { // If StartCapture has been called but not StopCapture // Call the C++ layer with the captured frame if (data.length == expectedFrameSize) { - ProvideCameraFrame(data, expectedFrameSize, context); + ProvideCameraFrame(data, expectedFrameSize, mCaptureRotation, + context); if (ownsBuffers) { // Give the video buffer to the camera service again. camera.addCallbackBuffer(data); @@ -342,46 +350,6 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { previewBufferLock.unlock(); } - // Sets the rotation of the preview render window. - // Does not affect the captured video image. - public void SetPreviewRotation(int rotation) { - Log.v(TAG, "SetPreviewRotation: " + rotation); - - if (camera != null) { - previewBufferLock.lock(); - int width = 0; - int height = 0; - int framerate = 0; - boolean wasCaptureRunning = isCaptureRunning; - - if (isCaptureRunning) { - width = mCaptureWidth; - height = mCaptureHeight; - framerate = mCaptureFPS; - StopCapture(); - } - - int resultRotation = 0; - if (currentDevice.frontCameraType == - VideoCaptureDeviceInfoAndroid.FrontFacingCameraType.Android23) { - // this is a 2.3 or later front facing camera. - // SetDisplayOrientation will flip the image horizontally - // before doing the rotation. - resultRotation=(360-rotation) % 360; // compensate the mirror - } - else { - // Back facing or 2.2 or previous front camera - resultRotation=rotation; - } - camera.setDisplayOrientation(resultRotation); - - if (wasCaptureRunning) { - StartCapture(width, height, framerate); - } - previewBufferLock.unlock(); - } - } - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.d(TAG, "VideoCaptureAndroid::surfaceChanged"); diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc b/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc index b2b49b65b58..13daf4cd38a 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc @@ -92,7 +92,7 @@ WebRtc_Word32 VideoCaptureAndroid::SetAndroidObjects(void* javaVM, return -1; } JNINativeMethod nativeFunctions = - { "ProvideCameraFrame", "([BIJ)V", + { "ProvideCameraFrame", "([BIIJ)V", (void*) &VideoCaptureAndroid::ProvideCameraFrame }; if (env->RegisterNatives(g_javaCmClass, &nativeFunctions, 1) == 0) { WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, -1, @@ -251,11 +251,29 @@ void JNICALL VideoCaptureAndroid::ProvideCameraFrame(JNIEnv * env, jobject, jbyteArray javaCameraFrame, jint length, + jint rotation, jlong context) { VideoCaptureAndroid* captureModule = reinterpret_cast(context); WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, -1, "%s: IncomingFrame %d", __FUNCTION__,length); + + switch (rotation) { + case 90: + captureModule->SetCaptureRotation(kCameraRotate90); + break; + case 180: + captureModule->SetCaptureRotation(kCameraRotate180); + break; + case 270: + captureModule->SetCaptureRotation(kCameraRotate270); + break; + case 0: + default: + captureModule->SetCaptureRotation(kCameraRotate0); + break; + } + jbyte* cameraFrame= env->GetByteArrayElements(javaCameraFrame,NULL); captureModule->IncomingFrame((WebRtc_UWord8*) cameraFrame, length,captureModule->_frameInfo,0); @@ -451,7 +469,6 @@ WebRtc_Word32 VideoCaptureAndroid::StartCapture( bool isAttached = false; WebRtc_Word32 result = 0; - WebRtc_Word32 rotation = 0; // get the JNI env for this thread JNIEnv *env; if (g_jvm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { @@ -498,21 +515,6 @@ WebRtc_Word32 VideoCaptureAndroid::StartCapture( "%s: Failed to find StartCapture id", __FUNCTION__); } - // get the method ID for the Android Java - // CaptureClass static GetRotateAmount method. - cid = env->GetMethodID(g_javaCmClass, "GetRotateAmount", "()I"); - if (cid != NULL) { - WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, -1, - "%s: Call GetRotateAmount", __FUNCTION__); - rotation = env->CallIntMethod(_javaCaptureObj, cid); - WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, -1, - "%s, GetRotateAmount = %d", __FUNCTION__, rotation); - } - else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1, - "%s: Failed to find GetRotateAmount id", __FUNCTION__); - } - // Detach this thread if it was attached if (isAttached) { if (g_jvm->DetachCurrentThread() < 0) { @@ -521,22 +523,6 @@ WebRtc_Word32 VideoCaptureAndroid::StartCapture( } } - switch (rotation) { - case 90: - SetCaptureRotation(kCameraRotate90); - break; - case 180: - SetCaptureRotation(kCameraRotate180); - break; - case 270: - SetCaptureRotation(kCameraRotate270); - break; - case 0: - default: - SetCaptureRotation(kCameraRotate0); - break; - } - if (result == 0) { _requestedCapability = capability; _captureStarted = true; @@ -618,65 +604,7 @@ WebRtc_Word32 VideoCaptureAndroid::CaptureSettings( WebRtc_Word32 VideoCaptureAndroid::SetCaptureRotation( VideoCaptureRotation rotation) { CriticalSectionScoped cs(&_apiCs); - if (VideoCaptureImpl::SetCaptureRotation(rotation) == 0) { - if (!g_jvm) - return -1; - - // get the JNI env for this thread - JNIEnv *env; - bool isAttached = false; - - // get the JNI env for this thread - if (g_jvm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { - // try to attach the thread and get the env - // Attach this thread to JVM - jint res = g_jvm->AttachCurrentThread(&env, NULL); - if ((res < 0) || !env) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, - _id, - "%s: Could not attach thread to JVM (%d, %p)", - __FUNCTION__, res, env); - return -1; - } - isAttached = true; - } - - jmethodID cid = env->GetMethodID(g_javaCmClass, "SetPreviewRotation", - "(I)V"); - if (cid == NULL) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1, - "%s: could not get java SetPreviewRotation ID", - __FUNCTION__); - return -1; - } - jint rotateFrame = 0; - switch (rotation) { - case kCameraRotate0: - rotateFrame = 0; - break; - case kCameraRotate90: - rotateFrame = 90; - break; - case kCameraRotate180: - rotateFrame = 180; - break; - case kCameraRotate270: - rotateFrame = 270; - break; - } - env->CallVoidMethod(_javaCaptureObj, cid, rotateFrame); - - // Detach this thread if it was attached - if (isAttached) { - if (g_jvm->DetachCurrentThread() < 0) { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioDevice, - _id, "%s: Could not detach thread from JVM", - __FUNCTION__); - } - } - - } - return 0; + return VideoCaptureImpl::SetCaptureRotation(rotation); } } // namespace videocapturemodule diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.h b/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.h index 15211cb61e3..73199593fb0 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.h +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.h @@ -47,7 +47,9 @@ class VideoCaptureAndroid : public VideoCaptureImpl { static void JNICALL ProvideCameraFrame (JNIEnv * env, jobject, jbyteArray javaCameraFrame, - jint length, jlong context); + jint length, + jint rotation, + jlong context); DeviceInfoAndroid _capInfo; jobject _javaCaptureObj; // Java Camera object. VideoCaptureCapability _frameInfo; diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index a75fd27ff3f..06db8852c41 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -2076,6 +2076,12 @@ abstract public class GeckoApp mFormAssistPopup.hide(); refreshChrome(); } + + if (mAppStateListeners != null) { + for (GeckoAppShell.AppStateListener listener: mAppStateListeners) { + listener.onConfigurationChanged(); + } + } } @Override diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 1c672814caa..a55cb5ff336 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -1965,6 +1965,7 @@ public class GeckoAppShell public interface AppStateListener { public void onPause(); public void onResume(); + public void onConfigurationChanged(); } public interface GeckoInterface { From 4bb2b603484ab6f8722c10c686fb4f7ea89792af Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Sun, 30 Jun 2013 22:23:16 -0700 Subject: [PATCH 04/28] Bug 713933: Make false start work with asynchronous certificate verification, r=bsmith --HG-- extra : rebase_source : b895a399e381996f7e55d06f94a684469e287b8d --- security/nss/coreconf/coreconf.dep | 1 + security/nss/lib/ssl/ssl.def | 7 + security/nss/lib/ssl/ssl.h | 73 +- security/nss/lib/ssl/ssl3con.c | 109 +- security/nss/lib/ssl/ssl3gthr.c | 4 +- security/nss/lib/ssl/sslauth.c | 10 +- security/nss/lib/ssl/sslimpl.h | 9 +- security/nss/lib/ssl/sslinfo.c | 10 +- security/nss/lib/ssl/sslreveal.c | 9 +- security/nss/lib/ssl/sslsecur.c | 84 +- security/nss/lib/ssl/sslsock.c | 8 +- security/patches/README | 4 + security/patches/bug-658222-false-start.patch | 1577 +++++++++++++++++ 13 files changed, 1818 insertions(+), 87 deletions(-) create mode 100644 security/patches/bug-658222-false-start.patch diff --git a/security/nss/coreconf/coreconf.dep b/security/nss/coreconf/coreconf.dep index 5182f75552c..590d1bfaeee 100644 --- a/security/nss/coreconf/coreconf.dep +++ b/security/nss/coreconf/coreconf.dep @@ -10,3 +10,4 @@ */ #error "Do not include this header file." + diff --git a/security/nss/lib/ssl/ssl.def b/security/nss/lib/ssl/ssl.def index fbf7fc579c1..33bc91e942d 100644 --- a/security/nss/lib/ssl/ssl.def +++ b/security/nss/lib/ssl/ssl.def @@ -163,3 +163,10 @@ SSL_SetStapledOCSPResponses; ;+ local: ;+*; ;+}; +;+NSS_3.15.2 { # NSS 3.15.2 release +;+ global: +SSL_SetCanFalseStartCallback; +SSL_DefaultCanFalseStart; +;+ local: +;+*; +;+}; diff --git a/security/nss/lib/ssl/ssl.h b/security/nss/lib/ssl/ssl.h index 6db0e340328..6f7664ac9c8 100644 --- a/security/nss/lib/ssl/ssl.h +++ b/security/nss/lib/ssl/ssl.h @@ -121,14 +121,22 @@ SSL_IMPORT PRFileDesc *DTLS_ImportFD(PRFileDesc *model, PRFileDesc *fd); #define SSL_ENABLE_FALSE_START 22 /* Enable SSL false start (off by */ /* default, applies only to */ /* clients). False start is a */ -/* mode where an SSL client will start sending application data before */ -/* verifying the server's Finished message. This means that we could end up */ -/* sending data to an imposter. However, the data will be encrypted and */ -/* only the true server can derive the session key. Thus, so long as the */ -/* cipher isn't broken this is safe. Because of this, False Start will only */ -/* occur on RSA or DH ciphersuites where the cipher's key length is >= 80 */ -/* bits. The advantage of False Start is that it saves a round trip for */ -/* client-speaks-first protocols when performing a full handshake. */ +/* mode where an SSL client will start sending application data before + * verifying the server's Finished message. This means that we could end up + * sending data to an imposter. However, the data will be encrypted and + * only the true server can derive the session key. Thus, so long as the + * cipher isn't broken this is safe. The advantage of false start is that + * it saves a round trip for client-speaks-first protocols when performing a + * full handshake. + * + * See SSL_DefaultCanFalseStart for the default criteria that NSS uses to + * determine whether to false start or not. See SSL_SetCanFalseStartCallback + * for how to change that criteria. In addition to those criteria, false start + * will only be done when the server selects a cipher suite with an effective + * key length of 80 bits or more (including RC4-128). Also, see + * SSL_HandshakeCallback for a description on how false start affects when the + * handshake callback gets called. + */ /* For SSL 3.0 and TLS 1.0, by default we prevent chosen plaintext attacks * on SSL CBC mode cipher suites (see RFC 4346 Section F.3) by splitting @@ -653,14 +661,59 @@ SSL_IMPORT SECStatus SSL_SetMaxServerCacheLocks(PRUint32 maxLocks); SSL_IMPORT SECStatus SSL_InheritMPServerSIDCache(const char * envString); /* -** Set the callback on a particular socket that gets called when we finish -** performing a handshake. +** Set the callback that normally gets called when the TLS handshake +** is complete. If false start is not enabled, then the handshake callback is +** called after verifying the peer's Finished message and before sending +** outgoing application data and before processing incoming application data. +** +** If false start is enabled and there is a custom CanFalseStartCallback +** callback set, then the handshake callback gets called after the peer's +** Finished message has been verified, which may be after application data is +** sent. +** +** If false start is enabled and there is not a custom CanFalseStartCallback +** callback established with SSL_SetCanFalseStartCallback then the handshake +** callback gets called before any application data is sent, which may be +** before the peer's Finished message has been verified. */ typedef void (PR_CALLBACK *SSLHandshakeCallback)(PRFileDesc *fd, void *client_data); SSL_IMPORT SECStatus SSL_HandshakeCallback(PRFileDesc *fd, SSLHandshakeCallback cb, void *client_data); +/* Applications that wish to customize TLS false start should set this callback +** function. NSS will invoke the functon to determine if a particular +** connection should use false start or not. SECSuccess indicates that the +** callback completed successfully, and if so *canFalseStart indicates if false +** start can be used. If the callback does not return SECSuccess then the +** handshake will be canceled. +** +** Applications that do not set the callback will use an internal set of +** criteria to determine if the connection should false start. If +** the callback is set false start will never be used without invoking the +** callback function, but some connections (e.g. resumed connections) will +** never use false start and therefore will not invoke the callback. +** +** NSS's internal criteria for this connection can be evaluated by calling +** SSL_DefaultCanFalseStart() from the custom callback. +** +** See the description of SSL_HandshakeCallback for important information on +** how registering a custom false start callback affects when the handshake +** callback gets called. +**/ +typedef SECStatus (PR_CALLBACK *SSLCanFalseStartCallback)( + PRFileDesc *fd, void *arg, PRBool *canFalseStart); + +SSL_IMPORT SECStatus SSL_SetCanFalseStartCallback( + PRFileDesc *fd, SSLCanFalseStartCallback callback, void *arg); + +/* A utility function that can be called from a custom CanFalseStartCallback +** function to determine what NSS would have done for this connection if the +** custom callback was not implemented. +**/ +SSL_IMPORT SECStatus SSL_DefaultCanFalseStart(PRFileDesc *fd, + PRBool *canFalseStart); + /* ** For the server, request a new handshake. For the client, begin a new ** handshake. If flushCache is non-zero, the SSL3 cache entry will be diff --git a/security/nss/lib/ssl/ssl3con.c b/security/nss/lib/ssl/ssl3con.c index f5087be84f3..53b6f237aec 100644 --- a/security/nss/lib/ssl/ssl3con.c +++ b/security/nss/lib/ssl/ssl3con.c @@ -6669,35 +6669,51 @@ done: return rv; } -PRBool -ssl3_CanFalseStart(sslSocket *ss) { - PRBool rv; +static SECStatus +ssl3_CheckFalseStart(sslSocket *ss) +{ + SECStatus rv; + PRBool maybeFalseStart = PR_TRUE; PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); + PORT_Assert( !ss->ssl3.hs.authCertificatePending ); - /* XXX: does not take into account whether we are waiting for - * SSL_AuthCertificateComplete or SSL_RestartHandshakeAfterCertReq. If/when - * that is done, this function could return different results each time it - * would be called. - */ + /* An attacker can control the selected ciphersuite so we only wish to + * do False Start in the case that the selected ciphersuite is + * sufficiently strong that the attack can gain no advantage. + * Therefore we always require an 80-bit cipher. */ ssl_GetSpecReadLock(ss); - rv = ss->opt.enableFalseStart && - !ss->sec.isServer && - !ss->ssl3.hs.isResuming && - ss->ssl3.cwSpec && - - /* An attacker can control the selected ciphersuite so we only wish to - * do False Start in the case that the selected ciphersuite is - * sufficiently strong that the attack can gain no advantage. - * Therefore we require an 80-bit cipher and a forward-secret key - * exchange. */ - ss->ssl3.cwSpec->cipher_def->secret_key_size >= 10 && - (ss->ssl3.hs.kea_def->kea == kea_dhe_dss || - ss->ssl3.hs.kea_def->kea == kea_dhe_rsa || - ss->ssl3.hs.kea_def->kea == kea_ecdhe_ecdsa || - ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa); + if (ss->ssl3.cwSpec->cipher_def->secret_key_size < 10) { + ss->ssl3.hs.canFalseStart = PR_FALSE; + maybeFalseStart = PR_FALSE; + } ssl_ReleaseSpecReadLock(ss); + if (!maybeFalseStart) { + return SECSuccess; + } + + if (!ss->canFalseStartCallback) { + rv = SSL_DefaultCanFalseStart(ss->fd, &ss->ssl3.hs.canFalseStart); + + if (rv == SECSuccess && + ss->ssl3.hs.canFalseStart && ss->handshakeCallback) { + /* Call the handshake callback here for backwards compatibility + * with applications that were using false start before + * canFalseStartCallback was added. + */ + (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); + } + } else { + rv = (ss->canFalseStartCallback)(ss->fd, + ss->canFalseStartCallbackData, + &ss->ssl3.hs.canFalseStart); + } + + if (rv != SECSuccess) { + ss->ssl3.hs.canFalseStart = PR_FALSE; + } + return rv; } @@ -6727,6 +6743,7 @@ ssl3_HandleServerHelloDone(sslSocket *ss) return SECFailure; } + ss->enoughFirstHsDone = PR_TRUE; rv = ssl3_SendClientSecondRound(ss); return rv; @@ -6825,6 +6842,23 @@ ssl3_SendClientSecondRound(sslSocket *ss) if (rv != SECSuccess) { goto loser; /* err code was set. */ } + + if (ss->opt.enableFalseStart) { + if (!ss->ssl3.hs.authCertificatePending) { + rv = ssl3_CheckFalseStart(ss); + if (rv != SECSuccess) { + goto loser; + } + } else { + /* The certificate authentication and the server's Finished + * message are going to race each other. If the certificate + * authentication wins, then we will try to false start. If the + * server's Finished message wins, then ssl3_HandleFinished will + * reset restartTarget to ssl3_FinishHandshake. + */ + ss->ssl3.hs.restartTarget = ssl3_CheckFalseStart; + } + } } rv = ssl3_SendFinished(ss, 0); @@ -6839,11 +6873,6 @@ ssl3_SendClientSecondRound(sslSocket *ss) else ss->ssl3.hs.ws = wait_change_cipher; - /* Do the handshake callback for sslv3 here, if we can false start. */ - if (ss->handshakeCallback != NULL && ssl3_CanFalseStart(ss)) { - (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); - } - return SECSuccess; loser: @@ -9416,13 +9445,6 @@ ssl3_AuthCertificate(sslSocket *ss) ss->ssl3.hs.authCertificatePending = PR_TRUE; rv = SECSuccess; - - /* XXX: Async cert validation and False Start don't work together - * safely yet; if we leave False Start enabled, we may end up false - * starting (sending application data) before we - * SSL_AuthCertificateComplete has been called. - */ - ss->opt.enableFalseStart = PR_FALSE; } if (rv != SECSuccess) { @@ -10070,6 +10092,11 @@ xmit_loser: ss->ssl3.hs.cacheSID = rv == SECSuccess; } + /* Cancel false start check since we already completed the handshake */ + if (ss->ssl3.hs.restartTarget == ssl3_CheckFalseStart) { + ss->ssl3.hs.restartTarget = NULL; + } + if (ss->ssl3.hs.authCertificatePending) { if (ss->ssl3.hs.restartTarget) { PR_NOT_REACHED("ssl3_HandleFinished: unexpected restartTarget"); @@ -10088,6 +10115,8 @@ xmit_loser: SECStatus ssl3_FinishHandshake(sslSocket * ss) { + PRBool falseStarted; + PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); PORT_Assert( ss->ssl3.hs.restartTarget == NULL ); @@ -10095,6 +10124,7 @@ ssl3_FinishHandshake(sslSocket * ss) /* The first handshake is now completed. */ ss->handshake = NULL; ss->firstHsDone = PR_TRUE; + ss->enoughFirstHsDone = PR_TRUE; if (ss->ssl3.hs.cacheSID) { (*ss->sec.cache)(ss->sec.ci.sid); @@ -10102,9 +10132,14 @@ ssl3_FinishHandshake(sslSocket * ss) } ss->ssl3.hs.ws = idle_handshake; + falseStarted = ss->ssl3.hs.canFalseStart; + ss->ssl3.hs.canFalseStart = PR_FALSE; /* False Start phase is complete */ - /* Do the handshake callback for sslv3 here, if we cannot false start. */ - if (ss->handshakeCallback != NULL && !ssl3_CanFalseStart(ss)) { + /* Call the handshake callback for sslv3 here, unless we called it already + * for the case where false start was done without a canFalseStartCallback. + */ + if (ss->handshakeCallback != NULL && + !(falseStarted && !ss->canFalseStartCallback)) { (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); } diff --git a/security/nss/lib/ssl/ssl3gthr.c b/security/nss/lib/ssl/ssl3gthr.c index 6d625152662..7385d6504e8 100644 --- a/security/nss/lib/ssl/ssl3gthr.c +++ b/security/nss/lib/ssl/ssl3gthr.c @@ -374,9 +374,7 @@ ssl3_GatherCompleteHandshake(sslSocket *ss, int flags) */ if (ss->opt.enableFalseStart) { ssl_GetSSL3HandshakeLock(ss); - canFalseStart = (ss->ssl3.hs.ws == wait_change_cipher || - ss->ssl3.hs.ws == wait_new_session_ticket) && - ssl3_CanFalseStart(ss); + canFalseStart = ss->ssl3.hs.canFalseStart; ssl_ReleaseSSL3HandshakeLock(ss); } } while (ss->ssl3.hs.ws != idle_handshake && diff --git a/security/nss/lib/ssl/sslauth.c b/security/nss/lib/ssl/sslauth.c index d2f57bfe68d..cb956d4bc97 100644 --- a/security/nss/lib/ssl/sslauth.c +++ b/security/nss/lib/ssl/sslauth.c @@ -60,7 +60,6 @@ SSL_SecurityStatus(PRFileDesc *fd, int *op, char **cp, int *kp0, int *kp1, sslSocket *ss; const char *cipherName; PRBool isDes = PR_FALSE; - PRBool enoughFirstHsDone = PR_FALSE; ss = ssl_FindSocket(fd); if (!ss) { @@ -78,14 +77,7 @@ SSL_SecurityStatus(PRFileDesc *fd, int *op, char **cp, int *kp0, int *kp1, *op = SSL_SECURITY_STATUS_OFF; } - if (ss->firstHsDone) { - enoughFirstHsDone = PR_TRUE; - } else if (ss->version >= SSL_LIBRARY_VERSION_3_0 && - ssl3_CanFalseStart(ss)) { - enoughFirstHsDone = PR_TRUE; - } - - if (ss->opt.useSecurity && enoughFirstHsDone) { + if (ss->opt.useSecurity && ss->enoughFirstHsDone) { if (ss->version < SSL_LIBRARY_VERSION_3_0) { cipherName = ssl_cipherName[ss->sec.cipherType]; } else { diff --git a/security/nss/lib/ssl/sslimpl.h b/security/nss/lib/ssl/sslimpl.h index 90e9567c172..b3e36e67e7d 100644 --- a/security/nss/lib/ssl/sslimpl.h +++ b/security/nss/lib/ssl/sslimpl.h @@ -868,6 +868,8 @@ const ssl3CipherSuiteDef *suite_def; PRUint32 rtTimeoutMs; /* The length of the current timeout * used for backoff (in ms) */ PRUint32 rtRetries; /* The retry counter */ + PRBool canFalseStart; /* Can/did we False Start */ + } SSL3HandshakeState; @@ -1116,6 +1118,10 @@ struct sslSocketStr { unsigned long clientAuthRequested; unsigned long delayDisabled; /* Nagle delay disabled */ unsigned long firstHsDone; /* first handshake is complete. */ + unsigned long enoughFirstHsDone; /* enough of the handshake is done + * for callbacks to be able to + * retrieve channel security + * parameters from callback functions. */ unsigned long handshakeBegun; unsigned long lastWriteBlocked; unsigned long recvdCloseNotify; /* received SSL EOF. */ @@ -1156,6 +1162,8 @@ const unsigned char * preferredCipher; void *badCertArg; SSLHandshakeCallback handshakeCallback; void *handshakeCallbackData; + SSLCanFalseStartCallback canFalseStartCallback; + void *canFalseStartCallbackData; void *pkcs11PinArg; SSLNextProtoCallback nextProtoCallback; void *nextProtoArg; @@ -1358,7 +1366,6 @@ extern void ssl3_SetAlwaysBlock(sslSocket *ss); extern SECStatus ssl_EnableNagleDelay(sslSocket *ss, PRBool enabled); -extern PRBool ssl3_CanFalseStart(sslSocket *ss); extern SECStatus ssl3_CompressMACEncryptRecord(ssl3CipherSpec * cwSpec, PRBool isServer, diff --git a/security/nss/lib/ssl/sslinfo.c b/security/nss/lib/ssl/sslinfo.c index 9f2597e3945..d0c23b73382 100644 --- a/security/nss/lib/ssl/sslinfo.c +++ b/security/nss/lib/ssl/sslinfo.c @@ -26,7 +26,6 @@ SSL_GetChannelInfo(PRFileDesc *fd, SSLChannelInfo *info, PRUintn len) sslSocket * ss; SSLChannelInfo inf; sslSessionID * sid; - PRBool enoughFirstHsDone = PR_FALSE; if (!info || len < sizeof inf.length) { PORT_SetError(SEC_ERROR_INVALID_ARGS); @@ -43,14 +42,7 @@ SSL_GetChannelInfo(PRFileDesc *fd, SSLChannelInfo *info, PRUintn len) memset(&inf, 0, sizeof inf); inf.length = PR_MIN(sizeof inf, len); - if (ss->firstHsDone) { - enoughFirstHsDone = PR_TRUE; - } else if (ss->version >= SSL_LIBRARY_VERSION_3_0 && - ssl3_CanFalseStart(ss)) { - enoughFirstHsDone = PR_TRUE; - } - - if (ss->opt.useSecurity && enoughFirstHsDone) { + if (ss->opt.useSecurity && ss->enoughFirstHsDone) { sid = ss->sec.ci.sid; inf.protocolVersion = ss->version; inf.authKeyBits = ss->sec.authKeyBits; diff --git a/security/nss/lib/ssl/sslreveal.c b/security/nss/lib/ssl/sslreveal.c index dc14794bd34..bf424a94c6c 100644 --- a/security/nss/lib/ssl/sslreveal.c +++ b/security/nss/lib/ssl/sslreveal.c @@ -77,7 +77,6 @@ SSL_HandshakeNegotiatedExtension(PRFileDesc * socket, { /* some decisions derived from SSL_GetChannelInfo */ sslSocket * sslsocket = NULL; - PRBool enoughFirstHsDone = PR_FALSE; if (!pYes) { PORT_SetError(SEC_ERROR_INVALID_ARGS); @@ -93,14 +92,8 @@ SSL_HandshakeNegotiatedExtension(PRFileDesc * socket, *pYes = PR_FALSE; - if (sslsocket->firstHsDone) { - enoughFirstHsDone = PR_TRUE; - } else if (sslsocket->ssl3.initialized && ssl3_CanFalseStart(sslsocket)) { - enoughFirstHsDone = PR_TRUE; - } - /* according to public API SSL_GetChannelInfo, this doesn't need a lock */ - if (sslsocket->opt.useSecurity && enoughFirstHsDone) { + if (sslsocket->opt.useSecurity && sslsocket->enoughFirstHsDone) { if (sslsocket->ssl3.initialized) { /* SSL3 and TLS */ /* now we know this socket went through ssl3_InitState() and * ss->xtnData got initialized, which is the only member accessed by diff --git a/security/nss/lib/ssl/sslsecur.c b/security/nss/lib/ssl/sslsecur.c index 49bb42bb71d..793982abf78 100644 --- a/security/nss/lib/ssl/sslsecur.c +++ b/security/nss/lib/ssl/sslsecur.c @@ -108,10 +108,12 @@ ssl_Do1stHandshake(sslSocket *ss) if ((ss->handshakeCallback != NULL) && /* has callback */ (!ss->firstHsDone) && /* only first time */ (ss->version < SSL_LIBRARY_VERSION_3_0)) { /* not ssl3 */ - ss->firstHsDone = PR_TRUE; + ss->firstHsDone = PR_TRUE; + ss->enoughFirstHsDone = PR_TRUE; (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); } - ss->firstHsDone = PR_TRUE; + ss->firstHsDone = PR_TRUE; + ss->enoughFirstHsDone = PR_TRUE; ss->gs.writeOffset = 0; ss->gs.readOffset = 0; break; @@ -206,6 +208,7 @@ SSL_ResetHandshake(PRFileDesc *s, PRBool asServer) ssl_Get1stHandshakeLock(ss); ss->firstHsDone = PR_FALSE; + ss->enoughFirstHsDone = PR_FALSE; if ( asServer ) { ss->handshake = ssl2_BeginServerHandshake; ss->handshaking = sslHandshakingAsServer; @@ -221,6 +224,8 @@ SSL_ResetHandshake(PRFileDesc *s, PRBool asServer) ssl_ReleaseRecvBufLock(ss); ssl_GetSSL3HandshakeLock(ss); + ss->ssl3.hs.canFalseStart = PR_FALSE; + ss->ssl3.hs.restartTarget = NULL; /* ** Blow away old security state and get a fresh setup. @@ -331,6 +336,74 @@ SSL_HandshakeCallback(PRFileDesc *fd, SSLHandshakeCallback cb, return SECSuccess; } +/* Register an application callback to be called when false start may happen. +** Acquires and releases HandshakeLock. +*/ +SECStatus +SSL_SetCanFalseStartCallback(PRFileDesc *fd, SSLCanFalseStartCallback cb, + void *client_data) +{ + sslSocket *ss; + + ss = ssl_FindSocket(fd); + if (!ss) { + SSL_DBG(("%d: SSL[%d]: bad socket in SSL_SetCanFalseStartCallback", + SSL_GETPID(), fd)); + return SECFailure; + } + + if (!ss->opt.useSecurity) { + PORT_SetError(SEC_ERROR_INVALID_ARGS); + return SECFailure; + } + + ssl_Get1stHandshakeLock(ss); + ssl_GetSSL3HandshakeLock(ss); + + ss->canFalseStartCallback = cb; + ss->canFalseStartCallbackData = client_data; + + ssl_ReleaseSSL3HandshakeLock(ss); + ssl_Release1stHandshakeLock(ss); + + return SECSuccess; +} + +/* A utility function that can be called from a custom CanFalseStartCallback +** function to determine what NSS would have done for this connection if the +** custom callback was not implemented. +*/ +SECStatus +SSL_DefaultCanFalseStart(PRFileDesc *fd, PRBool *canFalseStart) +{ + sslSocket *ss; + *canFalseStart = PR_FALSE; + ss = ssl_FindSocket(fd); + if (!ss) { + SSL_DBG(("%d: SSL[%d]: bad socket in SSL_DefaultCanFalseStart", + SSL_GETPID(), fd)); + return SECFailure; + } + + if (!ss->ssl3.initialized) { + PORT_SetError(SEC_ERROR_NOT_INITIALIZED); + return SECFailure; + } + + if (ss->version <= SSL_LIBRARY_VERSION_3_0) { + PORT_SetError(SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_VERSION); + return SECFailure; + } + + /* Require a forward-secret key exchange. */ + *canFalseStart = ss->ssl3.hs.kea_def->kea == kea_dhe_dss || + ss->ssl3.hs.kea_def->kea == kea_dhe_rsa || + ss->ssl3.hs.kea_def->kea == kea_ecdhe_ecdsa || + ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa; + + return SECSuccess; +} + /* Try to make progress on an SSL handshake by attempting to read the ** next handshake from the peer, and sending any responses. ** For non-blocking sockets, returns PR_ERROR_WOULD_BLOCK if it cannot @@ -1195,12 +1268,7 @@ ssl_SecureSend(sslSocket *ss, const unsigned char *buf, int len, int flags) ssl_Get1stHandshakeLock(ss); if (ss->version >= SSL_LIBRARY_VERSION_3_0) { ssl_GetSSL3HandshakeLock(ss); - if ((ss->ssl3.hs.ws == wait_change_cipher || - ss->ssl3.hs.ws == wait_finished || - ss->ssl3.hs.ws == wait_new_session_ticket) && - ssl3_CanFalseStart(ss)) { - canFalseStart = PR_TRUE; - } + canFalseStart = ss->ssl3.hs.canFalseStart; ssl_ReleaseSSL3HandshakeLock(ss); } if (!canFalseStart && diff --git a/security/nss/lib/ssl/sslsock.c b/security/nss/lib/ssl/sslsock.c index cd4a7a73e05..488b7f2a0a9 100644 --- a/security/nss/lib/ssl/sslsock.c +++ b/security/nss/lib/ssl/sslsock.c @@ -2341,9 +2341,13 @@ ssl_Poll(PRFileDesc *fd, PRInt16 how_flags, PRInt16 *p_out_flags) } else if (new_flags & PR_POLL_WRITE) { /* The caller is trying to write, but the handshake is ** blocked waiting for data to read, and the first - ** handshake has been sent. so do NOT to poll on write. + ** handshake has been sent. So do NOT to poll on write + ** unless we did false start. */ - new_flags ^= PR_POLL_WRITE; /* don't select on write. */ + if (!(ss->version >= SSL_LIBRARY_VERSION_3_0 && + ss->ssl3.hs.canFalseStart)) { + new_flags ^= PR_POLL_WRITE; /* don't select on write. */ + } new_flags |= PR_POLL_READ; /* do select on read. */ } } diff --git a/security/patches/README b/security/patches/README index 788bf6a533c..25f3069fec4 100644 --- a/security/patches/README +++ b/security/patches/README @@ -1,2 +1,6 @@ This directory contains patches that were added locally on top of the NSS release. + +bug-658222-false-start.patch: First iteration of false start. The patch will be + further modified to make it work for Chromium and + other projects before being checked in. diff --git a/security/patches/bug-658222-false-start.patch b/security/patches/bug-658222-false-start.patch new file mode 100644 index 00000000000..f58e60c31e4 --- /dev/null +++ b/security/patches/bug-658222-false-start.patch @@ -0,0 +1,1577 @@ +# HG changeset patch +# User Patrick McManus +# Date 1372453108 14400 +# Node ID 7587e41b0d6760166e1ab7ec4737fa2523038281 +# Parent bd363921496c4a219851de041249455e91fe3147 +bug 658222 - Enable TLS False Start (PSM) r=bsmith + +diff --git a/netwerk/base/public/security-prefs.js b/netwerk/base/public/security-prefs.js +--- a/netwerk/base/public/security-prefs.js ++++ b/netwerk/base/public/security-prefs.js +@@ -7,18 +7,20 @@ pref("security.tls.version.max", 1); + pref("security.enable_tls_session_tickets", true); + pref("security.enable_md5_signatures", false); + + pref("security.ssl.allow_unrestricted_renego_everywhere__temporarily_available_pref", false); + pref("security.ssl.renego_unrestricted_hosts", ""); + pref("security.ssl.treat_unsafe_negotiation_as_broken", false); + pref("security.ssl.require_safe_negotiation", false); + pref("security.ssl.warn_missing_rfc5746", 1); +-pref("security.ssl.enable_false_start", false); + pref("security.ssl.enable_ocsp_stapling", true); ++pref("security.ssl.enable_false_start", true); ++pref("security.ssl.false_start.require-npn", true); ++pref("security.ssl.false_start.require-forward-secrecy", false); + + pref("security.ssl3.rsa_rc4_128_md5", true); + pref("security.ssl3.rsa_rc4_128_sha", true); + pref("security.ssl3.rsa_fips_des_ede3_sha", true); + pref("security.ssl3.rsa_des_ede3_sha", true); + pref("security.ssl3.dhe_rsa_camellia_256_sha", true); + pref("security.ssl3.dhe_dss_camellia_256_sha", true); + pref("security.ssl3.rsa_camellia_256_sha", true); +diff --git a/netwerk/protocol/http/ConnectionDiagnostics.cpp b/netwerk/protocol/http/ConnectionDiagnostics.cpp +--- a/netwerk/protocol/http/ConnectionDiagnostics.cpp ++++ b/netwerk/protocol/http/ConnectionDiagnostics.cpp +@@ -122,18 +122,18 @@ nsHttpConnectionMgr::nsHalfOpenSocket::P + !!mSocketTransport.get(), !!mBackupTransport.get()); + } + + void + nsHttpConnection::PrintDiagnostics(nsCString &log) + { + log.AppendPrintf(" CanDirectlyActivate = %d\n", CanDirectlyActivate()); + +- log.AppendPrintf(" npncomplete = %d setupNPNCalled = %d\n", +- mNPNComplete, mSetupNPNCalled); ++ log.AppendPrintf(" npncomplete = %d setupSSLCalled = %d\n", ++ mNPNComplete, mSetupSSLCalled); + + log.AppendPrintf(" spdyVersion = %d reportedSpdy = %d everspdy = %d\n", + mUsingSpdyVersion, mReportedSpdy, mEverUsedSpdy); + + log.AppendPrintf(" iskeepalive = %d dontReuse = %d isReused = %d\n", + IsKeepAlive(), mDontReuse, mIsReused); + + log.AppendPrintf(" mTransaction = %d mSpdySession = %d\n", +diff --git a/netwerk/protocol/http/nsHttp.h b/netwerk/protocol/http/nsHttp.h +--- a/netwerk/protocol/http/nsHttp.h ++++ b/netwerk/protocol/http/nsHttp.h +@@ -53,16 +53,21 @@ typedef uint8_t nsHttpVersion; + // such as HTTP upgrade which are nonsensical for SPDY, it is not the + // SPDY configuration variable. + #define NS_HTTP_DISALLOW_SPDY (1<<7) + + // a transaction with this flag loads without respect to whether the load + // group is currently blocking on some resources + #define NS_HTTP_LOAD_UNBLOCKED (1<<8) + ++// These flags allow a transaction to use TLS false start with ++// weaker security profiles based on past history ++#define NS_HTTP_ALLOW_RSA_FALSESTART (1<<9) ++#define NS_HTTP_ALLOW_RC4_FALSESTART (1<<10) ++ + //----------------------------------------------------------------------------- + // some default values + //----------------------------------------------------------------------------- + + #define NS_HTTP_DEFAULT_PORT 80 + #define NS_HTTPS_DEFAULT_PORT 443 + + #define NS_HTTP_HEADER_SEPS ", \t" +diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp +--- a/netwerk/protocol/http/nsHttpChannel.cpp ++++ b/netwerk/protocol/http/nsHttpChannel.cpp +@@ -34,16 +34,24 @@ + #include "nsError.h" + #include "nsAlgorithm.h" + #include "GeckoProfiler.h" + #include "nsIConsoleService.h" + #include "base/compiler_specific.h" + #include "NullHttpTransaction.h" + #include "mozilla/Attributes.h" + #include "mozilla/VisualEventTracer.h" ++#include "nsISSLSocketControl.h" ++#include "sslt.h" ++#include "nsContentUtils.h" ++#include "nsIPermissionManager.h" ++#include "nsIPrincipal.h" ++#include "nsIScriptSecurityManager.h" ++#include "nsISSLStatus.h" ++#include "nsISSLStatusProvider.h" + + namespace mozilla { namespace net { + + namespace { + + // Device IDs for various cache types + const char kDiskDeviceID[] = "disk"; + const char kMemoryDeviceID[] = "memory"; +@@ -385,16 +393,17 @@ nsHttpChannel::Connect() + } + } + + // ensure that we are using a valid hostname + if (!net_IsValidHostName(nsDependentCString(mConnectionInfo->Host()))) + return NS_ERROR_UNKNOWN_HOST; + + // Consider opening a TCP connection right away ++ RetrieveSSLOptions(); + SpeculativeConnect(); + + // Don't allow resuming when cache must be used + if (mResuming && (mLoadFlags & LOAD_ONLY_FROM_CACHE)) { + LOG(("Resuming from cache is not supported yet")); + return NS_ERROR_DOCUMENT_NOT_CACHED; + } + +@@ -521,18 +530,19 @@ nsHttpChannel::SpeculativeConnect() + nsCOMPtr callbacks; + NS_NewNotificationCallbacksAggregation(mCallbacks, mLoadGroup, + getter_AddRefs(callbacks)); + if (!callbacks) + return; + + mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0); + mConnectionInfo->SetPrivate(mPrivateBrowsing); +- gHttpHandler->SpeculativeConnect(mConnectionInfo, +- callbacks); ++ gHttpHandler->SpeculativeConnect( ++ mConnectionInfo, callbacks, ++ mCaps & (NS_HTTP_ALLOW_RSA_FALSESTART | NS_HTTP_ALLOW_RC4_FALSESTART | NS_HTTP_DISALLOW_SPDY)); + } + + void + nsHttpChannel::DoNotifyListenerCleanup() + { + // We don't need this info anymore + CleanRedirectCacheChainIfNecessary(); + } +@@ -687,16 +697,47 @@ nsHttpChannel::SetupTransactionLoadGroup + + // Set the load group connection scope on the transaction + nsCOMPtr ci; + rootLoadGroup->GetConnectionInfo(getter_AddRefs(ci)); + if (ci) + mTransaction->SetLoadGroupConnectionInfo(ci); + } + ++void ++nsHttpChannel::RetrieveSSLOptions() ++{ ++ if (!IsHTTPS() || mPrivateBrowsing) ++ return; ++ ++ nsIPrincipal *principal = GetPrincipal(); ++ if (!principal) ++ return; ++ ++ nsCOMPtr permMgr = ++ do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); ++ if (!permMgr) ++ return; ++ ++ uint32_t perm; ++ nsresult rv = permMgr->TestPermissionFromPrincipal(principal, ++ "falsestart-rsa", &perm); ++ if (NS_SUCCEEDED(rv) && perm == nsIPermissionManager::ALLOW_ACTION) { ++ LOG(("nsHttpChannel::RetrieveSSLOptions [this=%p] " ++ "falsestart-rsa permission found\n", this)); ++ mCaps |= NS_HTTP_ALLOW_RSA_FALSESTART; ++ } ++ rv = permMgr->TestPermissionFromPrincipal(principal, "falsestart-rc4", &perm); ++ if (NS_SUCCEEDED(rv) && perm == nsIPermissionManager::ALLOW_ACTION) { ++ LOG(("nsHttpChannel::RetrieveSSLOptions [this=%p] " ++ "falsestart-rc4 permission found\n", this)); ++ mCaps |= NS_HTTP_ALLOW_RC4_FALSESTART; ++ } ++} ++ + nsresult + nsHttpChannel::SetupTransaction() + { + LOG(("nsHttpChannel::SetupTransaction [this=%p]\n", this)); + + NS_ENSURE_TRUE(!mTransaction, NS_ERROR_ALREADY_INITIALIZED); + + nsresult rv; +@@ -1154,16 +1195,99 @@ nsHttpChannel::ProcessSTSHeader() + if (NS_FAILED(rv)) { + LOG(("STS: Failed to parse STS header, continuing load.\n")); + return NS_OK; + } + + return NS_OK; + } + ++bool ++nsHttpChannel::IsHTTPS() ++{ ++ bool isHttps; ++ if (NS_FAILED(mURI->SchemeIs("https", &isHttps)) || !isHttps) ++ return false; ++ return true; ++} ++ ++void ++nsHttpChannel::ProcessSSLInformation() ++{ ++ // If this is HTTPS, record any use of RSA so that Key Exchange Algorithm ++ // can be whitelisted for TLS False Start in future sessions. We could ++ // do the same for DH but its rarity doesn't justify the lookup. ++ // Also do the same for RC4 symmetric ciphers. ++ ++ if (mCanceled || NS_FAILED(mStatus) || !mSecurityInfo || ++ !IsHTTPS() || mPrivateBrowsing) ++ return; ++ ++ nsCOMPtr ssl = do_QueryInterface(mSecurityInfo); ++ nsCOMPtr statusProvider = ++ do_QueryInterface(mSecurityInfo); ++ if (!ssl || !statusProvider) ++ return; ++ nsCOMPtr sslstat; ++ statusProvider->GetSSLStatus(getter_AddRefs(sslstat)); ++ if (!sslstat) ++ return; ++ ++ // If certificate exceptions are being used don't record this information ++ // in the permission manager. ++ bool trustCheck; ++ if (NS_FAILED(sslstat->GetIsDomainMismatch(&trustCheck)) || trustCheck) ++ return; ++ if (NS_FAILED(sslstat->GetIsNotValidAtThisTime(&trustCheck)) || trustCheck) ++ return; ++ if (NS_FAILED(sslstat->GetIsUntrusted(&trustCheck)) || trustCheck) ++ return; ++ ++ int16_t kea = ssl->GetKEAUsed(); ++ int16_t symcipher = ssl->GetSymmetricCipherUsed(); ++ ++ nsIPrincipal *principal = GetPrincipal(); ++ if (!principal) ++ return; ++ ++ // set a permission manager flag that future transactions can ++ // use via RetrieveSSLOptions(() ++ ++ nsCOMPtr permMgr = ++ do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); ++ if (!permMgr) ++ return; ++ ++ // Allow this to stand for a week ++ int64_t expireTime = (PR_Now() / PR_USEC_PER_MSEC) + ++ (86400 * 7 * PR_MSEC_PER_SEC); ++ ++ if (kea == ssl_kea_rsa) { ++ permMgr->AddFromPrincipal(principal, "falsestart-rsa", ++ nsIPermissionManager::ALLOW_ACTION, ++ nsIPermissionManager::EXPIRE_TIME, ++ expireTime); ++ LOG(("nsHttpChannel::ProcessSSLInformation [this=%p] " ++ "falsestart-rsa permission granted for this host\n", this)); ++ } else { ++ permMgr->RemoveFromPrincipal(principal, "falsestart-rsa"); ++ } ++ ++ if (symcipher == ssl_calg_rc4) { ++ permMgr->AddFromPrincipal(principal, "falsestart-rc4", ++ nsIPermissionManager::ALLOW_ACTION, ++ nsIPermissionManager::EXPIRE_TIME, ++ expireTime); ++ LOG(("nsHttpChannel::ProcessSSLInformation [this=%p] " ++ "falsestart-rc4 permission granted for this host\n", this)); ++ } else { ++ permMgr->RemoveFromPrincipal(principal, "falsestart-rc4"); ++ } ++} ++ + nsresult + nsHttpChannel::ProcessResponse() + { + nsresult rv; + uint32_t httpStatus = mResponseHead->Status(); + + // Gather data on whether the transaction and page (if this is + // the initial page load) is being loaded with SSL. +@@ -1186,16 +1310,18 @@ nsHttpChannel::ProcessResponse() + } else { + // Given a successful connection, process any STS data that's relevant. + rv = ProcessSTSHeader(); + MOZ_ASSERT(NS_SUCCEEDED(rv), "ProcessSTSHeader failed, continuing load."); + } + + MOZ_ASSERT(!mCachedContentIsValid); + ++ ProcessSSLInformation(); ++ + // notify "http-on-examine-response" observers + gHttpHandler->OnExamineResponse(this); + + SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie)); + + // handle unused username and password in url (see bug 232567) + if (httpStatus != 401 && httpStatus != 407) { + if (!mAuthRetryPending) +@@ -6020,16 +6146,40 @@ nsHttpChannel::ShouldSkipCache() + + LOG(("Cache dampener installed because service lock held too long [%fms]\n", + timeLocked)); + cacheSkippedUntil = TimeStamp::Now() + TimeDuration::FromSeconds(60); + gHttpHandler->SetCacheSkippedUntil(cacheSkippedUntil); + return true; + } + ++nsIPrincipal * ++nsHttpChannel::GetPrincipal() ++{ ++ if (mPrincipal) ++ return mPrincipal; ++ ++ nsIScriptSecurityManager *securityManager = ++ nsContentUtils::GetSecurityManager(); ++ ++ if (!securityManager) ++ return nullptr; ++ ++ securityManager->GetChannelPrincipal(this, getter_AddRefs(mPrincipal)); ++ if (!mPrincipal) ++ return nullptr; ++ ++ // principals with unknown app ids do not work with the permission manager ++ if (mPrincipal->GetUnknownAppId()) ++ mPrincipal = nullptr; ++ ++ return mPrincipal; ++} ++ ++ + NS_IMETHODIMP + nsHttpChannel::SetLoadGroup(nsILoadGroup *aLoadGroup) + { + MOZ_ASSERT(NS_IsMainThread(), "Wrong thread."); + + nsresult rv = HttpBaseChannel::SetLoadGroup(aLoadGroup); + if (NS_SUCCEEDED(rv)) { + UpdateAggregateCallbacks(); +diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h +--- a/netwerk/protocol/http/nsHttpChannel.h ++++ b/netwerk/protocol/http/nsHttpChannel.h +@@ -29,16 +29,17 @@ + #include "nsITimedChannel.h" + #include "nsIFile.h" + #include "nsDNSPrefetch.h" + #include "TimingStruct.h" + #include "AutoClose.h" + #include "mozilla/Telemetry.h" + + class nsAHttpConnection; ++class nsIPrincipal; + + namespace mozilla { namespace net { + + class HttpCacheQuery; + + //----------------------------------------------------------------------------- + // nsHttpChannel + //----------------------------------------------------------------------------- +@@ -169,16 +170,19 @@ private: + nsresult AsyncProcessRedirection(uint32_t httpStatus); + nsresult ContinueProcessRedirection(nsresult); + nsresult ContinueProcessRedirectionAfterFallback(nsresult); + nsresult ProcessFailedProxyConnect(uint32_t httpStatus); + nsresult ProcessFallback(bool *waitingForRedirectCallback); + nsresult ContinueProcessFallback(nsresult); + void HandleAsyncAbort(); + nsresult EnsureAssocReq(); ++ void ProcessSSLInformation(); ++ bool IsHTTPS(); ++ void RetrieveSSLOptions(); + + nsresult ContinueOnStartRequest1(nsresult); + nsresult ContinueOnStartRequest2(nsresult); + nsresult ContinueOnStartRequest3(nsresult); + + // redirection specific methods + void HandleAsyncRedirect(); + void HandleAsyncAPIRedirect(); +@@ -368,13 +372,17 @@ private: + void PushRedirectAsyncFunc(nsContinueRedirectionFunc func); + void PopRedirectAsyncFunc(nsContinueRedirectionFunc func); + + protected: + virtual void DoNotifyListenerCleanup(); + + private: // cache telemetry + bool mDidReval; ++ ++private: ++ nsIPrincipal *GetPrincipal(); ++ nsCOMPtr mPrincipal; + }; + + } } // namespace mozilla::net + + #endif // nsHttpChannel_h__ +diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp +--- a/netwerk/protocol/http/nsHttpConnection.cpp ++++ b/netwerk/protocol/http/nsHttpConnection.cpp +@@ -12,16 +12,17 @@ + #include "nsHttpRequestHead.h" + #include "nsHttpResponseHead.h" + #include "nsHttpHandler.h" + #include "nsIOService.h" + #include "nsISocketTransportService.h" + #include "nsISocketTransport.h" + #include "nsIServiceManager.h" + #include "nsISSLSocketControl.h" ++#include "sslt.h" + #include "nsStringStream.h" + #include "netCore.h" + #include "nsNetCID.h" + #include "nsProxyRelease.h" + #include "nsPreloadedStream.h" + #include "ASpdySession.h" + #include "mozilla/Telemetry.h" + #include "nsISupportsPriority.h" +@@ -59,21 +60,22 @@ nsHttpConnection::nsHttpConnection() + , mCompletedProxyConnect(false) + , mLastTransactionExpectedNoContent(false) + , mIdleMonitoring(false) + , mProxyConnectInProgress(false) + , mHttp1xTransactionCount(0) + , mRemainingConnectionUses(0xffffffff) + , mClassification(nsAHttpTransaction::CLASS_GENERAL) + , mNPNComplete(false) +- , mSetupNPNCalled(false) ++ , mSetupSSLCalled(false) + , mUsingSpdyVersion(0) + , mPriority(nsISupportsPriority::PRIORITY_NORMAL) + , mReportedSpdy(false) + , mEverUsedSpdy(false) ++ , mTransactionCaps(0) + { + LOG(("Creating nsHttpConnection @%x\n", this)); + + // grab a reference to the handler to ensure that it doesn't go away. + nsHttpHandler *handler = gHttpHandler; + NS_ADDREF(handler); + } + +@@ -231,18 +233,16 @@ nsHttpConnection::StartSpdy(uint8_t spdy + mSupportsPipelining = false; // dont use http/1 pipelines with spdy + mTransaction = mSpdySession; + mIdleTimeout = gHttpHandler->SpdyTimeout(); + } + + bool + nsHttpConnection::EnsureNPNComplete() + { +- // NPN is only used by SPDY right now. +- // + // If for some reason the components to check on NPN aren't available, + // this function will just return true to continue on and disable SPDY + + MOZ_ASSERT(mSocketTransport); + if (!mSocketTransport) { + // this cannot happen + mNPNComplete = true; + return true; +@@ -303,32 +303,33 @@ nsresult + nsHttpConnection::Activate(nsAHttpTransaction *trans, uint32_t caps, int32_t pri) + { + nsresult rv; + + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); + LOG(("nsHttpConnection::Activate [this=%p trans=%x caps=%x]\n", + this, trans, caps)); + ++ mTransactionCaps = caps; + mPriority = pri; + if (mTransaction && mUsingSpdyVersion) + return AddTransaction(trans, pri); + + NS_ENSURE_ARG_POINTER(trans); + NS_ENSURE_TRUE(!mTransaction, NS_ERROR_IN_PROGRESS); + + // reset the read timers to wash away any idle time + mLastReadTime = PR_IntervalNow(); + + // Update security callbacks + nsCOMPtr callbacks; + trans->GetSecurityCallbacks(getter_AddRefs(callbacks)); + SetSecurityCallbacks(callbacks); + +- SetupNPN(caps); // only for spdy ++ SetupSSL(caps); + + // take ownership of the transaction + mTransaction = trans; + + MOZ_ASSERT(!mIdleMonitoring, "Activating a connection with an Idle Monitor"); + mIdleMonitoring = false; + + // set mKeepAlive according to what will be requested +@@ -355,65 +356,80 @@ failed_activation: + if (NS_FAILED(rv)) { + mTransaction = nullptr; + } + + return rv; + } + + void +-nsHttpConnection::SetupNPN(uint32_t caps) ++nsHttpConnection::SetupSSL(uint32_t caps) + { +- if (mSetupNPNCalled) /* do only once */ ++ LOG(("nsHttpConnection::SetupSSL %p caps=0x%X\n", this, caps)); ++ ++ if (mSetupSSLCalled) // do only once + return; +- mSetupNPNCalled = true; ++ mSetupSSLCalled = true; + +- // Setup NPN Negotiation if necessary (only for SPDY) +- if (!mNPNComplete) { ++ if (mNPNComplete) ++ return; + +- mNPNComplete = true; ++ // we flip this back to false if SetNPNList succeeds at the end ++ // of this function ++ mNPNComplete = true; + +- if (mConnInfo->UsingSSL()) { +- LOG(("nsHttpConnection::SetupNPN Setting up " +- "Next Protocol Negotiation")); +- nsCOMPtr securityInfo; +- nsresult rv = +- mSocketTransport->GetSecurityInfo(getter_AddRefs(securityInfo)); +- if (NS_FAILED(rv)) +- return; ++ if (!mConnInfo->UsingSSL()) ++ return; + +- nsCOMPtr ssl = +- do_QueryInterface(securityInfo, &rv); +- if (NS_FAILED(rv)) +- return; ++ LOG(("nsHttpConnection::SetupSSL Setting up " ++ "Next Protocol Negotiation")); ++ nsCOMPtr securityInfo; ++ nsresult rv = ++ mSocketTransport->GetSecurityInfo(getter_AddRefs(securityInfo)); ++ if (NS_FAILED(rv)) ++ return; + +- nsTArray protocolArray; ++ nsCOMPtr ssl = do_QueryInterface(securityInfo, &rv); ++ if (NS_FAILED(rv)) ++ return; + +- // The first protocol is used as the fallback if none of the +- // protocols supported overlap with the server's list. +- // In the case of overlap, matching priority is driven by +- // the order of the server's advertisement. +- protocolArray.AppendElement(NS_LITERAL_CSTRING("http/1.1")); ++ if (caps & NS_HTTP_ALLOW_RSA_FALSESTART) { ++ LOG(("nsHttpConnection::SetupSSL %p " ++ ">= RSA Key Exchange Expected\n", this)); ++ ssl->SetKEAExpected(ssl_kea_rsa); ++ } + +- if (gHttpHandler->IsSpdyEnabled() && +- !(caps & NS_HTTP_DISALLOW_SPDY)) { +- LOG(("nsHttpConnection::SetupNPN Allow SPDY NPN selection")); +- if (gHttpHandler->SpdyInfo()->ProtocolEnabled(0)) +- protocolArray.AppendElement( +- gHttpHandler->SpdyInfo()->VersionString[0]); +- if (gHttpHandler->SpdyInfo()->ProtocolEnabled(1)) +- protocolArray.AppendElement( +- gHttpHandler->SpdyInfo()->VersionString[1]); +- } ++ if (caps & NS_HTTP_ALLOW_RC4_FALSESTART) { ++ LOG(("nsHttpConnection::SetupSSL %p " ++ ">= RC4 Key Exchange Expected\n", this)); ++ ssl->SetSymmetricCipherExpected(ssl_calg_rc4); ++ } + +- if (NS_SUCCEEDED(ssl->SetNPNList(protocolArray))) { +- LOG(("nsHttpConnection::Init Setting up SPDY Negotiation OK")); +- mNPNComplete = false; +- } +- } ++ nsTArray protocolArray; ++ ++ // The first protocol is used as the fallback if none of the ++ // protocols supported overlap with the server's list. ++ // In the case of overlap, matching priority is driven by ++ // the order of the server's advertisement. ++ protocolArray.AppendElement(NS_LITERAL_CSTRING("http/1.1")); ++ ++ if (gHttpHandler->IsSpdyEnabled() && ++ !(caps & NS_HTTP_DISALLOW_SPDY)) { ++ LOG(("nsHttpConnection::SetupSSL Allow SPDY NPN selection")); ++ if (gHttpHandler->SpdyInfo()->ProtocolEnabled(0)) ++ protocolArray.AppendElement( ++ gHttpHandler->SpdyInfo()->VersionString[0]); ++ if (gHttpHandler->SpdyInfo()->ProtocolEnabled(1)) ++ protocolArray.AppendElement( ++ gHttpHandler->SpdyInfo()->VersionString[1]); ++ } ++ ++ if (NS_SUCCEEDED(ssl->SetNPNList(protocolArray))) { ++ LOG(("nsHttpConnection::Init Setting up SPDY Negotiation OK")); ++ mNPNComplete = false; + } + } + + nsresult + nsHttpConnection::AddTransaction(nsAHttpTransaction *httpTransaction, + int32_t priority) + { + LOG(("nsHttpConnection::AddTransaction for SPDY")); +@@ -591,17 +607,17 @@ nsHttpConnection::TimeToLive() + bool + nsHttpConnection::IsAlive() + { + if (!mSocketTransport) + return false; + + // SocketTransport::IsAlive can run the SSL state machine, so make sure + // the NPN options are set before that happens. +- SetupNPN(0); ++ SetupSSL(mTransactionCaps); + + bool alive; + nsresult rv = mSocketTransport->IsAlive(&alive); + if (NS_FAILED(rv)) + alive = false; + + //#define TEST_RESTART_LOGIC + #ifdef TEST_RESTART_LOGIC +diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h +--- a/netwerk/protocol/http/nsHttpConnection.h ++++ b/netwerk/protocol/http/nsHttpConnection.h +@@ -153,16 +153,17 @@ public: + // When the connection is active this is called every second + void ReadTimeoutTick(); + + int64_t BytesWritten() { return mTotalBytesWritten; } + + void SetSecurityCallbacks(nsIInterfaceRequestor* aCallbacks); + void PrintDiagnostics(nsCString &log); + ++ void SetTransactionCaps(uint32_t aCaps) { mTransactionCaps = aCaps; } + private: + // called to cause the underlying socket to start speaking SSL + nsresult ProxyStartSSL(); + + nsresult OnTransactionDone(nsresult reason); + nsresult OnSocketWritable(); + nsresult OnSocketReadable(); + +@@ -170,17 +171,17 @@ private: + + PRIntervalTime IdleTime(); + bool IsAlive(); + bool SupportsPipelining(nsHttpResponseHead *); + + // Makes certain the SSL handshake is complete and NPN negotiation + // has had a chance to happen + bool EnsureNPNComplete(); +- void SetupNPN(uint32_t caps); ++ void SetupSSL(uint32_t caps); + + // Start the Spdy transaction handler when NPN indicates spdy/* + void StartSpdy(uint8_t versionLevel); + + // Directly Add a transaction to an active connection for SPDY + nsresult AddTransaction(nsAHttpTransaction *, int32_t); + + private: +@@ -235,22 +236,25 @@ private: + // transactions (including the current one) that the server expects to allow + // on this persistent connection. + uint32_t mRemainingConnectionUses; + + nsAHttpTransaction::Classifier mClassification; + + // SPDY related + bool mNPNComplete; +- bool mSetupNPNCalled; ++ bool mSetupSSLCalled; + + // version level in use, 0 if unused + uint8_t mUsingSpdyVersion; + + nsRefPtr mSpdySession; + int32_t mPriority; + bool mReportedSpdy; + + // mUsingSpdyVersion is cleared when mSpdySession is freed, this is permanent + bool mEverUsedSpdy; ++ ++ // The capabailities associated with the most recent transaction ++ uint32_t mTransactionCaps; + }; + + #endif // nsHttpConnection_h__ +diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp +--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp ++++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp +@@ -321,27 +321,28 @@ nsHttpConnectionMgr::DoShiftReloadConnec + 0, connInfo); + if (NS_SUCCEEDED(rv)) + connInfo.forget(); + return rv; + } + + nsresult + nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci, +- nsIInterfaceRequestor *callbacks) ++ nsIInterfaceRequestor *callbacks, ++ uint32_t caps) + { + LOG(("nsHttpConnectionMgr::SpeculativeConnect [ci=%s]\n", + ci->HashKey().get())); + + // Wrap up the callbacks and the target to ensure they're released on the target + // thread properly. + nsCOMPtr wrappedCallbacks; + NS_NewInterfaceRequestorAggregation(callbacks, nullptr, getter_AddRefs(wrappedCallbacks)); + +- uint32_t caps = ci->GetAnonymous() ? NS_HTTP_LOAD_ANONYMOUS : 0; ++ caps |= ci->GetAnonymous() ? NS_HTTP_LOAD_ANONYMOUS : 0; + nsRefPtr trans = + new NullHttpTransaction(ci, wrappedCallbacks, caps); + + nsresult rv = + PostEvent(&nsHttpConnectionMgr::OnMsgSpeculativeConnect, 0, trans); + if (NS_SUCCEEDED(rv)) + trans.forget(); + return rv; +@@ -2809,16 +2810,20 @@ nsHalfOpenSocket::OnOutputStreamReady(ns + + CancelBackupTimer(); + + // assign the new socket to the http connection + nsRefPtr conn = new nsHttpConnection(); + LOG(("nsHalfOpenSocket::OnOutputStreamReady " + "Created new nshttpconnection %p\n", conn.get())); + ++ // Some capabilities are needed before a transaciton actually gets ++ // scheduled (e.g. how to negotiate false start) ++ conn->SetTransactionCaps(mTransaction->Caps()); ++ + NetAddr peeraddr; + nsCOMPtr callbacks; + mTransaction->GetSecurityCallbacks(getter_AddRefs(callbacks)); + if (out == mStreamOut) { + TimeDuration rtt = TimeStamp::Now() - mPrimarySynStarted; + rv = conn->Init(mEnt->mConnInfo, + gHttpHandler->ConnMgr()->mMaxRequestDelay, + mSocketTransport, mStreamIn, mStreamOut, +diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h +--- a/netwerk/protocol/http/nsHttpConnectionMgr.h ++++ b/netwerk/protocol/http/nsHttpConnectionMgr.h +@@ -108,17 +108,18 @@ public: + + // called to indicate a transaction for the connectionInfo is likely coming + // soon. The connection manager may use this information to start a TCP + // and/or SSL level handshake for that resource immediately so that it is + // ready when the transaction is submitted. No obligation is taken on by the + // connection manager, nor is the submitter obligated to actually submit a + // real transaction for this connectionInfo. + nsresult SpeculativeConnect(nsHttpConnectionInfo *, +- nsIInterfaceRequestor *); ++ nsIInterfaceRequestor *, ++ uint32_t caps = 0); + + // called when a connection is done processing a transaction. if the + // connection can be reused then it will be added to the idle list, else + // it will be closed. + nsresult ReclaimConnection(nsHttpConnection *conn); + + // called by the main thread to execute the taketransport() logic on the + // socket thread after a 101 response has been received and the socket +diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h +--- a/netwerk/protocol/http/nsHttpHandler.h ++++ b/netwerk/protocol/http/nsHttpHandler.h +@@ -176,19 +176,20 @@ public: + } + + nsresult GetSocketThreadTarget(nsIEventTarget **target) + { + return mConnMgr->GetSocketThreadTarget(target); + } + + nsresult SpeculativeConnect(nsHttpConnectionInfo *ci, +- nsIInterfaceRequestor *callbacks) ++ nsIInterfaceRequestor *callbacks, ++ uint32_t caps = 0) + { +- return mConnMgr->SpeculativeConnect(ci, callbacks); ++ return mConnMgr->SpeculativeConnect(ci, callbacks, caps); + } + + // + // The HTTP handler caches pointers to specific XPCOM services, and + // provides the following helper routines for accessing those services: + // + nsresult GetStreamConverterService(nsIStreamConverterService **); + nsresult GetIOService(nsIIOService** service); +diff --git a/netwerk/socket/nsISSLSocketControl.idl b/netwerk/socket/nsISSLSocketControl.idl +--- a/netwerk/socket/nsISSLSocketControl.idl ++++ b/netwerk/socket/nsISSLSocketControl.idl +@@ -9,17 +9,17 @@ + interface nsIInterfaceRequestor; + + %{C++ + #include "nsTArray.h" + class nsCString; + %} + [ref] native nsCStringTArrayRef(nsTArray); + +-[scriptable, uuid(bb2bb490-3ba4-4254-b8f5-8b43c7b714ea)] ++[scriptable, builtinclass, uuid(c5eb9af4-238c-4fc6-bdec-d5ab5e7dce68)] + interface nsISSLSocketControl : nsISupports { + attribute nsIInterfaceRequestor notificationCallbacks; + + void proxyStartSSL(); + void StartTLS(); + + /* NPN (Next Protocol Negotiation) is a mechanism for + negotiating the protocol to be spoken inside the SSL +@@ -47,14 +47,30 @@ interface nsISSLSocketControl : nsISuppo + * a desired NPN negotiated protocol of npnProtocol can use the socket + * associated with this object instead of making a new one. + */ + boolean joinConnection( + in ACString npnProtocol, /* e.g. "spdy/2" */ + in ACString hostname, + in long port); + ++ /* The Key Exchange Algorithm and Symmetric Cipher ++ is used when determining whether or not to do false start. ++ After a handshake is complete it can be read from *Used, ++ before a handshake is started it may be set through *Expected. ++ The values correspond to the SSLKEAType and SSLCipherAlgorithm ++ enums in NSS or the *_UNKNOWN constant defined below. ++ */ ++ ++ [infallible] readonly attribute short KEAUsed; ++ [infallible] attribute short KEAExpected; ++ [infallible] readonly attribute short SymmetricCipherUsed; ++ [infallible] attribute short SymmetricCipherExpected; ++ ++ const short KEY_EXCHANGE_UNKNOWN = -1; ++ const short SYMMETRIC_CIPHER_UNKNOWN = -1; ++ + /* + * The original flags from the socket provider. + */ + readonly attribute uint32_t providerFlags; + }; + +diff --git a/security/manager/ssl/src/nsNSSCallbacks.cpp b/security/manager/ssl/src/nsNSSCallbacks.cpp +--- a/security/manager/ssl/src/nsNSSCallbacks.cpp ++++ b/security/manager/ssl/src/nsNSSCallbacks.cpp +@@ -819,31 +819,214 @@ PK11PasswordPrompt(PK11SlotInfo* slot, P + { + RefPtr runnable( + new PK11PasswordPromptRunnable(slot, + static_cast(arg))); + runnable->DispatchToMainThreadAndWait(); + return runnable->mResult; + } + ++// call with shutdown prevention lock held ++static void ++PreliminaryHandshakeDone(PRFileDesc* fd) ++{ ++ nsNSSSocketInfo* infoObject = (nsNSSSocketInfo*) fd->higher->secret; ++ if (!infoObject) ++ return; ++ ++ if (infoObject->IsPreliminaryHandshakeDone()) ++ return; ++ ++ infoObject->SetPreliminaryHandshakeDone(); ++ infoObject->SetFirstServerHelloReceived(); ++ ++ // Get the NPN value. ++ SSLNextProtoState state; ++ unsigned char npnbuf[256]; ++ unsigned int npnlen; ++ ++ if (SSL_GetNextProto(fd, &state, npnbuf, &npnlen, 256) == SECSuccess) { ++ if (state == SSL_NEXT_PROTO_NEGOTIATED) { ++ infoObject->SetNegotiatedNPN(reinterpret_cast(npnbuf), npnlen); ++ } ++ else { ++ infoObject->SetNegotiatedNPN(nullptr, 0); ++ } ++ mozilla::Telemetry::Accumulate(Telemetry::SSL_NPN_TYPE, state); ++ } ++ else { ++ infoObject->SetNegotiatedNPN(nullptr, 0); ++ } ++} ++ ++SECStatus ++CanFalseStartCallback(PRFileDesc* fd, void* client_data, PRBool *canFalseStart) ++{ ++ *canFalseStart = false; ++ ++ nsNSSShutDownPreventionLock locker; ++ ++ nsNSSSocketInfo* infoObject = (nsNSSSocketInfo*) fd->higher->secret; ++ if (!infoObject) { ++ PR_SetError(PR_INVALID_STATE_ERROR, 0); ++ return SECFailure; ++ } ++ ++ if (infoObject->isAlreadyShutDown()) { ++ MOZ_NOT_REACHED("SSL socket used after NSS shut down"); ++ PR_SetError(PR_INVALID_STATE_ERROR, 0); ++ return SECFailure; ++ } ++ ++ PreliminaryHandshakeDone(fd); ++ ++ SSLChannelInfo channelInfo; ++ if (SSL_GetChannelInfo(fd, &channelInfo, sizeof(channelInfo)) != SECSuccess) { ++ return SECSuccess; ++ } ++ ++ SSLCipherSuiteInfo cipherInfo; ++ if (SSL_GetCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo, ++ sizeof (cipherInfo)) != SECSuccess) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ " KEA %d\n", fd, ++ static_cast(cipherInfo.keaType))); ++ return SECSuccess; ++ } ++ ++ if (channelInfo.protocolVersion < SSL_LIBRARY_VERSION_TLS_1_0) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "SSL Version must be >= TLS1 %x\n", fd, ++ static_cast(channelInfo.protocolVersion))); ++ return SECSuccess; ++ } ++ ++ // never do false start without one of these key exchange algorithms ++ if (cipherInfo.keaType != ssl_kea_rsa && ++ cipherInfo.keaType != ssl_kea_dh && ++ cipherInfo.keaType != ssl_kea_ecdh) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "unsupported KEA %d\n", fd, ++ static_cast(cipherInfo.keaType))); ++ return SECSuccess; ++ } ++ ++ // never do false start without at least 80 bits of key material. This should ++ // be redundant to an NSS precondition ++ if (cipherInfo.effectiveKeyBits < 80) { ++ MOZ_NOT_REACHED("NSS is not enforcing the precondition that the effective " ++ "key size must be >= 80 bits for false start"); ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "key too small %d\n", fd, ++ static_cast(cipherInfo.effectiveKeyBits))); ++ PR_SetError(PR_INVALID_STATE_ERROR, 0); ++ return SECFailure; ++ } ++ ++ // XXX: An attacker can choose which protocols are advertised in the ++ // NPN extension. TODO(Bug 861311): We should restrict the ability ++ // of an attacker leverage this capability by restricting false start ++ // to the same protocol we previously saw for the server, after the ++ // first successful connection to the server. ++ ++ // Enforce NPN to do false start if policy requires it. Do this as an ++ // indicator if server compatibility. ++ nsSSLIOLayerHelpers& helpers = infoObject->SharedState().IOLayerHelpers(); ++ if (helpers.mFalseStartRequireNPN) { ++ nsAutoCString negotiatedNPN; ++ if (NS_FAILED(infoObject->GetNegotiatedNPN(negotiatedNPN)) || ++ !negotiatedNPN.Length()) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "NPN cannot be verified\n", fd)); ++ return SECSuccess; ++ } ++ } ++ ++ // If we're not using eliptical curve kea then make sure we've seen the ++ // same kea from this host in the past, to limit the potential for downgrade ++ // attacks. ++ if (cipherInfo.keaType != ssl_kea_ecdh) { ++ ++ if (helpers.mFalseStartRequireForwardSecrecy) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "KEA used is %d, but " ++ "require-forward-secrecy configured.\n", ++ fd, static_cast(cipherInfo.keaType))); ++ return SECSuccess; ++ } ++ ++ int16_t expected = infoObject->GetKEAExpected(); ++ if (cipherInfo.keaType != expected) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "KEA used is %d, expected %d\n", fd, ++ static_cast(cipherInfo.keaType), ++ static_cast(expected))); ++ return SECSuccess; ++ } ++ ++ // whitelist the expected key exchange algorithms that are ++ // acceptable for false start when seen before. ++ if (expected != ssl_kea_rsa && expected != ssl_kea_dh && ++ expected != ssl_kea_ecdh) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "KEA used, %d, " ++ "is not supported with False Start.\n", ++ fd, static_cast(expected))); ++ return SECSuccess; ++ } ++ } ++ ++ // If we're not using AES then verify that this is the historically expected ++ // symmetrical cipher for this host, to limit potential for downgrade attacks. ++ if (cipherInfo.symCipher != ssl_calg_aes) { ++ int16_t expected = infoObject->GetSymmetricCipherExpected(); ++ if (cipherInfo.symCipher != expected) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "Symmetric cipher used is %d, expected %d\n", ++ fd, static_cast(cipherInfo.symCipher), ++ static_cast(expected))); ++ return SECSuccess; ++ } ++ ++ // whitelist the expected ciphers that are ++ // acceptable for false start when seen before. ++ if ((expected != ssl_calg_rc4) && (expected != ssl_calg_3des) && ++ (expected != ssl_calg_aes)) { ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " ++ "Symmetric cipher used, %d, " ++ "is not supported with False Start.\n", ++ fd, static_cast(expected))); ++ return SECSuccess; ++ } ++ } ++ ++ infoObject->NoteTimeUntilReady(); ++ *canFalseStart = true; ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] ok\n", fd)); ++ return SECSuccess; ++} ++ + void HandshakeCallback(PRFileDesc* fd, void* client_data) { + nsNSSShutDownPreventionLock locker; + int32_t sslStatus; + char* cipherName = nullptr; + int32_t keyLength; + int32_t encryptBits; + + nsNSSSocketInfo* infoObject = (nsNSSSocketInfo*) fd->higher->secret; + + // certificate validation sets FirstServerHelloReceived, so if that flag +- // is absent at handshake time we have a resumed session. ++ // is absent at handshake time we have a resumed session. Check this before ++ // PreliminaryHandshakeDone() because that function also sets that flag. + bool isResumedSession = !(infoObject->GetFirstServerHelloReceived()); + +- // This is the first callback on resumption handshakes +- infoObject->SetFirstServerHelloReceived(); ++ // Do the bookkeeping that needs to be done after the ++ // server's ServerHello...ServerHelloDone have been processed, but that doesn't ++ // need the handshake to be completed. ++ PreliminaryHandshakeDone(fd); + + // If the handshake completed, then we know the site is TLS tolerant (if this + // was a TLS connection). + nsSSLIOLayerHelpers& ioLayerHelpers = infoObject->SharedState().IOLayerHelpers(); + ioLayerHelpers.rememberTolerantSite(infoObject); + + if (SECSuccess != SSL_SecurityStatus(fd, &sslStatus, &cipherName, &keyLength, + &encryptBits, nullptr, nullptr)) { +@@ -925,47 +1108,35 @@ void HandshakeCallback(PRFileDesc* fd, v + } + } + + status->mHaveKeyLengthAndCipher = true; + status->mKeyLength = keyLength; + status->mSecretKeyLength = encryptBits; + status->mCipherName.Assign(cipherName); + +- // Get the NPN value. +- SSLNextProtoState state; +- unsigned char npnbuf[256]; +- unsigned int npnlen; +- +- if (SSL_GetNextProto(fd, &state, npnbuf, &npnlen, 256) == SECSuccess) { +- if (state == SSL_NEXT_PROTO_NEGOTIATED) +- infoObject->SetNegotiatedNPN(reinterpret_cast(npnbuf), npnlen); +- else +- infoObject->SetNegotiatedNPN(nullptr, 0); +- mozilla::Telemetry::Accumulate(Telemetry::SSL_NPN_TYPE, state); +- } +- else +- infoObject->SetNegotiatedNPN(nullptr, 0); +- + SSLChannelInfo channelInfo; + if (SSL_GetChannelInfo(fd, &channelInfo, sizeof(channelInfo)) == SECSuccess) { + // Get the protocol version for telemetry + // 0=ssl3, 1=tls1, 2=tls1.1, 3=tls1.2 + unsigned int versionEnum = channelInfo.protocolVersion & 0xFF; + Telemetry::Accumulate(Telemetry::SSL_HANDSHAKE_VERSION, versionEnum); + + SSLCipherSuiteInfo cipherInfo; + if (SSL_GetCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo, +- sizeof (cipherInfo)) == SECSuccess) { ++ sizeof (cipherInfo)) == SECSuccess) { + // keyExchange null=0, rsa=1, dh=2, fortezza=3, ecdh=4 + Telemetry::Accumulate(Telemetry::SSL_KEY_EXCHANGE_ALGORITHM, + cipherInfo.keaType); ++ infoObject->SetKEAUsed(cipherInfo.keaType); ++ infoObject->SetSymmetricCipherUsed(cipherInfo.symCipher); + } +- + } ++ ++ infoObject->NoteTimeUntilReady(); + infoObject->SetHandshakeCompleted(isResumedSession); + + PORT_Free(cipherName); + } + + struct OCSPDefaultResponders { + const char *issuerName_string; + CERTName *issuerName; +diff --git a/security/manager/ssl/src/nsNSSCallbacks.h b/security/manager/ssl/src/nsNSSCallbacks.h +--- a/security/manager/ssl/src/nsNSSCallbacks.h ++++ b/security/manager/ssl/src/nsNSSCallbacks.h +@@ -18,16 +18,18 @@ + #include "nsString.h" + + class nsILoadGroup; + + char* + PK11PasswordPrompt(PK11SlotInfo *slot, PRBool retry, void* arg); + + void HandshakeCallback(PRFileDesc *fd, void *client_data); ++SECStatus CanFalseStartCallback(PRFileDesc* fd, void* client_data, ++ PRBool *canFalseStart); + + SECStatus RegisterMyOCSPAIAInfoCallback(); + SECStatus UnregisterMyOCSPAIAInfoCallback(); + + class nsHTTPListener MOZ_FINAL : public nsIStreamLoaderObserver + { + private: + // For XPCOM implementations that are not a base class for some other +diff --git a/security/manager/ssl/src/nsNSSIOLayer.cpp b/security/manager/ssl/src/nsNSSIOLayer.cpp +--- a/security/manager/ssl/src/nsNSSIOLayer.cpp ++++ b/security/manager/ssl/src/nsNSSIOLayer.cpp +@@ -78,22 +78,28 @@ nsNSSSocketInfo::nsNSSSocketInfo(SharedS + mForSTARTTLS(false), + mSSL3Enabled(false), + mTLSEnabled(false), + mHandshakePending(true), + mHasCleartextPhase(false), + mHandshakeInProgress(false), + mAllowTLSIntoleranceTimeout(true), + mRememberClientAuthCertificate(false), ++ mPreliminaryHandshakeDone(false), + mHandshakeStartTime(0), + mFirstServerHelloReceived(false), + mNPNCompleted(false), + mHandshakeCompleted(false), + mJoined(false), + mSentClientCert(false), ++ mNotedTimeUntilReady(false), ++ mKEAUsed(nsISSLSocketControl::KEY_EXCHANGE_UNKNOWN), ++ mKEAExpected(nsISSLSocketControl::KEY_EXCHANGE_UNKNOWN), ++ mSymmetricCipherUsed(nsISSLSocketControl::SYMMETRIC_CIPHER_UNKNOWN), ++ mSymmetricCipherExpected(nsISSLSocketControl::SYMMETRIC_CIPHER_UNKNOWN), + mProviderFlags(providerFlags), + mSocketCreationTimestamp(TimeStamp::Now()), + mPlaintextBytesRead(0) + { + } + + NS_IMPL_ISUPPORTS_INHERITED2(nsNSSSocketInfo, TransportSecurityInfo, + nsISSLSocketControl, +@@ -101,16 +107,58 @@ NS_IMPL_ISUPPORTS_INHERITED2(nsNSSSocket + + NS_IMETHODIMP + nsNSSSocketInfo::GetProviderFlags(uint32_t* aProviderFlags) + { + *aProviderFlags = mProviderFlags; + return NS_OK; + } + ++NS_IMETHODIMP ++nsNSSSocketInfo::GetKEAUsed(int16_t *aKea) ++{ ++ *aKea = mKEAUsed; ++ return NS_OK; ++} ++ ++NS_IMETHODIMP ++nsNSSSocketInfo::GetKEAExpected(int16_t *aKea) ++{ ++ *aKea = mKEAExpected; ++ return NS_OK; ++} ++ ++NS_IMETHODIMP ++nsNSSSocketInfo::SetKEAExpected(int16_t aKea) ++{ ++ mKEAExpected = aKea; ++ return NS_OK; ++} ++ ++NS_IMETHODIMP ++nsNSSSocketInfo::GetSymmetricCipherUsed(int16_t *aSymmetricCipher) ++{ ++ *aSymmetricCipher = mSymmetricCipherUsed; ++ return NS_OK; ++} ++ ++NS_IMETHODIMP ++nsNSSSocketInfo::GetSymmetricCipherExpected(int16_t *aSymmetricCipher) ++{ ++ *aSymmetricCipher = mSymmetricCipherExpected; ++ return NS_OK; ++} ++ ++NS_IMETHODIMP ++nsNSSSocketInfo::SetSymmetricCipherExpected(int16_t aSymmetricCipher) ++{ ++ mSymmetricCipherExpected = aSymmetricCipher; ++ return NS_OK; ++} ++ + nsresult + nsNSSSocketInfo::GetHandshakePending(bool *aHandshakePending) + { + *aHandshakePending = mHandshakePending; + return NS_OK; + } + + nsresult +@@ -193,21 +241,36 @@ getSecureBrowserUI(nsIInterfaceRequestor + if (docShell) { + (void) docShell->GetSecurityUI(result); + } + } + } + #endif + + void ++nsNSSSocketInfo::NoteTimeUntilReady() ++{ ++ if (mNotedTimeUntilReady) ++ return; ++ ++ mNotedTimeUntilReady = true; ++ ++ // This will include TCP and proxy tunnel wait time ++ Telemetry::AccumulateTimeDelta(Telemetry::SSL_TIME_UNTIL_READY, ++ mSocketCreationTimestamp, TimeStamp::Now()); ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ++ ("[%p] nsNSSSocketInfo::NoteTimeUntilReady\n", mFd)); ++} ++ ++void + nsNSSSocketInfo::SetHandshakeCompleted(bool aResumedSession) + { + if (!mHandshakeCompleted) { + // This will include TCP and proxy tunnel wait time +- Telemetry::AccumulateTimeDelta(Telemetry::SSL_TIME_UNTIL_READY, ++ Telemetry::AccumulateTimeDelta(Telemetry::SSL_TIME_UNTIL_HANDSHAKE_FINISHED, + mSocketCreationTimestamp, TimeStamp::Now()); + + // If the handshake is completed for the first time from just 1 callback + // that means that TLS session resumption must have been used. + Telemetry::Accumulate(Telemetry::SSL_RESUMED_SESSION, aResumedSession); + + // Remove the plain text layer as it is not needed anymore. + // The plain text layer is not always present - so its not a fatal error +@@ -215,16 +278,19 @@ nsNSSSocketInfo::SetHandshakeCompleted(b + PRFileDesc* poppedPlaintext = + PR_GetIdentitiesLayer(mFd, nsSSLIOLayerHelpers::nsSSLPlaintextLayerIdentity); + if (poppedPlaintext) { + PR_PopIOLayer(mFd, nsSSLIOLayerHelpers::nsSSLPlaintextLayerIdentity); + poppedPlaintext->dtor(poppedPlaintext); + } + + mHandshakeCompleted = true; ++ ++ PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ++ ("[%p] nsNSSSocketInfo::SetHandshakeCompleted\n", (void*)mFd)); + } + } + + void + nsNSSSocketInfo::SetNegotiatedNPN(const char *value, uint32_t length) + { + if (!value) + mNegotiatedNPN.Truncate(); +@@ -1090,16 +1156,18 @@ nsSSLIOLayerPoll(PRFileDesc * fd, int16_ + + nsSSLIOLayerHelpers::nsSSLIOLayerHelpers() + : mutex(nullptr) + , mTLSIntolerantSites(nullptr) + , mTLSTolerantSites(nullptr) + , mRenegoUnrestrictedSites(nullptr) + , mTreatUnsafeNegotiationAsBroken(false) + , mWarnLevelMissingRFC5746(1) ++, mFalseStartRequireNPN(true) ++, mFalseStartRequireForwardSecrecy(false) + { + } + + static int _PSM_InvalidInt(void) + { + PR_ASSERT(!"I/O method is invalid"); + PR_SetError(PR_INVALID_METHOD_ERROR, 0); + return -1; +@@ -1280,16 +1348,22 @@ PrefObserver::Observe(nsISupports *aSubj + } else if (prefName.Equals("security.ssl.treat_unsafe_negotiation_as_broken")) { + bool enabled; + Preferences::GetBool("security.ssl.treat_unsafe_negotiation_as_broken", &enabled); + mOwner->setTreatUnsafeNegotiationAsBroken(enabled); + } else if (prefName.Equals("security.ssl.warn_missing_rfc5746")) { + int32_t warnLevel = 1; + Preferences::GetInt("security.ssl.warn_missing_rfc5746", &warnLevel); + mOwner->setWarnLevelMissingRFC5746(warnLevel); ++ } else if (prefName.Equals("security.ssl.false_start.require-npn")) { ++ Preferences::GetBool("security.ssl.false_start.require-npn", ++ &mOwner->mFalseStartRequireNPN); ++ } else if (prefName.Equals("security.ssl.false_start.require-forward-secrecy")) { ++ Preferences::GetBool("security.ssl.false_start.require-forward-secrecy", ++ &mOwner->mFalseStartRequireForwardSecrecy); + } + } + return NS_OK; + } + + static int32_t PlaintextRecv(PRFileDesc *fd, void *buf, int32_t amount, + int flags, PRIntervalTime timeout) + { +@@ -1307,16 +1381,18 @@ static int32_t PlaintextRecv(PRFileDesc + return bytesRead; + } + + nsSSLIOLayerHelpers::~nsSSLIOLayerHelpers() + { + Preferences::RemoveObserver(mPrefObserver, "security.ssl.renego_unrestricted_hosts"); + Preferences::RemoveObserver(mPrefObserver, "security.ssl.treat_unsafe_negotiation_as_broken"); + Preferences::RemoveObserver(mPrefObserver, "security.ssl.warn_missing_rfc5746"); ++ Preferences::RemoveObserver(mPrefObserver, "security.ssl.false_start.require-npn"); ++ Preferences::RemoveObserver(mPrefObserver, "security.ssl.false_start.require-forward-secrecy"); + } + + nsresult nsSSLIOLayerHelpers::Init() + { + if (!nsSSLIOLayerInitialized) { + nsSSLIOLayerInitialized = true; + nsSSLIOLayerIdentity = PR_GetUniqueIdentity("NSS layer"); + nsSSLIOLayerMethods = *PR_GetDefaultIOMethods(); +@@ -1381,24 +1457,32 @@ nsresult nsSSLIOLayerHelpers::Init() + bool enabled = false; + Preferences::GetBool("security.ssl.treat_unsafe_negotiation_as_broken", &enabled); + setTreatUnsafeNegotiationAsBroken(enabled); + + int32_t warnLevel = 1; + Preferences::GetInt("security.ssl.warn_missing_rfc5746", &warnLevel); + setWarnLevelMissingRFC5746(warnLevel); + ++ Preferences::GetBool("security.ssl.false_start.require-npn", ++ &mFalseStartRequireNPN); ++ Preferences::GetBool("security.ssl.false_start.require-forward-secrecy", ++ &mFalseStartRequireForwardSecrecy); ++ + mPrefObserver = new PrefObserver(this); + Preferences::AddStrongObserver(mPrefObserver, + "security.ssl.renego_unrestricted_hosts"); + Preferences::AddStrongObserver(mPrefObserver, + "security.ssl.treat_unsafe_negotiation_as_broken"); + Preferences::AddStrongObserver(mPrefObserver, + "security.ssl.warn_missing_rfc5746"); +- ++ Preferences::AddStrongObserver(mPrefObserver, ++ "security.ssl.false_start.require-npn"); ++ Preferences::AddStrongObserver(mPrefObserver, ++ "security.ssl.false_start.require-forward-secrecy"); + return NS_OK; + } + + void nsSSLIOLayerHelpers::clearStoredData() + { + mRenegoUnrestrictedSites->Clear(); + mTLSTolerantSites->Clear(); + mTLSIntolerantSites->Clear(); +@@ -2474,16 +2558,17 @@ nsSSLIOLayerImportFD(PRFileDesc *fd, + nsNSSShutDownPreventionLock locker; + PRFileDesc* sslSock = SSL_ImportFD(nullptr, fd); + if (!sslSock) { + NS_ASSERTION(false, "NSS: Error importing socket"); + return nullptr; + } + SSL_SetPKCS11PinArg(sslSock, (nsIInterfaceRequestor*)infoObject); + SSL_HandshakeCallback(sslSock, HandshakeCallback, infoObject); ++ SSL_SetCanFalseStartCallback(sslSock, CanFalseStartCallback, infoObject); + + // Disable this hook if we connect anonymously. See bug 466080. + uint32_t flags = 0; + infoObject->GetProviderFlags(&flags); + if (flags & nsISocketProvider::ANONYMOUS_CONNECT) { + SSL_GetClientAuthDataHook(sslSock, nullptr, infoObject); + } else { + SSL_GetClientAuthDataHook(sslSock, +diff --git a/security/manager/ssl/src/nsNSSIOLayer.h b/security/manager/ssl/src/nsNSSIOLayer.h +--- a/security/manager/ssl/src/nsNSSIOLayer.h ++++ b/security/manager/ssl/src/nsNSSIOLayer.h +@@ -56,16 +56,17 @@ public: + + void SetAllowTLSIntoleranceTimeout(bool aAllow); + + PRStatus CloseSocketAndDestroy( + const nsNSSShutDownPreventionLock & proofOfLock); + + void SetNegotiatedNPN(const char *value, uint32_t length); + void SetHandshakeCompleted(bool aResumedSession); ++ void NoteTimeUntilReady(); + + bool GetJoined() { return mJoined; } + void SetSentClientCert() { mSentClientCert = true; } + + uint32_t GetProviderFlags() const { return mProviderFlags; } + + mozilla::psm::SharedSSLState& SharedState(); + +@@ -88,40 +89,73 @@ public: + } + + bool IsSSL3Enabled() const { return mSSL3Enabled; } + void SetSSL3Enabled(bool enabled) { mSSL3Enabled = enabled; } + bool IsTLSEnabled() const { return mTLSEnabled; } + void SetTLSEnabled(bool enabled) { mTLSEnabled = enabled; } + + void AddPlaintextBytesRead(uint64_t val) { mPlaintextBytesRead += val; } ++ ++ bool IsPreliminaryHandshakeDone() const { return mPreliminaryHandshakeDone; } ++ void SetPreliminaryHandshakeDone() { mPreliminaryHandshakeDone = true; } ++ ++ void SetKEAUsed(PRUint16 kea) { mKEAUsed = kea; } ++ inline int16_t GetKEAExpected() // infallible in nsISSLSocketControl ++ { ++ int16_t result; ++ mozilla::DebugOnly rv = GetKEAExpected(&result); ++ MOZ_ASSERT(NS_SUCCEEDED(rv)); ++ return result; ++ } ++ void SetSymmetricCipherUsed(PRUint16 symmetricCipher) ++ { ++ mSymmetricCipherUsed = symmetricCipher; ++ } ++ inline int16_t GetSymmetricCipherExpected() // infallible in nsISSLSocketControl ++ { ++ int16_t result; ++ mozilla::DebugOnly rv = GetSymmetricCipherExpected(&result); ++ MOZ_ASSERT(NS_SUCCEEDED(rv)); ++ return result; ++ } ++ + private: + PRFileDesc* mFd; + + CertVerificationState mCertVerificationState; + + mozilla::psm::SharedSSLState& mSharedState; + bool mForSTARTTLS; + bool mSSL3Enabled; + bool mTLSEnabled; + bool mHandshakePending; + bool mHasCleartextPhase; + bool mHandshakeInProgress; + bool mAllowTLSIntoleranceTimeout; + bool mRememberClientAuthCertificate; ++ bool mPreliminaryHandshakeDone; // after false start items are complete + PRIntervalTime mHandshakeStartTime; + bool mFirstServerHelloReceived; + + nsresult ActivateSSL(); + + nsCString mNegotiatedNPN; + bool mNPNCompleted; + bool mHandshakeCompleted; + bool mJoined; + bool mSentClientCert; ++ bool mNotedTimeUntilReady; ++ ++ // mKEA* and mSymmetricCipher* are used in false start detetermination ++ // values are from nsISSLSocketControl ++ PRInt16 mKEAUsed; ++ PRInt16 mKEAExpected; ++ PRInt16 mSymmetricCipherUsed; ++ PRInt16 mSymmetricCipherExpected; + + uint32_t mProviderFlags; + mozilla::TimeStamp mSocketCreationTimestamp; + uint64_t mPlaintextBytesRead; + }; + + class nsSSLIOLayerHelpers + { +@@ -159,16 +193,19 @@ public: + void addIntolerantSite(const nsCString &str); + void removeIntolerantSite(const nsCString &str); + bool isKnownAsIntolerantSite(const nsCString &str); + + void setRenegoUnrestrictedSites(const nsCString &str); + bool isRenegoUnrestrictedSite(const nsCString &str); + + void clearStoredData(); ++ ++ bool mFalseStartRequireNPN; ++ bool mFalseStartRequireForwardSecrecy; + private: + nsCOMPtr mPrefObserver; + }; + + nsresult nsSSLIOLayerNewSocket(int32_t family, + const char *host, + int32_t port, + const char *proxyHost, +diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json +--- a/toolkit/components/telemetry/Histograms.json ++++ b/toolkit/components/telemetry/Histograms.json +@@ -838,16 +838,22 @@ + }, + "SSL_TIME_UNTIL_READY": { + "kind": "exponential", + "high": "60000", + "n_buckets": 200, + "extended_statistics_ok": true, + "description": "ms of SSL wait time including TCP and proxy tunneling" + }, ++ "SSL_TIME_UNTIL_HANDSHAKE_FINISHED": { ++ "kind": "exponential", ++ "high": "60000", ++ "n_buckets": 200, ++ "description": "ms of SSL wait time for full handshake including TCP and proxy tunneling" ++ }, + "SSL_BYTES_BEFORE_CERT_CALLBACK": { + "kind": "exponential", + "high": "32000", + "n_buckets": 64, + "extended_statistics_ok": true, + "description": "plaintext bytes read before a server certificate authenticated" + }, + "SSL_NPN_TYPE": { From 9c44286c03fe7f72e0926559dd894a6bc9440507 Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Fri, 28 Jun 2013 16:58:28 -0400 Subject: [PATCH 05/28] bug 658222 - Enable TLS False Start (PSM) r=bsmith --HG-- extra : rebase_source : ac9f77ba73a0a902f4b6aa8d52add7d52efb1b53 --- netwerk/base/public/security-prefs.js | 4 +- .../protocol/http/ConnectionDiagnostics.cpp | 4 +- netwerk/protocol/http/nsHttp.h | 5 + netwerk/protocol/http/nsHttpChannel.cpp | 154 ++++++++++++- netwerk/protocol/http/nsHttpChannel.h | 8 + netwerk/protocol/http/nsHttpConnection.cpp | 104 +++++---- netwerk/protocol/http/nsHttpConnection.h | 8 +- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 9 +- netwerk/protocol/http/nsHttpConnectionMgr.h | 3 +- netwerk/protocol/http/nsHttpHandler.h | 5 +- netwerk/socket/nsISSLSocketControl.idl | 18 +- security/manager/ssl/src/nsNSSCallbacks.cpp | 211 ++++++++++++++++-- security/manager/ssl/src/nsNSSCallbacks.h | 2 + security/manager/ssl/src/nsNSSIOLayer.cpp | 89 +++++++- security/manager/ssl/src/nsNSSIOLayer.h | 37 +++ toolkit/components/telemetry/Histograms.json | 6 + 16 files changed, 588 insertions(+), 79 deletions(-) diff --git a/netwerk/base/public/security-prefs.js b/netwerk/base/public/security-prefs.js index 43571dc9bcf..f4d21327184 100644 --- a/netwerk/base/public/security-prefs.js +++ b/netwerk/base/public/security-prefs.js @@ -12,8 +12,10 @@ pref("security.ssl.renego_unrestricted_hosts", ""); pref("security.ssl.treat_unsafe_negotiation_as_broken", false); pref("security.ssl.require_safe_negotiation", false); pref("security.ssl.warn_missing_rfc5746", 1); -pref("security.ssl.enable_false_start", false); pref("security.ssl.enable_ocsp_stapling", true); +pref("security.ssl.enable_false_start", true); +pref("security.ssl.false_start.require-npn", true); +pref("security.ssl.false_start.require-forward-secrecy", false); pref("security.ssl3.rsa_rc4_128_md5", true); pref("security.ssl3.rsa_rc4_128_sha", true); diff --git a/netwerk/protocol/http/ConnectionDiagnostics.cpp b/netwerk/protocol/http/ConnectionDiagnostics.cpp index 0103cb0622c..99688837e05 100644 --- a/netwerk/protocol/http/ConnectionDiagnostics.cpp +++ b/netwerk/protocol/http/ConnectionDiagnostics.cpp @@ -127,8 +127,8 @@ nsHttpConnection::PrintDiagnostics(nsCString &log) { log.AppendPrintf(" CanDirectlyActivate = %d\n", CanDirectlyActivate()); - log.AppendPrintf(" npncomplete = %d setupNPNCalled = %d\n", - mNPNComplete, mSetupNPNCalled); + log.AppendPrintf(" npncomplete = %d setupSSLCalled = %d\n", + mNPNComplete, mSetupSSLCalled); log.AppendPrintf(" spdyVersion = %d reportedSpdy = %d everspdy = %d\n", mUsingSpdyVersion, mReportedSpdy, mEverUsedSpdy); diff --git a/netwerk/protocol/http/nsHttp.h b/netwerk/protocol/http/nsHttp.h index ba189be3b27..ace7f8f059d 100644 --- a/netwerk/protocol/http/nsHttp.h +++ b/netwerk/protocol/http/nsHttp.h @@ -58,6 +58,11 @@ typedef uint8_t nsHttpVersion; // group is currently blocking on some resources #define NS_HTTP_LOAD_UNBLOCKED (1<<8) +// These flags allow a transaction to use TLS false start with +// weaker security profiles based on past history +#define NS_HTTP_ALLOW_RSA_FALSESTART (1<<9) +#define NS_HTTP_ALLOW_RC4_FALSESTART (1<<10) + //----------------------------------------------------------------------------- // some default values //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index e77aff5813f..544cabc9059 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -40,6 +40,14 @@ #include "NullHttpTransaction.h" #include "mozilla/Attributes.h" #include "mozilla/VisualEventTracer.h" +#include "nsISSLSocketControl.h" +#include "sslt.h" +#include "nsContentUtils.h" +#include "nsIPermissionManager.h" +#include "nsIPrincipal.h" +#include "nsIScriptSecurityManager.h" +#include "nsISSLStatus.h" +#include "nsISSLStatusProvider.h" namespace mozilla { namespace net { @@ -391,6 +399,7 @@ nsHttpChannel::Connect() return NS_ERROR_UNKNOWN_HOST; // Consider opening a TCP connection right away + RetrieveSSLOptions(); SpeculativeConnect(); // Don't allow resuming when cache must be used @@ -527,8 +536,9 @@ nsHttpChannel::SpeculativeConnect() mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0); mConnectionInfo->SetPrivate(mPrivateBrowsing); - gHttpHandler->SpeculativeConnect(mConnectionInfo, - callbacks); + gHttpHandler->SpeculativeConnect( + mConnectionInfo, callbacks, + mCaps & (NS_HTTP_ALLOW_RSA_FALSESTART | NS_HTTP_ALLOW_RC4_FALSESTART | NS_HTTP_DISALLOW_SPDY)); } void @@ -693,6 +703,37 @@ nsHttpChannel::SetupTransactionLoadGroupInfo() mTransaction->SetLoadGroupConnectionInfo(ci); } +void +nsHttpChannel::RetrieveSSLOptions() +{ + if (!IsHTTPS() || mPrivateBrowsing) + return; + + nsIPrincipal *principal = GetPrincipal(); + if (!principal) + return; + + nsCOMPtr permMgr = + do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); + if (!permMgr) + return; + + uint32_t perm; + nsresult rv = permMgr->TestPermissionFromPrincipal(principal, + "falsestart-rsa", &perm); + if (NS_SUCCEEDED(rv) && perm == nsIPermissionManager::ALLOW_ACTION) { + LOG(("nsHttpChannel::RetrieveSSLOptions [this=%p] " + "falsestart-rsa permission found\n", this)); + mCaps |= NS_HTTP_ALLOW_RSA_FALSESTART; + } + rv = permMgr->TestPermissionFromPrincipal(principal, "falsestart-rc4", &perm); + if (NS_SUCCEEDED(rv) && perm == nsIPermissionManager::ALLOW_ACTION) { + LOG(("nsHttpChannel::RetrieveSSLOptions [this=%p] " + "falsestart-rc4 permission found\n", this)); + mCaps |= NS_HTTP_ALLOW_RC4_FALSESTART; + } +} + nsresult nsHttpChannel::SetupTransaction() { @@ -1160,6 +1201,89 @@ nsHttpChannel::ProcessSTSHeader() return NS_OK; } +bool +nsHttpChannel::IsHTTPS() +{ + bool isHttps; + if (NS_FAILED(mURI->SchemeIs("https", &isHttps)) || !isHttps) + return false; + return true; +} + +void +nsHttpChannel::ProcessSSLInformation() +{ + // If this is HTTPS, record any use of RSA so that Key Exchange Algorithm + // can be whitelisted for TLS False Start in future sessions. We could + // do the same for DH but its rarity doesn't justify the lookup. + // Also do the same for RC4 symmetric ciphers. + + if (mCanceled || NS_FAILED(mStatus) || !mSecurityInfo || + !IsHTTPS() || mPrivateBrowsing) + return; + + nsCOMPtr ssl = do_QueryInterface(mSecurityInfo); + nsCOMPtr statusProvider = + do_QueryInterface(mSecurityInfo); + if (!ssl || !statusProvider) + return; + nsCOMPtr sslstat; + statusProvider->GetSSLStatus(getter_AddRefs(sslstat)); + if (!sslstat) + return; + + // If certificate exceptions are being used don't record this information + // in the permission manager. + bool trustCheck; + if (NS_FAILED(sslstat->GetIsDomainMismatch(&trustCheck)) || trustCheck) + return; + if (NS_FAILED(sslstat->GetIsNotValidAtThisTime(&trustCheck)) || trustCheck) + return; + if (NS_FAILED(sslstat->GetIsUntrusted(&trustCheck)) || trustCheck) + return; + + int16_t kea = ssl->GetKEAUsed(); + int16_t symcipher = ssl->GetSymmetricCipherUsed(); + + nsIPrincipal *principal = GetPrincipal(); + if (!principal) + return; + + // set a permission manager flag that future transactions can + // use via RetrieveSSLOptions(() + + nsCOMPtr permMgr = + do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); + if (!permMgr) + return; + + // Allow this to stand for a week + int64_t expireTime = (PR_Now() / PR_USEC_PER_MSEC) + + (86400 * 7 * PR_MSEC_PER_SEC); + + if (kea == ssl_kea_rsa) { + permMgr->AddFromPrincipal(principal, "falsestart-rsa", + nsIPermissionManager::ALLOW_ACTION, + nsIPermissionManager::EXPIRE_TIME, + expireTime); + LOG(("nsHttpChannel::ProcessSSLInformation [this=%p] " + "falsestart-rsa permission granted for this host\n", this)); + } else { + permMgr->RemoveFromPrincipal(principal, "falsestart-rsa"); + } + + if (symcipher == ssl_calg_rc4) { + permMgr->AddFromPrincipal(principal, "falsestart-rc4", + nsIPermissionManager::ALLOW_ACTION, + nsIPermissionManager::EXPIRE_TIME, + expireTime); + LOG(("nsHttpChannel::ProcessSSLInformation [this=%p] " + "falsestart-rc4 permission granted for this host\n", this)); + } else { + permMgr->RemoveFromPrincipal(principal, "falsestart-rc4"); + } +} + nsresult nsHttpChannel::ProcessResponse() { @@ -1192,6 +1316,8 @@ nsHttpChannel::ProcessResponse() MOZ_ASSERT(!mCachedContentIsValid); + ProcessSSLInformation(); + // notify "http-on-examine-response" observers gHttpHandler->OnExamineResponse(this); @@ -6037,6 +6163,30 @@ nsHttpChannel::ShouldSkipCache() return true; } +nsIPrincipal * +nsHttpChannel::GetPrincipal() +{ + if (mPrincipal) + return mPrincipal; + + nsIScriptSecurityManager *securityManager = + nsContentUtils::GetSecurityManager(); + + if (!securityManager) + return nullptr; + + securityManager->GetChannelPrincipal(this, getter_AddRefs(mPrincipal)); + if (!mPrincipal) + return nullptr; + + // principals with unknown app ids do not work with the permission manager + if (mPrincipal->GetUnknownAppId()) + mPrincipal = nullptr; + + return mPrincipal; +} + + NS_IMETHODIMP nsHttpChannel::SetLoadGroup(nsILoadGroup *aLoadGroup) { diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 3fd347bb06f..41c1661e9d0 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -34,6 +34,7 @@ #include "mozilla/Telemetry.h" class nsAHttpConnection; +class nsIPrincipal; namespace mozilla { namespace net { @@ -174,6 +175,9 @@ private: nsresult ContinueProcessFallback(nsresult); void HandleAsyncAbort(); nsresult EnsureAssocReq(); + void ProcessSSLInformation(); + bool IsHTTPS(); + void RetrieveSSLOptions(); nsresult ContinueOnStartRequest1(nsresult); nsresult ContinueOnStartRequest2(nsresult); @@ -373,6 +377,10 @@ protected: private: // cache telemetry bool mDidReval; + +private: + nsIPrincipal *GetPrincipal(); + nsCOMPtr mPrincipal; }; } } // namespace mozilla::net diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index 695f8a5a9ff..2a46db3b732 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -17,6 +17,7 @@ #include "nsISocketTransport.h" #include "nsIServiceManager.h" #include "nsISSLSocketControl.h" +#include "sslt.h" #include "nsStringStream.h" #include "netCore.h" #include "nsNetCID.h" @@ -64,11 +65,12 @@ nsHttpConnection::nsHttpConnection() , mRemainingConnectionUses(0xffffffff) , mClassification(nsAHttpTransaction::CLASS_GENERAL) , mNPNComplete(false) - , mSetupNPNCalled(false) + , mSetupSSLCalled(false) , mUsingSpdyVersion(0) , mPriority(nsISupportsPriority::PRIORITY_NORMAL) , mReportedSpdy(false) , mEverUsedSpdy(false) + , mTransactionCaps(0) { LOG(("Creating nsHttpConnection @%x\n", this)); @@ -236,8 +238,6 @@ nsHttpConnection::StartSpdy(uint8_t spdyVersion) bool nsHttpConnection::EnsureNPNComplete() { - // NPN is only used by SPDY right now. - // // If for some reason the components to check on NPN aren't available, // this function will just return true to continue on and disable SPDY @@ -308,6 +308,7 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, uint32_t caps, int32_t pri LOG(("nsHttpConnection::Activate [this=%p trans=%x caps=%x]\n", this, trans, caps)); + mTransactionCaps = caps; mPriority = pri; if (mTransaction && mUsingSpdyVersion) return AddTransaction(trans, pri); @@ -323,7 +324,7 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, uint32_t caps, int32_t pri trans->GetSecurityCallbacks(getter_AddRefs(callbacks)); SetSecurityCallbacks(callbacks); - SetupNPN(caps); // only for spdy + SetupSSL(caps); // take ownership of the transaction mTransaction = trans; @@ -360,55 +361,70 @@ failed_activation: } void -nsHttpConnection::SetupNPN(uint32_t caps) +nsHttpConnection::SetupSSL(uint32_t caps) { - if (mSetupNPNCalled) /* do only once */ + LOG(("nsHttpConnection::SetupSSL %p caps=0x%X\n", this, caps)); + + if (mSetupSSLCalled) // do only once return; - mSetupNPNCalled = true; + mSetupSSLCalled = true; - // Setup NPN Negotiation if necessary (only for SPDY) - if (!mNPNComplete) { + if (mNPNComplete) + return; - mNPNComplete = true; + // we flip this back to false if SetNPNList succeeds at the end + // of this function + mNPNComplete = true; - if (mConnInfo->UsingSSL()) { - LOG(("nsHttpConnection::SetupNPN Setting up " - "Next Protocol Negotiation")); - nsCOMPtr securityInfo; - nsresult rv = - mSocketTransport->GetSecurityInfo(getter_AddRefs(securityInfo)); - if (NS_FAILED(rv)) - return; + if (!mConnInfo->UsingSSL()) + return; - nsCOMPtr ssl = - do_QueryInterface(securityInfo, &rv); - if (NS_FAILED(rv)) - return; + LOG(("nsHttpConnection::SetupSSL Setting up " + "Next Protocol Negotiation")); + nsCOMPtr securityInfo; + nsresult rv = + mSocketTransport->GetSecurityInfo(getter_AddRefs(securityInfo)); + if (NS_FAILED(rv)) + return; - nsTArray protocolArray; + nsCOMPtr ssl = do_QueryInterface(securityInfo, &rv); + if (NS_FAILED(rv)) + return; - // The first protocol is used as the fallback if none of the - // protocols supported overlap with the server's list. - // In the case of overlap, matching priority is driven by - // the order of the server's advertisement. - protocolArray.AppendElement(NS_LITERAL_CSTRING("http/1.1")); + if (caps & NS_HTTP_ALLOW_RSA_FALSESTART) { + LOG(("nsHttpConnection::SetupSSL %p " + ">= RSA Key Exchange Expected\n", this)); + ssl->SetKEAExpected(ssl_kea_rsa); + } - if (gHttpHandler->IsSpdyEnabled() && - !(caps & NS_HTTP_DISALLOW_SPDY)) { - LOG(("nsHttpConnection::SetupNPN Allow SPDY NPN selection")); - if (gHttpHandler->SpdyInfo()->ProtocolEnabled(0)) - protocolArray.AppendElement( - gHttpHandler->SpdyInfo()->VersionString[0]); - if (gHttpHandler->SpdyInfo()->ProtocolEnabled(1)) - protocolArray.AppendElement( - gHttpHandler->SpdyInfo()->VersionString[1]); - } + if (caps & NS_HTTP_ALLOW_RC4_FALSESTART) { + LOG(("nsHttpConnection::SetupSSL %p " + ">= RC4 Key Exchange Expected\n", this)); + ssl->SetSymmetricCipherExpected(ssl_calg_rc4); + } - if (NS_SUCCEEDED(ssl->SetNPNList(protocolArray))) { - LOG(("nsHttpConnection::Init Setting up SPDY Negotiation OK")); - mNPNComplete = false; - } - } + nsTArray protocolArray; + + // The first protocol is used as the fallback if none of the + // protocols supported overlap with the server's list. + // In the case of overlap, matching priority is driven by + // the order of the server's advertisement. + protocolArray.AppendElement(NS_LITERAL_CSTRING("http/1.1")); + + if (gHttpHandler->IsSpdyEnabled() && + !(caps & NS_HTTP_DISALLOW_SPDY)) { + LOG(("nsHttpConnection::SetupSSL Allow SPDY NPN selection")); + if (gHttpHandler->SpdyInfo()->ProtocolEnabled(0)) + protocolArray.AppendElement( + gHttpHandler->SpdyInfo()->VersionString[0]); + if (gHttpHandler->SpdyInfo()->ProtocolEnabled(1)) + protocolArray.AppendElement( + gHttpHandler->SpdyInfo()->VersionString[1]); + } + + if (NS_SUCCEEDED(ssl->SetNPNList(protocolArray))) { + LOG(("nsHttpConnection::Init Setting up SPDY Negotiation OK")); + mNPNComplete = false; } } @@ -596,7 +612,7 @@ nsHttpConnection::IsAlive() // SocketTransport::IsAlive can run the SSL state machine, so make sure // the NPN options are set before that happens. - SetupNPN(0); + SetupSSL(mTransactionCaps); bool alive; nsresult rv = mSocketTransport->IsAlive(&alive); diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h index 3ef1ec872da..a5c1e7d1c85 100644 --- a/netwerk/protocol/http/nsHttpConnection.h +++ b/netwerk/protocol/http/nsHttpConnection.h @@ -158,6 +158,7 @@ public: void SetSecurityCallbacks(nsIInterfaceRequestor* aCallbacks); void PrintDiagnostics(nsCString &log); + void SetTransactionCaps(uint32_t aCaps) { mTransactionCaps = aCaps; } private: // called to cause the underlying socket to start speaking SSL nsresult ProxyStartSSL(); @@ -175,7 +176,7 @@ private: // Makes certain the SSL handshake is complete and NPN negotiation // has had a chance to happen bool EnsureNPNComplete(); - void SetupNPN(uint32_t caps); + void SetupSSL(uint32_t caps); // Start the Spdy transaction handler when NPN indicates spdy/* void StartSpdy(uint8_t versionLevel); @@ -240,7 +241,7 @@ private: // SPDY related bool mNPNComplete; - bool mSetupNPNCalled; + bool mSetupSSLCalled; // version level in use, 0 if unused uint8_t mUsingSpdyVersion; @@ -251,6 +252,9 @@ private: // mUsingSpdyVersion is cleared when mSpdySession is freed, this is permanent bool mEverUsedSpdy; + + // The capabailities associated with the most recent transaction + uint32_t mTransactionCaps; }; #endif // nsHttpConnection_h__ diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 06459dd5b2d..9b4aa4524c0 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -326,7 +326,8 @@ nsHttpConnectionMgr::DoShiftReloadConnectionCleanup(nsHttpConnectionInfo *aCI) nsresult nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci, - nsIInterfaceRequestor *callbacks) + nsIInterfaceRequestor *callbacks, + uint32_t caps) { LOG(("nsHttpConnectionMgr::SpeculativeConnect [ci=%s]\n", ci->HashKey().get())); @@ -336,7 +337,7 @@ nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci, nsCOMPtr wrappedCallbacks; NS_NewInterfaceRequestorAggregation(callbacks, nullptr, getter_AddRefs(wrappedCallbacks)); - uint32_t caps = ci->GetAnonymous() ? NS_HTTP_LOAD_ANONYMOUS : 0; + caps |= ci->GetAnonymous() ? NS_HTTP_LOAD_ANONYMOUS : 0; nsRefPtr trans = new NullHttpTransaction(ci, wrappedCallbacks, caps); @@ -2814,6 +2815,10 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out) LOG(("nsHalfOpenSocket::OnOutputStreamReady " "Created new nshttpconnection %p\n", conn.get())); + // Some capabilities are needed before a transaciton actually gets + // scheduled (e.g. how to negotiate false start) + conn->SetTransactionCaps(mTransaction->Caps()); + NetAddr peeraddr; nsCOMPtr callbacks; mTransaction->GetSecurityCallbacks(getter_AddRefs(callbacks)); diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h index 2e8a08d8d32..acd5635f9f6 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.h +++ b/netwerk/protocol/http/nsHttpConnectionMgr.h @@ -113,7 +113,8 @@ public: // connection manager, nor is the submitter obligated to actually submit a // real transaction for this connectionInfo. nsresult SpeculativeConnect(nsHttpConnectionInfo *, - nsIInterfaceRequestor *); + nsIInterfaceRequestor *, + uint32_t caps = 0); // called when a connection is done processing a transaction. if the // connection can be reused then it will be added to the idle list, else diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 84841ff2ed6..6ecf0271f7e 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -181,9 +181,10 @@ public: } nsresult SpeculativeConnect(nsHttpConnectionInfo *ci, - nsIInterfaceRequestor *callbacks) + nsIInterfaceRequestor *callbacks, + uint32_t caps = 0) { - return mConnMgr->SpeculativeConnect(ci, callbacks); + return mConnMgr->SpeculativeConnect(ci, callbacks, caps); } // diff --git a/netwerk/socket/nsISSLSocketControl.idl b/netwerk/socket/nsISSLSocketControl.idl index 258f207e656..18c500e6997 100644 --- a/netwerk/socket/nsISSLSocketControl.idl +++ b/netwerk/socket/nsISSLSocketControl.idl @@ -14,7 +14,7 @@ class nsCString; %} [ref] native nsCStringTArrayRef(nsTArray); -[scriptable, uuid(bb2bb490-3ba4-4254-b8f5-8b43c7b714ea)] +[scriptable, builtinclass, uuid(c5eb9af4-238c-4fc6-bdec-d5ab5e7dce68)] interface nsISSLSocketControl : nsISupports { attribute nsIInterfaceRequestor notificationCallbacks; @@ -52,6 +52,22 @@ interface nsISSLSocketControl : nsISupports { in ACString hostname, in long port); + /* The Key Exchange Algorithm and Symmetric Cipher + is used when determining whether or not to do false start. + After a handshake is complete it can be read from *Used, + before a handshake is started it may be set through *Expected. + The values correspond to the SSLKEAType and SSLCipherAlgorithm + enums in NSS or the *_UNKNOWN constant defined below. + */ + + [infallible] readonly attribute short KEAUsed; + [infallible] attribute short KEAExpected; + [infallible] readonly attribute short SymmetricCipherUsed; + [infallible] attribute short SymmetricCipherExpected; + + const short KEY_EXCHANGE_UNKNOWN = -1; + const short SYMMETRIC_CIPHER_UNKNOWN = -1; + /* * The original flags from the socket provider. */ diff --git a/security/manager/ssl/src/nsNSSCallbacks.cpp b/security/manager/ssl/src/nsNSSCallbacks.cpp index 6f64e316c8c..b0412cebee8 100644 --- a/security/manager/ssl/src/nsNSSCallbacks.cpp +++ b/security/manager/ssl/src/nsNSSCallbacks.cpp @@ -824,6 +824,186 @@ PK11PasswordPrompt(PK11SlotInfo* slot, PRBool retry, void* arg) return runnable->mResult; } +// call with shutdown prevention lock held +static void +PreliminaryHandshakeDone(PRFileDesc* fd) +{ + nsNSSSocketInfo* infoObject = (nsNSSSocketInfo*) fd->higher->secret; + if (!infoObject) + return; + + if (infoObject->IsPreliminaryHandshakeDone()) + return; + + infoObject->SetPreliminaryHandshakeDone(); + infoObject->SetFirstServerHelloReceived(); + + // Get the NPN value. + SSLNextProtoState state; + unsigned char npnbuf[256]; + unsigned int npnlen; + + if (SSL_GetNextProto(fd, &state, npnbuf, &npnlen, 256) == SECSuccess) { + if (state == SSL_NEXT_PROTO_NEGOTIATED) { + infoObject->SetNegotiatedNPN(reinterpret_cast(npnbuf), npnlen); + } + else { + infoObject->SetNegotiatedNPN(nullptr, 0); + } + mozilla::Telemetry::Accumulate(Telemetry::SSL_NPN_TYPE, state); + } + else { + infoObject->SetNegotiatedNPN(nullptr, 0); + } +} + +SECStatus +CanFalseStartCallback(PRFileDesc* fd, void* client_data, PRBool *canFalseStart) +{ + *canFalseStart = false; + + nsNSSShutDownPreventionLock locker; + + nsNSSSocketInfo* infoObject = (nsNSSSocketInfo*) fd->higher->secret; + if (!infoObject) { + PR_SetError(PR_INVALID_STATE_ERROR, 0); + return SECFailure; + } + + if (infoObject->isAlreadyShutDown()) { + MOZ_CRASH("SSL socket used after NSS shut down"); + PR_SetError(PR_INVALID_STATE_ERROR, 0); + return SECFailure; + } + + PreliminaryHandshakeDone(fd); + + SSLChannelInfo channelInfo; + if (SSL_GetChannelInfo(fd, &channelInfo, sizeof(channelInfo)) != SECSuccess) { + return SECSuccess; + } + + SSLCipherSuiteInfo cipherInfo; + if (SSL_GetCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo, + sizeof (cipherInfo)) != SECSuccess) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + " KEA %d\n", fd, + static_cast(cipherInfo.keaType))); + return SECSuccess; + } + + if (channelInfo.protocolVersion < SSL_LIBRARY_VERSION_TLS_1_0) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "SSL Version must be >= TLS1 %x\n", fd, + static_cast(channelInfo.protocolVersion))); + return SECSuccess; + } + + // never do false start without one of these key exchange algorithms + if (cipherInfo.keaType != ssl_kea_rsa && + cipherInfo.keaType != ssl_kea_dh && + cipherInfo.keaType != ssl_kea_ecdh) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "unsupported KEA %d\n", fd, + static_cast(cipherInfo.keaType))); + return SECSuccess; + } + + // never do false start without at least 80 bits of key material. This should + // be redundant to an NSS precondition + if (cipherInfo.effectiveKeyBits < 80) { + MOZ_CRASH("NSS is not enforcing the precondition that the effective " + "key size must be >= 80 bits for false start"); + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "key too small %d\n", fd, + static_cast(cipherInfo.effectiveKeyBits))); + PR_SetError(PR_INVALID_STATE_ERROR, 0); + return SECFailure; + } + + // XXX: An attacker can choose which protocols are advertised in the + // NPN extension. TODO(Bug 861311): We should restrict the ability + // of an attacker leverage this capability by restricting false start + // to the same protocol we previously saw for the server, after the + // first successful connection to the server. + + // Enforce NPN to do false start if policy requires it. Do this as an + // indicator if server compatibility. + nsSSLIOLayerHelpers& helpers = infoObject->SharedState().IOLayerHelpers(); + if (helpers.mFalseStartRequireNPN) { + nsAutoCString negotiatedNPN; + if (NS_FAILED(infoObject->GetNegotiatedNPN(negotiatedNPN)) || + !negotiatedNPN.Length()) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "NPN cannot be verified\n", fd)); + return SECSuccess; + } + } + + // If we're not using eliptical curve kea then make sure we've seen the + // same kea from this host in the past, to limit the potential for downgrade + // attacks. + if (cipherInfo.keaType != ssl_kea_ecdh) { + + if (helpers.mFalseStartRequireForwardSecrecy) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "KEA used is %d, but " + "require-forward-secrecy configured.\n", + fd, static_cast(cipherInfo.keaType))); + return SECSuccess; + } + + int16_t expected = infoObject->GetKEAExpected(); + if (cipherInfo.keaType != expected) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "KEA used is %d, expected %d\n", fd, + static_cast(cipherInfo.keaType), + static_cast(expected))); + return SECSuccess; + } + + // whitelist the expected key exchange algorithms that are + // acceptable for false start when seen before. + if (expected != ssl_kea_rsa && expected != ssl_kea_dh && + expected != ssl_kea_ecdh) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "KEA used, %d, " + "is not supported with False Start.\n", + fd, static_cast(expected))); + return SECSuccess; + } + } + + // If we're not using AES then verify that this is the historically expected + // symmetrical cipher for this host, to limit potential for downgrade attacks. + if (cipherInfo.symCipher != ssl_calg_aes) { + int16_t expected = infoObject->GetSymmetricCipherExpected(); + if (cipherInfo.symCipher != expected) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "Symmetric cipher used is %d, expected %d\n", + fd, static_cast(cipherInfo.symCipher), + static_cast(expected))); + return SECSuccess; + } + + // whitelist the expected ciphers that are + // acceptable for false start when seen before. + if ((expected != ssl_calg_rc4) && (expected != ssl_calg_3des) && + (expected != ssl_calg_aes)) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] failed - " + "Symmetric cipher used, %d, " + "is not supported with False Start.\n", + fd, static_cast(expected))); + return SECSuccess; + } + } + + infoObject->NoteTimeUntilReady(); + *canFalseStart = true; + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("CanFalseStartCallback [%p] ok\n", fd)); + return SECSuccess; +} + void HandshakeCallback(PRFileDesc* fd, void* client_data) { nsNSSShutDownPreventionLock locker; int32_t sslStatus; @@ -834,11 +1014,14 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) { nsNSSSocketInfo* infoObject = (nsNSSSocketInfo*) fd->higher->secret; // certificate validation sets FirstServerHelloReceived, so if that flag - // is absent at handshake time we have a resumed session. + // is absent at handshake time we have a resumed session. Check this before + // PreliminaryHandshakeDone() because that function also sets that flag. bool isResumedSession = !(infoObject->GetFirstServerHelloReceived()); - // This is the first callback on resumption handshakes - infoObject->SetFirstServerHelloReceived(); + // Do the bookkeeping that needs to be done after the + // server's ServerHello...ServerHelloDone have been processed, but that doesn't + // need the handshake to be completed. + PreliminaryHandshakeDone(fd); // If the handshake completed, then we know the site is TLS tolerant (if this // was a TLS connection). @@ -930,21 +1113,6 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) { status->mSecretKeyLength = encryptBits; status->mCipherName.Assign(cipherName); - // Get the NPN value. - SSLNextProtoState state; - unsigned char npnbuf[256]; - unsigned int npnlen; - - if (SSL_GetNextProto(fd, &state, npnbuf, &npnlen, 256) == SECSuccess) { - if (state == SSL_NEXT_PROTO_NEGOTIATED) - infoObject->SetNegotiatedNPN(reinterpret_cast(npnbuf), npnlen); - else - infoObject->SetNegotiatedNPN(nullptr, 0); - mozilla::Telemetry::Accumulate(Telemetry::SSL_NPN_TYPE, state); - } - else - infoObject->SetNegotiatedNPN(nullptr, 0); - SSLChannelInfo channelInfo; if (SSL_GetChannelInfo(fd, &channelInfo, sizeof(channelInfo)) == SECSuccess) { // Get the protocol version for telemetry @@ -954,13 +1122,16 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) { SSLCipherSuiteInfo cipherInfo; if (SSL_GetCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo, - sizeof (cipherInfo)) == SECSuccess) { + sizeof (cipherInfo)) == SECSuccess) { // keyExchange null=0, rsa=1, dh=2, fortezza=3, ecdh=4 Telemetry::Accumulate(Telemetry::SSL_KEY_EXCHANGE_ALGORITHM, cipherInfo.keaType); + infoObject->SetKEAUsed(cipherInfo.keaType); + infoObject->SetSymmetricCipherUsed(cipherInfo.symCipher); } - } + + infoObject->NoteTimeUntilReady(); infoObject->SetHandshakeCompleted(isResumedSession); PORT_Free(cipherName); diff --git a/security/manager/ssl/src/nsNSSCallbacks.h b/security/manager/ssl/src/nsNSSCallbacks.h index 48b62c46b36..b267efb2e83 100644 --- a/security/manager/ssl/src/nsNSSCallbacks.h +++ b/security/manager/ssl/src/nsNSSCallbacks.h @@ -23,6 +23,8 @@ char* PK11PasswordPrompt(PK11SlotInfo *slot, PRBool retry, void* arg); void HandshakeCallback(PRFileDesc *fd, void *client_data); +SECStatus CanFalseStartCallback(PRFileDesc* fd, void* client_data, + PRBool *canFalseStart); SECStatus RegisterMyOCSPAIAInfoCallback(); SECStatus UnregisterMyOCSPAIAInfoCallback(); diff --git a/security/manager/ssl/src/nsNSSIOLayer.cpp b/security/manager/ssl/src/nsNSSIOLayer.cpp index 42945bdec2d..cd079797d4f 100644 --- a/security/manager/ssl/src/nsNSSIOLayer.cpp +++ b/security/manager/ssl/src/nsNSSIOLayer.cpp @@ -83,12 +83,18 @@ nsNSSSocketInfo::nsNSSSocketInfo(SharedSSLState& aState, uint32_t providerFlags) mHandshakeInProgress(false), mAllowTLSIntoleranceTimeout(true), mRememberClientAuthCertificate(false), + mPreliminaryHandshakeDone(false), mHandshakeStartTime(0), mFirstServerHelloReceived(false), mNPNCompleted(false), mHandshakeCompleted(false), mJoined(false), mSentClientCert(false), + mNotedTimeUntilReady(false), + mKEAUsed(nsISSLSocketControl::KEY_EXCHANGE_UNKNOWN), + mKEAExpected(nsISSLSocketControl::KEY_EXCHANGE_UNKNOWN), + mSymmetricCipherUsed(nsISSLSocketControl::SYMMETRIC_CIPHER_UNKNOWN), + mSymmetricCipherExpected(nsISSLSocketControl::SYMMETRIC_CIPHER_UNKNOWN), mProviderFlags(providerFlags), mSocketCreationTimestamp(TimeStamp::Now()), mPlaintextBytesRead(0) @@ -106,6 +112,48 @@ nsNSSSocketInfo::GetProviderFlags(uint32_t* aProviderFlags) return NS_OK; } +NS_IMETHODIMP +nsNSSSocketInfo::GetKEAUsed(int16_t *aKea) +{ + *aKea = mKEAUsed; + return NS_OK; +} + +NS_IMETHODIMP +nsNSSSocketInfo::GetKEAExpected(int16_t *aKea) +{ + *aKea = mKEAExpected; + return NS_OK; +} + +NS_IMETHODIMP +nsNSSSocketInfo::SetKEAExpected(int16_t aKea) +{ + mKEAExpected = aKea; + return NS_OK; +} + +NS_IMETHODIMP +nsNSSSocketInfo::GetSymmetricCipherUsed(int16_t *aSymmetricCipher) +{ + *aSymmetricCipher = mSymmetricCipherUsed; + return NS_OK; +} + +NS_IMETHODIMP +nsNSSSocketInfo::GetSymmetricCipherExpected(int16_t *aSymmetricCipher) +{ + *aSymmetricCipher = mSymmetricCipherExpected; + return NS_OK; +} + +NS_IMETHODIMP +nsNSSSocketInfo::SetSymmetricCipherExpected(int16_t aSymmetricCipher) +{ + mSymmetricCipherExpected = aSymmetricCipher; + return NS_OK; +} + nsresult nsNSSSocketInfo::GetHandshakePending(bool *aHandshakePending) { @@ -197,12 +245,27 @@ getSecureBrowserUI(nsIInterfaceRequestor * callbacks, } #endif +void +nsNSSSocketInfo::NoteTimeUntilReady() +{ + if (mNotedTimeUntilReady) + return; + + mNotedTimeUntilReady = true; + + // This will include TCP and proxy tunnel wait time + Telemetry::AccumulateTimeDelta(Telemetry::SSL_TIME_UNTIL_READY, + mSocketCreationTimestamp, TimeStamp::Now()); + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("[%p] nsNSSSocketInfo::NoteTimeUntilReady\n", mFd)); +} + void nsNSSSocketInfo::SetHandshakeCompleted(bool aResumedSession) { if (!mHandshakeCompleted) { // This will include TCP and proxy tunnel wait time - Telemetry::AccumulateTimeDelta(Telemetry::SSL_TIME_UNTIL_READY, + Telemetry::AccumulateTimeDelta(Telemetry::SSL_TIME_UNTIL_HANDSHAKE_FINISHED, mSocketCreationTimestamp, TimeStamp::Now()); // If the handshake is completed for the first time from just 1 callback @@ -220,6 +283,9 @@ nsNSSSocketInfo::SetHandshakeCompleted(bool aResumedSession) } mHandshakeCompleted = true; + + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("[%p] nsNSSSocketInfo::SetHandshakeCompleted\n", (void*)mFd)); } } @@ -1095,6 +1161,8 @@ nsSSLIOLayerHelpers::nsSSLIOLayerHelpers() , mRenegoUnrestrictedSites(nullptr) , mTreatUnsafeNegotiationAsBroken(false) , mWarnLevelMissingRFC5746(1) +, mFalseStartRequireNPN(true) +, mFalseStartRequireForwardSecrecy(false) { } @@ -1285,6 +1353,12 @@ PrefObserver::Observe(nsISupports *aSubject, const char *aTopic, int32_t warnLevel = 1; Preferences::GetInt("security.ssl.warn_missing_rfc5746", &warnLevel); mOwner->setWarnLevelMissingRFC5746(warnLevel); + } else if (prefName.Equals("security.ssl.false_start.require-npn")) { + Preferences::GetBool("security.ssl.false_start.require-npn", + &mOwner->mFalseStartRequireNPN); + } else if (prefName.Equals("security.ssl.false_start.require-forward-secrecy")) { + Preferences::GetBool("security.ssl.false_start.require-forward-secrecy", + &mOwner->mFalseStartRequireForwardSecrecy); } } return NS_OK; @@ -1312,6 +1386,8 @@ nsSSLIOLayerHelpers::~nsSSLIOLayerHelpers() Preferences::RemoveObserver(mPrefObserver, "security.ssl.renego_unrestricted_hosts"); Preferences::RemoveObserver(mPrefObserver, "security.ssl.treat_unsafe_negotiation_as_broken"); Preferences::RemoveObserver(mPrefObserver, "security.ssl.warn_missing_rfc5746"); + Preferences::RemoveObserver(mPrefObserver, "security.ssl.false_start.require-npn"); + Preferences::RemoveObserver(mPrefObserver, "security.ssl.false_start.require-forward-secrecy"); } nsresult nsSSLIOLayerHelpers::Init() @@ -1386,6 +1462,11 @@ nsresult nsSSLIOLayerHelpers::Init() Preferences::GetInt("security.ssl.warn_missing_rfc5746", &warnLevel); setWarnLevelMissingRFC5746(warnLevel); + Preferences::GetBool("security.ssl.false_start.require-npn", + &mFalseStartRequireNPN); + Preferences::GetBool("security.ssl.false_start.require-forward-secrecy", + &mFalseStartRequireForwardSecrecy); + mPrefObserver = new PrefObserver(this); Preferences::AddStrongObserver(mPrefObserver, "security.ssl.renego_unrestricted_hosts"); @@ -1393,7 +1474,10 @@ nsresult nsSSLIOLayerHelpers::Init() "security.ssl.treat_unsafe_negotiation_as_broken"); Preferences::AddStrongObserver(mPrefObserver, "security.ssl.warn_missing_rfc5746"); - + Preferences::AddStrongObserver(mPrefObserver, + "security.ssl.false_start.require-npn"); + Preferences::AddStrongObserver(mPrefObserver, + "security.ssl.false_start.require-forward-secrecy"); return NS_OK; } @@ -2479,6 +2563,7 @@ nsSSLIOLayerImportFD(PRFileDesc *fd, } SSL_SetPKCS11PinArg(sslSock, (nsIInterfaceRequestor*)infoObject); SSL_HandshakeCallback(sslSock, HandshakeCallback, infoObject); + SSL_SetCanFalseStartCallback(sslSock, CanFalseStartCallback, infoObject); // Disable this hook if we connect anonymously. See bug 466080. uint32_t flags = 0; diff --git a/security/manager/ssl/src/nsNSSIOLayer.h b/security/manager/ssl/src/nsNSSIOLayer.h index 27143671009..d64715df767 100644 --- a/security/manager/ssl/src/nsNSSIOLayer.h +++ b/security/manager/ssl/src/nsNSSIOLayer.h @@ -61,6 +61,7 @@ public: void SetNegotiatedNPN(const char *value, uint32_t length); void SetHandshakeCompleted(bool aResumedSession); + void NoteTimeUntilReady(); bool GetJoined() { return mJoined; } void SetSentClientCert() { mSentClientCert = true; } @@ -93,6 +94,30 @@ public: void SetTLSEnabled(bool enabled) { mTLSEnabled = enabled; } void AddPlaintextBytesRead(uint64_t val) { mPlaintextBytesRead += val; } + + bool IsPreliminaryHandshakeDone() const { return mPreliminaryHandshakeDone; } + void SetPreliminaryHandshakeDone() { mPreliminaryHandshakeDone = true; } + + void SetKEAUsed(PRUint16 kea) { mKEAUsed = kea; } + inline int16_t GetKEAExpected() // infallible in nsISSLSocketControl + { + int16_t result; + mozilla::DebugOnly rv = GetKEAExpected(&result); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + return result; + } + void SetSymmetricCipherUsed(PRUint16 symmetricCipher) + { + mSymmetricCipherUsed = symmetricCipher; + } + inline int16_t GetSymmetricCipherExpected() // infallible in nsISSLSocketControl + { + int16_t result; + mozilla::DebugOnly rv = GetSymmetricCipherExpected(&result); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + return result; + } + private: PRFileDesc* mFd; @@ -107,6 +132,7 @@ private: bool mHandshakeInProgress; bool mAllowTLSIntoleranceTimeout; bool mRememberClientAuthCertificate; + bool mPreliminaryHandshakeDone; // after false start items are complete PRIntervalTime mHandshakeStartTime; bool mFirstServerHelloReceived; @@ -117,6 +143,14 @@ private: bool mHandshakeCompleted; bool mJoined; bool mSentClientCert; + bool mNotedTimeUntilReady; + + // mKEA* and mSymmetricCipher* are used in false start detetermination + // values are from nsISSLSocketControl + PRInt16 mKEAUsed; + PRInt16 mKEAExpected; + PRInt16 mSymmetricCipherUsed; + PRInt16 mSymmetricCipherExpected; uint32_t mProviderFlags; mozilla::TimeStamp mSocketCreationTimestamp; @@ -164,6 +198,9 @@ public: bool isRenegoUnrestrictedSite(const nsCString &str); void clearStoredData(); + + bool mFalseStartRequireNPN; + bool mFalseStartRequireForwardSecrecy; private: nsCOMPtr mPrefObserver; }; diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 0bb5bafac4d..77e0aa16ba2 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -843,6 +843,12 @@ "extended_statistics_ok": true, "description": "ms of SSL wait time including TCP and proxy tunneling" }, + "SSL_TIME_UNTIL_HANDSHAKE_FINISHED": { + "kind": "exponential", + "high": "60000", + "n_buckets": 200, + "description": "ms of SSL wait time for full handshake including TCP and proxy tunneling" + }, "SSL_BYTES_BEFORE_CERT_CALLBACK": { "kind": "exponential", "high": "32000", From cae92d7c43cbe4db2d86ff45a5a2918a2391cfcb Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 28 Jun 2013 13:42:14 +0900 Subject: [PATCH 06/28] Bug 888132 - MOZ_GOOGLE_API_KEY_FILE should be an include file. r=khuey --- configure.in | 2 +- toolkit/components/urlformatter/Makefile.in | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 5b5eebbe291..93bdca8a079 100644 --- a/configure.in +++ b/configure.in @@ -4340,7 +4340,7 @@ MOZ_ARG_WITH_STRING(google-api-keyfile, if test -z "$MOZ_GOOGLE_API_KEY"; then MOZ_GOOGLE_API_KEY=no-google-api-key fi -AC_DEFINE_UNQUOTED(MOZ_GOOGLE_API_KEY, $MOZ_GOOGLE_API_KEY) +AC_SUBST(MOZ_GOOGLE_API_KEY) # Allow the application to influence configure with a confvars.sh script. AC_MSG_CHECKING([if app-specific confvars.sh exists]) diff --git a/toolkit/components/urlformatter/Makefile.in b/toolkit/components/urlformatter/Makefile.in index 07908dc8e6a..91d9132a925 100644 --- a/toolkit/components/urlformatter/Makefile.in +++ b/toolkit/components/urlformatter/Makefile.in @@ -14,4 +14,13 @@ DISABLED_EXTRA_COMPONENTS = \ nsURLFormatter.manifest \ $(NULL) +export:: google_api_key + +EXTRA_PP_COMPONENTS_FLAGS = -I google_api_key + include $(topsrcdir)/config/rules.mk + +google_api_key: + @echo "#define MOZ_GOOGLE_API_KEY $(MOZ_GOOGLE_API_KEY)" > $@ + +GARBAGE += google_api_key From 03004a2676cca8f2d29b9758666e632003b1e6dc Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Fri, 28 Jun 2013 23:25:08 -0400 Subject: [PATCH 07/28] Bug 498181 - Offer to reset a user's profile if it was last used more than two months ago. r=jaws --HG-- rename : toolkit/content/resetProfile.js => toolkit/modules/ResetProfile.jsm extra : rebase_source : 88969c77e4d86ba2d6cecbe188e19ad390f6629d --- browser/components/nsBrowserGlue.js | 44 ++++++++++ toolkit/content/Makefile.in | 2 - toolkit/content/aboutSupport.js | 28 +------ toolkit/content/aboutSupport.xhtml | 2 +- toolkit/content/jar.mn | 2 +- toolkit/content/resetProfile.js | 63 ++------------ .../chrome/global/resetProfile.properties | 12 +++ toolkit/locales/jar.mn | 1 + toolkit/modules/Makefile.in | 6 ++ toolkit/modules/ResetProfile.jsm | 84 +++++++++++++++++++ 10 files changed, 157 insertions(+), 87 deletions(-) create mode 100644 toolkit/locales/en-US/chrome/global/resetProfile.properties create mode 100644 toolkit/modules/ResetProfile.jsm diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index a8db7d10b26..d297d0fe9f4 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -516,6 +516,41 @@ BrowserGlue.prototype = { nb.PRIORITY_INFO_LOW, buttons); }, + /** + * Show a notification bar offering a reset if the profile has been unused for some time. + */ + _resetUnusedProfileNotification: function () { + let win = this.getMostRecentBrowserWindow(); + if (!win) + return; + + Cu.import("resource://gre/modules/ResetProfile.jsm"); + if (!ResetProfile.resetSupported()) + return; + + let productName = Services.strings + .createBundle("chrome://branding/locale/brand.properties") + .GetStringFromName("brandShortName"); + let resetBundle = Services.strings + .createBundle("chrome://global/locale/resetProfile.properties"); + + let message = resetBundle.formatStringFromName("resetUnusedProfile.message", [productName], 1); + let buttons = [ + { + label: resetBundle.formatStringFromName("resetProfile.resetButton.label", [productName], 1), + accessKey: resetBundle.GetStringFromName("resetProfile.resetButton.accesskey"), + callback: function () { + ResetProfile.openConfirmationDialog(win); + } + }, + ]; + + let nb = win.document.getElementById("global-notificationbox"); + nb.appendNotification(message, "reset-unused-profile", + "chrome://global/skin/icons/question-16.png", + nb.PRIORITY_INFO_LOW, buttons); + }, + // the first browser window has finished initializing _onFirstWindowLoaded: function BG__onFirstWindowLoaded() { #ifdef XP_WIN @@ -530,6 +565,15 @@ BrowserGlue.prototype = { #endif this._trackSlowStartup(); + + // Offer to reset a user's profile if it hasn't been used for 60 days. + const OFFER_PROFILE_RESET_INTERVAL_MS = 60 * 24 * 60 * 60 * 1000; + let processStartupTime = Services.startup.getStartupInfo().process; + let lastUse = Services.appinfo.replacedLockTime; + if (processStartupTime && lastUse && + processStartupTime.getTime() - lastUse >= OFFER_PROFILE_RESET_INTERVAL_MS) { + this._resetUnusedProfileNotification(); + } }, /** diff --git a/toolkit/content/Makefile.in b/toolkit/content/Makefile.in index fb48ab2602e..a769ea70fba 100644 --- a/toolkit/content/Makefile.in +++ b/toolkit/content/Makefile.in @@ -25,8 +25,6 @@ DEFINES += \ -DCXX_VERSION="$(CXX_VERSION)" \ -DCXXFLAGS="$(CXXFLAGS)" \ -DCPPFLAGS="$(CPPFLAGS)" \ - -DMOZ_APP_NAME=$(MOZ_APP_NAME) \ - -DMOZ_BUILD_APP=$(MOZ_BUILD_APP) \ $(NULL) MOZ_SOURCE_STAMP ?= $(shell hg -R $(topsrcdir) parent --template="{node|short}\n" 2>/dev/null) diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index a9f2d570e39..bd826b76865 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -6,6 +6,7 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components; Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Troubleshoot.jsm"); +Components.utils.import("resource://gre/modules/ResetProfile.jsm"); window.addEventListener("load", function onload(event) { window.removeEventListener("load", onload, false); @@ -516,31 +517,6 @@ function showUpdateHistory() { * Profile reset is only supported for the default profile if the appropriate migrator exists. */ function populateResetBox() { - if (resetSupported()) + if (ResetProfile.resetSupported()) $("reset-box").style.visibility = "visible"; } - -/** - * Restart the application to reset the profile. - */ -function resetProfileAndRestart() { - let branding = Services.strings.createBundle("chrome://branding/locale/brand.properties"); - let brandShortName = branding.GetStringFromName("brandShortName"); - - // Prompt the user to confirm. - let retVals = { - reset: false, - }; - window.openDialog("chrome://global/content/resetProfile.xul", null, - "chrome,modal,centerscreen,titlebar,dialog=yes", retVals); - if (!retVals.reset) - return; - - // Set the reset profile environment variable. - let env = Cc["@mozilla.org/process/environment;1"] - .getService(Ci.nsIEnvironment); - env.set("MOZ_RESET_PROFILE_RESTART", "1"); - - let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); - appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart); -} diff --git a/toolkit/content/aboutSupport.xhtml b/toolkit/content/aboutSupport.xhtml index e3973e66e10..f0c4a8c0a3a 100644 --- a/toolkit/content/aboutSupport.xhtml +++ b/toolkit/content/aboutSupport.xhtml @@ -30,7 +30,7 @@ diff --git a/toolkit/content/jar.mn b/toolkit/content/jar.mn index 5c235096239..54b82bdd635 100644 --- a/toolkit/content/jar.mn +++ b/toolkit/content/jar.mn @@ -43,7 +43,7 @@ toolkit.jar: + content/global/mozilla.xhtml (mozilla.xhtml) content/global/nsDragAndDrop.js (nsDragAndDrop.js) content/global/resetProfile.css (resetProfile.css) -* content/global/resetProfile.js (resetProfile.js) + content/global/resetProfile.js (resetProfile.js) content/global/resetProfile.xul (resetProfile.xul) content/global/resetProfileProgress.xul (resetProfileProgress.xul) content/global/treeUtils.js (treeUtils.js) diff --git a/toolkit/content/resetProfile.js b/toolkit/content/resetProfile.js index a908f7de8bf..d46b43b01e2 100644 --- a/toolkit/content/resetProfile.js +++ b/toolkit/content/resetProfile.js @@ -2,16 +2,18 @@ * 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/. */ -Components.utils.import("resource://gre/modules/Services.jsm"); +"use strict"; -let Cc = Components.classes; -let Ci = Components.interfaces; +let Cu = Components.utils; + +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/ResetProfile.jsm"); // based on onImportItemsPageShow from migration.js function populateResetPane(aContainerID) { let resetProfileItems = document.getElementById(aContainerID); try { - let dataTypes = getMigratedData(); + let dataTypes = ResetProfile.getMigratedData(); for (let dataType of dataTypes) { let label = document.createElement("label"); label.setAttribute("value", dataType); @@ -26,59 +28,6 @@ function onResetProfileLoad() { populateResetPane("migratedItems"); } -/** - * Check if reset is supported for the currently running profile. - * - * @return boolean whether reset is supported. - */ -function resetSupported() { - let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]. - getService(Ci.nsIToolkitProfileService); - let currentProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); - -#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__"; -#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__"; - - // Reset is only supported for the default profile if the self-migrator used for reset exists. - try { - return currentProfileDir.equals(profileService.selectedProfile.rootDir) && - ("@mozilla.org/profile/migrator;1?app=" + MOZ_BUILD_APP + "&type=" + MOZ_APP_NAME in Cc); - } catch (e) { - // Catch exception when there is no selected profile. - Cu.reportError(e); - } - return false; -} - -function getMigratedData() { - Components.utils.import("resource:///modules/MigrationUtils.jsm"); - -#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__"; -#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__"; - - // From migration.properties - const MIGRATED_TYPES = [ - 128,// Windows/Tabs - 4, // History and Bookmarks - 16, // Passwords - 8, // Form History - 2, // Cookies - ]; - - // Loop over possible data to migrate to give the user a list of what will be preserved. - let dataTypes = []; - for (let itemID of MIGRATED_TYPES) { - try { - let typeName = MigrationUtils.getLocalizedString(itemID + "_" + MOZ_APP_NAME); - dataTypes.push(typeName); - } catch (x) { - // Catch exceptions when the string for a data type doesn't exist. - Components.utils.reportError(x); - } - } - return dataTypes; -} - function onResetProfileAccepted() { let retVals = window.arguments[0]; retVals.reset = true; diff --git a/toolkit/locales/en-US/chrome/global/resetProfile.properties b/toolkit/locales/en-US/chrome/global/resetProfile.properties new file mode 100644 index 00000000000..a5289b6a7cb --- /dev/null +++ b/toolkit/locales/en-US/chrome/global/resetProfile.properties @@ -0,0 +1,12 @@ +# 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/. + +# LOCALIZATION NOTE: These strings are used for profile reset. + +# LOCALIZATION NOTE (resetUnusedProfile.message): %S is brandShortName. +resetUnusedProfile.message=It looks like you haven't started %S in a while. Do you want to clean it up for a fresh, like-new experience? And by the way, welcome back! + +# LOCALIZATION NOTE (resetProfile.resetButton.label): %S is brandShortName. +resetProfile.resetButton.label=Reset %S… +resetProfile.resetButton.accesskey=e diff --git a/toolkit/locales/jar.mn b/toolkit/locales/jar.mn index 86dd35f4fb3..638576baa9a 100644 --- a/toolkit/locales/jar.mn +++ b/toolkit/locales/jar.mn @@ -58,6 +58,7 @@ locale/@AB_CD@/global/printProgress.dtd (%chrome/global/printProgress.dtd) locale/@AB_CD@/global/regionNames.properties (%chrome/global/regionNames.properties) locale/@AB_CD@/global/resetProfile.dtd (%chrome/global/resetProfile.dtd) + locale/@AB_CD@/global/resetProfile.properties (%chrome/global/resetProfile.properties) locale/@AB_CD@/global/dialog.properties (%chrome/global/dialog.properties) locale/@AB_CD@/global/tree.dtd (%chrome/global/tree.dtd) locale/@AB_CD@/global/textcontext.dtd (%chrome/global/textcontext.dtd) diff --git a/toolkit/modules/Makefile.in b/toolkit/modules/Makefile.in index c7b459feac5..71721a1eaec 100644 --- a/toolkit/modules/Makefile.in +++ b/toolkit/modules/Makefile.in @@ -13,8 +13,14 @@ ifdef MOZ_TOOLKIT_SEARCH DEFINES += -DMOZ_TOOLKIT_SEARCH endif +DEFINES += \ + -DMOZ_APP_NAME=$(MOZ_APP_NAME) \ + -DMOZ_BUILD_APP=$(MOZ_BUILD_APP) \ + $(NULL) + EXTRA_PP_JS_MODULES = \ CertUtils.jsm \ + ResetProfile.jsm \ Services.jsm \ Troubleshoot.jsm \ UpdateChannel.jsm \ diff --git a/toolkit/modules/ResetProfile.jsm b/toolkit/modules/ResetProfile.jsm new file mode 100644 index 00000000000..db57f2ac797 --- /dev/null +++ b/toolkit/modules/ResetProfile.jsm @@ -0,0 +1,84 @@ +/* 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/. */ + +"use strict"; + +this.EXPORTED_SYMBOLS = ["ResetProfile"]; + +const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; +#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__"; +#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__"; + +Cu.import("resource://gre/modules/Services.jsm"); + +this.ResetProfile = { + /** + * Check if reset is supported for the currently running profile. + * + * @return boolean whether reset is supported. + */ + resetSupported: function() { + let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]. + getService(Ci.nsIToolkitProfileService); + let currentProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); + + // Reset is only supported for the default profile if the self-migrator used for reset exists. + try { + return currentProfileDir.equals(profileService.selectedProfile.rootDir) && + ("@mozilla.org/profile/migrator;1?app=" + MOZ_BUILD_APP + "&type=" + MOZ_APP_NAME in Cc); + } catch (e) { + // Catch exception when there is no selected profile. + Cu.reportError(e); + } + return false; + }, + + getMigratedData: function() { + Cu.import("resource:///modules/MigrationUtils.jsm"); + + // From migration.properties + const MIGRATED_TYPES = [ + 128,// Windows/Tabs + 4, // History and Bookmarks + 16, // Passwords + 8, // Form History + 2, // Cookies + ]; + + // Loop over possible data to migrate to give the user a list of what will be preserved. + let dataTypes = []; + for (let itemID of MIGRATED_TYPES) { + try { + let typeName = MigrationUtils.getLocalizedString(itemID + "_" + MOZ_APP_NAME); + dataTypes.push(typeName); + } catch (x) { + // Catch exceptions when the string for a data type doesn't exist. + Cu.reportError(x); + } + } + return dataTypes; + }, + + /** + * Ask the user if they wish to restart the application to reset the profile. + */ + openConfirmationDialog: function(window) { + // Prompt the user to confirm. + let params = { + reset: false, + }; + window.openDialog("chrome://global/content/resetProfile.xul", null, + "chrome,modal,centerscreen,titlebar,dialog=yes", params); + if (!params.reset) + return; + + // Set the reset profile environment variable. + let env = Cc["@mozilla.org/process/environment;1"] + .getService(Ci.nsIEnvironment); + env.set("MOZ_RESET_PROFILE_RESTART", "1"); + + let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); + appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart); + }, +}; From 5671b0b7ae2220d63b367d69214478b15e589eab Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Sun, 30 Jun 2013 21:12:26 -0400 Subject: [PATCH 08/28] Bug 888570 - Lazily load ForgetAboutSite.jsm from browser/components/places/content/controller.js. r=jaws --HG-- rename : toolkit/content/resetProfile.js => toolkit/modules/ResetProfile.jsm extra : rebase_source : 840e79ad4b087999f08ffbdbf152418ecb9182ea --- browser/components/places/content/controller.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index 5627c8eff44..f422ea469b2 100644 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -4,7 +4,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "ForgetAboutSite", + "resource://gre/modules/ForgetAboutSite.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm"); From adc9faa17a31c3a3fca88c05e8bb57e939f64357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kan-Ru=20Chen=20=28=E9=99=B3=E4=BE=83=E5=A6=82=29?= Date: Thu, 27 Jun 2013 17:50:30 +0800 Subject: [PATCH 09/28] Bug 883024 - Install missing stylesheets for b2g. r=roc --- b2g/installer/package-manifest.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index fa9159cc7ce..b8c1f81a3c8 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -605,6 +605,9 @@ @BINPATH@/res/EditorOverride.css @BINPATH@/res/contenteditable.css @BINPATH@/res/designmode.css +@BINPATH@/res/ImageDocument.css +@BINPATH@/res/TopLevelImageDocument.css +@BINPATH@/res/TopLevelVideoDocument.css @BINPATH@/res/table-add-column-after-active.gif @BINPATH@/res/table-add-column-after-hover.gif @BINPATH@/res/table-add-column-after.gif From 4006ded057df1272bb8671e4232bcbbdb248b354 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:00:54 +0200 Subject: [PATCH 10/28] Bug 883892 - Followup: remove comment that refers to removed code. --- dom/base/nsDOMClassInfo.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index ba4a07a9681..2ecef3b4e52 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -313,11 +313,6 @@ static const char kDOMStringBundleURL[] = nsIXPCScriptable::IS_GLOBAL_OBJECT | \ nsIXPCScriptable::WANT_OUTER_OBJECT) -// We need to let JavaScript QI elements to interfaces that are not in -// the classinfo since XBL can be used to dynamically implement new -// unknown interfaces on elements, accessibility relies on this being -// possible. - #define ARRAY_SCRIPTABLE_FLAGS \ (DOM_DEFAULT_SCRIPTABLE_FLAGS | \ nsIXPCScriptable::WANT_GETPROPERTY | \ From b5ea9cce84e35e97e05de0ca8869d3c5b158e35c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:01:23 +0200 Subject: [PATCH 11/28] Bug 883114 - Part a: remove various make rules in dom; r=ted --- dom/devicestorage/ipc/Makefile.in | 7 +-- dom/permission/tests/Makefile.in | 26 ++++------ dom/tests/mochitest/crypto/Makefile.in | 48 ++++++++++--------- .../dom-level2-html/files/Makefile.in | 8 +--- .../files/applets/org/w3c/domts/Makefile.in | 17 +++++++ .../files/applets/org/w3c/domts/moz.build | 6 +++ .../mochitest/dom-level2-html/files/moz.build | 3 ++ 7 files changed, 63 insertions(+), 52 deletions(-) create mode 100644 dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/Makefile.in create mode 100644 dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/moz.build diff --git a/dom/devicestorage/ipc/Makefile.in b/dom/devicestorage/ipc/Makefile.in index d843f292944..ad29695d5ac 100644 --- a/dom/devicestorage/ipc/Makefile.in +++ b/dom/devicestorage/ipc/Makefile.in @@ -10,8 +10,7 @@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk - -TEST_FILES = \ +MOCHITEST_FILES := \ test_ipc.html \ ../test/devicestorage_common.js \ $(NULL) @@ -20,7 +19,3 @@ TEST_FILES = \ include $(topsrcdir)/config/config.mk include $(topsrcdir)/ipc/chromium/chromium-config.mk include $(topsrcdir)/config/rules.mk - -libs:: $(TEST_FILES) - $(INSTALL) $(foreach f,$^,"$f") \ - $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)\ diff --git a/dom/permission/tests/Makefile.in b/dom/permission/tests/Makefile.in index e541524ebbf..62eca2fe2af 100644 --- a/dom/permission/tests/Makefile.in +++ b/dom/permission/tests/Makefile.in @@ -2,7 +2,7 @@ # 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/. -DEPTH = ../../.. +DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ @@ -11,9 +11,7 @@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -include $(topsrcdir)/config/rules.mk - -_TEST_FILES = \ +MOCHITEST_FILES = \ test_permission_basics.html \ test_alarms.html \ test_idle.html \ @@ -30,19 +28,19 @@ _TEST_FILES = \ $(NULL) # disabled until bug 859593 is fixed -#_TEST_FILES += \ +#MOCHITEST_FILES += \ # test_camera.html \ # $(NULL) ifdef MOZ_B2G -_TEST_FILES += \ +MOCHITEST_FILES += \ test_keyboard.html \ test_wifi-manage.html \ $(NULL) endif ifdef MOZ_B2G_RIL -_TEST_FILES += \ +MOCHITEST_FILES += \ test_cellbroadcast.html \ test_mobileconnection.html \ test_networkstats-manage.html \ @@ -52,31 +50,27 @@ _TEST_FILES += \ endif ifdef MOZ_B2G_FM -_TEST_FILES += \ +MOCHITEST_FILES += \ test_fmradio.html \ $(NULL) endif ifdef MOZ_B2G_BT -_TEST_FILES += \ +MOCHITEST_FILES += \ test_bluetooth.html \ $(NULL) endif ifdef MOZ_WEBSMS_BACKEND -_TEST_FILES += \ +MOCHITEST_FILES += \ test_sms.html \ $(NULL) endif ifdef MOZ_TIME_MANAGER -_TEST_FILES += \ +MOCHITEST_FILES += \ test_time.html \ $(NULL) endif -_CHROME_TEST_FILES = \ - $(NULL) - -libs:: $(_TEST_FILES) - $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) +include $(topsrcdir)/config/rules.mk diff --git a/dom/tests/mochitest/crypto/Makefile.in b/dom/tests/mochitest/crypto/Makefile.in index ce2e344a677..3ff37077fa6 100644 --- a/dom/tests/mochitest/crypto/Makefile.in +++ b/dom/tests/mochitest/crypto/Makefile.in @@ -1,25 +1,27 @@ # 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/. - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ -relativesrcdir = @relativesrcdir@ - -include $(DEPTH)/config/autoconf.mk -include $(topsrcdir)/config/rules.mk - -_TEST_FILES = \ - test_getRandomValues.html \ - $(NULL) - -ifndef MOZ_DISABLE_CRYPTOLEGACY -_TEST_FILES += test_legacy.html -else -_TEST_FILES += test_no_legacy.html -endif - -libs:: $(_TEST_FILES) - $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) +# You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +MOCHITEST_FILES := \ + test_getRandomValues.html \ + $(NULL) + +ifndef MOZ_DISABLE_CRYPTOLEGACY +MOCHITEST_FILES += \ + test_legacy.html \ + $(NULL) +else +MOCHITEST_FILES += \ + test_no_legacy.html \ + $(NULL) +endif + +include $(topsrcdir)/config/rules.mk diff --git a/dom/tests/mochitest/dom-level2-html/files/Makefile.in b/dom/tests/mochitest/dom-level2-html/files/Makefile.in index 760ad12ebd6..d2dc024d59c 100644 --- a/dom/tests/mochitest/dom-level2-html/files/Makefile.in +++ b/dom/tests/mochitest/dom-level2-html/files/Makefile.in @@ -1,4 +1,3 @@ -# # 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/. @@ -219,10 +218,5 @@ MOCHITEST_FILES = \ xhtml1-strict.dtd \ xhtml1-transitional.dtd \ $(NULL) -MOCHITEST_FILES_J = \ - applets/org/w3c/domts/DOMTSApplet.class \ - $(NULL) -include $(topsrcdir)/config/rules.mk -libs:: $(MOCHITEST_FILES_J) - $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)/applets/org/w3c/domts +include $(topsrcdir)/config/rules.mk diff --git a/dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/Makefile.in b/dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/Makefile.in new file mode 100644 index 00000000000..7de0bc4b8db --- /dev/null +++ b/dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/Makefile.in @@ -0,0 +1,17 @@ +# 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/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +MOCHITEST_FILES := \ + DOMTSApplet.class \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/moz.build b/dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/moz.build new file mode 100644 index 00000000000..895d11993cf --- /dev/null +++ b/dom/tests/mochitest/dom-level2-html/files/applets/org/w3c/domts/moz.build @@ -0,0 +1,6 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + diff --git a/dom/tests/mochitest/dom-level2-html/files/moz.build b/dom/tests/mochitest/dom-level2-html/files/moz.build index 895d11993cf..22970ec9b8e 100644 --- a/dom/tests/mochitest/dom-level2-html/files/moz.build +++ b/dom/tests/mochitest/dom-level2-html/files/moz.build @@ -4,3 +4,6 @@ # 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/. +DIRS += [ + 'applets/org/w3c/domts', +] From 952b42c3f5a8d6831aadca027e56cc89d782c307 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:14 +0200 Subject: [PATCH 12/28] Bug 883114 - Part b: remove make rules from workers; r=ted --HG-- rename : dom/workers/test/relativeLoad_sub_import.js => dom/workers/test/subdir/relativeLoad_sub_import.js rename : dom/workers/test/relativeLoad_sub_worker.js => dom/workers/test/subdir/relativeLoad_sub_worker.js rename : dom/workers/test/relativeLoad_sub_worker2.js => dom/workers/test/subdir/relativeLoad_sub_worker2.js --- dom/workers/test/Makefile.in | 9 --------- dom/workers/test/moz.build | 5 ++++- dom/workers/test/subdir/Makefile.in | 19 +++++++++++++++++++ dom/workers/test/subdir/moz.build | 6 ++++++ .../{ => subdir}/relativeLoad_sub_import.js | 0 .../{ => subdir}/relativeLoad_sub_worker.js | 0 .../{ => subdir}/relativeLoad_sub_worker2.js | 0 7 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 dom/workers/test/subdir/Makefile.in create mode 100644 dom/workers/test/subdir/moz.build rename dom/workers/test/{ => subdir}/relativeLoad_sub_import.js (100%) rename dom/workers/test/{ => subdir}/relativeLoad_sub_worker.js (100%) rename dom/workers/test/{ => subdir}/relativeLoad_sub_worker2.js (100%) diff --git a/dom/workers/test/Makefile.in b/dom/workers/test/Makefile.in index 06397c0d5f8..fa969da9c7d 100644 --- a/dom/workers/test/Makefile.in +++ b/dom/workers/test/Makefile.in @@ -111,12 +111,6 @@ MOCHITEST_FILES = \ # Disabled for frequent failures (bug 841505, bug 842344, etc) # test_xhr_timeout.html \ -_SUBDIRMOCHITEST_FILES = \ - relativeLoad_sub_worker.js \ - relativeLoad_sub_worker2.js \ - relativeLoad_sub_import.js \ - $(NULL) - MOCHITEST_CHROME_FILES = \ test_chromeWorker.xul \ test_chromeWorkerJSM.xul \ @@ -153,7 +147,4 @@ MOCHITEST_CHROME_FILES = \ url_worker.js \ $(NULL) -libs:: $(_SUBDIRMOCHITEST_FILES) - $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)/subdir - include $(topsrcdir)/config/rules.mk diff --git a/dom/workers/test/moz.build b/dom/workers/test/moz.build index ef71e6d750c..92cb282e8ff 100644 --- a/dom/workers/test/moz.build +++ b/dom/workers/test/moz.build @@ -4,4 +4,7 @@ # 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/. -DIRS += ['extensions'] +DIRS += [ + 'extensions', + 'subdir', +] diff --git a/dom/workers/test/subdir/Makefile.in b/dom/workers/test/subdir/Makefile.in new file mode 100644 index 00000000000..621db8dc83d --- /dev/null +++ b/dom/workers/test/subdir/Makefile.in @@ -0,0 +1,19 @@ +# 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/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +MOCHITEST_FILES := \ + relativeLoad_sub_worker.js \ + relativeLoad_sub_worker2.js \ + relativeLoad_sub_import.js \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/dom/workers/test/subdir/moz.build b/dom/workers/test/subdir/moz.build new file mode 100644 index 00000000000..895d11993cf --- /dev/null +++ b/dom/workers/test/subdir/moz.build @@ -0,0 +1,6 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + diff --git a/dom/workers/test/relativeLoad_sub_import.js b/dom/workers/test/subdir/relativeLoad_sub_import.js similarity index 100% rename from dom/workers/test/relativeLoad_sub_import.js rename to dom/workers/test/subdir/relativeLoad_sub_import.js diff --git a/dom/workers/test/relativeLoad_sub_worker.js b/dom/workers/test/subdir/relativeLoad_sub_worker.js similarity index 100% rename from dom/workers/test/relativeLoad_sub_worker.js rename to dom/workers/test/subdir/relativeLoad_sub_worker.js diff --git a/dom/workers/test/relativeLoad_sub_worker2.js b/dom/workers/test/subdir/relativeLoad_sub_worker2.js similarity index 100% rename from dom/workers/test/relativeLoad_sub_worker2.js rename to dom/workers/test/subdir/relativeLoad_sub_worker2.js From 5220c2049162e9d5897698a617998faf2770dac7 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:19 +0200 Subject: [PATCH 13/28] Bug 883114 - Part d: remove make rules in toolkit/content/tests; r=ted --- toolkit/content/tests/chrome/Makefile.in | 5 ++++- toolkit/content/tests/widgets/Makefile.in | 9 --------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/toolkit/content/tests/chrome/Makefile.in b/toolkit/content/tests/chrome/Makefile.in index afaf50c82b6..beb5b5860d8 100644 --- a/toolkit/content/tests/chrome/Makefile.in +++ b/toolkit/content/tests/chrome/Makefile.in @@ -10,7 +10,10 @@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -MOCHITEST_CHROME_FILES = findbar_window.xul \ +MOCHITEST_CHROME_FILES = \ + ../widgets/popup_shared.js \ + ../widgets/tree_shared.js \ + findbar_window.xul \ test_findbar.xul \ findbar_events_window.xul \ test_findbar_events.xul \ diff --git a/toolkit/content/tests/widgets/Makefile.in b/toolkit/content/tests/widgets/Makefile.in index 53115dae7b3..3331a7e2566 100644 --- a/toolkit/content/tests/widgets/Makefile.in +++ b/toolkit/content/tests/widgets/Makefile.in @@ -11,11 +11,6 @@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -_CHROME_FILES = \ - popup_shared.js \ - tree_shared.js \ - $(NULL) - MOCHITEST_FILES = \ test_contextmenu_nested.xul \ tree_shared.js \ @@ -62,8 +57,4 @@ MOCHITEST_FILES += \ $(NULL) endif -libs:: $(_CHROME_FILES) - $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/../chrome - include $(topsrcdir)/config/rules.mk - From 0410606b02d44ea8ceb02584c0d2b847384df195 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:23 +0200 Subject: [PATCH 14/28] Bug 883114 - Part e: remove make rules in toolkit/content/tests/chrome/rtl*; r=ted --HG-- rename : toolkit/content/tests/chrome/rtltest/dirtest.xul => toolkit/content/tests/chrome/rtltest/content/dirtest.xul --- .../content/tests/chrome/rtlchrome/Makefile.in | 13 +++++++------ .../content/tests/chrome/rtltest/Makefile.in | 10 +++++----- .../tests/chrome/rtltest/content/Makefile.in | 17 +++++++++++++++++ .../chrome/rtltest/{ => content}/dirtest.xul | 0 .../tests/chrome/rtltest/content/moz.build | 6 ++++++ toolkit/content/tests/chrome/rtltest/moz.build | 3 +++ 6 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 toolkit/content/tests/chrome/rtltest/content/Makefile.in rename toolkit/content/tests/chrome/rtltest/{ => content}/dirtest.xul (100%) create mode 100644 toolkit/content/tests/chrome/rtltest/content/moz.build diff --git a/toolkit/content/tests/chrome/rtlchrome/Makefile.in b/toolkit/content/tests/chrome/rtlchrome/Makefile.in index b484ffe0925..67656bde5df 100644 --- a/toolkit/content/tests/chrome/rtlchrome/Makefile.in +++ b/toolkit/content/tests/chrome/rtlchrome/Makefile.in @@ -1,4 +1,3 @@ -# # 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/. @@ -10,9 +9,11 @@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -include $(topsrcdir)/config/rules.mk -libs:: rtl.manifest rtl.css rtl.dtd - $(INSTALL) @srcdir@/rtl.manifest $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/ - $(INSTALL) @srcdir@/rtl.css $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/ - $(INSTALL) @srcdir@/rtl.dtd $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/ +MOCHITEST_CHROME_FILES := \ + rtl.css \ + rtl.dtd \ + rtl.manifest \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/toolkit/content/tests/chrome/rtltest/Makefile.in b/toolkit/content/tests/chrome/rtltest/Makefile.in index c42c98ed1b6..3c72d00b171 100644 --- a/toolkit/content/tests/chrome/rtltest/Makefile.in +++ b/toolkit/content/tests/chrome/rtltest/Makefile.in @@ -1,4 +1,3 @@ -# # 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/. @@ -10,8 +9,9 @@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -include $(topsrcdir)/config/rules.mk -libs:: righttoleft.manifest dirtest.xul - $(INSTALL) @srcdir@/righttoleft.manifest $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/ - $(INSTALL) @srcdir@/dirtest.xul $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/content/ +MOCHITEST_CHROME_FILES := \ + righttoleft.manifest \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/toolkit/content/tests/chrome/rtltest/content/Makefile.in b/toolkit/content/tests/chrome/rtltest/content/Makefile.in new file mode 100644 index 00000000000..47bece880c4 --- /dev/null +++ b/toolkit/content/tests/chrome/rtltest/content/Makefile.in @@ -0,0 +1,17 @@ +# 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/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +MOCHITEST_CHROME_FILES := \ + dirtest.xul \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/toolkit/content/tests/chrome/rtltest/dirtest.xul b/toolkit/content/tests/chrome/rtltest/content/dirtest.xul similarity index 100% rename from toolkit/content/tests/chrome/rtltest/dirtest.xul rename to toolkit/content/tests/chrome/rtltest/content/dirtest.xul diff --git a/toolkit/content/tests/chrome/rtltest/content/moz.build b/toolkit/content/tests/chrome/rtltest/content/moz.build new file mode 100644 index 00000000000..895d11993cf --- /dev/null +++ b/toolkit/content/tests/chrome/rtltest/content/moz.build @@ -0,0 +1,6 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + diff --git a/toolkit/content/tests/chrome/rtltest/moz.build b/toolkit/content/tests/chrome/rtltest/moz.build index 895d11993cf..2540d3effe4 100644 --- a/toolkit/content/tests/chrome/rtltest/moz.build +++ b/toolkit/content/tests/chrome/rtltest/moz.build @@ -4,3 +4,6 @@ # 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/. +DIRS += [ + 'content', +] From 88ffbf173bc003b54a4bfa2ac1e59d4b04b79cbc Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:28 +0200 Subject: [PATCH 15/28] Bug 880318 - Don't use nsIDOMDocument::GetHidden in media elements; r=cpearce --- content/html/content/src/HTMLAudioElement.cpp | 7 +------ content/html/content/src/HTMLVideoElement.cpp | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/content/html/content/src/HTMLAudioElement.cpp b/content/html/content/src/HTMLAudioElement.cpp index 474e4e60bac..b1ac20605ba 100644 --- a/content/html/content/src/HTMLAudioElement.cpp +++ b/content/html/content/src/HTMLAudioElement.cpp @@ -289,12 +289,7 @@ HTMLAudioElement::UpdateAudioChannelPlayingState() // Use a weak ref so the audio channel agent can't leak |this|. mAudioChannelAgent->InitWithWeakCallback(mAudioChannelType, this); - nsCOMPtr domDoc = do_QueryInterface(OwnerDoc()); - if (domDoc) { - bool hidden = false; - domDoc->GetHidden(&hidden); - mAudioChannelAgent->SetVisibilityState(!hidden); - } + mAudioChannelAgent->SetVisibilityState(!OwnerDoc()->Hidden()); } if (mPlayingThroughTheAudioChannel) { diff --git a/content/html/content/src/HTMLVideoElement.cpp b/content/html/content/src/HTMLVideoElement.cpp index 840dbd78d61..61ea2640153 100644 --- a/content/html/content/src/HTMLVideoElement.cpp +++ b/content/html/content/src/HTMLVideoElement.cpp @@ -273,12 +273,7 @@ HTMLVideoElement::WakeLockRelease() void HTMLVideoElement::WakeLockUpdate() { - bool hidden = true; - - nsCOMPtr domDoc = do_QueryInterface(OwnerDoc()); - if (domDoc) { - domDoc->GetHidden(&hidden); - } + bool hidden = OwnerDoc()->Hidden(); if (mScreenWakeLock && (mPaused || hidden)) { mScreenWakeLock->Unlock(); From 032d1cbb6621c2f22c4b935f304a98223580ebca Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:32 +0200 Subject: [PATCH 16/28] Bug 887012 - Remove some emptyish makefiles; r=gps --- browser/components/sidebar/Makefile.in | 19 ------------------ browser/fuel/src/Makefile.in | 14 ------------- dom/messages/Makefile.in | 20 ------------------- dom/permission/Makefile.in | 19 ------------------ dom/push/src/Makefile.in | 18 ----------------- dom/settings/Makefile.in | 19 ------------------ dom/wappush/Makefile.in | 14 ------------- toolkit/components/Makefile.in | 17 ---------------- toolkit/components/console/Makefile.in | 18 ----------------- toolkit/components/contentprefs/Makefile.in | 17 ---------------- toolkit/components/microformats/Makefile.in | 12 ----------- toolkit/components/prompts/src/Makefile.in | 17 ---------------- toolkit/components/social/Makefile.in | 12 ----------- toolkit/components/thumbnails/Makefile.in | 17 ---------------- toolkit/components/urlformatter/Makefile.in | 17 ---------------- toolkit/forgetaboutsite/Makefile.in | 12 ----------- toolkit/mozapps/handling/Makefile.in | 14 ------------- xpcom/reflect/xptcall/src/md/test/Makefile.in | 16 --------------- 18 files changed, 292 deletions(-) delete mode 100644 browser/components/sidebar/Makefile.in delete mode 100644 browser/fuel/src/Makefile.in delete mode 100644 dom/messages/Makefile.in delete mode 100644 dom/permission/Makefile.in delete mode 100644 dom/push/src/Makefile.in delete mode 100644 dom/settings/Makefile.in delete mode 100644 dom/wappush/Makefile.in delete mode 100644 toolkit/components/Makefile.in delete mode 100644 toolkit/components/console/Makefile.in delete mode 100644 toolkit/components/contentprefs/Makefile.in delete mode 100644 toolkit/components/microformats/Makefile.in delete mode 100644 toolkit/components/prompts/src/Makefile.in delete mode 100644 toolkit/components/social/Makefile.in delete mode 100644 toolkit/components/thumbnails/Makefile.in delete mode 100644 toolkit/components/urlformatter/Makefile.in delete mode 100644 toolkit/forgetaboutsite/Makefile.in delete mode 100644 toolkit/mozapps/handling/Makefile.in delete mode 100644 xpcom/reflect/xptcall/src/md/test/Makefile.in diff --git a/browser/components/sidebar/Makefile.in b/browser/components/sidebar/Makefile.in deleted file mode 100644 index 1f610b72ab7..00000000000 --- a/browser/components/sidebar/Makefile.in +++ /dev/null @@ -1,19 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - nsSidebar.manifest \ - nsSidebar.js \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - diff --git a/browser/fuel/src/Makefile.in b/browser/fuel/src/Makefile.in deleted file mode 100644 index f479051d7d0..00000000000 --- a/browser/fuel/src/Makefile.in +++ /dev/null @@ -1,14 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = fuelApplication.manifest - -include $(topsrcdir)/config/rules.mk diff --git a/dom/messages/Makefile.in b/dom/messages/Makefile.in deleted file mode 100644 index f2414961298..00000000000 --- a/dom/messages/Makefile.in +++ /dev/null @@ -1,20 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -relativesrcdir = @relativesrcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - SystemMessageManager.js \ - SystemMessageInternal.js \ - SystemMessageManager.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/dom/permission/Makefile.in b/dom/permission/Makefile.in deleted file mode 100644 index 44d753aea64..00000000000 --- a/dom/permission/Makefile.in +++ /dev/null @@ -1,19 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - PermissionSettings.js \ - PermissionSettings.manifest \ - PermissionPromptService.js \ - PermissionPromptService.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/dom/push/src/Makefile.in b/dom/push/src/Makefile.in deleted file mode 100644 index 4c368998901..00000000000 --- a/dom/push/src/Makefile.in +++ /dev/null @@ -1,18 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - Push.js \ - Push.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - diff --git a/dom/settings/Makefile.in b/dom/settings/Makefile.in deleted file mode 100644 index 661a4f1e80a..00000000000 --- a/dom/settings/Makefile.in +++ /dev/null @@ -1,19 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - SettingsManager.js \ - SettingsManager.manifest \ - SettingsService.js \ - SettingsService.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/dom/wappush/Makefile.in b/dom/wappush/Makefile.in deleted file mode 100644 index bfb4a4b4e63..00000000000 --- a/dom/wappush/Makefile.in +++ /dev/null @@ -1,14 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -relativesrcdir = @relativesrcdir@ - -include $(DEPTH)/config/autoconf.mk - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/Makefile.in b/toolkit/components/Makefile.in deleted file mode 100644 index c004e6390d7..00000000000 --- a/toolkit/components/Makefile.in +++ /dev/null @@ -1,17 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(topsrcdir)/config/config.mk - -DISABLED_EXTRA_COMPONENTS = \ - nsDefaultCLH.manifest \ - nsDefaultCLH.js \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/console/Makefile.in b/toolkit/components/console/Makefile.in deleted file mode 100644 index 8a4a08c4047..00000000000 --- a/toolkit/components/console/Makefile.in +++ /dev/null @@ -1,18 +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/. - - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - jsconsole-clhandler.js \ - jsconsole-clhandler.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/contentprefs/Makefile.in b/toolkit/components/contentprefs/Makefile.in deleted file mode 100644 index c81fce4f7aa..00000000000 --- a/toolkit/components/contentprefs/Makefile.in +++ /dev/null @@ -1,17 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - nsContentPrefService.js \ - nsContentPrefService.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/microformats/Makefile.in b/toolkit/components/microformats/Makefile.in deleted file mode 100644 index e5c6e187e36..00000000000 --- a/toolkit/components/microformats/Makefile.in +++ /dev/null @@ -1,12 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/prompts/src/Makefile.in b/toolkit/components/prompts/src/Makefile.in deleted file mode 100644 index a9cfba6f843..00000000000 --- a/toolkit/components/prompts/src/Makefile.in +++ /dev/null @@ -1,17 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - nsPrompter.js \ - nsPrompter.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/social/Makefile.in b/toolkit/components/social/Makefile.in deleted file mode 100644 index e5c6e187e36..00000000000 --- a/toolkit/components/social/Makefile.in +++ /dev/null @@ -1,12 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/thumbnails/Makefile.in b/toolkit/components/thumbnails/Makefile.in deleted file mode 100644 index 0922a069626..00000000000 --- a/toolkit/components/thumbnails/Makefile.in +++ /dev/null @@ -1,17 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - BrowserPageThumbs.manifest \ - PageThumbsProtocol.js \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/urlformatter/Makefile.in b/toolkit/components/urlformatter/Makefile.in deleted file mode 100644 index 07908dc8e6a..00000000000 --- a/toolkit/components/urlformatter/Makefile.in +++ /dev/null @@ -1,17 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = \ - nsURLFormatter.manifest \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/forgetaboutsite/Makefile.in b/toolkit/forgetaboutsite/Makefile.in deleted file mode 100644 index a86718977bb..00000000000 --- a/toolkit/forgetaboutsite/Makefile.in +++ /dev/null @@ -1,12 +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/. - -DEPTH := @DEPTH@ -topsrcdir := @top_srcdir@ -srcdir := @srcdir@ -VPATH := @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -include $(topsrcdir)/config/rules.mk diff --git a/toolkit/mozapps/handling/Makefile.in b/toolkit/mozapps/handling/Makefile.in deleted file mode 100644 index 659ef7688b0..00000000000 --- a/toolkit/mozapps/handling/Makefile.in +++ /dev/null @@ -1,14 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_EXTRA_COMPONENTS = nsContentDispatchChooser.js nsContentDispatchChooser.manifest - -include $(topsrcdir)/config/rules.mk diff --git a/xpcom/reflect/xptcall/src/md/test/Makefile.in b/xpcom/reflect/xptcall/src/md/test/Makefile.in deleted file mode 100644 index 3de8ebe1fd1..00000000000 --- a/xpcom/reflect/xptcall/src/md/test/Makefile.in +++ /dev/null @@ -1,16 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DISABLED_SIMPLE_PROGRAMS = stub_test - -include $(topsrcdir)/config/rules.mk - From ae221922f0bdcbc3fecc0c242f0fe6454d18cf65 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:37 +0200 Subject: [PATCH 17/28] Bug 887909 - Convert IDBFileHandle to WebIDL; r=janv --- dom/base/nsDOMClassInfo.cpp | 8 ------- dom/base/nsDOMClassInfoClasses.h | 1 - dom/bindings/Bindings.conf | 5 +++++ dom/indexedDB/IDBFileHandle.cpp | 30 +++++++++++--------------- dom/indexedDB/IDBFileHandle.h | 13 +++++------ dom/indexedDB/moz.build | 1 - dom/indexedDB/nsIIDBFileHandle.idl | 15 ------------- dom/webidl/IDBFileHandle.webidl | 10 +++++++++ dom/webidl/WebIDL.mk | 1 + js/xpconnect/src/dom_quickstubs.qsconf | 1 - 10 files changed, 36 insertions(+), 49 deletions(-) delete mode 100644 dom/indexedDB/nsIIDBFileHandle.idl create mode 100644 dom/webidl/IDBFileHandle.webidl diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 2ecef3b4e52..ed11065308a 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -222,7 +222,6 @@ #include "HTMLLegendElement.h" #include "mozilla/dom/indexedDB/IDBWrapperCache.h" -#include "mozilla/dom/indexedDB/IDBFileHandle.h" #include "mozilla/dom/indexedDB/IDBRequest.h" #include "mozilla/dom/indexedDB/IDBDatabase.h" #include "mozilla/dom/indexedDB/IDBEvents.h" @@ -681,8 +680,6 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA_WITH_NAME(IDBFileHandle, FileHandle, nsEventTargetSH, - EVENTTARGET_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH, IDBEVENTTARGET_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH, @@ -1667,11 +1664,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBFileHandle, nsIDOMFileHandle) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileHandle) - DOM_CLASSINFO_MAP_ENTRY(nsIIDBFileHandle) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest) DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest) DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 5b6217845a1..2b3da7124dd 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -134,7 +134,6 @@ DOMCI_CLASS(ContentFrameMessageManager) DOMCI_CLASS(ChromeMessageBroadcaster) DOMCI_CLASS(ChromeMessageSender) -DOMCI_CLASS(IDBFileHandle) DOMCI_CLASS(IDBRequest) DOMCI_CLASS(IDBDatabase) DOMCI_CLASS(IDBObjectStore) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index f1bc6c6bad5..db3e0bea9a7 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -557,6 +557,10 @@ DOMInterfaces = { 'nativeType': 'mozilla::dom::indexedDB::IDBFactory', }, +'IDBFileHandle': { + 'nativeType': 'mozilla::dom::indexedDB::IDBFileHandle', +}, + 'IDBVersionChangeEvent': { 'nativeType': 'mozilla::dom::indexedDB::IDBVersionChangeEvent', 'headerFile': 'IDBEvents.h', @@ -1625,6 +1629,7 @@ addExternalIface('File') addExternalIface('FileCallback', nativeType='nsIFileCallback', headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('HitRegionOptions', nativeType='nsISupports') +addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase') addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) diff --git a/dom/indexedDB/IDBFileHandle.cpp b/dom/indexedDB/IDBFileHandle.cpp index 3f866441cb9..4c17370afd5 100644 --- a/dom/indexedDB/IDBFileHandle.cpp +++ b/dom/indexedDB/IDBFileHandle.cpp @@ -7,8 +7,8 @@ #include "IDBFileHandle.h" #include "mozilla/dom/file/File.h" +#include "mozilla/dom/IDBFileHandleBinding.h" #include "mozilla/dom/quota/FileStreams.h" -#include "nsDOMClassInfoID.h" #include "IDBDatabase.h" @@ -35,6 +35,13 @@ GetFileFor(FileInfo* aFileInfo) } // anonymous namespace +// virtual +JSObject* +IDBFileHandle::WrapObject(JSContext* aCx, JS::Handle aScope) +{ + return IDBFileHandleBinding::Wrap(aCx, aScope, this); +} + // static already_AddRefed IDBFileHandle::Create(IDBDatabase* aDatabase, @@ -99,24 +106,13 @@ IDBFileHandle::CreateFileObject(mozilla::dom::file::LockedFile* aLockedFile, return file.forget(); } -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBFileHandle) - NS_INTERFACE_MAP_ENTRY(nsIIDBFileHandle) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBFileHandle) -NS_INTERFACE_MAP_END_INHERITING(FileHandle) - -NS_IMPL_ADDREF_INHERITED(IDBFileHandle, FileHandle) -NS_IMPL_RELEASE_INHERITED(IDBFileHandle, FileHandle) - -DOMCI_DATA(IDBFileHandle, IDBFileHandle) - -NS_IMETHODIMP -IDBFileHandle::GetDatabase(nsIIDBDatabase** aDatabase) +nsIIDBDatabase* +IDBFileHandle::Database() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - nsCOMPtr database = do_QueryInterface(mFileStorage); - NS_ASSERTION(database, "This should always succeed!"); + IDBDatabase* database = static_cast(mFileStorage.get()); + MOZ_ASSERT(database); - database.forget(aDatabase); - return NS_OK; + return database; } diff --git a/dom/indexedDB/IDBFileHandle.h b/dom/indexedDB/IDBFileHandle.h index 114116f15d3..a15922fc09a 100644 --- a/dom/indexedDB/IDBFileHandle.h +++ b/dom/indexedDB/IDBFileHandle.h @@ -9,19 +9,18 @@ #include "IndexedDatabase.h" -#include "nsIIDBFileHandle.h" - #include "mozilla/dom/file/FileHandle.h" #include "mozilla/dom/indexedDB/FileInfo.h" +class nsIIDBDatabase; + BEGIN_INDEXEDDB_NAMESPACE -class IDBFileHandle : public mozilla::dom::file::FileHandle, - public nsIIDBFileHandle +class IDBFileHandle : public mozilla::dom::file::FileHandle { public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIIDBFILEHANDLE + virtual JSObject* + WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; NS_IMETHOD_(int64_t) GetFileId() @@ -46,6 +45,8 @@ public: CreateFileObject(mozilla::dom::file::LockedFile* aLockedFile, uint32_t aFileSize); + nsIIDBDatabase* Database(); + private: IDBFileHandle() { } diff --git a/dom/indexedDB/moz.build b/dom/indexedDB/moz.build index 9b0cbb1db9d..4a2452b723f 100644 --- a/dom/indexedDB/moz.build +++ b/dom/indexedDB/moz.build @@ -11,7 +11,6 @@ XPIDL_SOURCES += [ 'nsIIDBCursor.idl', 'nsIIDBCursorWithValue.idl', 'nsIIDBDatabase.idl', - 'nsIIDBFileHandle.idl', 'nsIIDBIndex.idl', 'nsIIDBKeyRange.idl', 'nsIIDBObjectStore.idl', diff --git a/dom/indexedDB/nsIIDBFileHandle.idl b/dom/indexedDB/nsIIDBFileHandle.idl deleted file mode 100644 index 2a18bb69605..00000000000 --- a/dom/indexedDB/nsIIDBFileHandle.idl +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -interface nsIIDBDatabase; - -[scriptable, builtinclass, uuid(7b05f6bb-26b0-4c12-a9a1-e31dd933deb8)] -interface nsIIDBFileHandle : nsISupports -{ - readonly attribute nsIIDBDatabase database; -}; diff --git a/dom/webidl/IDBFileHandle.webidl b/dom/webidl/IDBFileHandle.webidl new file mode 100644 index 00000000000..b2eee301938 --- /dev/null +++ b/dom/webidl/IDBFileHandle.webidl @@ -0,0 +1,10 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +interface IDBDatabase; + +interface IDBFileHandle : FileHandle { + readonly attribute IDBDatabase database; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 9aac9d73d74..a5ce5dac631 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -163,6 +163,7 @@ webidl_files = \ HTMLVideoElement.webidl \ IDBDatabase.webidl \ IDBFactory.webidl \ + IDBFileHandle.webidl \ IDBVersionChangeEvent.webidl \ ImageData.webidl \ ImageDocument.webidl \ diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index f60f197623f..9a2b1f64d7c 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -94,7 +94,6 @@ members = [ 'nsIIDBCursor.*', 'nsIIDBCursorWithValue.*', 'nsIIDBDatabase.*', - 'nsIIDBFileHandle.*', 'nsIIDBIndex.*', 'nsIIDBKeyRange.*', 'nsIIDBObjectStore.*', From d2041977f85f8e5fb373e9d84f63eccc4baa2969 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:46 +0200 Subject: [PATCH 18/28] Bug 886247 - Move SVGAnimatedEnumeration to WebIDL; r=dzbarsky --- .../content/src/SVGAnimatedEnumeration.cpp | 33 +++++++++ .../svg/content/src/SVGAnimatedEnumeration.h | 68 +++++++++++++++++++ .../svg/content/src/SVGClipPathElement.cpp | 6 +- content/svg/content/src/SVGClipPathElement.h | 2 +- .../src/SVGComponentTransferFunctionElement.h | 2 +- content/svg/content/src/SVGFEBlendElement.cpp | 2 +- content/svg/content/src/SVGFEBlendElement.h | 2 +- .../content/src/SVGFEColorMatrixElement.cpp | 2 +- .../svg/content/src/SVGFEColorMatrixElement.h | 2 +- .../svg/content/src/SVGFECompositeElement.cpp | 2 +- .../svg/content/src/SVGFECompositeElement.h | 2 +- .../src/SVGFEConvolveMatrixElement.cpp | 2 +- .../content/src/SVGFEConvolveMatrixElement.h | 2 +- .../src/SVGFEDisplacementMapElement.cpp | 4 +- .../content/src/SVGFEDisplacementMapElement.h | 4 +- .../content/src/SVGFEMorphologyElement.cpp | 2 +- .../svg/content/src/SVGFEMorphologyElement.h | 2 +- .../content/src/SVGFETurbulenceElement.cpp | 4 +- .../svg/content/src/SVGFETurbulenceElement.h | 4 +- content/svg/content/src/SVGFilterElement.cpp | 4 +- content/svg/content/src/SVGFilterElement.h | 4 +- .../svg/content/src/SVGGradientElement.cpp | 4 +- content/svg/content/src/SVGGradientElement.h | 4 +- content/svg/content/src/SVGMarkerElement.cpp | 22 ++---- content/svg/content/src/SVGMarkerElement.h | 36 ++++++---- content/svg/content/src/SVGMaskElement.cpp | 4 +- content/svg/content/src/SVGMaskElement.h | 4 +- content/svg/content/src/SVGPatternElement.cpp | 4 +- content/svg/content/src/SVGPatternElement.h | 4 +- .../svg/content/src/SVGTextPathElement.cpp | 4 +- content/svg/content/src/SVGTextPathElement.h | 4 +- content/svg/content/src/moz.build | 2 + content/svg/content/src/nsSVGEnum.cpp | 24 +------ content/svg/content/src/nsSVGEnum.h | 41 +++++------ content/svg/content/src/nsSVGFilters.cpp | 2 +- dom/base/nsDOMClassInfo.cpp | 7 -- dom/base/nsDOMClassInfoClasses.h | 1 - dom/bindings/Bindings.conf | 1 - dom/webidl/SVGAnimatedEnumeration.webidl | 17 +++++ dom/webidl/SVGClipPathElement.webidl | 2 - dom/webidl/SVGFEBlendElement.webidl | 2 - dom/webidl/SVGFEColorMatrixElement.webidl | 2 - dom/webidl/SVGFECompositeElement.webidl | 1 - dom/webidl/SVGFEConvolveMatrixElement.webidl | 1 - dom/webidl/SVGFEDisplacementMapElement.webidl | 1 - dom/webidl/SVGFEMorphologyElement.webidl | 1 - dom/webidl/SVGFETurbulenceElement.webidl | 1 - dom/webidl/SVGFilterElement.webidl | 1 - dom/webidl/SVGMarkerElement.webidl | 2 - dom/webidl/SVGMaskElement.webidl | 2 - dom/webidl/SVGPatternElement.webidl | 2 - dom/webidl/SVGTextContentElement.webidl | 2 - dom/webidl/SVGTextPathElement.webidl | 2 - dom/webidl/WebIDL.mk | 1 + 54 files changed, 212 insertions(+), 151 deletions(-) create mode 100644 content/svg/content/src/SVGAnimatedEnumeration.cpp create mode 100644 content/svg/content/src/SVGAnimatedEnumeration.h create mode 100644 dom/webidl/SVGAnimatedEnumeration.webidl diff --git a/content/svg/content/src/SVGAnimatedEnumeration.cpp b/content/svg/content/src/SVGAnimatedEnumeration.cpp new file mode 100644 index 00000000000..b166e107651 --- /dev/null +++ b/content/svg/content/src/SVGAnimatedEnumeration.cpp @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGAnimatedEnumeration.h" + +#include "mozilla/dom/SVGAnimatedEnumerationBinding.h" + +namespace mozilla { +namespace dom { + +NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAnimatedEnumeration, + mSVGElement) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnimatedEnumeration) +NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedEnumeration) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimatedEnumeration) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration) + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +JSObject* +SVGAnimatedEnumeration::WrapObject(JSContext* aCx, JS::Handle aScope) +{ + return SVGAnimatedEnumerationBinding::Wrap(aCx, aScope, this); +} + +} // namespace dom +} // namespace mozilla diff --git a/content/svg/content/src/SVGAnimatedEnumeration.h b/content/svg/content/src/SVGAnimatedEnumeration.h new file mode 100644 index 00000000000..0ae4d184d51 --- /dev/null +++ b/content/svg/content/src/SVGAnimatedEnumeration.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGAnimatedEnumeration_h +#define mozilla_dom_SVGAnimatedEnumeration_h + +#include "nsIDOMSVGAnimatedEnum.h" +#include "nsWrapperCache.h" + +#include "nsSVGElement.h" + +namespace mozilla { +namespace dom { + +class SVGAnimatedEnumeration : public nsIDOMSVGAnimatedEnumeration + , public nsWrapperCache +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGAnimatedEnumeration) + + nsSVGElement* GetParentObject() const + { + return mSVGElement; + } + + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aScope) + MOZ_OVERRIDE MOZ_FINAL; + + virtual uint16_t BaseVal() = 0; + virtual void SetBaseVal(uint16_t aBaseVal, ErrorResult& aRv) = 0; + virtual uint16_t AnimVal() = 0; + + NS_IMETHOD GetBaseVal(uint16_t* aResult) MOZ_OVERRIDE MOZ_FINAL + { + *aResult = BaseVal(); + return NS_OK; + } + NS_IMETHOD SetBaseVal(uint16_t aValue) MOZ_OVERRIDE MOZ_FINAL + { + ErrorResult rv; + SetBaseVal(aValue, rv); + return rv.ErrorCode(); + } + NS_IMETHOD GetAnimVal(uint16_t* aResult) MOZ_OVERRIDE MOZ_FINAL + { + *aResult = AnimVal(); + return NS_OK; + } + +protected: + explicit SVGAnimatedEnumeration(nsSVGElement* aSVGElement) + : mSVGElement(aSVGElement) + { + SetIsDOMBinding(); + } + virtual ~SVGAnimatedEnumeration() {}; + + nsRefPtr mSVGElement; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGAnimatedEnumeration_h diff --git a/content/svg/content/src/SVGClipPathElement.cpp b/content/svg/content/src/SVGClipPathElement.cpp index acf404e9583..6bbd696df93 100644 --- a/content/svg/content/src/SVGClipPathElement.cpp +++ b/content/svg/content/src/SVGClipPathElement.cpp @@ -36,12 +36,10 @@ SVGClipPathElement::SVGClipPathElement(already_AddRefed aNodeInfo) { } -already_AddRefed +already_AddRefed SVGClipPathElement::ClipPathUnits() { - nsCOMPtr unit; - mEnumAttributes[CLIPPATHUNITS].ToDOMAnimatedEnum(getter_AddRefs(unit), this); - return unit.forget(); + return mEnumAttributes[CLIPPATHUNITS].ToDOMAnimatedEnum(this); } nsSVGElement::EnumAttributesInfo diff --git a/content/svg/content/src/SVGClipPathElement.h b/content/svg/content/src/SVGClipPathElement.h index 5483ac09a32..f348cd6a4c7 100644 --- a/content/svg/content/src/SVGClipPathElement.h +++ b/content/svg/content/src/SVGClipPathElement.h @@ -34,7 +34,7 @@ public: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; // WebIDL - already_AddRefed ClipPathUnits(); + already_AddRefed ClipPathUnits(); protected: diff --git a/content/svg/content/src/SVGComponentTransferFunctionElement.h b/content/svg/content/src/SVGComponentTransferFunctionElement.h index 7a05f899cfd..e03f27c5809 100644 --- a/content/svg/content/src/SVGComponentTransferFunctionElement.h +++ b/content/svg/content/src/SVGComponentTransferFunctionElement.h @@ -47,7 +47,7 @@ public: // WebIDL virtual JSObject* WrapNode(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE = 0; - already_AddRefed Type(); + already_AddRefed Type(); already_AddRefed TableValues(); already_AddRefed Slope(); already_AddRefed Intercept(); diff --git a/content/svg/content/src/SVGFEBlendElement.cpp b/content/svg/content/src/SVGFEBlendElement.cpp index 1acea503df7..f06e3ad288f 100644 --- a/content/svg/content/src/SVGFEBlendElement.cpp +++ b/content/svg/content/src/SVGFEBlendElement.cpp @@ -62,7 +62,7 @@ SVGFEBlendElement::In2() return mStringAttributes[IN2].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEBlendElement::Mode() { return mEnumAttributes[MODE].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFEBlendElement.h b/content/svg/content/src/SVGFEBlendElement.h index 265a0d3f13d..bc0892ef093 100644 --- a/content/svg/content/src/SVGFEBlendElement.h +++ b/content/svg/content/src/SVGFEBlendElement.h @@ -50,7 +50,7 @@ public: // WebIDL already_AddRefed In1(); already_AddRefed In2(); - already_AddRefed Mode(); + already_AddRefed Mode(); protected: diff --git a/content/svg/content/src/SVGFEColorMatrixElement.cpp b/content/svg/content/src/SVGFEColorMatrixElement.cpp index ecb5a945d69..99478681048 100644 --- a/content/svg/content/src/SVGFEColorMatrixElement.cpp +++ b/content/svg/content/src/SVGFEColorMatrixElement.cpp @@ -63,7 +63,7 @@ SVGFEColorMatrixElement::In1() return mStringAttributes[IN1].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEColorMatrixElement::Type() { return mEnumAttributes[TYPE].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFEColorMatrixElement.h b/content/svg/content/src/SVGFEColorMatrixElement.h index 56271c06b25..947d9856829 100644 --- a/content/svg/content/src/SVGFEColorMatrixElement.h +++ b/content/svg/content/src/SVGFEColorMatrixElement.h @@ -50,7 +50,7 @@ public: // WebIDL already_AddRefed In1(); - already_AddRefed Type(); + already_AddRefed Type(); already_AddRefed Values(); protected: diff --git a/content/svg/content/src/SVGFECompositeElement.cpp b/content/svg/content/src/SVGFECompositeElement.cpp index b2353602fdd..d8b207f489a 100644 --- a/content/svg/content/src/SVGFECompositeElement.cpp +++ b/content/svg/content/src/SVGFECompositeElement.cpp @@ -67,7 +67,7 @@ SVGFECompositeElement::In2() return mStringAttributes[IN2].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFECompositeElement::Operator() { return mEnumAttributes[OPERATOR].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFECompositeElement.h b/content/svg/content/src/SVGFECompositeElement.h index 7ad13bf4c39..8bdfd390c15 100644 --- a/content/svg/content/src/SVGFECompositeElement.h +++ b/content/svg/content/src/SVGFECompositeElement.h @@ -57,7 +57,7 @@ public: // WebIDL already_AddRefed In1(); already_AddRefed In2(); - already_AddRefed Operator(); + already_AddRefed Operator(); already_AddRefed K1(); already_AddRefed K2(); already_AddRefed K3(); diff --git a/content/svg/content/src/SVGFEConvolveMatrixElement.cpp b/content/svg/content/src/SVGFEConvolveMatrixElement.cpp index 757e4e48eab..496f049dac4 100644 --- a/content/svg/content/src/SVGFEConvolveMatrixElement.cpp +++ b/content/svg/content/src/SVGFEConvolveMatrixElement.cpp @@ -122,7 +122,7 @@ SVGFEConvolveMatrixElement::TargetY() return mIntegerAttributes[TARGET_Y].ToDOMAnimatedInteger(this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::EdgeMode() { return mEnumAttributes[EDGEMODE].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFEConvolveMatrixElement.h b/content/svg/content/src/SVGFEConvolveMatrixElement.h index 89a53fe6839..f3700d98f97 100644 --- a/content/svg/content/src/SVGFEConvolveMatrixElement.h +++ b/content/svg/content/src/SVGFEConvolveMatrixElement.h @@ -64,7 +64,7 @@ public: already_AddRefed KernelMatrix(); already_AddRefed TargetX(); already_AddRefed TargetY(); - already_AddRefed EdgeMode(); + already_AddRefed EdgeMode(); already_AddRefed PreserveAlpha(); already_AddRefed Divisor(); already_AddRefed Bias(); diff --git a/content/svg/content/src/SVGFEDisplacementMapElement.cpp b/content/svg/content/src/SVGFEDisplacementMapElement.cpp index 42f58a1976e..40a0e11f518 100644 --- a/content/svg/content/src/SVGFEDisplacementMapElement.cpp +++ b/content/svg/content/src/SVGFEDisplacementMapElement.cpp @@ -83,13 +83,13 @@ SVGFEDisplacementMapElement::Scale() return mNumberAttributes[SCALE].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEDisplacementMapElement::XChannelSelector() { return mEnumAttributes[CHANNEL_X].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGFEDisplacementMapElement::YChannelSelector() { return mEnumAttributes[CHANNEL_Y].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFEDisplacementMapElement.h b/content/svg/content/src/SVGFEDisplacementMapElement.h index 372d2f343e5..651a2b57efb 100644 --- a/content/svg/content/src/SVGFEDisplacementMapElement.h +++ b/content/svg/content/src/SVGFEDisplacementMapElement.h @@ -52,8 +52,8 @@ public: already_AddRefed In1(); already_AddRefed In2(); already_AddRefed Scale(); - already_AddRefed XChannelSelector(); - already_AddRefed YChannelSelector(); + already_AddRefed XChannelSelector(); + already_AddRefed YChannelSelector(); protected: virtual bool OperatesOnSRGB(nsSVGFilterInstance* aInstance, diff --git a/content/svg/content/src/SVGFEMorphologyElement.cpp b/content/svg/content/src/SVGFEMorphologyElement.cpp index ad3273a37f8..81475c92138 100644 --- a/content/svg/content/src/SVGFEMorphologyElement.cpp +++ b/content/svg/content/src/SVGFEMorphologyElement.cpp @@ -64,7 +64,7 @@ SVGFEMorphologyElement::In1() return mStringAttributes[IN1].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEMorphologyElement::Operator() { return mEnumAttributes[OPERATOR].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFEMorphologyElement.h b/content/svg/content/src/SVGFEMorphologyElement.h index 929bb3bea95..0622ce24942 100644 --- a/content/svg/content/src/SVGFEMorphologyElement.h +++ b/content/svg/content/src/SVGFEMorphologyElement.h @@ -51,7 +51,7 @@ public: // WebIDL already_AddRefed In1(); - already_AddRefed Operator(); + already_AddRefed Operator(); already_AddRefed RadiusX(); already_AddRefed RadiusY(); void SetRadius(float rx, float ry); diff --git a/content/svg/content/src/SVGFETurbulenceElement.cpp b/content/svg/content/src/SVGFETurbulenceElement.cpp index 46cdc0dbd98..0bd789286d9 100644 --- a/content/svg/content/src/SVGFETurbulenceElement.cpp +++ b/content/svg/content/src/SVGFETurbulenceElement.cpp @@ -110,13 +110,13 @@ SVGFETurbulenceElement::Seed() return mNumberAttributes[SEED].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFETurbulenceElement::StitchTiles() { return mEnumAttributes[STITCHTILES].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGFETurbulenceElement::Type() { return mEnumAttributes[TYPE].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFETurbulenceElement.h b/content/svg/content/src/SVGFETurbulenceElement.h index 7660adcdb4b..744be76876d 100644 --- a/content/svg/content/src/SVGFETurbulenceElement.h +++ b/content/svg/content/src/SVGFETurbulenceElement.h @@ -52,8 +52,8 @@ public: already_AddRefed BaseFrequencyY(); already_AddRefed NumOctaves(); already_AddRefed Seed(); - already_AddRefed StitchTiles(); - already_AddRefed Type(); + already_AddRefed StitchTiles(); + already_AddRefed Type(); protected: virtual NumberAttributesInfo GetNumberInfo() MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGFilterElement.cpp b/content/svg/content/src/SVGFilterElement.cpp index f0254e2befe..0921ad952f7 100644 --- a/content/svg/content/src/SVGFilterElement.cpp +++ b/content/svg/content/src/SVGFilterElement.cpp @@ -93,13 +93,13 @@ SVGFilterElement::Height() return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this); } -already_AddRefed +already_AddRefed SVGFilterElement::FilterUnits() { return mEnumAttributes[FILTERUNITS].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGFilterElement::PrimitiveUnits() { return mEnumAttributes[PRIMITIVEUNITS].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGFilterElement.h b/content/svg/content/src/SVGFilterElement.h index 0cbb7c7c438..5024b3d50fe 100644 --- a/content/svg/content/src/SVGFilterElement.h +++ b/content/svg/content/src/SVGFilterElement.h @@ -52,8 +52,8 @@ public: already_AddRefed Y(); already_AddRefed Width(); already_AddRefed Height(); - already_AddRefed FilterUnits(); - already_AddRefed PrimitiveUnits(); + already_AddRefed FilterUnits(); + already_AddRefed PrimitiveUnits(); already_AddRefed FilterResX(); already_AddRefed FilterResY(); void SetFilterRes(uint32_t filterResX, uint32_t filterResY); diff --git a/content/svg/content/src/SVGGradientElement.cpp b/content/svg/content/src/SVGGradientElement.cpp index a796efa9598..55d0d9d7063 100644 --- a/content/svg/content/src/SVGGradientElement.cpp +++ b/content/svg/content/src/SVGGradientElement.cpp @@ -71,7 +71,7 @@ SVGGradientElement::GetStringInfo() ArrayLength(sStringInfo)); } -already_AddRefed +already_AddRefed SVGGradientElement::GradientUnits() { return mEnumAttributes[GRADIENTUNITS].ToDOMAnimatedEnum(this); @@ -87,7 +87,7 @@ SVGGradientElement::GradientTransform() GetAnimatedTransformList(DO_ALLOCATE), this); } -already_AddRefed +already_AddRefed SVGGradientElement::SpreadMethod() { return mEnumAttributes[SPREADMETHOD].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGGradientElement.h b/content/svg/content/src/SVGGradientElement.h index e4c9f39780a..9725bc7f5c4 100644 --- a/content/svg/content/src/SVGGradientElement.h +++ b/content/svg/content/src/SVGGradientElement.h @@ -59,9 +59,9 @@ public: } // WebIDL - already_AddRefed GradientUnits(); + already_AddRefed GradientUnits(); already_AddRefed GradientTransform(); - already_AddRefed SpreadMethod(); + already_AddRefed SpreadMethod(); already_AddRefed Href(); protected: diff --git a/content/svg/content/src/SVGMarkerElement.cpp b/content/svg/content/src/SVGMarkerElement.cpp index 982a813e66b..14e5ec3d55f 100644 --- a/content/svg/content/src/SVGMarkerElement.cpp +++ b/content/svg/content/src/SVGMarkerElement.cpp @@ -53,20 +53,6 @@ nsSVGElement::AngleInfo SVGMarkerElement::sAngleInfo[1] = { &nsGkAtoms::orient, 0, SVG_ANGLETYPE_UNSPECIFIED } }; -//---------------------------------------------------------------------- -// nsISupports methods - -NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGOrientType::DOMAnimatedEnum, mSVGElement) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGOrientType::DOMAnimatedEnum) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGOrientType::DOMAnimatedEnum) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGOrientType::DOMAnimatedEnum) - NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedEnumeration) -NS_INTERFACE_MAP_END - //---------------------------------------------------------------------- // Implementation @@ -86,10 +72,10 @@ nsSVGOrientType::SetBaseValue(uint16_t aValue, return NS_ERROR_DOM_SYNTAX_ERR; } -already_AddRefed +already_AddRefed nsSVGOrientType::ToDOMAnimatedEnum(nsSVGElement *aSVGElement) { - nsCOMPtr toReturn = + nsRefPtr toReturn = new DOMAnimatedEnum(this, aSVGElement); return toReturn.forget(); } @@ -134,7 +120,7 @@ SVGMarkerElement::RefY() return mLengthAttributes[REFY].ToDOMAnimatedLength(this); } -already_AddRefed +already_AddRefed SVGMarkerElement::MarkerUnits() { return mEnumAttributes[MARKERUNITS].ToDOMAnimatedEnum(this); @@ -152,7 +138,7 @@ SVGMarkerElement::MarkerHeight() return mLengthAttributes[MARKERHEIGHT].ToDOMAnimatedLength(this); } -already_AddRefed +already_AddRefed SVGMarkerElement::OrientType() { return mOrientType.ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGMarkerElement.h b/content/svg/content/src/SVGMarkerElement.h index 031b7ada0f5..ea0107b75e8 100644 --- a/content/svg/content/src/SVGMarkerElement.h +++ b/content/svg/content/src/SVGMarkerElement.h @@ -14,6 +14,7 @@ #include "SVGAnimatedPreserveAspectRatio.h" #include "nsSVGElement.h" #include "mozilla/Attributes.h" +#include "mozilla/dom/SVGAnimatedEnumeration.h" class nsSVGMarkerFrame; @@ -56,31 +57,36 @@ public: uint16_t GetAnimValue() const { return mAnimVal; } - already_AddRefed + already_AddRefed ToDOMAnimatedEnum(nsSVGElement* aSVGElement); private: nsSVGEnumValue mAnimVal; nsSVGEnumValue mBaseVal; - struct DOMAnimatedEnum MOZ_FINAL : public nsIDOMSVGAnimatedEnumeration + struct DOMAnimatedEnum MOZ_FINAL : public SVGAnimatedEnumeration { - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedEnum) - DOMAnimatedEnum(nsSVGOrientType* aVal, nsSVGElement *aSVGElement) - : mVal(aVal), mSVGElement(aSVGElement) {} + : SVGAnimatedEnumeration(aSVGElement) + , mVal(aVal) + {} nsSVGOrientType *mVal; // kept alive because it belongs to content - nsRefPtr mSVGElement; - NS_IMETHOD GetBaseVal(uint16_t* aResult) MOZ_OVERRIDE - { *aResult = mVal->GetBaseValue(); return NS_OK; } - NS_IMETHOD SetBaseVal(uint16_t aValue) MOZ_OVERRIDE - { return mVal->SetBaseValue(aValue, mSVGElement); } - NS_IMETHOD GetAnimVal(uint16_t* aResult) MOZ_OVERRIDE - { *aResult = mVal->GetAnimValue(); return NS_OK; } + using mozilla::dom::SVGAnimatedEnumeration::SetBaseVal; + virtual uint16_t BaseVal() MOZ_OVERRIDE + { + return mVal->GetBaseValue(); + } + virtual void SetBaseVal(uint16_t aBaseVal, ErrorResult& aRv) MOZ_OVERRIDE + { + aRv = mVal->SetBaseValue(aBaseVal, mSVGElement); + } + virtual uint16_t AnimVal() MOZ_OVERRIDE + { + return mVal->GetAnimValue(); + } }; }; @@ -122,10 +128,10 @@ public: already_AddRefed PreserveAspectRatio(); already_AddRefed RefX(); already_AddRefed RefY(); - already_AddRefed MarkerUnits(); + already_AddRefed MarkerUnits(); already_AddRefed MarkerWidth(); already_AddRefed MarkerHeight(); - already_AddRefed OrientType(); + already_AddRefed OrientType(); already_AddRefed OrientAngle(); void SetOrientToAuto(); void SetOrientToAngle(SVGAngle& angle, ErrorResult& rv); diff --git a/content/svg/content/src/SVGMaskElement.cpp b/content/svg/content/src/SVGMaskElement.cpp index 67b1f486789..a4444e081aa 100644 --- a/content/svg/content/src/SVGMaskElement.cpp +++ b/content/svg/content/src/SVGMaskElement.cpp @@ -58,13 +58,13 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMaskElement) //---------------------------------------------------------------------- -already_AddRefed +already_AddRefed SVGMaskElement::MaskUnits() { return mEnumAttributes[MASKUNITS].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGMaskElement::MaskContentUnits() { return mEnumAttributes[MASKCONTENTUNITS].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGMaskElement.h b/content/svg/content/src/SVGMaskElement.h index ef89efee3b0..ca2d79defbd 100644 --- a/content/svg/content/src/SVGMaskElement.h +++ b/content/svg/content/src/SVGMaskElement.h @@ -42,8 +42,8 @@ public: virtual bool HasValidDimensions() const MOZ_OVERRIDE; // WebIDL - already_AddRefed MaskUnits(); - already_AddRefed MaskContentUnits(); + already_AddRefed MaskUnits(); + already_AddRefed MaskContentUnits(); already_AddRefed X(); already_AddRefed Y(); already_AddRefed Width(); diff --git a/content/svg/content/src/SVGPatternElement.cpp b/content/svg/content/src/SVGPatternElement.cpp index 4a0f64225e0..064f895a772 100644 --- a/content/svg/content/src/SVGPatternElement.cpp +++ b/content/svg/content/src/SVGPatternElement.cpp @@ -80,13 +80,13 @@ SVGPatternElement::PreserveAspectRatio() //---------------------------------------------------------------------- -already_AddRefed +already_AddRefed SVGPatternElement::PatternUnits() { return mEnumAttributes[PATTERNUNITS].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGPatternElement::PatternContentUnits() { return mEnumAttributes[PATTERNCONTENTUNITS].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGPatternElement.h b/content/svg/content/src/SVGPatternElement.h index 6f605aa0b7b..039d4a72276 100644 --- a/content/svg/content/src/SVGPatternElement.h +++ b/content/svg/content/src/SVGPatternElement.h @@ -56,8 +56,8 @@ public: // WebIDL already_AddRefed ViewBox(); already_AddRefed PreserveAspectRatio(); - already_AddRefed PatternUnits(); - already_AddRefed PatternContentUnits(); + already_AddRefed PatternUnits(); + already_AddRefed PatternContentUnits(); already_AddRefed PatternTransform(); already_AddRefed X(); already_AddRefed Y(); diff --git a/content/svg/content/src/SVGTextPathElement.cpp b/content/svg/content/src/SVGTextPathElement.cpp index 6497655d181..8f8c4f5b0bd 100644 --- a/content/svg/content/src/SVGTextPathElement.cpp +++ b/content/svg/content/src/SVGTextPathElement.cpp @@ -84,13 +84,13 @@ SVGTextPathElement::StartOffset() return mLengthAttributes[STARTOFFSET].ToDOMAnimatedLength(this); } -already_AddRefed +already_AddRefed SVGTextPathElement::Method() { return mEnumAttributes[METHOD].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGTextPathElement::Spacing() { return mEnumAttributes[SPACING].ToDOMAnimatedEnum(this); diff --git a/content/svg/content/src/SVGTextPathElement.h b/content/svg/content/src/SVGTextPathElement.h index 07db029c0b0..a948c38b71c 100644 --- a/content/svg/content/src/SVGTextPathElement.h +++ b/content/svg/content/src/SVGTextPathElement.h @@ -53,8 +53,8 @@ public: // WebIDL already_AddRefed StartOffset(); - already_AddRefed Method(); - already_AddRefed Spacing(); + already_AddRefed Method(); + already_AddRefed Spacing(); already_AddRefed Href(); protected: diff --git a/content/svg/content/src/moz.build b/content/svg/content/src/moz.build index aa287546320..be6f44d998f 100644 --- a/content/svg/content/src/moz.build +++ b/content/svg/content/src/moz.build @@ -23,6 +23,7 @@ EXPORTS.mozilla.dom += [ 'SVGAnimateTransformElement.h', 'SVGAnimatedAngle.h', 'SVGAnimatedBoolean.h', + 'SVGAnimatedEnumeration.h', 'SVGAnimatedLength.h', 'SVGAnimatedRect.h', 'SVGAnimatedString.h', @@ -116,6 +117,7 @@ CPP_SOURCES += [ 'SVGAnimateTransformElement.cpp', 'SVGAnimatedAngle.cpp', 'SVGAnimatedBoolean.cpp', + 'SVGAnimatedEnumeration.cpp', 'SVGAnimatedLength.cpp', 'SVGAnimatedLengthList.cpp', 'SVGAnimatedNumberList.cpp', diff --git a/content/svg/content/src/nsSVGEnum.cpp b/content/svg/content/src/nsSVGEnum.cpp index d09b09f23fc..ca7c0b59d54 100644 --- a/content/svg/content/src/nsSVGEnum.cpp +++ b/content/svg/content/src/nsSVGEnum.cpp @@ -12,19 +12,7 @@ #include "SMILEnumType.h" using namespace mozilla; - -NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGEnum::DOMAnimatedEnum, mSVGElement) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGEnum::DOMAnimatedEnum) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGEnum::DOMAnimatedEnum) - -DOMCI_DATA(SVGAnimatedEnumeration, nsSVGEnum::DOMAnimatedEnum) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGEnum::DOMAnimatedEnum) - NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedEnumeration) -NS_INTERFACE_MAP_END +using namespace mozilla::dom; static nsSVGAttrTearoffTable sSVGAnimatedEnumTearoffTable; @@ -122,15 +110,7 @@ nsSVGEnum::SetAnimValue(uint16_t aValue, nsSVGElement *aSVGElement) aSVGElement->DidAnimateEnum(mAttrEnum); } -nsresult -nsSVGEnum::ToDOMAnimatedEnum(nsIDOMSVGAnimatedEnumeration **aResult, - nsSVGElement *aSVGElement) -{ - *aResult = ToDOMAnimatedEnum(aSVGElement).get(); - return NS_OK; -} - -already_AddRefed +already_AddRefed nsSVGEnum::ToDOMAnimatedEnum(nsSVGElement* aSVGElement) { nsRefPtr domAnimatedEnum = diff --git a/content/svg/content/src/nsSVGEnum.h b/content/svg/content/src/nsSVGEnum.h index a7c369014a6..9007d6ba3e1 100644 --- a/content/svg/content/src/nsSVGEnum.h +++ b/content/svg/content/src/nsSVGEnum.h @@ -13,6 +13,7 @@ #include "nsISMILAttr.h" #include "nsSVGElement.h" #include "mozilla/Attributes.h" +#include "mozilla/dom/SVGAnimatedEnumeration.h" class nsIAtom; class nsSMILValue; @@ -53,10 +54,7 @@ public: bool IsExplicitlySet() const { return mIsAnimated || mIsBaseSet; } - nsresult ToDOMAnimatedEnum(nsIDOMSVGAnimatedEnumeration **aResult, - nsSVGElement* aSVGElement); - - already_AddRefed + already_AddRefed ToDOMAnimatedEnum(nsSVGElement* aSVGElement); // Returns a new nsISMILAttr object that the caller must delete @@ -72,30 +70,33 @@ private: nsSVGEnumMapping *GetMapping(nsSVGElement *aSVGElement); public: - struct DOMAnimatedEnum MOZ_FINAL : public nsIDOMSVGAnimatedEnumeration + struct DOMAnimatedEnum MOZ_FINAL : public mozilla::dom::SVGAnimatedEnumeration { - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedEnum) - DOMAnimatedEnum(nsSVGEnum* aVal, nsSVGElement *aSVGElement) - : mVal(aVal), mSVGElement(aSVGElement) {} + : mozilla::dom::SVGAnimatedEnumeration(aSVGElement) + , mVal(aVal) + {} virtual ~DOMAnimatedEnum(); nsSVGEnum *mVal; // kept alive because it belongs to content - nsRefPtr mSVGElement; - NS_IMETHOD GetBaseVal(uint16_t* aResult) MOZ_OVERRIDE - { *aResult = mVal->GetBaseValue(); return NS_OK; } - NS_IMETHOD SetBaseVal(uint16_t aValue) MOZ_OVERRIDE - { return mVal->SetBaseValue(aValue, mSVGElement); } - - // Script may have modified animation parameters or timeline -- DOM getters - // need to flush any resample requests to reflect these modifications. - NS_IMETHOD GetAnimVal(uint16_t* aResult) MOZ_OVERRIDE + using mozilla::dom::SVGAnimatedEnumeration::SetBaseVal; + virtual uint16_t BaseVal() MOZ_OVERRIDE { + return mVal->GetBaseValue(); + } + virtual void SetBaseVal(uint16_t aBaseVal, + mozilla::ErrorResult& aRv) MOZ_OVERRIDE + { + aRv = mVal->SetBaseValue(aBaseVal, mSVGElement); + } + virtual uint16_t AnimVal() MOZ_OVERRIDE + { + // Script may have modified animation parameters or timeline -- DOM + // getters need to flush any resample requests to reflect these + // modifications. mSVGElement->FlushAnimations(); - *aResult = mVal->GetAnimValue(); - return NS_OK; + return mVal->GetAnimValue(); } }; diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index e928223f04d..11fed8110d2 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -387,7 +387,7 @@ SVGComponentTransferFunctionElement::AttributeAffectsRendering(int32_t aNameSpac //---------------------------------------------------------------------- -already_AddRefed +already_AddRefed SVGComponentTransferFunctionElement::Type() { return mEnumAttributes[TYPE].ToDOMAnimatedEnum(this); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index ed11065308a..0706c9babae 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -183,7 +183,6 @@ #include "nsIDOMXPathResult.h" #include "nsIDOMMozBrowserFrame.h" -#include "nsIDOMSVGAnimatedEnum.h" #include "nsIDOMSVGAnimatedInteger.h" #include "nsIDOMSVGAnimatedNumber.h" #include "nsIDOMSVGLength.h" @@ -571,8 +570,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) // other SVG classes - NS_DEFINE_CLASSINFO_DATA(SVGAnimatedEnumeration, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGAnimatedInteger, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumber, nsDOMGenericSH, @@ -1511,10 +1508,6 @@ nsDOMClassInfo::Init() // The SVG document // other SVG classes - DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedEnumeration, nsIDOMSVGAnimatedEnumeration) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedInteger, nsIDOMSVGAnimatedInteger) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedInteger) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 2b3da7124dd..b9bc2eaa168 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -74,7 +74,6 @@ DOMCI_CLASS(CSSMozDocumentRule) DOMCI_CLASS(CSSSupportsRule) // other SVG classes -DOMCI_CLASS(SVGAnimatedEnumeration) DOMCI_CLASS(SVGAnimatedInteger) DOMCI_CLASS(SVGAnimatedNumber) DOMCI_CLASS(SVGLength) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index db3e0bea9a7..dcd583bccad 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1663,7 +1663,6 @@ addExternalIface('PrintCallback', nativeType='nsIPrintCallback', headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('Selection', nativeType='nsISelection') addExternalIface('StyleSheetList') -addExternalIface('SVGAnimatedEnumeration', headerFile='nsIDOMSVGAnimatedEnum.h') addExternalIface('SVGAnimatedNumber') addExternalIface('SVGLength') addExternalIface('SVGNumber') diff --git a/dom/webidl/SVGAnimatedEnumeration.webidl b/dom/webidl/SVGAnimatedEnumeration.webidl new file mode 100644 index 00000000000..80591c2f1b1 --- /dev/null +++ b/dom/webidl/SVGAnimatedEnumeration.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedEnumeration + * + * Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. + * W3C liability, trademark and document use rules apply. + */ + +interface SVGAnimatedEnumeration { + [SetterThrows] + attribute unsigned short baseVal; + readonly attribute unsigned short animVal; +}; diff --git a/dom/webidl/SVGClipPathElement.webidl b/dom/webidl/SVGClipPathElement.webidl index aba8f52fbf6..ea21f176d7a 100644 --- a/dom/webidl/SVGClipPathElement.webidl +++ b/dom/webidl/SVGClipPathElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGClipPathElement : SVGElement { readonly attribute SVGAnimatedEnumeration clipPathUnits; readonly attribute SVGAnimatedTransformList transform; diff --git a/dom/webidl/SVGFEBlendElement.webidl b/dom/webidl/SVGFEBlendElement.webidl index bf65478efda..ee8c75e51d1 100644 --- a/dom/webidl/SVGFEBlendElement.webidl +++ b/dom/webidl/SVGFEBlendElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGFEBlendElement : SVGElement { // Blend Mode Types diff --git a/dom/webidl/SVGFEColorMatrixElement.webidl b/dom/webidl/SVGFEColorMatrixElement.webidl index 717e36d89a2..b234f21bd2d 100644 --- a/dom/webidl/SVGFEColorMatrixElement.webidl +++ b/dom/webidl/SVGFEColorMatrixElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGFEColorMatrixElement : SVGElement { // Color Matrix Types diff --git a/dom/webidl/SVGFECompositeElement.webidl b/dom/webidl/SVGFECompositeElement.webidl index 1d9d0f4736a..3407777e45a 100644 --- a/dom/webidl/SVGFECompositeElement.webidl +++ b/dom/webidl/SVGFECompositeElement.webidl @@ -10,7 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; interface SVGAnimatedNumber; interface SVGFECompositeElement : SVGElement { diff --git a/dom/webidl/SVGFEConvolveMatrixElement.webidl b/dom/webidl/SVGFEConvolveMatrixElement.webidl index ad45fc9f108..96eec68cf8a 100644 --- a/dom/webidl/SVGFEConvolveMatrixElement.webidl +++ b/dom/webidl/SVGFEConvolveMatrixElement.webidl @@ -10,7 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; interface SVGAnimatedNumber; interface SVGFEConvolveMatrixElement : SVGElement { diff --git a/dom/webidl/SVGFEDisplacementMapElement.webidl b/dom/webidl/SVGFEDisplacementMapElement.webidl index ae2353eb1de..573cd8e267e 100644 --- a/dom/webidl/SVGFEDisplacementMapElement.webidl +++ b/dom/webidl/SVGFEDisplacementMapElement.webidl @@ -10,7 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; interface SVGAnimatedNumber; interface SVGFEDisplacementMapElement : SVGElement { diff --git a/dom/webidl/SVGFEMorphologyElement.webidl b/dom/webidl/SVGFEMorphologyElement.webidl index 2928c41a3c3..bf0298e6225 100644 --- a/dom/webidl/SVGFEMorphologyElement.webidl +++ b/dom/webidl/SVGFEMorphologyElement.webidl @@ -10,7 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; interface SVGAnimatedNumber; interface SVGFEMorphologyElement : SVGElement { diff --git a/dom/webidl/SVGFETurbulenceElement.webidl b/dom/webidl/SVGFETurbulenceElement.webidl index 521286908b0..193e59028a3 100644 --- a/dom/webidl/SVGFETurbulenceElement.webidl +++ b/dom/webidl/SVGFETurbulenceElement.webidl @@ -10,7 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; interface SVGAnimatedInteger; interface SVGAnimatedNumber; diff --git a/dom/webidl/SVGFilterElement.webidl b/dom/webidl/SVGFilterElement.webidl index fee239ec6b4..2242ea775d2 100644 --- a/dom/webidl/SVGFilterElement.webidl +++ b/dom/webidl/SVGFilterElement.webidl @@ -10,7 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; interface SVGAnimatedInteger; interface SVGFilterElement : SVGElement { diff --git a/dom/webidl/SVGMarkerElement.webidl b/dom/webidl/SVGMarkerElement.webidl index f80ef0d159c..fb1e9cd7f56 100644 --- a/dom/webidl/SVGMarkerElement.webidl +++ b/dom/webidl/SVGMarkerElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGMarkerElement : SVGElement { // Marker Unit Types diff --git a/dom/webidl/SVGMaskElement.webidl b/dom/webidl/SVGMaskElement.webidl index 334f5aba5c9..3cf3439b490 100644 --- a/dom/webidl/SVGMaskElement.webidl +++ b/dom/webidl/SVGMaskElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGMaskElement : SVGElement { // Mask Types diff --git a/dom/webidl/SVGPatternElement.webidl b/dom/webidl/SVGPatternElement.webidl index 05f71594b40..8dc7e01b4fa 100644 --- a/dom/webidl/SVGPatternElement.webidl +++ b/dom/webidl/SVGPatternElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGPatternElement : SVGElement { [Constant] readonly attribute SVGAnimatedEnumeration patternUnits; diff --git a/dom/webidl/SVGTextContentElement.webidl b/dom/webidl/SVGTextContentElement.webidl index f858f5c1fb0..d105289fc5f 100644 --- a/dom/webidl/SVGTextContentElement.webidl +++ b/dom/webidl/SVGTextContentElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGTextContentElement : SVGGraphicsElement { // lengthAdjust Types diff --git a/dom/webidl/SVGTextPathElement.webidl b/dom/webidl/SVGTextPathElement.webidl index a8932d14db5..7e330a8ef7d 100644 --- a/dom/webidl/SVGTextPathElement.webidl +++ b/dom/webidl/SVGTextPathElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedEnumeration; - interface SVGTextPathElement : SVGTextContentElement { // textPath Method Types diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index a5ce5dac631..236e3702cb5 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -228,6 +228,7 @@ webidl_files = \ SVGAngle.webidl \ SVGAnimatedAngle.webidl \ SVGAnimatedBoolean.webidl \ + SVGAnimatedEnumeration.webidl \ SVGAnimatedLength.webidl \ SVGAnimatedLengthList.webidl \ SVGAnimatedNumberList.webidl \ From 6fa75b2d82e4fdf7f0dd898f89dfaaf55cb187a7 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:02:56 +0200 Subject: [PATCH 19/28] Bug 886270 - Move SVGAnimatedInteger to WebIDL; r=dzbarsky --- .../svg/content/src/SVGAnimatedInteger.cpp | 32 ++++++++++++ content/svg/content/src/SVGAnimatedInteger.h | 51 +++++++++++++++++++ .../src/SVGFEConvolveMatrixElement.cpp | 8 +-- .../content/src/SVGFEConvolveMatrixElement.h | 8 +-- .../content/src/SVGFETurbulenceElement.cpp | 2 +- .../svg/content/src/SVGFETurbulenceElement.h | 2 +- content/svg/content/src/SVGFilterElement.cpp | 4 +- content/svg/content/src/SVGFilterElement.h | 4 +- content/svg/content/src/moz.build | 2 + content/svg/content/src/nsSVGInteger.cpp | 24 +-------- content/svg/content/src/nsSVGInteger.h | 35 +++++++------ content/svg/content/src/nsSVGIntegerPair.cpp | 25 +-------- content/svg/content/src/nsSVGIntegerPair.h | 41 +++++++-------- dom/base/nsDOMClassInfo.cpp | 7 --- dom/base/nsDOMClassInfoClasses.h | 1 - dom/bindings/Bindings.conf | 1 - dom/interfaces/svg/moz.build | 1 - .../svg/nsIDOMSVGAnimatedInteger.idl | 25 --------- dom/webidl/SVGAnimatedInteger.webidl | 16 ++++++ dom/webidl/SVGFETurbulenceElement.webidl | 1 - dom/webidl/SVGFilterElement.webidl | 2 - dom/webidl/WebIDL.mk | 1 + 22 files changed, 156 insertions(+), 137 deletions(-) create mode 100644 content/svg/content/src/SVGAnimatedInteger.cpp create mode 100644 content/svg/content/src/SVGAnimatedInteger.h delete mode 100644 dom/interfaces/svg/nsIDOMSVGAnimatedInteger.idl create mode 100644 dom/webidl/SVGAnimatedInteger.webidl diff --git a/content/svg/content/src/SVGAnimatedInteger.cpp b/content/svg/content/src/SVGAnimatedInteger.cpp new file mode 100644 index 00000000000..b3a9621b91a --- /dev/null +++ b/content/svg/content/src/SVGAnimatedInteger.cpp @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGAnimatedInteger.h" + +#include "mozilla/dom/SVGAnimatedIntegerBinding.h" + +namespace mozilla { +namespace dom { + +NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAnimatedInteger, + mSVGElement) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnimatedInteger) +NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedInteger) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimatedInteger) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +JSObject* +SVGAnimatedInteger::WrapObject(JSContext* aCx, JS::Handle aScope) +{ + return SVGAnimatedIntegerBinding::Wrap(aCx, aScope, this); +} + +} // namespace dom +} // namespace mozilla diff --git a/content/svg/content/src/SVGAnimatedInteger.h b/content/svg/content/src/SVGAnimatedInteger.h new file mode 100644 index 00000000000..7eb37e6b668 --- /dev/null +++ b/content/svg/content/src/SVGAnimatedInteger.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGAnimatedInteger_h +#define mozilla_dom_SVGAnimatedInteger_h + +#include "nsIDOMSVGAnimatedEnum.h" +#include "nsWrapperCache.h" + +#include "nsSVGElement.h" + +namespace mozilla { +namespace dom { + +class SVGAnimatedInteger : public nsISupports + , public nsWrapperCache +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGAnimatedInteger) + + nsSVGElement* GetParentObject() const + { + return mSVGElement; + } + + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aScope) + MOZ_OVERRIDE MOZ_FINAL; + + virtual int32_t BaseVal() = 0; + virtual void SetBaseVal(int32_t aBaseVal) = 0; + virtual int32_t AnimVal() = 0; + +protected: + explicit SVGAnimatedInteger(nsSVGElement* aSVGElement) + : mSVGElement(aSVGElement) + { + SetIsDOMBinding(); + } + virtual ~SVGAnimatedInteger() {}; + + nsRefPtr mSVGElement; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGAnimatedInteger_h diff --git a/content/svg/content/src/SVGFEConvolveMatrixElement.cpp b/content/svg/content/src/SVGFEConvolveMatrixElement.cpp index 496f049dac4..8f0bd2b5e05 100644 --- a/content/svg/content/src/SVGFEConvolveMatrixElement.cpp +++ b/content/svg/content/src/SVGFEConvolveMatrixElement.cpp @@ -91,13 +91,13 @@ SVGFEConvolveMatrixElement::In1() return mStringAttributes[IN1].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::OrderX() { return mIntegerPairAttributes[ORDER].ToDOMAnimatedInteger(nsSVGIntegerPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::OrderY() { return mIntegerPairAttributes[ORDER].ToDOMAnimatedInteger(nsSVGIntegerPair::eSecond, this); @@ -110,13 +110,13 @@ SVGFEConvolveMatrixElement::KernelMatrix() this, KERNELMATRIX); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::TargetX() { return mIntegerAttributes[TARGET_X].ToDOMAnimatedInteger(this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::TargetY() { return mIntegerAttributes[TARGET_Y].ToDOMAnimatedInteger(this); diff --git a/content/svg/content/src/SVGFEConvolveMatrixElement.h b/content/svg/content/src/SVGFEConvolveMatrixElement.h index f3700d98f97..6851d795c46 100644 --- a/content/svg/content/src/SVGFEConvolveMatrixElement.h +++ b/content/svg/content/src/SVGFEConvolveMatrixElement.h @@ -59,11 +59,11 @@ public: // WebIDL already_AddRefed In1(); - already_AddRefed OrderX(); - already_AddRefed OrderY(); + already_AddRefed OrderX(); + already_AddRefed OrderY(); already_AddRefed KernelMatrix(); - already_AddRefed TargetX(); - already_AddRefed TargetY(); + already_AddRefed TargetX(); + already_AddRefed TargetY(); already_AddRefed EdgeMode(); already_AddRefed PreserveAlpha(); already_AddRefed Divisor(); diff --git a/content/svg/content/src/SVGFETurbulenceElement.cpp b/content/svg/content/src/SVGFETurbulenceElement.cpp index 0bd789286d9..4940513854f 100644 --- a/content/svg/content/src/SVGFETurbulenceElement.cpp +++ b/content/svg/content/src/SVGFETurbulenceElement.cpp @@ -98,7 +98,7 @@ SVGFETurbulenceElement::BaseFrequencyY() return mNumberPairAttributes[BASE_FREQ].ToDOMAnimatedNumber(nsSVGNumberPair::eSecond, this); } -already_AddRefed +already_AddRefed SVGFETurbulenceElement::NumOctaves() { return mIntegerAttributes[OCTAVES].ToDOMAnimatedInteger(this); diff --git a/content/svg/content/src/SVGFETurbulenceElement.h b/content/svg/content/src/SVGFETurbulenceElement.h index 744be76876d..b89ead2acaa 100644 --- a/content/svg/content/src/SVGFETurbulenceElement.h +++ b/content/svg/content/src/SVGFETurbulenceElement.h @@ -50,7 +50,7 @@ public: // WebIDL already_AddRefed BaseFrequencyX(); already_AddRefed BaseFrequencyY(); - already_AddRefed NumOctaves(); + already_AddRefed NumOctaves(); already_AddRefed Seed(); already_AddRefed StitchTiles(); already_AddRefed Type(); diff --git a/content/svg/content/src/SVGFilterElement.cpp b/content/svg/content/src/SVGFilterElement.cpp index 0921ad952f7..5fad0563efc 100644 --- a/content/svg/content/src/SVGFilterElement.cpp +++ b/content/svg/content/src/SVGFilterElement.cpp @@ -105,14 +105,14 @@ SVGFilterElement::PrimitiveUnits() return mEnumAttributes[PRIMITIVEUNITS].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGFilterElement::FilterResX() { return mIntegerPairAttributes[FILTERRES].ToDOMAnimatedInteger(nsSVGIntegerPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFilterElement::FilterResY() { return mIntegerPairAttributes[FILTERRES].ToDOMAnimatedInteger(nsSVGIntegerPair::eSecond, diff --git a/content/svg/content/src/SVGFilterElement.h b/content/svg/content/src/SVGFilterElement.h index 5024b3d50fe..4bff3745d59 100644 --- a/content/svg/content/src/SVGFilterElement.h +++ b/content/svg/content/src/SVGFilterElement.h @@ -54,8 +54,8 @@ public: already_AddRefed Height(); already_AddRefed FilterUnits(); already_AddRefed PrimitiveUnits(); - already_AddRefed FilterResX(); - already_AddRefed FilterResY(); + already_AddRefed FilterResX(); + already_AddRefed FilterResY(); void SetFilterRes(uint32_t filterResX, uint32_t filterResY); already_AddRefed Href(); diff --git a/content/svg/content/src/moz.build b/content/svg/content/src/moz.build index be6f44d998f..797a5657cc2 100644 --- a/content/svg/content/src/moz.build +++ b/content/svg/content/src/moz.build @@ -24,6 +24,7 @@ EXPORTS.mozilla.dom += [ 'SVGAnimatedAngle.h', 'SVGAnimatedBoolean.h', 'SVGAnimatedEnumeration.h', + 'SVGAnimatedInteger.h', 'SVGAnimatedLength.h', 'SVGAnimatedRect.h', 'SVGAnimatedString.h', @@ -118,6 +119,7 @@ CPP_SOURCES += [ 'SVGAnimatedAngle.cpp', 'SVGAnimatedBoolean.cpp', 'SVGAnimatedEnumeration.cpp', + 'SVGAnimatedInteger.cpp', 'SVGAnimatedLength.cpp', 'SVGAnimatedLengthList.cpp', 'SVGAnimatedNumberList.cpp', diff --git a/content/svg/content/src/nsSVGInteger.cpp b/content/svg/content/src/nsSVGInteger.cpp index d227b4efdf5..e80c1ffbc26 100644 --- a/content/svg/content/src/nsSVGInteger.cpp +++ b/content/svg/content/src/nsSVGInteger.cpp @@ -10,19 +10,7 @@ #include "SMILIntegerType.h" using namespace mozilla; - -NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGInteger::DOMAnimatedInteger, mSVGElement) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGInteger::DOMAnimatedInteger) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGInteger::DOMAnimatedInteger) - -DOMCI_DATA(SVGAnimatedInteger, nsSVGInteger::DOMAnimatedInteger) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGInteger::DOMAnimatedInteger) - NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedInteger) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedInteger) -NS_INTERFACE_MAP_END +using namespace mozilla::dom; /* Implementation */ @@ -112,15 +100,7 @@ nsSVGInteger::SetAnimValue(int aValue, nsSVGElement *aSVGElement) aSVGElement->DidAnimateInteger(mAttrEnum); } -nsresult -nsSVGInteger::ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult, - nsSVGElement *aSVGElement) -{ - *aResult = ToDOMAnimatedInteger(aSVGElement).get(); - return NS_OK; -} - -already_AddRefed +already_AddRefed nsSVGInteger::ToDOMAnimatedInteger(nsSVGElement *aSVGElement) { nsRefPtr domAnimatedInteger = diff --git a/content/svg/content/src/nsSVGInteger.h b/content/svg/content/src/nsSVGInteger.h index 5fb8b6661a7..36474e8ada3 100644 --- a/content/svg/content/src/nsSVGInteger.h +++ b/content/svg/content/src/nsSVGInteger.h @@ -9,7 +9,7 @@ #include "nsAutoPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsError.h" -#include "nsIDOMSVGAnimatedInteger.h" +#include "SVGAnimatedInteger.h" #include "nsISMILAttr.h" #include "nsSVGElement.h" #include "mozilla/Attributes.h" @@ -53,10 +53,8 @@ public: bool IsExplicitlySet() const { return mIsAnimated || mIsBaseSet; } - already_AddRefed + already_AddRefed ToDOMAnimatedInteger(nsSVGElement* aSVGElement); - nsresult ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult, - nsSVGElement* aSVGElement); // Returns a new nsISMILAttr object that the caller must delete nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement); @@ -69,30 +67,31 @@ private: bool mIsBaseSet; public: - struct DOMAnimatedInteger MOZ_FINAL : public nsIDOMSVGAnimatedInteger + struct DOMAnimatedInteger MOZ_FINAL : public mozilla::dom::SVGAnimatedInteger { - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedInteger) - - DOMAnimatedInteger(nsSVGInteger* aVal, nsSVGElement *aSVGElement) - : mVal(aVal), mSVGElement(aSVGElement) {} + DOMAnimatedInteger(nsSVGInteger* aVal, nsSVGElement* aSVGElement) + : mozilla::dom::SVGAnimatedInteger(aSVGElement) + , mVal(aVal) + {} virtual ~DOMAnimatedInteger(); nsSVGInteger* mVal; // kept alive because it belongs to content - nsRefPtr mSVGElement; - NS_IMETHOD GetBaseVal(int32_t* aResult) MOZ_OVERRIDE - { *aResult = mVal->GetBaseValue(); return NS_OK; } - NS_IMETHOD SetBaseVal(int32_t aValue) MOZ_OVERRIDE - { mVal->SetBaseValue(aValue, mSVGElement); return NS_OK; } + virtual int32_t BaseVal() MOZ_OVERRIDE + { + return mVal->GetBaseValue(); + } + virtual void SetBaseVal(int32_t aValue) MOZ_OVERRIDE + { + mVal->SetBaseValue(aValue, mSVGElement); + } // Script may have modified animation parameters or timeline -- DOM getters // need to flush any resample requests to reflect these modifications. - NS_IMETHOD GetAnimVal(int32_t* aResult) MOZ_OVERRIDE + virtual int32_t AnimVal() MOZ_OVERRIDE { mSVGElement->FlushAnimations(); - *aResult = mVal->GetAnimValue(); - return NS_OK; + return mVal->GetAnimValue(); } }; diff --git a/content/svg/content/src/nsSVGIntegerPair.cpp b/content/svg/content/src/nsSVGIntegerPair.cpp index 6f78db9ba03..246ab627588 100644 --- a/content/svg/content/src/nsSVGIntegerPair.cpp +++ b/content/svg/content/src/nsSVGIntegerPair.cpp @@ -13,19 +13,7 @@ #include "SVGIntegerPairSMILType.h" using namespace mozilla; - -NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGIntegerPair::DOMAnimatedInteger, mSVGElement) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGIntegerPair::DOMAnimatedInteger) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGIntegerPair::DOMAnimatedInteger) - -DOMCI_DATA(SVGAnimatedIntegerPair, nsSVGIntegerPair::DOMAnimatedInteger) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGIntegerPair::DOMAnimatedInteger) - NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedInteger) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedInteger) -NS_INTERFACE_MAP_END +using namespace mozilla::dom; static nsSVGAttrTearoffTable sSVGFirstAnimatedIntegerTearoffTable; @@ -168,16 +156,7 @@ nsSVGIntegerPair::SetAnimValue(const int32_t aValue[2], nsSVGElement *aSVGElemen aSVGElement->DidAnimateIntegerPair(mAttrEnum); } -nsresult -nsSVGIntegerPair::ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult, - PairIndex aIndex, - nsSVGElement *aSVGElement) -{ - *aResult = ToDOMAnimatedInteger(aIndex, aSVGElement).get(); - return NS_OK; -} - -already_AddRefed +already_AddRefed nsSVGIntegerPair::ToDOMAnimatedInteger(PairIndex aIndex, nsSVGElement* aSVGElement) { diff --git a/content/svg/content/src/nsSVGIntegerPair.h b/content/svg/content/src/nsSVGIntegerPair.h index e4c7d5fae8a..436eba4f7d5 100644 --- a/content/svg/content/src/nsSVGIntegerPair.h +++ b/content/svg/content/src/nsSVGIntegerPair.h @@ -9,10 +9,10 @@ #include "nsAutoPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsError.h" -#include "nsIDOMSVGAnimatedInteger.h" #include "nsISMILAttr.h" #include "nsSVGElement.h" #include "mozilla/Attributes.h" +#include "mozilla/dom/SVGAnimatedInteger.h" class nsSMILValue; @@ -59,10 +59,7 @@ public: bool IsExplicitlySet() const { return mIsAnimated || mIsBaseSet; } - nsresult ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult, - PairIndex aIndex, - nsSVGElement* aSVGElement); - already_AddRefed + already_AddRefed ToDOMAnimatedInteger(PairIndex aIndex, nsSVGElement* aSVGElement); // Returns a new nsISMILAttr object that the caller must delete @@ -77,34 +74,34 @@ private: bool mIsBaseSet; public: - struct DOMAnimatedInteger MOZ_FINAL : public nsIDOMSVGAnimatedInteger + struct DOMAnimatedInteger MOZ_FINAL : public mozilla::dom::SVGAnimatedInteger { - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedInteger) - - DOMAnimatedInteger(nsSVGIntegerPair* aVal, PairIndex aIndex, nsSVGElement *aSVGElement) - : mVal(aVal), mSVGElement(aSVGElement), mIndex(aIndex) {} + DOMAnimatedInteger(nsSVGIntegerPair* aVal, PairIndex aIndex, + nsSVGElement* aSVGElement) + : mozilla::dom::SVGAnimatedInteger(aSVGElement) + , mVal(aVal) + , mIndex(aIndex) + {} virtual ~DOMAnimatedInteger(); nsSVGIntegerPair* mVal; // kept alive because it belongs to content - nsRefPtr mSVGElement; PairIndex mIndex; // are we the first or second integer - NS_IMETHOD GetBaseVal(int32_t* aResult) MOZ_OVERRIDE - { *aResult = mVal->GetBaseValue(mIndex); return NS_OK; } - NS_IMETHOD SetBaseVal(int32_t aValue) MOZ_OVERRIDE - { - mVal->SetBaseValue(aValue, mIndex, mSVGElement); - return NS_OK; - } + virtual int32_t BaseVal() MOZ_OVERRIDE + { + return mVal->GetBaseValue(mIndex); + } + virtual void SetBaseVal(int32_t aValue) MOZ_OVERRIDE + { + mVal->SetBaseValue(aValue, mIndex, mSVGElement); + } // Script may have modified animation parameters or timeline -- DOM getters // need to flush any resample requests to reflect these modifications. - NS_IMETHOD GetAnimVal(int32_t* aResult) MOZ_OVERRIDE + virtual int32_t AnimVal() MOZ_OVERRIDE { mSVGElement->FlushAnimations(); - *aResult = mVal->GetAnimValue(mIndex); - return NS_OK; + return mVal->GetAnimValue(mIndex); } }; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 0706c9babae..ace2b3a871e 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -183,7 +183,6 @@ #include "nsIDOMXPathResult.h" #include "nsIDOMMozBrowserFrame.h" -#include "nsIDOMSVGAnimatedInteger.h" #include "nsIDOMSVGAnimatedNumber.h" #include "nsIDOMSVGLength.h" #include "nsIDOMSVGNumber.h" @@ -570,8 +569,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) // other SVG classes - NS_DEFINE_CLASSINFO_DATA(SVGAnimatedInteger, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumber, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH, @@ -1508,10 +1505,6 @@ nsDOMClassInfo::Init() // The SVG document // other SVG classes - DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedInteger, nsIDOMSVGAnimatedInteger) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedInteger) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumber, nsIDOMSVGAnimatedNumber) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumber) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index b9bc2eaa168..bdb1d9ffe92 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -74,7 +74,6 @@ DOMCI_CLASS(CSSMozDocumentRule) DOMCI_CLASS(CSSSupportsRule) // other SVG classes -DOMCI_CLASS(SVGAnimatedInteger) DOMCI_CLASS(SVGAnimatedNumber) DOMCI_CLASS(SVGLength) DOMCI_CLASS(SVGNumber) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index dcd583bccad..7a900a74605 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1663,7 +1663,6 @@ addExternalIface('PrintCallback', nativeType='nsIPrintCallback', headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('Selection', nativeType='nsISelection') addExternalIface('StyleSheetList') -addExternalIface('SVGAnimatedNumber') addExternalIface('SVGLength') addExternalIface('SVGNumber') addExternalIface('TouchList', headerFile='nsIDOMTouchEvent.h') diff --git a/dom/interfaces/svg/moz.build b/dom/interfaces/svg/moz.build index b41c9da2842..9fa6ad75ae4 100644 --- a/dom/interfaces/svg/moz.build +++ b/dom/interfaces/svg/moz.build @@ -6,7 +6,6 @@ XPIDL_SOURCES += [ 'nsIDOMSVGAnimatedEnum.idl', - 'nsIDOMSVGAnimatedInteger.idl', 'nsIDOMSVGAnimatedNumber.idl', 'nsIDOMSVGElement.idl', 'nsIDOMSVGLength.idl', diff --git a/dom/interfaces/svg/nsIDOMSVGAnimatedInteger.idl b/dom/interfaces/svg/nsIDOMSVGAnimatedInteger.idl deleted file mode 100644 index 7869941ee73..00000000000 --- a/dom/interfaces/svg/nsIDOMSVGAnimatedInteger.idl +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "domstubs.idl" - -/** - * The nsIDOMSVGAnimatedNumber interface is the interface to an SVG - * Animated Integer. - * - * For more information on this interface please see - * http://www.w3.org/TR/SVG11/types.html - * - */ - -[scriptable, uuid(7b196db6-955e-4a9f-8f42-645ebc2ce938)] -interface nsIDOMSVGAnimatedInteger : nsISupports -{ - attribute long baseVal; - // raises DOMException on setting - readonly attribute long animVal; -}; - - diff --git a/dom/webidl/SVGAnimatedInteger.webidl b/dom/webidl/SVGAnimatedInteger.webidl new file mode 100644 index 00000000000..61b43b3517b --- /dev/null +++ b/dom/webidl/SVGAnimatedInteger.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedInteger + * + * Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. + * W3C liability, trademark and document use rules apply. + */ + +interface SVGAnimatedInteger { + attribute long baseVal; + readonly attribute long animVal; +}; diff --git a/dom/webidl/SVGFETurbulenceElement.webidl b/dom/webidl/SVGFETurbulenceElement.webidl index 193e59028a3..6eb3da2a201 100644 --- a/dom/webidl/SVGFETurbulenceElement.webidl +++ b/dom/webidl/SVGFETurbulenceElement.webidl @@ -10,7 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedInteger; interface SVGAnimatedNumber; interface SVGFETurbulenceElement : SVGElement { diff --git a/dom/webidl/SVGFilterElement.webidl b/dom/webidl/SVGFilterElement.webidl index 2242ea775d2..f0c3129978c 100644 --- a/dom/webidl/SVGFilterElement.webidl +++ b/dom/webidl/SVGFilterElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedInteger; - interface SVGFilterElement : SVGElement { readonly attribute SVGAnimatedEnumeration filterUnits; readonly attribute SVGAnimatedEnumeration primitiveUnits; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 236e3702cb5..68b0b286bb0 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -229,6 +229,7 @@ webidl_files = \ SVGAnimatedAngle.webidl \ SVGAnimatedBoolean.webidl \ SVGAnimatedEnumeration.webidl \ + SVGAnimatedInteger.webidl \ SVGAnimatedLength.webidl \ SVGAnimatedLengthList.webidl \ SVGAnimatedNumberList.webidl \ From c477a69e4e11be2e44f583b971e6ad77977727de Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:03:04 +0200 Subject: [PATCH 20/28] Bug 886289 - Move SVGAnimatedNumber to WebIDL; r=dzbarsky --- content/svg/content/src/SVGAnimatedNumber.cpp | 32 ++++++++++++ content/svg/content/src/SVGAnimatedNumber.h | 51 +++++++++++++++++++ .../src/SVGComponentTransferFunctionElement.h | 10 ++-- .../svg/content/src/SVGFECompositeElement.cpp | 8 +-- .../svg/content/src/SVGFECompositeElement.h | 8 +-- .../src/SVGFEConvolveMatrixElement.cpp | 8 +-- .../content/src/SVGFEConvolveMatrixElement.h | 8 +-- .../src/SVGFEDiffuseLightingElement.cpp | 8 +-- .../content/src/SVGFEDiffuseLightingElement.h | 8 +-- .../src/SVGFEDisplacementMapElement.cpp | 2 +- .../content/src/SVGFEDisplacementMapElement.h | 2 +- .../content/src/SVGFEDistantLightElement.cpp | 4 +- .../content/src/SVGFEDistantLightElement.h | 4 +- .../content/src/SVGFEGaussianBlurElement.cpp | 4 +- .../content/src/SVGFEGaussianBlurElement.h | 4 +- .../content/src/SVGFEMorphologyElement.cpp | 4 +- .../svg/content/src/SVGFEMorphologyElement.h | 4 +- .../svg/content/src/SVGFEOffsetElement.cpp | 4 +- content/svg/content/src/SVGFEOffsetElement.h | 4 +- .../content/src/SVGFEPointLightElement.cpp | 6 +-- .../svg/content/src/SVGFEPointLightElement.h | 6 +-- .../src/SVGFESpecularLightingElement.cpp | 10 ++-- .../src/SVGFESpecularLightingElement.h | 10 ++-- .../svg/content/src/SVGFESpotLightElement.cpp | 16 +++--- .../svg/content/src/SVGFESpotLightElement.h | 16 +++--- .../content/src/SVGFETurbulenceElement.cpp | 6 +-- .../svg/content/src/SVGFETurbulenceElement.h | 6 +-- content/svg/content/src/SVGPathElement.cpp | 6 +-- content/svg/content/src/SVGPathElement.h | 2 +- content/svg/content/src/SVGStopElement.cpp | 6 +-- content/svg/content/src/SVGStopElement.h | 2 +- content/svg/content/src/moz.build | 2 + content/svg/content/src/nsSVGFilters.cpp | 10 ++-- content/svg/content/src/nsSVGNumber2.cpp | 26 ++-------- content/svg/content/src/nsSVGNumber2.h | 42 +++++++-------- content/svg/content/src/nsSVGNumberPair.cpp | 27 +--------- content/svg/content/src/nsSVGNumberPair.h | 42 +++++++-------- dom/base/nsDOMClassInfo.cpp | 7 --- dom/base/nsDOMClassInfoClasses.h | 1 - dom/webidl/SVGAnimatedNumber.webidl | 16 ++++++ dom/webidl/SVGFECompositeElement.webidl | 2 - dom/webidl/SVGFEConvolveMatrixElement.webidl | 2 - dom/webidl/SVGFEDiffuseLightingElement.webidl | 2 - dom/webidl/SVGFEDisplacementMapElement.webidl | 2 - dom/webidl/SVGFEDistantLightElement.webidl | 2 - dom/webidl/SVGFEGaussianBlurElement.webidl | 2 - dom/webidl/SVGFEMorphologyElement.webidl | 2 - dom/webidl/SVGFEOffsetElement.webidl | 2 - dom/webidl/SVGFEPointLightElement.webidl | 2 - .../SVGFESpecularLightingElement.webidl | 2 - dom/webidl/SVGFESpotLightElement.webidl | 2 - dom/webidl/SVGFETurbulenceElement.webidl | 2 - dom/webidl/SVGStopElement.webidl | 2 - dom/webidl/WebIDL.mk | 1 + 54 files changed, 240 insertions(+), 229 deletions(-) create mode 100644 content/svg/content/src/SVGAnimatedNumber.cpp create mode 100644 content/svg/content/src/SVGAnimatedNumber.h create mode 100644 dom/webidl/SVGAnimatedNumber.webidl diff --git a/content/svg/content/src/SVGAnimatedNumber.cpp b/content/svg/content/src/SVGAnimatedNumber.cpp new file mode 100644 index 00000000000..88415061c04 --- /dev/null +++ b/content/svg/content/src/SVGAnimatedNumber.cpp @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGAnimatedNumber.h" + +#include "mozilla/dom/SVGAnimatedNumberBinding.h" + +namespace mozilla { +namespace dom { + +NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAnimatedNumber, + mSVGElement) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnimatedNumber) +NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedNumber) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimatedNumber) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +JSObject* +SVGAnimatedNumber::WrapObject(JSContext* aCx, JS::Handle aScope) +{ + return SVGAnimatedNumberBinding::Wrap(aCx, aScope, this); +} + +} // namespace dom +} // namespace mozilla diff --git a/content/svg/content/src/SVGAnimatedNumber.h b/content/svg/content/src/SVGAnimatedNumber.h new file mode 100644 index 00000000000..380563710fe --- /dev/null +++ b/content/svg/content/src/SVGAnimatedNumber.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGAnimatedNumber_h +#define mozilla_dom_SVGAnimatedNumber_h + +#include "nsISupports.h" +#include "nsWrapperCache.h" + +#include "nsSVGElement.h" + +namespace mozilla { +namespace dom { + +class SVGAnimatedNumber : public nsISupports + , public nsWrapperCache +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGAnimatedNumber) + + nsSVGElement* GetParentObject() const + { + return mSVGElement; + } + + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aScope) + MOZ_OVERRIDE MOZ_FINAL; + + virtual float BaseVal() = 0; + virtual void SetBaseVal(float aBaseVal) = 0; + virtual float AnimVal() = 0; + +protected: + explicit SVGAnimatedNumber(nsSVGElement* aSVGElement) + : mSVGElement(aSVGElement) + { + SetIsDOMBinding(); + } + virtual ~SVGAnimatedNumber() {}; + + nsRefPtr mSVGElement; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGAnimatedNumber_h diff --git a/content/svg/content/src/SVGComponentTransferFunctionElement.h b/content/svg/content/src/SVGComponentTransferFunctionElement.h index e03f27c5809..b168ced82ec 100644 --- a/content/svg/content/src/SVGComponentTransferFunctionElement.h +++ b/content/svg/content/src/SVGComponentTransferFunctionElement.h @@ -49,11 +49,11 @@ public: JS::Handle aScope) MOZ_OVERRIDE = 0; already_AddRefed Type(); already_AddRefed TableValues(); - already_AddRefed Slope(); - already_AddRefed Intercept(); - already_AddRefed Amplitude(); - already_AddRefed Exponent(); - already_AddRefed Offset(); + already_AddRefed Slope(); + already_AddRefed Intercept(); + already_AddRefed Amplitude(); + already_AddRefed Exponent(); + already_AddRefed Offset(); protected: virtual NumberAttributesInfo GetNumberInfo() MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGFECompositeElement.cpp b/content/svg/content/src/SVGFECompositeElement.cpp index d8b207f489a..08045a8a639 100644 --- a/content/svg/content/src/SVGFECompositeElement.cpp +++ b/content/svg/content/src/SVGFECompositeElement.cpp @@ -73,25 +73,25 @@ SVGFECompositeElement::Operator() return mEnumAttributes[OPERATOR].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGFECompositeElement::K1() { return mNumberAttributes[ATTR_K1].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFECompositeElement::K2() { return mNumberAttributes[ATTR_K2].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFECompositeElement::K3() { return mNumberAttributes[ATTR_K3].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFECompositeElement::K4() { return mNumberAttributes[ATTR_K4].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/SVGFECompositeElement.h b/content/svg/content/src/SVGFECompositeElement.h index 8bdfd390c15..e15a73e15ad 100644 --- a/content/svg/content/src/SVGFECompositeElement.h +++ b/content/svg/content/src/SVGFECompositeElement.h @@ -58,10 +58,10 @@ public: already_AddRefed In1(); already_AddRefed In2(); already_AddRefed Operator(); - already_AddRefed K1(); - already_AddRefed K2(); - already_AddRefed K3(); - already_AddRefed K4(); + already_AddRefed K1(); + already_AddRefed K2(); + already_AddRefed K3(); + already_AddRefed K4(); void SetK(float k1, float k2, float k3, float k4); protected: diff --git a/content/svg/content/src/SVGFEConvolveMatrixElement.cpp b/content/svg/content/src/SVGFEConvolveMatrixElement.cpp index 8f0bd2b5e05..296b22d25af 100644 --- a/content/svg/content/src/SVGFEConvolveMatrixElement.cpp +++ b/content/svg/content/src/SVGFEConvolveMatrixElement.cpp @@ -134,26 +134,26 @@ SVGFEConvolveMatrixElement::PreserveAlpha() return mBooleanAttributes[PRESERVEALPHA].ToDOMAnimatedBoolean(this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::Divisor() { return mNumberAttributes[DIVISOR].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::Bias() { return mNumberAttributes[BIAS].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::KernelUnitLengthX() { return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(nsSVGNumberPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFEConvolveMatrixElement::KernelUnitLengthY() { return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(nsSVGNumberPair::eSecond, diff --git a/content/svg/content/src/SVGFEConvolveMatrixElement.h b/content/svg/content/src/SVGFEConvolveMatrixElement.h index 6851d795c46..5502130bc40 100644 --- a/content/svg/content/src/SVGFEConvolveMatrixElement.h +++ b/content/svg/content/src/SVGFEConvolveMatrixElement.h @@ -66,10 +66,10 @@ public: already_AddRefed TargetY(); already_AddRefed EdgeMode(); already_AddRefed PreserveAlpha(); - already_AddRefed Divisor(); - already_AddRefed Bias(); - already_AddRefed KernelUnitLengthX(); - already_AddRefed KernelUnitLengthY(); + already_AddRefed Divisor(); + already_AddRefed Bias(); + already_AddRefed KernelUnitLengthX(); + already_AddRefed KernelUnitLengthY(); protected: virtual bool OperatesOnPremultipledAlpha(int32_t) MOZ_OVERRIDE { diff --git a/content/svg/content/src/SVGFEDiffuseLightingElement.cpp b/content/svg/content/src/SVGFEDiffuseLightingElement.cpp index f8900170aac..09409be2b22 100644 --- a/content/svg/content/src/SVGFEDiffuseLightingElement.cpp +++ b/content/svg/content/src/SVGFEDiffuseLightingElement.cpp @@ -31,26 +31,26 @@ SVGFEDiffuseLightingElement::In1() return mStringAttributes[IN1].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEDiffuseLightingElement::SurfaceScale() { return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEDiffuseLightingElement::DiffuseConstant() { return mNumberAttributes[DIFFUSE_CONSTANT].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEDiffuseLightingElement::KernelUnitLengthX() { return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber( nsSVGNumberPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFEDiffuseLightingElement::KernelUnitLengthY() { return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber( diff --git a/content/svg/content/src/SVGFEDiffuseLightingElement.h b/content/svg/content/src/SVGFEDiffuseLightingElement.h index 8994f485478..2558fdf6e01 100644 --- a/content/svg/content/src/SVGFEDiffuseLightingElement.h +++ b/content/svg/content/src/SVGFEDiffuseLightingElement.h @@ -36,10 +36,10 @@ public: // WebIDL already_AddRefed In1(); - already_AddRefed SurfaceScale(); - already_AddRefed DiffuseConstant(); - already_AddRefed KernelUnitLengthX(); - already_AddRefed KernelUnitLengthY(); + already_AddRefed SurfaceScale(); + already_AddRefed DiffuseConstant(); + already_AddRefed KernelUnitLengthX(); + already_AddRefed KernelUnitLengthY(); protected: virtual void LightPixel(const float *N, const float *L, diff --git a/content/svg/content/src/SVGFEDisplacementMapElement.cpp b/content/svg/content/src/SVGFEDisplacementMapElement.cpp index 40a0e11f518..b9ebc0f6fdc 100644 --- a/content/svg/content/src/SVGFEDisplacementMapElement.cpp +++ b/content/svg/content/src/SVGFEDisplacementMapElement.cpp @@ -77,7 +77,7 @@ SVGFEDisplacementMapElement::In2() return mStringAttributes[IN2].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEDisplacementMapElement::Scale() { return mNumberAttributes[SCALE].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/SVGFEDisplacementMapElement.h b/content/svg/content/src/SVGFEDisplacementMapElement.h index 651a2b57efb..9cbe8e94dae 100644 --- a/content/svg/content/src/SVGFEDisplacementMapElement.h +++ b/content/svg/content/src/SVGFEDisplacementMapElement.h @@ -51,7 +51,7 @@ public: // WebIDL already_AddRefed In1(); already_AddRefed In2(); - already_AddRefed Scale(); + already_AddRefed Scale(); already_AddRefed XChannelSelector(); already_AddRefed YChannelSelector(); diff --git a/content/svg/content/src/SVGFEDistantLightElement.cpp b/content/svg/content/src/SVGFEDistantLightElement.cpp index 872fb344926..0a84cc3b627 100644 --- a/content/svg/content/src/SVGFEDistantLightElement.cpp +++ b/content/svg/content/src/SVGFEDistantLightElement.cpp @@ -40,13 +40,13 @@ SVGFEDistantLightElement::AttributeAffectsRendering(int32_t aNameSpaceID, aAttribute == nsGkAtoms::elevation); } -already_AddRefed +already_AddRefed SVGFEDistantLightElement::Azimuth() { return mNumberAttributes[AZIMUTH].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEDistantLightElement::Elevation() { return mNumberAttributes[ELEVATION].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/SVGFEDistantLightElement.h b/content/svg/content/src/SVGFEDistantLightElement.h index 998a07d8f87..4c6eaaea8b8 100644 --- a/content/svg/content/src/SVGFEDistantLightElement.h +++ b/content/svg/content/src/SVGFEDistantLightElement.h @@ -36,8 +36,8 @@ public: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; // WebIDL - already_AddRefed Azimuth(); - already_AddRefed Elevation(); + already_AddRefed Azimuth(); + already_AddRefed Elevation(); protected: virtual NumberAttributesInfo GetNumberInfo() MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGFEGaussianBlurElement.cpp b/content/svg/content/src/SVGFEGaussianBlurElement.cpp index 5bfe9ea0e69..6c85b5788cb 100644 --- a/content/svg/content/src/SVGFEGaussianBlurElement.cpp +++ b/content/svg/content/src/SVGFEGaussianBlurElement.cpp @@ -43,13 +43,13 @@ SVGFEGaussianBlurElement::In1() return mStringAttributes[IN1].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEGaussianBlurElement::StdDeviationX() { return mNumberPairAttributes[STD_DEV].ToDOMAnimatedNumber(nsSVGNumberPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFEGaussianBlurElement::StdDeviationY() { return mNumberPairAttributes[STD_DEV].ToDOMAnimatedNumber(nsSVGNumberPair::eSecond, this); diff --git a/content/svg/content/src/SVGFEGaussianBlurElement.h b/content/svg/content/src/SVGFEGaussianBlurElement.h index 27a36a5f08e..83db266ddd0 100644 --- a/content/svg/content/src/SVGFEGaussianBlurElement.h +++ b/content/svg/content/src/SVGFEGaussianBlurElement.h @@ -51,8 +51,8 @@ public: // WebIDL already_AddRefed In1(); - already_AddRefed StdDeviationX(); - already_AddRefed StdDeviationY(); + already_AddRefed StdDeviationX(); + already_AddRefed StdDeviationY(); void SetStdDeviation(float stdDeviationX, float stdDeviationY); protected: diff --git a/content/svg/content/src/SVGFEMorphologyElement.cpp b/content/svg/content/src/SVGFEMorphologyElement.cpp index 81475c92138..29ce00cb00c 100644 --- a/content/svg/content/src/SVGFEMorphologyElement.cpp +++ b/content/svg/content/src/SVGFEMorphologyElement.cpp @@ -70,13 +70,13 @@ SVGFEMorphologyElement::Operator() return mEnumAttributes[OPERATOR].ToDOMAnimatedEnum(this); } -already_AddRefed +already_AddRefed SVGFEMorphologyElement::RadiusX() { return mNumberPairAttributes[RADIUS].ToDOMAnimatedNumber(nsSVGNumberPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFEMorphologyElement::RadiusY() { return mNumberPairAttributes[RADIUS].ToDOMAnimatedNumber(nsSVGNumberPair::eSecond, this); diff --git a/content/svg/content/src/SVGFEMorphologyElement.h b/content/svg/content/src/SVGFEMorphologyElement.h index 0622ce24942..2796383702b 100644 --- a/content/svg/content/src/SVGFEMorphologyElement.h +++ b/content/svg/content/src/SVGFEMorphologyElement.h @@ -52,8 +52,8 @@ public: // WebIDL already_AddRefed In1(); already_AddRefed Operator(); - already_AddRefed RadiusX(); - already_AddRefed RadiusY(); + already_AddRefed RadiusX(); + already_AddRefed RadiusY(); void SetRadius(float rx, float ry); protected: diff --git a/content/svg/content/src/SVGFEOffsetElement.cpp b/content/svg/content/src/SVGFEOffsetElement.cpp index a22b64c65cb..3a23d5a7710 100644 --- a/content/svg/content/src/SVGFEOffsetElement.cpp +++ b/content/svg/content/src/SVGFEOffsetElement.cpp @@ -45,13 +45,13 @@ SVGFEOffsetElement::In1() return mStringAttributes[IN1].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFEOffsetElement::Dx() { return mNumberAttributes[DX].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEOffsetElement::Dy() { return mNumberAttributes[DY].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/SVGFEOffsetElement.h b/content/svg/content/src/SVGFEOffsetElement.h index a04ffdbcba6..fcfcd6e7974 100644 --- a/content/svg/content/src/SVGFEOffsetElement.h +++ b/content/svg/content/src/SVGFEOffsetElement.h @@ -50,8 +50,8 @@ public: // WebIDL already_AddRefed In1(); - already_AddRefed Dx(); - already_AddRefed Dy(); + already_AddRefed Dx(); + already_AddRefed Dy(); protected: nsIntPoint GetOffset(const nsSVGFilterInstance& aInstance); diff --git a/content/svg/content/src/SVGFEPointLightElement.cpp b/content/svg/content/src/SVGFEPointLightElement.cpp index 389e46978ab..70f658fe088 100644 --- a/content/svg/content/src/SVGFEPointLightElement.cpp +++ b/content/svg/content/src/SVGFEPointLightElement.cpp @@ -44,19 +44,19 @@ SVGFEPointLightElement::AttributeAffectsRendering(int32_t aNameSpaceID, //---------------------------------------------------------------------- -already_AddRefed +already_AddRefed SVGFEPointLightElement::X() { return mNumberAttributes[ATTR_X].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEPointLightElement::Y() { return mNumberAttributes[ATTR_Y].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFEPointLightElement::Z() { return mNumberAttributes[ATTR_Z].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/SVGFEPointLightElement.h b/content/svg/content/src/SVGFEPointLightElement.h index 50b19071e1f..82088e0c55f 100644 --- a/content/svg/content/src/SVGFEPointLightElement.h +++ b/content/svg/content/src/SVGFEPointLightElement.h @@ -36,9 +36,9 @@ public: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; // WebIDL - already_AddRefed X(); - already_AddRefed Y(); - already_AddRefed Z(); + already_AddRefed X(); + already_AddRefed Y(); + already_AddRefed Z(); protected: virtual NumberAttributesInfo GetNumberInfo() MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGFESpecularLightingElement.cpp b/content/svg/content/src/SVGFESpecularLightingElement.cpp index ceabd9b42d7..52d5f56dcac 100644 --- a/content/svg/content/src/SVGFESpecularLightingElement.cpp +++ b/content/svg/content/src/SVGFESpecularLightingElement.cpp @@ -29,32 +29,32 @@ SVGFESpecularLightingElement::In1() return mStringAttributes[IN1].ToDOMAnimatedString(this); } -already_AddRefed +already_AddRefed SVGFESpecularLightingElement::SurfaceScale() { return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpecularLightingElement::SpecularConstant() { return mNumberAttributes[SPECULAR_CONSTANT].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpecularLightingElement::SpecularExponent() { return mNumberAttributes[SPECULAR_EXPONENT].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpecularLightingElement::KernelUnitLengthX() { return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber( nsSVGNumberPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFESpecularLightingElement::KernelUnitLengthY() { return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber( diff --git a/content/svg/content/src/SVGFESpecularLightingElement.h b/content/svg/content/src/SVGFESpecularLightingElement.h index 14a88332922..d7a16106e47 100644 --- a/content/svg/content/src/SVGFESpecularLightingElement.h +++ b/content/svg/content/src/SVGFESpecularLightingElement.h @@ -42,11 +42,11 @@ public: // WebIDL already_AddRefed In1(); - already_AddRefed SurfaceScale(); - already_AddRefed SpecularConstant(); - already_AddRefed SpecularExponent(); - already_AddRefed KernelUnitLengthX(); - already_AddRefed KernelUnitLengthY(); + already_AddRefed SurfaceScale(); + already_AddRefed SpecularConstant(); + already_AddRefed SpecularExponent(); + already_AddRefed KernelUnitLengthX(); + already_AddRefed KernelUnitLengthY(); protected: virtual void LightPixel(const float *N, const float *L, diff --git a/content/svg/content/src/SVGFESpotLightElement.cpp b/content/svg/content/src/SVGFESpotLightElement.cpp index 76d34dbe3eb..36fe08bf3ac 100644 --- a/content/svg/content/src/SVGFESpotLightElement.cpp +++ b/content/svg/content/src/SVGFESpotLightElement.cpp @@ -54,49 +54,49 @@ SVGFESpotLightElement::AttributeAffectsRendering(int32_t aNameSpaceID, //---------------------------------------------------------------------- -already_AddRefed +already_AddRefed SVGFESpotLightElement::X() { return mNumberAttributes[ATTR_X].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpotLightElement::Y() { return mNumberAttributes[ATTR_Y].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpotLightElement::Z() { return mNumberAttributes[ATTR_Z].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpotLightElement::PointsAtX() { return mNumberAttributes[POINTS_AT_X].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpotLightElement::PointsAtY() { return mNumberAttributes[POINTS_AT_Y].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpotLightElement::PointsAtZ() { return mNumberAttributes[POINTS_AT_Z].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpotLightElement::SpecularExponent() { return mNumberAttributes[SPECULAR_EXPONENT].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGFESpotLightElement::LimitingConeAngle() { return mNumberAttributes[LIMITING_CONE_ANGLE].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/SVGFESpotLightElement.h b/content/svg/content/src/SVGFESpotLightElement.h index 4df4a6c5eb3..ae440828e01 100644 --- a/content/svg/content/src/SVGFESpotLightElement.h +++ b/content/svg/content/src/SVGFESpotLightElement.h @@ -39,14 +39,14 @@ public: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; // WebIDL - already_AddRefed X(); - already_AddRefed Y(); - already_AddRefed Z(); - already_AddRefed PointsAtX(); - already_AddRefed PointsAtY(); - already_AddRefed PointsAtZ(); - already_AddRefed SpecularExponent(); - already_AddRefed LimitingConeAngle(); + already_AddRefed X(); + already_AddRefed Y(); + already_AddRefed Z(); + already_AddRefed PointsAtX(); + already_AddRefed PointsAtY(); + already_AddRefed PointsAtZ(); + already_AddRefed SpecularExponent(); + already_AddRefed LimitingConeAngle(); protected: virtual NumberAttributesInfo GetNumberInfo() MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGFETurbulenceElement.cpp b/content/svg/content/src/SVGFETurbulenceElement.cpp index 4940513854f..528ccd206ab 100644 --- a/content/svg/content/src/SVGFETurbulenceElement.cpp +++ b/content/svg/content/src/SVGFETurbulenceElement.cpp @@ -86,13 +86,13 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFETurbulenceElement) //---------------------------------------------------------------------- -already_AddRefed +already_AddRefed SVGFETurbulenceElement::BaseFrequencyX() { return mNumberPairAttributes[BASE_FREQ].ToDOMAnimatedNumber(nsSVGNumberPair::eFirst, this); } -already_AddRefed +already_AddRefed SVGFETurbulenceElement::BaseFrequencyY() { return mNumberPairAttributes[BASE_FREQ].ToDOMAnimatedNumber(nsSVGNumberPair::eSecond, this); @@ -104,7 +104,7 @@ SVGFETurbulenceElement::NumOctaves() return mIntegerAttributes[OCTAVES].ToDOMAnimatedInteger(this); } -already_AddRefed +already_AddRefed SVGFETurbulenceElement::Seed() { return mNumberAttributes[SEED].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/SVGFETurbulenceElement.h b/content/svg/content/src/SVGFETurbulenceElement.h index b89ead2acaa..bd04b252df7 100644 --- a/content/svg/content/src/SVGFETurbulenceElement.h +++ b/content/svg/content/src/SVGFETurbulenceElement.h @@ -48,10 +48,10 @@ public: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; // WebIDL - already_AddRefed BaseFrequencyX(); - already_AddRefed BaseFrequencyY(); + already_AddRefed BaseFrequencyX(); + already_AddRefed BaseFrequencyY(); already_AddRefed NumOctaves(); - already_AddRefed Seed(); + already_AddRefed Seed(); already_AddRefed StitchTiles(); already_AddRefed Type(); diff --git a/content/svg/content/src/SVGPathElement.cpp b/content/svg/content/src/SVGPathElement.cpp index b7f78510f4c..ddcad823274 100644 --- a/content/svg/content/src/SVGPathElement.cpp +++ b/content/svg/content/src/SVGPathElement.cpp @@ -42,12 +42,10 @@ SVGPathElement::SVGPathElement(already_AddRefed aNodeInfo) NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPathElement) -already_AddRefed +already_AddRefed SVGPathElement::PathLength() { - nsCOMPtr number; - mPathLength.ToDOMAnimatedNumber(getter_AddRefs(number), this); - return number.forget(); + return mPathLength.ToDOMAnimatedNumber(this); } float diff --git a/content/svg/content/src/SVGPathElement.h b/content/svg/content/src/SVGPathElement.h index a902dfa3d67..ce21a978166 100644 --- a/content/svg/content/src/SVGPathElement.h +++ b/content/svg/content/src/SVGPathElement.h @@ -74,7 +74,7 @@ public: gfxFloat GetPathLengthScale(PathLengthScaleForType aFor); // WebIDL - already_AddRefed PathLength(); + already_AddRefed PathLength(); float GetTotalLength(ErrorResult& rv); already_AddRefed GetPointAtLength(float distance, ErrorResult& rv); uint32_t GetPathSegAtLength(float distance); diff --git a/content/svg/content/src/SVGStopElement.cpp b/content/svg/content/src/SVGStopElement.cpp index da90908a7de..3a18f14c661 100644 --- a/content/svg/content/src/SVGStopElement.cpp +++ b/content/svg/content/src/SVGStopElement.cpp @@ -35,12 +35,10 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStopElement) //---------------------------------------------------------------------- -already_AddRefed +already_AddRefed SVGStopElement::Offset() { - nsCOMPtr offset; - mOffset.ToDOMAnimatedNumber(getter_AddRefs(offset), this); - return offset.forget(); + return mOffset.ToDOMAnimatedNumber(this); } //---------------------------------------------------------------------- diff --git a/content/svg/content/src/SVGStopElement.h b/content/svg/content/src/SVGStopElement.h index e2ac5d4733a..b5fdf872c07 100644 --- a/content/svg/content/src/SVGStopElement.h +++ b/content/svg/content/src/SVGStopElement.h @@ -33,7 +33,7 @@ public: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; // WebIDL - already_AddRefed Offset(); + already_AddRefed Offset(); protected: diff --git a/content/svg/content/src/moz.build b/content/svg/content/src/moz.build index 797a5657cc2..32956b746e3 100644 --- a/content/svg/content/src/moz.build +++ b/content/svg/content/src/moz.build @@ -26,6 +26,7 @@ EXPORTS.mozilla.dom += [ 'SVGAnimatedEnumeration.h', 'SVGAnimatedInteger.h', 'SVGAnimatedLength.h', + 'SVGAnimatedNumber.h', 'SVGAnimatedRect.h', 'SVGAnimatedString.h', 'SVGAnimatedTransformList.h', @@ -122,6 +123,7 @@ CPP_SOURCES += [ 'SVGAnimatedInteger.cpp', 'SVGAnimatedLength.cpp', 'SVGAnimatedLengthList.cpp', + 'SVGAnimatedNumber.cpp', 'SVGAnimatedNumberList.cpp', 'SVGAnimatedPathSegList.cpp', 'SVGAnimatedPointList.cpp', diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index 11fed8110d2..dabdc8de513 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -400,31 +400,31 @@ SVGComponentTransferFunctionElement::TableValues() &mNumberListAttributes[TABLEVALUES], this, TABLEVALUES); } -already_AddRefed +already_AddRefed SVGComponentTransferFunctionElement::Slope() { return mNumberAttributes[SLOPE].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGComponentTransferFunctionElement::Intercept() { return mNumberAttributes[INTERCEPT].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGComponentTransferFunctionElement::Amplitude() { return mNumberAttributes[AMPLITUDE].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGComponentTransferFunctionElement::Exponent() { return mNumberAttributes[EXPONENT].ToDOMAnimatedNumber(this); } -already_AddRefed +already_AddRefed SVGComponentTransferFunctionElement::Offset() { return mNumberAttributes[OFFSET].ToDOMAnimatedNumber(this); diff --git a/content/svg/content/src/nsSVGNumber2.cpp b/content/svg/content/src/nsSVGNumber2.cpp index 17ad2fb87f6..b19682945d7 100644 --- a/content/svg/content/src/nsSVGNumber2.cpp +++ b/content/svg/content/src/nsSVGNumber2.cpp @@ -14,6 +14,9 @@ #include "nsIDOMSVGNumber.h" #include "mozilla/Attributes.h" +using namespace mozilla; +using namespace mozilla::dom; + class DOMSVGNumber MOZ_FINAL : public nsIDOMSVGNumber { public: @@ -33,22 +36,9 @@ private: float mVal; }; -NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGNumber2::DOMAnimatedNumber, mSVGElement) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGNumber2::DOMAnimatedNumber) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGNumber2::DOMAnimatedNumber) - NS_IMPL_ADDREF(DOMSVGNumber) NS_IMPL_RELEASE(DOMSVGNumber) -DOMCI_DATA(SVGAnimatedNumber, nsSVGNumber2::DOMAnimatedNumber) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGNumber2::DOMAnimatedNumber) - NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedNumber) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedNumber) -NS_INTERFACE_MAP_END - NS_INTERFACE_MAP_BEGIN(DOMSVGNumber) NS_INTERFACE_MAP_ENTRY(nsIDOMSVGNumber) NS_INTERFACE_MAP_ENTRY(nsISupports) @@ -150,7 +140,7 @@ nsSVGNumber2::SetAnimValue(float aValue, nsSVGElement *aSVGElement) aSVGElement->DidAnimateNumber(mAttrEnum); } -already_AddRefed +already_AddRefed nsSVGNumber2::ToDOMAnimatedNumber(nsSVGElement* aSVGElement) { nsRefPtr domAnimatedNumber = @@ -163,14 +153,6 @@ nsSVGNumber2::ToDOMAnimatedNumber(nsSVGElement* aSVGElement) return domAnimatedNumber.forget(); } -nsresult -nsSVGNumber2::ToDOMAnimatedNumber(nsIDOMSVGAnimatedNumber **aResult, - nsSVGElement *aSVGElement) -{ - *aResult = ToDOMAnimatedNumber(aSVGElement).get(); - return NS_OK; -} - nsSVGNumber2::DOMAnimatedNumber::~DOMAnimatedNumber() { sSVGAnimatedNumberTearoffTable.RemoveTearoff(mVal); diff --git a/content/svg/content/src/nsSVGNumber2.h b/content/svg/content/src/nsSVGNumber2.h index 36494956f6a..4e951a899bb 100644 --- a/content/svg/content/src/nsSVGNumber2.h +++ b/content/svg/content/src/nsSVGNumber2.h @@ -9,11 +9,11 @@ #include "nsAutoPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsError.h" -#include "nsIDOMSVGAnimatedNumber.h" #include "nsISMILAttr.h" #include "nsMathUtils.h" #include "nsSVGElement.h" #include "mozilla/Attributes.h" +#include "mozilla/dom/SVGAnimatedNumber.h" class nsSMILValue; @@ -53,10 +53,8 @@ public: bool IsExplicitlySet() const { return mIsAnimated || mIsBaseSet; } - already_AddRefed + already_AddRefed ToDOMAnimatedNumber(nsSVGElement* aSVGElement); - nsresult ToDOMAnimatedNumber(nsIDOMSVGAnimatedNumber **aResult, - nsSVGElement* aSVGElement); // Returns a new nsISMILAttr object that the caller must delete nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement); @@ -69,36 +67,32 @@ private: bool mIsBaseSet; public: - struct DOMAnimatedNumber MOZ_FINAL : public nsIDOMSVGAnimatedNumber + struct DOMAnimatedNumber MOZ_FINAL : public mozilla::dom::SVGAnimatedNumber { - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedNumber) - - DOMAnimatedNumber(nsSVGNumber2* aVal, nsSVGElement *aSVGElement) - : mVal(aVal), mSVGElement(aSVGElement) {} + DOMAnimatedNumber(nsSVGNumber2* aVal, nsSVGElement* aSVGElement) + : mozilla::dom::SVGAnimatedNumber(aSVGElement) + , mVal(aVal) + {} virtual ~DOMAnimatedNumber(); nsSVGNumber2* mVal; // kept alive because it belongs to content - nsRefPtr mSVGElement; - NS_IMETHOD GetBaseVal(float* aResult) MOZ_OVERRIDE - { *aResult = mVal->GetBaseValue(); return NS_OK; } - NS_IMETHOD SetBaseVal(float aValue) MOZ_OVERRIDE - { - if (!NS_finite(aValue)) { - return NS_ERROR_ILLEGAL_VALUE; - } - mVal->SetBaseValue(aValue, mSVGElement); - return NS_OK; - } + virtual float BaseVal() MOZ_OVERRIDE + { + return mVal->GetBaseValue(); + } + virtual void SetBaseVal(float aValue) MOZ_OVERRIDE + { + MOZ_ASSERT(NS_finite(aValue)); + mVal->SetBaseValue(aValue, mSVGElement); + } // Script may have modified animation parameters or timeline -- DOM getters // need to flush any resample requests to reflect these modifications. - NS_IMETHOD GetAnimVal(float* aResult) MOZ_OVERRIDE + virtual float AnimVal() MOZ_OVERRIDE { mSVGElement->FlushAnimations(); - *aResult = mVal->GetAnimValue(); - return NS_OK; + return mVal->GetAnimValue(); } }; diff --git a/content/svg/content/src/nsSVGNumberPair.cpp b/content/svg/content/src/nsSVGNumberPair.cpp index 91f3cf5f2d9..b2537290094 100644 --- a/content/svg/content/src/nsSVGNumberPair.cpp +++ b/content/svg/content/src/nsSVGNumberPair.cpp @@ -14,21 +14,7 @@ #include "SVGNumberPairSMILType.h" using namespace mozilla; - -NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGNumberPair::DOMAnimatedNumber, mSVGElement) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGNumberPair::DOMAnimatedNumber) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGNumberPair::DOMAnimatedNumber) - -DOMCI_DATA(SVGAnimatedNumberPair, nsSVGNumberPair::DOMAnimatedNumber) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGNumberPair::DOMAnimatedNumber) - NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedNumber) - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedNumber) -NS_INTERFACE_MAP_END - -/* Implementation */ +using namespace mozilla::dom; static nsSVGAttrTearoffTable sSVGFirstAnimatedNumberTearoffTable; @@ -166,16 +152,7 @@ nsSVGNumberPair::SetAnimValue(const float aValue[2], nsSVGElement *aSVGElement) aSVGElement->DidAnimateNumberPair(mAttrEnum); } -nsresult -nsSVGNumberPair::ToDOMAnimatedNumber(nsIDOMSVGAnimatedNumber** aResult, - PairIndex aIndex, - nsSVGElement* aSVGElement) -{ - *aResult = ToDOMAnimatedNumber(aIndex, aSVGElement).get(); - return NS_OK; -} - -already_AddRefed +already_AddRefed nsSVGNumberPair::ToDOMAnimatedNumber(PairIndex aIndex, nsSVGElement* aSVGElement) { diff --git a/content/svg/content/src/nsSVGNumberPair.h b/content/svg/content/src/nsSVGNumberPair.h index 81be0df1400..9861841db2b 100644 --- a/content/svg/content/src/nsSVGNumberPair.h +++ b/content/svg/content/src/nsSVGNumberPair.h @@ -9,11 +9,11 @@ #include "nsAutoPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsError.h" -#include "nsIDOMSVGAnimatedNumber.h" #include "nsISMILAttr.h" #include "nsMathUtils.h" #include "nsSVGElement.h" #include "mozilla/Attributes.h" +#include "mozilla/dom/SVGAnimatedNumber.h" class nsSMILValue; @@ -60,10 +60,7 @@ public: bool IsExplicitlySet() const { return mIsAnimated || mIsBaseSet; } - nsresult ToDOMAnimatedNumber(nsIDOMSVGAnimatedNumber** aResult, - PairIndex aIndex, - nsSVGElement* aSVGElement); - already_AddRefed + already_AddRefed ToDOMAnimatedNumber(PairIndex aIndex, nsSVGElement* aSVGElement); // Returns a new nsISMILAttr object that the caller must delete @@ -78,37 +75,34 @@ private: bool mIsBaseSet; public: - struct DOMAnimatedNumber MOZ_FINAL : public nsIDOMSVGAnimatedNumber + struct DOMAnimatedNumber MOZ_FINAL : public mozilla::dom::SVGAnimatedNumber { - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedNumber) - DOMAnimatedNumber(nsSVGNumberPair* aVal, PairIndex aIndex, nsSVGElement *aSVGElement) - : mVal(aVal), mSVGElement(aSVGElement), mIndex(aIndex) {} + : mozilla::dom::SVGAnimatedNumber(aSVGElement) + , mVal(aVal) + , mIndex(aIndex) + {} virtual ~DOMAnimatedNumber(); nsSVGNumberPair* mVal; // kept alive because it belongs to content - nsRefPtr mSVGElement; PairIndex mIndex; // are we the first or second number - NS_IMETHOD GetBaseVal(float* aResult) MOZ_OVERRIDE - { *aResult = mVal->GetBaseValue(mIndex); return NS_OK; } - NS_IMETHOD SetBaseVal(float aValue) MOZ_OVERRIDE - { - if (!NS_finite(aValue)) { - return NS_ERROR_ILLEGAL_VALUE; - } - mVal->SetBaseValue(aValue, mIndex, mSVGElement); - return NS_OK; - } + virtual float BaseVal() MOZ_OVERRIDE + { + return mVal->GetBaseValue(mIndex); + } + virtual void SetBaseVal(float aValue) MOZ_OVERRIDE + { + MOZ_ASSERT(NS_finite(aValue)); + mVal->SetBaseValue(aValue, mIndex, mSVGElement); + } // Script may have modified animation parameters or timeline -- DOM getters // need to flush any resample requests to reflect these modifications. - NS_IMETHOD GetAnimVal(float* aResult) MOZ_OVERRIDE + virtual float AnimVal() MOZ_OVERRIDE { mSVGElement->FlushAnimations(); - *aResult = mVal->GetAnimValue(mIndex); - return NS_OK; + return mVal->GetAnimValue(mIndex); } }; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index ace2b3a871e..b3d6c034584 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -183,7 +183,6 @@ #include "nsIDOMXPathResult.h" #include "nsIDOMMozBrowserFrame.h" -#include "nsIDOMSVGAnimatedNumber.h" #include "nsIDOMSVGLength.h" #include "nsIDOMSVGNumber.h" @@ -569,8 +568,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) // other SVG classes - NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumber, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH, @@ -1505,10 +1502,6 @@ nsDOMClassInfo::Init() // The SVG document // other SVG classes - DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumber, nsIDOMSVGAnimatedNumber) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumber) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(SVGLength, nsIDOMSVGLength) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLength) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index bdb1d9ffe92..f9ba5a9932f 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -74,7 +74,6 @@ DOMCI_CLASS(CSSMozDocumentRule) DOMCI_CLASS(CSSSupportsRule) // other SVG classes -DOMCI_CLASS(SVGAnimatedNumber) DOMCI_CLASS(SVGLength) DOMCI_CLASS(SVGNumber) diff --git a/dom/webidl/SVGAnimatedNumber.webidl b/dom/webidl/SVGAnimatedNumber.webidl new file mode 100644 index 00000000000..5908f0f868e --- /dev/null +++ b/dom/webidl/SVGAnimatedNumber.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedNumber + * + * Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. + * W3C liability, trademark and document use rules apply. + */ + +interface SVGAnimatedNumber { + attribute float baseVal; + readonly attribute float animVal; +}; diff --git a/dom/webidl/SVGFECompositeElement.webidl b/dom/webidl/SVGFECompositeElement.webidl index 3407777e45a..ed016508960 100644 --- a/dom/webidl/SVGFECompositeElement.webidl +++ b/dom/webidl/SVGFECompositeElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFECompositeElement : SVGElement { // Composite Operators diff --git a/dom/webidl/SVGFEConvolveMatrixElement.webidl b/dom/webidl/SVGFEConvolveMatrixElement.webidl index 96eec68cf8a..1ace1cf1167 100644 --- a/dom/webidl/SVGFEConvolveMatrixElement.webidl +++ b/dom/webidl/SVGFEConvolveMatrixElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEConvolveMatrixElement : SVGElement { // Edge Mode Values diff --git a/dom/webidl/SVGFEDiffuseLightingElement.webidl b/dom/webidl/SVGFEDiffuseLightingElement.webidl index 176950c3a1f..98cf34c7d37 100644 --- a/dom/webidl/SVGFEDiffuseLightingElement.webidl +++ b/dom/webidl/SVGFEDiffuseLightingElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEDiffuseLightingElement : SVGElement { readonly attribute SVGAnimatedString in1; readonly attribute SVGAnimatedNumber surfaceScale; diff --git a/dom/webidl/SVGFEDisplacementMapElement.webidl b/dom/webidl/SVGFEDisplacementMapElement.webidl index 573cd8e267e..114bc3a1f4f 100644 --- a/dom/webidl/SVGFEDisplacementMapElement.webidl +++ b/dom/webidl/SVGFEDisplacementMapElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEDisplacementMapElement : SVGElement { // Channel Selectors diff --git a/dom/webidl/SVGFEDistantLightElement.webidl b/dom/webidl/SVGFEDistantLightElement.webidl index 9a1f881d626..78b396f82d0 100644 --- a/dom/webidl/SVGFEDistantLightElement.webidl +++ b/dom/webidl/SVGFEDistantLightElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEDistantLightElement : SVGElement { readonly attribute SVGAnimatedNumber azimuth; readonly attribute SVGAnimatedNumber elevation; diff --git a/dom/webidl/SVGFEGaussianBlurElement.webidl b/dom/webidl/SVGFEGaussianBlurElement.webidl index dfd932ed365..d63fbbe983c 100644 --- a/dom/webidl/SVGFEGaussianBlurElement.webidl +++ b/dom/webidl/SVGFEGaussianBlurElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEGaussianBlurElement : SVGElement { readonly attribute SVGAnimatedString in1; readonly attribute SVGAnimatedNumber stdDeviationX; diff --git a/dom/webidl/SVGFEMorphologyElement.webidl b/dom/webidl/SVGFEMorphologyElement.webidl index bf0298e6225..97190238ebf 100644 --- a/dom/webidl/SVGFEMorphologyElement.webidl +++ b/dom/webidl/SVGFEMorphologyElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEMorphologyElement : SVGElement { // Morphology Operators diff --git a/dom/webidl/SVGFEOffsetElement.webidl b/dom/webidl/SVGFEOffsetElement.webidl index 039cf5c86d5..0ff9a8187ad 100644 --- a/dom/webidl/SVGFEOffsetElement.webidl +++ b/dom/webidl/SVGFEOffsetElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEOffsetElement : SVGElement { readonly attribute SVGAnimatedString in1; readonly attribute SVGAnimatedNumber dx; diff --git a/dom/webidl/SVGFEPointLightElement.webidl b/dom/webidl/SVGFEPointLightElement.webidl index 1f1c8a52a13..fc906336e46 100644 --- a/dom/webidl/SVGFEPointLightElement.webidl +++ b/dom/webidl/SVGFEPointLightElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFEPointLightElement : SVGElement { readonly attribute SVGAnimatedNumber x; readonly attribute SVGAnimatedNumber y; diff --git a/dom/webidl/SVGFESpecularLightingElement.webidl b/dom/webidl/SVGFESpecularLightingElement.webidl index 4f885dc8a5a..fbe5ab19483 100644 --- a/dom/webidl/SVGFESpecularLightingElement.webidl +++ b/dom/webidl/SVGFESpecularLightingElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFESpecularLightingElement : SVGElement { readonly attribute SVGAnimatedString in1; readonly attribute SVGAnimatedNumber surfaceScale; diff --git a/dom/webidl/SVGFESpotLightElement.webidl b/dom/webidl/SVGFESpotLightElement.webidl index 9676036f333..c85ffa7d1aa 100644 --- a/dom/webidl/SVGFESpotLightElement.webidl +++ b/dom/webidl/SVGFESpotLightElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFESpotLightElement : SVGElement { readonly attribute SVGAnimatedNumber x; readonly attribute SVGAnimatedNumber y; diff --git a/dom/webidl/SVGFETurbulenceElement.webidl b/dom/webidl/SVGFETurbulenceElement.webidl index 6eb3da2a201..7bb08f55766 100644 --- a/dom/webidl/SVGFETurbulenceElement.webidl +++ b/dom/webidl/SVGFETurbulenceElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGFETurbulenceElement : SVGElement { // Turbulence Types diff --git a/dom/webidl/SVGStopElement.webidl b/dom/webidl/SVGStopElement.webidl index 85e19bda33a..9171bd6186c 100644 --- a/dom/webidl/SVGStopElement.webidl +++ b/dom/webidl/SVGStopElement.webidl @@ -10,8 +10,6 @@ * liability, trademark and document use rules apply. */ -interface SVGAnimatedNumber; - interface SVGStopElement : SVGElement { readonly attribute SVGAnimatedNumber offset; }; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 68b0b286bb0..8a53a22118b 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -232,6 +232,7 @@ webidl_files = \ SVGAnimatedInteger.webidl \ SVGAnimatedLength.webidl \ SVGAnimatedLengthList.webidl \ + SVGAnimatedNumber.webidl \ SVGAnimatedNumberList.webidl \ SVGAnimatedPathData.webidl \ SVGAnimatedPoints.webidl \ From 09a439737c9a6025369c135e7a5591a9eaa16269 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:03:13 +0200 Subject: [PATCH 21/28] Bug 887009 - Pass MutableHandleValue to Invoke(); r=terrence --- js/src/builtin/Object.cpp | 7 +++++- js/src/builtin/TestingFunctions.cpp | 2 +- js/src/ion/AsmJS.cpp | 6 ++--- js/src/ion/BaselineIC.cpp | 2 +- js/src/ion/VMFunctions.cpp | 8 ++++++- js/src/jsapi.cpp | 28 ++++++++++++++++++---- js/src/jscntxtinlines.h | 2 +- js/src/jsiter.cpp | 6 ++--- js/src/jsobj.cpp | 4 ++-- js/src/jsproxy.cpp | 36 ++++++++++++++--------------- js/src/jsreflect.cpp | 24 +++++++++---------- js/src/jsstr.cpp | 2 +- js/src/vm/Debugger.cpp | 26 ++++++++++----------- js/src/vm/Interpreter.cpp | 8 +++---- js/src/vm/Interpreter.h | 4 ++-- js/src/vm/Shape-inl.h | 10 ++++---- 16 files changed, 102 insertions(+), 73 deletions(-) diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index d0a5eef9f69..14679a7ca0e 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -538,7 +538,12 @@ obj_watch_handler(JSContext *cx, JSObject *obj_, jsid id_, jsval old, JSObject *callable = (JSObject *)closure; Value argv[] = { IdToValue(id), old, *nvp }; - return Invoke(cx, ObjectValue(*obj), ObjectOrNullValue(callable), ArrayLength(argv), argv, nvp); + RootedValue rv(cx); + if (!Invoke(cx, ObjectValue(*obj), ObjectOrNullValue(callable), ArrayLength(argv), argv, &rv)) + return false; + + *nvp = rv; + return true; } static JSBool diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 7f226fb8e1d..57c72e4a6ee 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -914,7 +914,7 @@ ShellObjectMetadataCallback(JSContext *cx, JSObject **pmetadata) Value thisv = UndefinedValue(); RootedValue rval(cx); - if (!Invoke(cx, thisv, ObjectValue(*objectMetadataFunction), 0, NULL, rval.address())) + if (!Invoke(cx, thisv, ObjectValue(*objectMetadataFunction), 0, NULL, &rval)) return false; if (rval.isObject()) diff --git a/js/src/ion/AsmJS.cpp b/js/src/ion/AsmJS.cpp index 553105ed73e..fba56d34a07 100644 --- a/js/src/ion/AsmJS.cpp +++ b/js/src/ion/AsmJS.cpp @@ -5293,7 +5293,7 @@ InvokeFromAsmJS_Ignore(JSContext *cx, AsmJSModule::ExitDatum *exitDatum, int32_t { RootedValue fval(cx, ObjectValue(*exitDatum->fun)); RootedValue rval(cx); - if (!Invoke(cx, UndefinedValue(), fval, argc, argv, rval.address())) + if (!Invoke(cx, UndefinedValue(), fval, argc, argv, &rval)) return false; if (!TryEnablingIon(cx, exitDatum, argc, argv)) @@ -5307,7 +5307,7 @@ InvokeFromAsmJS_ToInt32(JSContext *cx, AsmJSModule::ExitDatum *exitDatum, int32_ { RootedValue fval(cx, ObjectValue(*exitDatum->fun)); RootedValue rval(cx); - if (!Invoke(cx, UndefinedValue(), fval, argc, argv, rval.address())) + if (!Invoke(cx, UndefinedValue(), fval, argc, argv, &rval)) return false; if (!TryEnablingIon(cx, exitDatum, argc, argv)) @@ -5326,7 +5326,7 @@ InvokeFromAsmJS_ToNumber(JSContext *cx, AsmJSModule::ExitDatum *exitDatum, int32 { RootedValue fval(cx, ObjectValue(*exitDatum->fun)); RootedValue rval(cx); - if (!Invoke(cx, UndefinedValue(), fval, argc, argv, rval.address())) + if (!Invoke(cx, UndefinedValue(), fval, argc, argv, &rval)) return false; if (!TryEnablingIon(cx, exitDatum, argc, argv)) diff --git a/js/src/ion/BaselineIC.cpp b/js/src/ion/BaselineIC.cpp index 06e0939d7c3..d9f9bee5a09 100644 --- a/js/src/ion/BaselineIC.cpp +++ b/js/src/ion/BaselineIC.cpp @@ -6995,7 +6995,7 @@ DoCallFallback(JSContext *cx, BaselineFrame *frame, ICCall_Fallback *stub, uint3 res.set(vp[0]); } else { JS_ASSERT(op == JSOP_CALL || op == JSOP_FUNCALL || op == JSOP_FUNAPPLY || op == JSOP_EVAL); - if (!Invoke(cx, thisv, callee, argc, args, res.address())) + if (!Invoke(cx, thisv, callee, argc, args, res)) return false; } diff --git a/js/src/ion/VMFunctions.cpp b/js/src/ion/VMFunctions.cpp index 362d3f56b5d..ab69a5fc2a3 100644 --- a/js/src/ion/VMFunctions.cpp +++ b/js/src/ion/VMFunctions.cpp @@ -76,7 +76,13 @@ InvokeFunction(JSContext *cx, HandleFunction fun0, uint32_t argc, Value *argv, V // we use InvokeConstructor that creates it at the callee side. if (thisv.isMagic(JS_IS_CONSTRUCTING)) return InvokeConstructor(cx, ObjectValue(*fun), argc, argvWithoutThis, rval); - return Invoke(cx, thisv, ObjectValue(*fun), argc, argvWithoutThis, rval); + + RootedValue rv(cx); + if (!Invoke(cx, thisv, ObjectValue(*fun), argc, argvWithoutThis, &rv)) + return false; + + *rval = rv; + return true; } JSObject * diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index eea7fa0eb93..9c1660747d4 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -5658,7 +5658,11 @@ JS_CallFunction(JSContext *cx, JSObject *objArg, JSFunction *fun, unsigned argc, assertSameCompartment(cx, obj, fun, JSValueArray(argv, argc)); AutoLastFrameCheck lfc(cx); - return Invoke(cx, ObjectOrNullValue(obj), ObjectValue(*fun), argc, argv, rval); + RootedValue rv(cx); + if (!Invoke(cx, ObjectOrNullValue(obj), ObjectValue(*fun), argc, argv, &rv)) + return false; + *rval = rv; + return true; } JS_PUBLIC_API(JSBool) @@ -5678,8 +5682,14 @@ JS_CallFunctionName(JSContext *cx, JSObject *objArg, const char *name, unsigned RootedValue v(cx); RootedId id(cx, AtomToId(atom)); - return JSObject::getGeneric(cx, obj, obj, id, &v) && - Invoke(cx, ObjectOrNullValue(obj), v, argc, argv, rval); + if (!JSObject::getGeneric(cx, obj, obj, id, &v)) + return false; + + RootedValue rv(cx); + if (!Invoke(cx, ObjectOrNullValue(obj), v, argc, argv, &rv)) + return false; + *rval = rv; + return true; } JS_PUBLIC_API(JSBool) @@ -5693,7 +5703,11 @@ JS_CallFunctionValue(JSContext *cx, JSObject *objArg, jsval fval, unsigned argc, assertSameCompartment(cx, obj, fval, JSValueArray(argv, argc)); AutoLastFrameCheck lfc(cx); - return Invoke(cx, ObjectOrNullValue(obj), fval, argc, argv, rval); + RootedValue rv(cx); + if (!Invoke(cx, ObjectOrNullValue(obj), fval, argc, argv, &rv)) + return false; + *rval = rv; + return true; } JS_PUBLIC_API(bool) @@ -5704,7 +5718,11 @@ JS::Call(JSContext *cx, jsval thisv, jsval fval, unsigned argc, jsval *argv, jsv assertSameCompartment(cx, thisv, fval, JSValueArray(argv, argc)); AutoLastFrameCheck lfc(cx); - return Invoke(cx, thisv, fval, argc, argv, rval); + RootedValue rv(cx); + if (!Invoke(cx, thisv, fval, argc, argv, &rv)) + return false; + *rval = rv; + return true; } JS_PUBLIC_API(JSObject *) diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index 9d43dd2566c..a4948c4cc2e 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -421,7 +421,7 @@ CallSetter(JSContext *cx, HandleObject obj, HandleId id, StrictPropertyOp op, un { if (attrs & JSPROP_SETTER) { RootedValue opv(cx, CastAsObjectJsval(op)); - return InvokeGetterOrSetter(cx, obj, opv, 1, vp.address(), vp.address()); + return InvokeGetterOrSetter(cx, obj, opv, 1, vp.address(), vp); } if (attrs & JSPROP_GETTER) diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index ed3466c0594..1bf49c28453 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -334,7 +334,7 @@ GetCustomIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandle /* Otherwise call it and return that object. */ Value arg = BooleanValue((flags & JSITER_FOREACH) == 0); - if (!Invoke(cx, ObjectValue(*obj), vp, 1, &arg, vp.address())) + if (!Invoke(cx, ObjectValue(*obj), vp, 1, &arg, vp)) return false; if (vp.isPrimitive()) { /* @@ -584,7 +584,7 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa return false; } - if (!Invoke(cx, ObjectOrNullValue(obj), method, 0, NULL, vp.address())) + if (!Invoke(cx, ObjectOrNullValue(obj), method, 0, NULL, vp)) return false; JSObject *resultObj = ToObject(cx, vp); @@ -1244,7 +1244,7 @@ js_IteratorMore(JSContext *cx, HandleObject iterobj, MutableHandleValue rval) /* Call the iterator object's .next method. */ if (!JSObject::getProperty(cx, iterobj, iterobj, cx->names().next, rval)) return false; - if (!Invoke(cx, ObjectValue(*iterobj), rval, 0, NULL, rval.address())) { + if (!Invoke(cx, ObjectValue(*iterobj), rval, 0, NULL, rval)) { /* Check for StopIteration. */ if (!cx->isExceptionPending() || !IsStopIteration(cx->getPendingException())) return false; diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index a97a04863e5..e2f817e7f68 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -4302,7 +4302,7 @@ JSObject::callMethod(JSContext *cx, HandleId id, unsigned argc, Value *argv, Mut RootedObject obj(cx, this); if (!JSObject::getGeneric(cx, obj, obj, id, &fval)) return false; - return Invoke(cx, ObjectValue(*obj), fval, argc, argv, vp.address()); + return Invoke(cx, ObjectValue(*obj), fval, argc, argv, vp); } JSBool @@ -4668,7 +4668,7 @@ MaybeCallMethod(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp.setObject(*obj); return true; } - return Invoke(cx, ObjectValue(*obj), vp, 0, NULL, vp.address()); + return Invoke(cx, ObjectValue(*obj), vp, 0, NULL, vp); } JS_FRIEND_API(JSBool) diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index 44b70b39389..6c3bf9b2cf6 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -155,8 +155,7 @@ BaseProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject receiver, return true; } if (desc.attrs & JSPROP_GETTER) - return InvokeGetterOrSetter(cx, receiver, CastAsObjectJsval(desc.getter), 0, NULL, - vp.address()); + return InvokeGetterOrSetter(cx, receiver, CastAsObjectJsval(desc.getter), 0, NULL, vp); if (!(desc.attrs & JSPROP_SHARED)) vp.set(desc.value); else @@ -472,7 +471,7 @@ DirectProxyHandler::call(JSContext *cx, HandleObject proxy, const CallArgs &args { assertEnteredPolicy(cx, proxy, JSID_VOID); RootedValue target(cx, GetProxyPrivate(proxy)); - return Invoke(cx, args.thisv(), target, args.length(), args.array(), args.rval().address()); + return Invoke(cx, args.thisv(), target, args.length(), args.array(), args.rval()); } bool @@ -665,7 +664,7 @@ static bool Trap(JSContext *cx, HandleObject handler, HandleValue fval, unsigned argc, Value* argv, MutableHandleValue rval) { - return Invoke(cx, ObjectValue(*handler), fval, argc, argv, rval.address()); + return Invoke(cx, ObjectValue(*handler), fval, argc, argv, rval); } static bool @@ -1013,7 +1012,7 @@ ScriptedIndirectProxyHandler::call(JSContext *cx, HandleObject proxy, const Call { assertEnteredPolicy(cx, proxy, JSID_VOID); RootedValue call(cx, GetCall(proxy)); - return Invoke(cx, args.thisv(), call, args.length(), args.array(), args.rval().address()); + return Invoke(cx, args.thisv(), call, args.length(), args.array(), args.rval()); } bool @@ -1378,7 +1377,7 @@ TrapGetOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHandle value }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 2, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step 6 @@ -1487,7 +1486,7 @@ TrapDefineOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHan normalizedDesc }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 3, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // steps 7-8 @@ -1668,7 +1667,7 @@ ScriptedDirectProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy) ObjectValue(*target) }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 1, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step f @@ -1767,7 +1766,7 @@ ScriptedDirectProxyHandler::getOwnPropertyNames(JSContext *cx, HandleObject prox ObjectValue(*target) }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 1, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step f @@ -1809,7 +1808,7 @@ ScriptedDirectProxyHandler::delete_(JSContext *cx, HandleObject proxy, HandleId value }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 2, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step 6-7 @@ -1857,7 +1856,7 @@ ScriptedDirectProxyHandler::enumerate(JSContext *cx, HandleObject proxy, AutoIdV ObjectOrNullValue(target) }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 1, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step f @@ -1904,7 +1903,7 @@ ScriptedDirectProxyHandler::has(JSContext *cx, HandleObject proxy, HandleId id, value }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 2, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step 6 @@ -1964,7 +1963,7 @@ ScriptedDirectProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId i value }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 2, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step 6 @@ -2034,7 +2033,7 @@ ScriptedDirectProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject ObjectOrNullValue(receiver) }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 3, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step 6 @@ -2104,7 +2103,7 @@ ScriptedDirectProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObject ObjectValue(*receiver) }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 4, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step 6 @@ -2166,7 +2165,7 @@ ScriptedDirectProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector ObjectOrNullValue(target) }; RootedValue trapResult(cx); - if (!Invoke(cx, ObjectValue(*handler), trap, 1, argv, trapResult.address())) + if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult)) return false; // step f @@ -2227,7 +2226,7 @@ ScriptedDirectProxyHandler::call(JSContext *cx, HandleObject proxy, const CallAr ObjectValue(*argsArray) }; RootedValue thisValue(cx, ObjectValue(*handler)); - return Invoke(cx, thisValue, trap, ArrayLength(argv), argv, args.rval().address()); + return Invoke(cx, thisValue, trap, ArrayLength(argv), argv, args.rval()); } bool @@ -2264,8 +2263,7 @@ ScriptedDirectProxyHandler::construct(JSContext *cx, HandleObject proxy, const C ObjectValue(*argsArray) }; RootedValue thisValue(cx, ObjectValue(*handler)); - return Invoke(cx, thisValue, trap, ArrayLength(constructArgv), constructArgv, - args.rval().address()); + return Invoke(cx, thisValue, trap, ArrayLength(constructArgv), constructArgv, args.rval()); } ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton; diff --git a/js/src/jsreflect.cpp b/js/src/jsreflect.cpp index 6346bb2c211..eaea6606eb6 100644 --- a/js/src/jsreflect.cpp +++ b/js/src/jsreflect.cpp @@ -204,12 +204,12 @@ class NodeBuilder return false; Value argv[] = { loc }; AutoValueArray ava(cx, argv, 1); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } Value argv[] = { NullValue() }; /* no zero-length arrays allowed! */ AutoValueArray ava(cx, argv, 1); - return Invoke(cx, userv, fun, 0, argv, dst.address()); + return Invoke(cx, userv, fun, 0, argv, dst); } bool callback(HandleValue fun, HandleValue v1, TokenPos *pos, MutableHandleValue dst) { @@ -219,12 +219,12 @@ class NodeBuilder return false; Value argv[] = { v1, loc }; AutoValueArray ava(cx, argv, 2); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } Value argv[] = { v1 }; AutoValueArray ava(cx, argv, 1); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } bool callback(HandleValue fun, HandleValue v1, HandleValue v2, TokenPos *pos, @@ -235,12 +235,12 @@ class NodeBuilder return false; Value argv[] = { v1, v2, loc }; AutoValueArray ava(cx, argv, 3); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } Value argv[] = { v1, v2 }; AutoValueArray ava(cx, argv, 2); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } bool callback(HandleValue fun, HandleValue v1, HandleValue v2, HandleValue v3, TokenPos *pos, @@ -251,12 +251,12 @@ class NodeBuilder return false; Value argv[] = { v1, v2, v3, loc }; AutoValueArray ava(cx, argv, 4); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } Value argv[] = { v1, v2, v3 }; AutoValueArray ava(cx, argv, 3); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } bool callback(HandleValue fun, HandleValue v1, HandleValue v2, HandleValue v3, HandleValue v4, @@ -267,12 +267,12 @@ class NodeBuilder return false; Value argv[] = { v1, v2, v3, v4, loc }; AutoValueArray ava(cx, argv, 5); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } Value argv[] = { v1, v2, v3, v4 }; AutoValueArray ava(cx, argv, 4); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } bool callback(HandleValue fun, HandleValue v1, HandleValue v2, HandleValue v3, HandleValue v4, @@ -283,12 +283,12 @@ class NodeBuilder return false; Value argv[] = { v1, v2, v3, v4, v5, loc }; AutoValueArray ava(cx, argv, 6); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } Value argv[] = { v1, v2, v3, v4, v5 }; AutoValueArray ava(cx, argv, 5); - return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst.address()); + return Invoke(cx, userv, fun, ArrayLength(argv), argv, dst); } // WARNING: Returning a Handle is non-standard, but it works in this case diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index df44659794d..b03e34ba629 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -3831,7 +3831,7 @@ js::ValueToSource(JSContext *cx, const Value &v) if (!JSObject::getProperty(cx, obj, obj, cx->names().toSource, &fval)) return NULL; if (js_IsCallable(fval)) { - if (!Invoke(cx, ObjectValue(*obj), fval, 0, NULL, rval.address())) + if (!Invoke(cx, ObjectValue(*obj), fval, 0, NULL, &rval)) return NULL; } diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 00066f86e23..b3812f5181f 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -565,7 +565,7 @@ Debugger::slowPathOnLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool frame /* Call the onPop handler. */ RootedValue rval(cx); bool hookOk = Invoke(cx, ObjectValue(*frameobj), handler, 1, completion.address(), - rval.address()); + &rval); RootedValue nextValue(cx); JSTrapStatus nextStatus = dbg->parseResumptionValue(ac, hookOk, rval, &nextValue); @@ -758,7 +758,7 @@ Debugger::handleUncaughtExceptionHelper(Maybe &ac, Value exc = cx->getPendingException(); RootedValue rv(cx); cx->clearPendingException(); - if (Invoke(cx, ObjectValue(*object), fval, 1, &exc, rv.address())) + if (Invoke(cx, ObjectValue(*object), fval, 1, &exc, &rv)) return vp ? parseResumptionValue(ac, true, rv, *vp, false) : JSTRAP_CONTINUE; } @@ -912,11 +912,11 @@ Debugger::parseResumptionValue(Maybe &ac, bool ok, const Value return shape->propid() == returnId ? JSTRAP_RETURN : JSTRAP_THROW; } -bool +static bool CallMethodIfPresent(JSContext *cx, HandleObject obj, const char *name, int argc, Value *argv, - Value *rval) + MutableHandleValue rval) { - rval->setUndefined(); + rval.setUndefined(); JSAtom *atom = Atomize(cx, name, strlen(name)); if (!atom) return false; @@ -944,7 +944,7 @@ Debugger::fireDebuggerStatement(JSContext *cx, MutableHandleValue vp) return handleUncaughtException(ac, vp, false); RootedValue rv(cx); - bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), rv.address()); + bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), &rv); return parseResumptionValue(ac, ok, rv, vp); } @@ -971,7 +971,7 @@ Debugger::fireExceptionUnwind(JSContext *cx, MutableHandleValue vp) return handleUncaughtException(ac, vp, false); RootedValue rv(cx); - bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 2, argv, rv.address()); + bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 2, argv, &rv); JSTrapStatus st = parseResumptionValue(ac, ok, rv, vp); if (st == JSTRAP_CONTINUE) cx->setPendingException(exc); @@ -994,7 +994,7 @@ Debugger::fireEnterFrame(JSContext *cx, MutableHandleValue vp) return handleUncaughtException(ac, vp, false); RootedValue rv(cx); - bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), rv.address()); + bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), &rv); return parseResumptionValue(ac, ok, rv, vp); } @@ -1016,7 +1016,7 @@ Debugger::fireNewScript(JSContext *cx, HandleScript script) Value argv[1]; argv[0].setObject(*dsobj); - Value rv; + RootedValue rv(cx); if (!Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv)) handleUncaughtException(ac, true); } @@ -1170,7 +1170,7 @@ Debugger::onTrap(JSContext *cx, MutableHandleValue vp) return dbg->handleUncaughtException(ac, vp, false); RootedValue rv(cx); Rooted handler(cx, bp->handler); - bool ok = CallMethodIfPresent(cx, handler, "hit", 1, argv, rv.address()); + bool ok = CallMethodIfPresent(cx, handler, "hit", 1, argv, &rv); JSTrapStatus st = dbg->parseResumptionValue(ac, ok, rv, vp, true); if (st != JSTRAP_CONTINUE) return st; @@ -1283,7 +1283,7 @@ Debugger::onSingleStep(JSContext *cx, MutableHandleValue vp) const Value &handler = frame->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER); RootedValue rval(cx); - bool ok = Invoke(cx, ObjectValue(*frame), handler, 0, NULL, rval.address()); + bool ok = Invoke(cx, ObjectValue(*frame), handler, 0, NULL, &rval); JSTrapStatus st = dbg->parseResumptionValue(ac, ok, rval, vp); if (st != JSTRAP_CONTINUE) return st; @@ -1312,7 +1312,7 @@ Debugger::fireNewGlobalObject(JSContext *cx, Handle global, Muta return handleUncaughtException(ac, false); RootedValue rv(cx); - bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, rv.address()); + bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv); return parseResumptionValue(ac, ok, rv, vp); } @@ -4923,7 +4923,7 @@ ApplyOrCall(JSContext *cx, unsigned argc, Value *vp, ApplyOrCallMode mode) * compartment and populate args.rval(). */ RootedValue rval(cx); - bool ok = Invoke(cx, thisv, calleev, callArgc, callArgv, rval.address()); + bool ok = Invoke(cx, thisv, calleev, callArgc, callArgv, &rval); return dbg->receiveCompletionValue(ac, ok, rval, args.rval()); } diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index de3868bef78..c21ba6f0b18 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -503,7 +503,7 @@ js::Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct) bool js::Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, Value *argv, - Value *rval) + MutableHandleValue rval) { InvokeArgs args(cx); if (!args.init(argc)) @@ -529,7 +529,7 @@ js::Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, if (!Invoke(cx, args)) return false; - *rval = args.rval(); + rval.set(args.rval()); return true; } @@ -588,8 +588,8 @@ js::InvokeConstructor(JSContext *cx, const Value &fval, unsigned argc, Value *ar } bool -js::InvokeGetterOrSetter(JSContext *cx, JSObject *obj, const Value &fval, unsigned argc, Value *argv, - Value *rval) +js::InvokeGetterOrSetter(JSContext *cx, JSObject *obj, const Value &fval, unsigned argc, + Value *argv, MutableHandleValue rval) { /* * Invoke could result in another try to get or set the same id again, see diff --git a/js/src/vm/Interpreter.h b/js/src/vm/Interpreter.h index 6fa0de00116..66bda81f6cb 100644 --- a/js/src/vm/Interpreter.h +++ b/js/src/vm/Interpreter.h @@ -131,7 +131,7 @@ Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct = NO_CONSTRUCT); */ extern bool Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, Value *argv, - Value *rval); + MutableHandleValue rval); /* * This helper takes care of the infinite-recursion check necessary for @@ -139,7 +139,7 @@ Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, Valu */ extern bool InvokeGetterOrSetter(JSContext *cx, JSObject *obj, const Value &fval, unsigned argc, Value *argv, - Value *rval); + MutableHandleValue rval); /* * InvokeConstructor implement a function call from a constructor context diff --git a/js/src/vm/Shape-inl.h b/js/src/vm/Shape-inl.h index ab2b1b43d4e..1863752f5a7 100644 --- a/js/src/vm/Shape-inl.h +++ b/js/src/vm/Shape-inl.h @@ -297,13 +297,14 @@ Shape::getUserId(JSContext *cx, MutableHandleId idp) const } inline bool -Shape::get(JSContext* cx, HandleObject receiver, JSObject* obj, JSObject *pobj, MutableHandleValue vp) +Shape::get(JSContext* cx, HandleObject receiver, JSObject* obj, JSObject *pobj, + MutableHandleValue vp) { JS_ASSERT(!hasDefaultGetter()); if (hasGetterValue()) { Value fval = getterValue(); - return InvokeGetterOrSetter(cx, receiver, fval, 0, 0, vp.address()); + return InvokeGetterOrSetter(cx, receiver, fval, 0, 0, vp); } Rooted self(cx, this); @@ -315,13 +316,14 @@ Shape::get(JSContext* cx, HandleObject receiver, JSObject* obj, JSObject *pobj, } inline bool -Shape::set(JSContext* cx, HandleObject obj, HandleObject receiver, bool strict, MutableHandleValue vp) +Shape::set(JSContext* cx, HandleObject obj, HandleObject receiver, bool strict, + MutableHandleValue vp) { JS_ASSERT_IF(hasDefaultSetter(), hasGetterValue()); if (attrs & JSPROP_SETTER) { Value fval = setterValue(); - return InvokeGetterOrSetter(cx, receiver, fval, 1, vp.address(), vp.address()); + return InvokeGetterOrSetter(cx, receiver, fval, 1, vp.address(), vp); } if (attrs & JSPROP_GETTER) From 4019955ea2b7482a378c462bc20238ab477f2ee7 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:14:24 +0200 Subject: [PATCH 22/28] Bug 888235 - Use CSSIntSize for nsGlobalWindow::GetInnerWidth/Height; f=kats r=mrbkap --- dom/base/nsGlobalWindow.cpp | 60 ++++++++++++++++++------------------- dom/base/nsGlobalWindow.h | 5 ++++ layout/base/Units.h | 6 ++++ 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index a2db2d67a5b..1a2aaebe1f7 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -4061,11 +4061,10 @@ nsGlobalWindow::CSSToDevIntPixels(nsIntSize px) presContext->CSSPixelsToDevPixels(px.height)); } - -NS_IMETHODIMP -nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth) +nsresult +nsGlobalWindow::GetInnerSize(CSSIntSize& aSize) { - FORWARD_TO_OUTER(GetInnerWidth, (aInnerWidth), NS_ERROR_NOT_INITIALIZED); + MOZ_ASSERT(IsOuterWindow()); EnsureSizeUpToDate(); @@ -4075,17 +4074,29 @@ nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth) mDocShell->GetPresContext(getter_AddRefs(presContext)); nsRefPtr presShell = mDocShell->GetPresShell(); - if (presContext && presShell) { - nsRefPtr viewManager = presShell->GetViewManager(); - if (viewManager) { - viewManager->FlushDelayedResize(false); - } - nsRect shellArea = presContext->GetVisibleArea(); - *aInnerWidth = nsPresContext::AppUnitsToIntCSSPixels(shellArea.width); - } else { - *aInnerWidth = 0; + if (!presContext || !presShell) { + aSize = CSSIntSize(0, 0); + return NS_OK; } + nsRefPtr viewManager = presShell->GetViewManager(); + if (viewManager) { + viewManager->FlushDelayedResize(false); + } + aSize = CSSIntRect::FromAppUnitsRounded(presContext->GetVisibleArea().Size()); + return NS_OK; +} + +NS_IMETHODIMP +nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth) +{ + FORWARD_TO_OUTER(GetInnerWidth, (aInnerWidth), NS_ERROR_NOT_INITIALIZED); + + CSSIntSize size; + nsresult rv = GetInnerSize(size); + NS_ENSURE_SUCCESS(rv, rv); + + *aInnerWidth = size.width; return NS_OK; } @@ -4140,24 +4151,11 @@ nsGlobalWindow::GetInnerHeight(int32_t* aInnerHeight) { FORWARD_TO_OUTER(GetInnerHeight, (aInnerHeight), NS_ERROR_NOT_INITIALIZED); - EnsureSizeUpToDate(); + CSSIntSize size; + nsresult rv = GetInnerSize(size); + NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_STATE(mDocShell); - - nsRefPtr presContext; - mDocShell->GetPresContext(getter_AddRefs(presContext)); - nsRefPtr presShell = mDocShell->GetPresShell(); - - if (presContext && presShell) { - nsRefPtr viewManager = presShell->GetViewManager(); - if (viewManager) { - viewManager->FlushDelayedResize(false); - } - nsRect shellArea = presContext->GetVisibleArea(); - *aInnerHeight = nsPresContext::AppUnitsToIntCSSPixels(shellArea.height); - } else { - *aInnerHeight = 0; - } + *aInnerHeight = size.height; return NS_OK; } @@ -10855,6 +10853,8 @@ nsGlobalWindow::FlushPendingNotifications(mozFlushType aType) void nsGlobalWindow::EnsureSizeUpToDate() { + MOZ_ASSERT(IsOuterWindow()); + // If we're a subframe, make sure our size is up to date. It's OK that this // crosses the content/chrome boundary, since chrome can have pending reflows // too. diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index aab22536c26..9028d274f89 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -65,6 +65,7 @@ #include "nsIDocument.h" #include "mozilla/dom/EventTarget.h" +#include "Units.h" // JS includes #include "jsapi.h" @@ -442,6 +443,7 @@ public: void DispatchDOMWindowCreated(); virtual NS_HIDDEN_(void) SetOpenerWindow(nsIDOMWindow* aOpener, bool aOriginalOpener); + // Outer windows only. virtual NS_HIDDEN_(void) EnsureSizeUpToDate(); virtual NS_HIDDEN_(nsIDOMWindow*) EnterModalState(); @@ -996,6 +998,9 @@ protected: bool aDoFlush); nsresult GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY); + // Outer windows only. + nsresult GetInnerSize(mozilla::CSSIntSize& aSize); + nsresult GetOuterSize(nsIntSize* aSizeCSSPixels); nsresult SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth); nsRect GetInnerScreenRect(); diff --git a/layout/base/Units.h b/layout/base/Units.h index 03b705d68d7..13143aa52b0 100644 --- a/layout/base/Units.h +++ b/layout/base/Units.h @@ -85,6 +85,12 @@ struct CSSPixel { NSAppUnitsToIntPixels(aPoint.y, float(nsDeviceContext::AppUnitsPerCSSPixel()))); } + static CSSIntSize FromAppUnitsRounded(const nsSize& aSize) + { + return CSSIntSize(NSAppUnitsToIntPixels(aSize.width, float(nsDeviceContext::AppUnitsPerCSSPixel())), + NSAppUnitsToIntPixels(aSize.height, float(nsDeviceContext::AppUnitsPerCSSPixel()))); + } + static CSSIntRect FromAppUnitsRounded(const nsRect& aRect) { return CSSIntRect(NSAppUnitsToIntPixels(aRect.x, float(nsDeviceContext::AppUnitsPerCSSPixel())), NSAppUnitsToIntPixels(aRect.y, float(nsDeviceContext::AppUnitsPerCSSPixel())), From 7b4e543404ab5223f8627edf3ab95c0ab4739025 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:14:34 +0200 Subject: [PATCH 23/28] Bug 888318 - Use CSSIntPoint for nsGlobalWindow::ScrollTo; f=kats r=mrbkap --- dom/base/nsGlobalWindow.cpp | 32 ++++++++++++++++++++------------ dom/base/nsGlobalWindow.h | 2 ++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 1a2aaebe1f7..731c678e2a0 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6034,11 +6034,19 @@ nsGlobalWindow::GetTopWindowRoot() NS_IMETHODIMP nsGlobalWindow::Scroll(int32_t aXScroll, int32_t aYScroll) { - return ScrollTo(aXScroll, aYScroll); + ScrollTo(CSSIntPoint(aXScroll, aYScroll)); + return NS_OK; } NS_IMETHODIMP nsGlobalWindow::ScrollTo(int32_t aXScroll, int32_t aYScroll) +{ + ScrollTo(CSSIntPoint(aXScroll, aYScroll)); + return NS_OK; +} + +void +nsGlobalWindow::ScrollTo(const CSSIntPoint& aScroll) { FlushPendingNotifications(Flush_Layout); nsIScrollableFrame *sf = GetScrollFrame(); @@ -6046,22 +6054,21 @@ nsGlobalWindow::ScrollTo(int32_t aXScroll, int32_t aYScroll) if (sf) { // Here we calculate what the max pixel value is that we can // scroll to, we do this by dividing maxint with the pixel to - // twips conversion factor, and substracting 4, the 4 comes from + // twips conversion factor, and subtracting 4, the 4 comes from // experimenting with this value, anything less makes the view // code not scroll correctly, I have no idea why. -- jst const int32_t maxpx = nsPresContext::AppUnitsToIntCSSPixels(0x7fffffff) - 4; - if (aXScroll > maxpx) { - aXScroll = maxpx; + CSSIntPoint scroll(aScroll); + if (scroll.x > maxpx) { + scroll.x = maxpx; } - if (aYScroll > maxpx) { - aYScroll = maxpx; + if (scroll.y > maxpx) { + scroll.y = maxpx; } - sf->ScrollToCSSPixels(nsIntPoint(aXScroll, aYScroll)); + sf->ScrollToCSSPixels(nsIntPoint(scroll.x, scroll.y)); } - - return NS_OK; } NS_IMETHODIMP @@ -6071,12 +6078,13 @@ nsGlobalWindow::ScrollBy(int32_t aXScrollDif, int32_t aYScrollDif) nsIScrollableFrame *sf = GetScrollFrame(); if (sf) { - nsPoint scrollPos = sf->GetScrollPosition(); + CSSIntPoint scrollPos = + CSSIntPoint::FromAppUnitsRounded(sf->GetScrollPosition()) + + CSSIntPoint(aXScrollDif, aYScrollDif); // It seems like it would make more sense for ScrollBy to use // SMOOTH mode, but tests seem to depend on the synchronous behaviour. // Perhaps Web content does too. - return ScrollTo(nsPresContext::AppUnitsToIntCSSPixels(scrollPos.x) + aXScrollDif, - nsPresContext::AppUnitsToIntCSSPixels(scrollPos.y) + aYScrollDif); + ScrollTo(scrollPos); } return NS_OK; diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 9028d274f89..38a5619eba3 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1005,6 +1005,8 @@ protected: nsresult SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth); nsRect GetInnerScreenRect(); + void ScrollTo(const mozilla::CSSIntPoint& aScroll); + bool IsFrame() { return GetParentInternal() != nullptr; From 9a38df8e5669b51cbb0994944dee2b0d975eb066 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:14:36 +0200 Subject: [PATCH 24/28] Bug 888321 - Pass CSSIntPoint to ScrollToCSSPixels; f=kats r=roc --- content/base/public/Element.h | 9 +++++---- dom/base/nsGlobalWindow.cpp | 2 +- layout/generic/nsGfxScrollFrame.cpp | 5 ++--- layout/generic/nsGfxScrollFrame.h | 6 +++--- layout/generic/nsIScrollableFrame.h | 2 +- layout/xul/base/src/nsScrollBoxObject.cpp | 4 +++- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/content/base/public/Element.h b/content/base/public/Element.h index 8f67a72674b..632f6a6d942 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -39,6 +39,7 @@ #include "nsAttrValue.h" #include "mozilla/dom/BindingDeclarations.h" #include "nsIHTMLCollection.h" +#include "Units.h" class nsIDOMEventListener; class nsIFrame; @@ -674,8 +675,8 @@ public: { nsIScrollableFrame* sf = GetScrollFrame(); if (sf) { - sf->ScrollToCSSPixels(nsIntPoint(sf->GetScrollPositionCSSPixels().x, - aScrollTop)); + sf->ScrollToCSSPixels(CSSIntPoint(sf->GetScrollPositionCSSPixels().x, + aScrollTop)); } } int32_t ScrollLeft() @@ -687,8 +688,8 @@ public: { nsIScrollableFrame* sf = GetScrollFrame(); if (sf) { - sf->ScrollToCSSPixels(nsIntPoint(aScrollLeft, - sf->GetScrollPositionCSSPixels().y)); + sf->ScrollToCSSPixels(CSSIntPoint(aScrollLeft, + sf->GetScrollPositionCSSPixels().y)); } } int32_t ScrollWidth(); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 731c678e2a0..07efaed7c2c 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6067,7 +6067,7 @@ nsGlobalWindow::ScrollTo(const CSSIntPoint& aScroll) if (scroll.y > maxpx) { scroll.y = maxpx; } - sf->ScrollToCSSPixels(nsIntPoint(scroll.x, scroll.y)); + sf->ScrollToCSSPixels(scroll); } } diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 8239e973c69..939d355810d 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1577,12 +1577,11 @@ nsGfxScrollFrameInner::AsyncScrollCallback(void* anInstance, mozilla::TimeStamp } void -nsGfxScrollFrameInner::ScrollToCSSPixels(nsIntPoint aScrollPosition) +nsGfxScrollFrameInner::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition) { nsPoint current = GetScrollPosition(); nsIntPoint currentCSSPixels = GetScrollPositionCSSPixels(); - nsPoint pt(nsPresContext::CSSPixelsToAppUnits(aScrollPosition.x), - nsPresContext::CSSPixelsToAppUnits(aScrollPosition.y)); + nsPoint pt = CSSPoint::ToAppUnits(aScrollPosition); nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f); nsRect range(pt.x - halfPixel, pt.y - halfPixel, 2*halfPixel - 1, 2*halfPixel - 1); // XXX I don't think the following blocks are needed anymore, now that diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index c6c0f9a9b48..ec749a0cabb 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -170,7 +170,7 @@ public: const nsRect* aRange = nullptr) { ScrollToWithOrigin(aScrollPosition, aMode, nsGkAtoms::other, aRange); } - void ScrollToCSSPixels(nsIntPoint aScrollPosition); + void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition); void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition); nsIntPoint GetScrollPositionCSSPixels(); void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange); @@ -519,7 +519,7 @@ public: const nsRect* aRange = nullptr) MOZ_OVERRIDE { mInner.ScrollTo(aScrollPosition, aMode, aRange); } - virtual void ScrollToCSSPixels(nsIntPoint aScrollPosition) MOZ_OVERRIDE { + virtual void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition) MOZ_OVERRIDE { mInner.ScrollToCSSPixels(aScrollPosition); } virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition) MOZ_OVERRIDE { @@ -783,7 +783,7 @@ public: const nsRect* aRange = nullptr) MOZ_OVERRIDE { mInner.ScrollTo(aScrollPosition, aMode, aRange); } - virtual void ScrollToCSSPixels(nsIntPoint aScrollPosition) MOZ_OVERRIDE { + virtual void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition) MOZ_OVERRIDE { mInner.ScrollToCSSPixels(aScrollPosition); } virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition) MOZ_OVERRIDE { diff --git a/layout/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index 430c683264c..837b56a1e27 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -156,7 +156,7 @@ public: * rounding to CSS pixels) will be exactly aScrollPosition. * The scroll mode is INSTANT. */ - virtual void ScrollToCSSPixels(nsIntPoint aScrollPosition) = 0; + virtual void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition) = 0; /** * Scrolls to a particular position in float CSS pixels. * This does not guarantee that GetScrollPositionCSSPixels equals diff --git a/layout/xul/base/src/nsScrollBoxObject.cpp b/layout/xul/base/src/nsScrollBoxObject.cpp index 41a1b3975a4..d408fb02e35 100644 --- a/layout/xul/base/src/nsScrollBoxObject.cpp +++ b/layout/xul/base/src/nsScrollBoxObject.cpp @@ -13,6 +13,8 @@ #include "nsIFrame.h" #include "nsIScrollableFrame.h" +using namespace mozilla; + class nsScrollBoxObject : public nsIScrollBoxObject, public nsBoxObject { public: @@ -54,7 +56,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollTo(int32_t x, int32_t y) nsIScrollableFrame* sf = GetScrollFrame(); if (!sf) return NS_ERROR_FAILURE; - sf->ScrollToCSSPixels(nsIntPoint(x, y)); + sf->ScrollToCSSPixels(CSSIntPoint(x, y)); return NS_OK; } From 2dcf517a55e556bccc0653cc4dce5e4b56c923a8 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 1 Jul 2013 09:14:36 +0200 Subject: [PATCH 25/28] Bug 888579 - Remove some code that handled WN Nodes; r=bholley --- dom/bindings/BindingUtils.cpp | 2 + js/xpconnect/src/XPCJSRuntime.cpp | 33 ++----- js/xpconnect/src/xpcprivate.h | 3 - js/xpconnect/wrappers/XrayWrapper.cpp | 135 +------------------------- 4 files changed, 10 insertions(+), 163 deletions(-) diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 9c3310758cc..ff71e66d944 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -636,6 +636,8 @@ NativeInterface2JSObjectAndThrowIfFailed(JSContext* aCx, bool TryPreserveWrapper(JSObject* obj) { + MOZ_ASSERT(IsDOMObject(obj)); + if (nsISupports* native = UnwrapDOMObjectToISupports(obj)) { nsWrapperCache* cache = nullptr; CallQueryInterface(native, &cache); diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 3892538f707..a56bcf55504 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1,6 +1,6 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=4 et sw=4 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -71,9 +71,6 @@ const char* XPCJSRuntime::mStrings[] = { "__proto__", // IDX_PROTO "__iterator__", // IDX_ITERATOR "__exposedProps__", // IDX_EXPOSEDPROPS - "baseURIObject", // IDX_BASEURIOBJECT - "nodePrincipal", // IDX_NODEPRINCIPAL - "mozMatchesSelector" // IDX_MOZMATCHESSELECTOR }; /***************************************************************************/ @@ -2514,29 +2511,13 @@ CompartmentNameCallback(JSRuntime *rt, JSCompartment *comp, } static bool -PreserveWrapper(JSContext *cx, JSObject *objArg) +PreserveWrapper(JSContext *cx, JSObject *obj) { MOZ_ASSERT(cx); - MOZ_ASSERT(objArg); - MOZ_ASSERT(js::GetObjectClass(objArg)->ext.isWrappedNative || - mozilla::dom::IsDOMObject(objArg)); + MOZ_ASSERT(obj); + MOZ_ASSERT(IS_WN_REFLECTOR(obj) || mozilla::dom::IsDOMObject(obj)); - RootedObject obj(cx, objArg); - XPCCallContext ccx(NATIVE_CALLER, cx); - if (!ccx.IsValid()) - return false; - - if (!IS_WN_REFLECTOR(obj)) - return mozilla::dom::TryPreserveWrapper(obj); - - nsISupports *supports = XPCWrappedNative::Get(obj)->Native(); - - // For pre-Paris DOM bindings objects, we only support Node. - if (nsCOMPtr node = do_QueryInterface(supports)) { - node->PreserveWrapper(supports); - return true; - } - return false; + return mozilla::dom::IsDOMObject(obj) && mozilla::dom::TryPreserveWrapper(obj); } static nsresult diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index cc6a82598d0..e74fb74f19c 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -717,9 +717,6 @@ public: IDX_PROTO , IDX_ITERATOR , IDX_EXPOSEDPROPS , - IDX_BASEURIOBJECT , - IDX_NODEPRINCIPAL , - IDX_MOZMATCHESSELECTOR , IDX_TOTAL_COUNT // just a count of the above }; diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 1803f442413..22fcd21feb2 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -11,9 +11,7 @@ #include "WaiveXrayWrapper.h" #include "WrapperFactory.h" -#include "nsINode.h" #include "nsIContent.h" -#include "nsIDocument.h" #include "nsContentUtils.h" #include "XPCWrapper.h" @@ -681,44 +679,6 @@ Is(JSObject *wrapper) static nsQueryInterface do_QueryInterfaceNative(JSContext* cx, HandleObject wrapper); -// Helper function to work around some limitations of the current XPC -// calling mechanism. See: bug 763897. -// The idea is that we unwrap the 'this' object, and find the wrapped -// native that belongs to it. Then we simply make the call directly -// on it after a Query Interface. -static JSBool -mozMatchesSelectorStub(JSContext *cx, unsigned argc, jsval *vp) -{ - if (argc < 1) { - JS_ReportError(cx, "Not enough arguments"); - return false; - } - - RootedObject wrapper(cx, JS_THIS_OBJECT(cx, vp)); - RootedString selector(cx, JS_ValueToString(cx, JS_ARGV(cx, vp)[0])); - if (!selector) { - return false; - } - nsDependentJSString selectorStr; - NS_ENSURE_TRUE(selectorStr.init(cx, selector), false); - - nsCOMPtr element = do_QueryInterfaceNative(cx, wrapper); - if (!element) { - JS_ReportError(cx, "Unexpected object"); - return false; - } - - bool ret; - nsresult rv = element->MozMatchesSelector(selectorStr, &ret); - if (NS_FAILED(rv)) { - XPCThrower::Throw(rv, cx); - return false; - } - - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - return true; -} - void XPCWrappedNativeXrayTraits::preserveWrapper(JSObject *target) { @@ -735,28 +695,6 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr JSPropertyDescriptor *desc, unsigned flags) { MOZ_ASSERT(js::GetObjectJSClass(holder) == &HolderClass); - XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance(); - if (id == rt->GetStringID(XPCJSRuntime::IDX_MOZMATCHESSELECTOR) && - Is(wrapper)) - { - // XPC calling mechanism cannot handle call/bind properly in some cases - // especially through xray wrappers. This is a temporary work around for - // this problem for mozMatchesSelector. See: bug 763897. - desc->obj = wrapper; - desc->attrs = JSPROP_ENUMERATE; - RootedObject proto(cx); - if (!JS_GetPrototype(cx, wrapper, proto.address())) - return false; - JSFunction *fun = JS_NewFunction(cx, mozMatchesSelectorStub, - 1, 0, proto, - "mozMatchesSelector"); - NS_ENSURE_TRUE(fun, false); - desc->value = OBJECT_TO_JSVAL(JS_GetFunctionObject(fun)); - desc->getter = NULL; - desc->setter = NULL; - desc->shortid = 0; - return true; - } desc->obj = NULL; @@ -855,60 +793,6 @@ wrappedJSObject_getter(JSContext *cx, HandleObject wrapper, HandleId id, Mutable return WrapperFactory::WaiveXrayAndWrap(cx, vp.address()); } -static JSBool -WrapURI(JSContext *cx, nsIURI *uri, MutableHandleValue vp) -{ - RootedObject scope(cx, JS_GetGlobalForScopeChain(cx)); - nsresult rv = - nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, scope, uri, nullptr, - &NS_GET_IID(nsIURI), true, - vp.address(), nullptr); - if (NS_FAILED(rv)) { - XPCThrower::Throw(rv, cx); - return false; - } - return true; -} - -static JSBool -baseURIObject_getter(JSContext *cx, HandleObject wrapper, HandleId id, MutableHandleValue vp) -{ - nsCOMPtr native = do_QueryInterfaceNative(cx, wrapper); - if (!native) { - JS_ReportError(cx, "Unexpected object"); - return false; - } - - nsCOMPtr uri = native->GetBaseURI(); - if (!uri) { - JS_ReportOutOfMemory(cx); - return false; - } - - return WrapURI(cx, uri, vp); -} - -static JSBool -nodePrincipal_getter(JSContext *cx, HandleObject wrapper, HandleId id, MutableHandleValue vp) -{ - nsCOMPtr node = do_QueryInterfaceNative(cx, wrapper); - if (!node) { - JS_ReportError(cx, "Unexpected object"); - return false; - } - - RootedObject scope(cx, JS_GetGlobalForScopeChain(cx)); - nsresult rv = - nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, scope, node->NodePrincipal(), nullptr, - &NS_GET_IID(nsIPrincipal), true, - vp.address(), nullptr); - if (NS_FAILED(rv)) { - XPCThrower::Throw(rv, cx); - return false; - } - return true; -} - bool XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper, HandleObject wrapper, HandleObject holder, HandleId id, @@ -973,23 +857,6 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper // Xray wrappers don't use the regular wrapper hierarchy, so we should be // in the wrapper's compartment here, not the wrappee. MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx)); - XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance(); - if (AccessCheck::isChrome(wrapper) && - ((id == rt->GetStringID(XPCJSRuntime::IDX_BASEURIOBJECT) || - id == rt->GetStringID(XPCJSRuntime::IDX_NODEPRINCIPAL)) && - Is(wrapper))) - { - desc->obj = wrapper; - desc->attrs = JSPROP_ENUMERATE|JSPROP_SHARED; - if (id == rt->GetStringID(XPCJSRuntime::IDX_BASEURIOBJECT)) - desc->getter = baseURIObject_getter; - else - desc->getter = nodePrincipal_getter; - desc->setter = NULL; - desc->shortid = 0; - desc->value = JSVAL_VOID; - return true; - } JSBool hasProp; if (!JS_HasPropertyById(cx, holder, id, &hasProp)) { @@ -1589,7 +1456,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wra // If we still have nothing, we're done. if (!desc->obj) - return true; + return true; if (!JS_DefinePropertyById(cx, holder, id, desc->value, desc->getter, desc->setter, desc->attrs) || From 9a12a377e696598515230275e6d6f820e7949423 Mon Sep 17 00:00:00 2001 From: Heather Arthur Date: Mon, 1 Jul 2013 01:38:16 -0700 Subject: [PATCH 26/28] Bug 887468 - Make custom request form look okay; r=vporof --- browser/devtools/netmonitor/netmonitor.xul | 7 ++----- browser/themes/linux/devtools/netmonitor.css | 4 ++++ browser/themes/osx/devtools/netmonitor.css | 4 ++++ browser/themes/windows/devtools/netmonitor.css | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/browser/devtools/netmonitor/netmonitor.xul b/browser/devtools/netmonitor/netmonitor.xul index 48165c5376f..f02b943243d 100644 --- a/browser/devtools/netmonitor/netmonitor.xul +++ b/browser/devtools/netmonitor/netmonitor.xul @@ -225,10 +225,7 @@ class="tabpanel-summary-container" align="center"> + oninput="NetMonitorView.CustomRequest.onUpdate('method');"/> @@ -251,7 +248,7 @@ diff --git a/browser/themes/linux/devtools/netmonitor.css b/browser/themes/linux/devtools/netmonitor.css index 59a2854009c..3937d9bde48 100644 --- a/browser/themes/linux/devtools/netmonitor.css +++ b/browser/themes/linux/devtools/netmonitor.css @@ -441,6 +441,10 @@ box.requests-menu-status[code^="5"] { margin-top: 0.5em; } +#custom-method-value { + width: 4.5em; +} + /* Footer */ #requests-menu-footer { diff --git a/browser/themes/osx/devtools/netmonitor.css b/browser/themes/osx/devtools/netmonitor.css index ad31a365888..54e4ab07d42 100644 --- a/browser/themes/osx/devtools/netmonitor.css +++ b/browser/themes/osx/devtools/netmonitor.css @@ -441,6 +441,10 @@ box.requests-menu-status[code^="5"] { margin-top: 0.5em; } +#custom-method-value { + width: 4.5em; +} + /* Footer */ #requests-menu-footer { diff --git a/browser/themes/windows/devtools/netmonitor.css b/browser/themes/windows/devtools/netmonitor.css index 1dc29e0676d..b82c80098c9 100644 --- a/browser/themes/windows/devtools/netmonitor.css +++ b/browser/themes/windows/devtools/netmonitor.css @@ -441,6 +441,10 @@ box.requests-menu-status[code^="5"] { margin-top: 0.5em; } +#custom-method-value { + width: 4.5em; +} + /* Footer */ #requests-menu-footer { From f40dfee213808466663cff531eece1d34712a172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Mon, 1 Jul 2013 11:33:28 +0200 Subject: [PATCH 27/28] Backed out changeset 7965d384123c --- browser/base/content/urlbarBindings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index d3519ffadb7..bd8318209ac 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -159,7 +159,7 @@ true Date: Mon, 1 Jul 2013 13:55:08 +0200 Subject: [PATCH 28/28] Bug 888746 - browser_bug422590.js should enable location bar, r=dao --- browser/base/content/test/browser_bug422590.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/base/content/test/browser_bug422590.js b/browser/base/content/test/browser_bug422590.js index 2ecb4c0b94a..f26919cc51b 100644 --- a/browser/base/content/test/browser_bug422590.js +++ b/browser/base/content/test/browser_bug422590.js @@ -7,7 +7,7 @@ function test() { function testChromeless() { // test a chromeless window var newWin = openDialog(getBrowserURL(), "_blank", - "chrome,dialog=no,toolbar=no", "about:blank"); + "chrome,dialog=no,location=yes,toolbar=no", "about:blank"); ok(newWin, "got new window"); whenDelayedStartupFinished(newWin, function () {