Merge inbound to m-c. a=merge

This commit is contained in:
Ryan VanderMeulen 2016-01-13 20:25:33 -05:00
commit 065a253bf1
159 changed files with 3081 additions and 1881 deletions

View File

@ -218,11 +218,13 @@ ToNSString(id aValue)
int32_t start = range.location;
int32_t end = start + range.length;
nsIntRect bounds;
DesktopIntRect bounds;
if (textAcc) {
bounds = textAcc->TextBounds(start, end);
bounds =
DesktopIntRect::FromUnknownRect(textAcc->TextBounds(start, end));
} else if (proxy) {
bounds = proxy->TextBounds(start, end);
bounds =
DesktopIntRect::FromUnknownRect(proxy->TextBounds(start, end));
}
return [NSValue valueWithRect:nsCocoaUtils::GeckoRectToCocoaRect(bounds)];

View File

@ -28,7 +28,7 @@
</ms_asmv3:trustInfo>
<ms_asmv3:application xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3">
<ms_asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
<dpiAware>True/PM</dpiAware>
</ms_asmv3:windowsSettings>
</ms_asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">

View File

@ -4,6 +4,10 @@
#aboutDialog {
width: 620px;
/* Set an explicit line-height to avoid discrepancies in 'auto' spacing
across screens with different device DPI, which may cause font metrics
to round differently. */
line-height: 1.5;
}
#rightBox {

View File

@ -3476,6 +3476,9 @@ var SessionStoreInternal = {
}
// only modify those aspects which aren't correct yet
if (!isNaN(aLeft) && !isNaN(aTop) && (aLeft != win_("screenX") || aTop != win_("screenY"))) {
aWindow.moveTo(aLeft, aTop);
}
if (aWidth && aHeight && (aWidth != win_("width") || aHeight != win_("height"))) {
// Don't resize the window if it's currently maximized and we would
// maximize it again shortly after.
@ -3483,9 +3486,6 @@ var SessionStoreInternal = {
aWindow.resizeTo(aWidth, aHeight);
}
}
if (!isNaN(aLeft) && !isNaN(aTop) && (aLeft != win_("screenX") || aTop != win_("screenY"))) {
aWindow.moveTo(aLeft, aTop);
}
if (aSizeMode && win_("sizemode") != aSizeMode)
{
switch (aSizeMode)

View File

@ -12,7 +12,7 @@ AC_DEFUN([MOZ_RUST_SUPPORT], [
_RUSTC_MINOR_VERSION=`echo ${RUSTC_VERSION} | cut -d . -f 2`
_RUSTC_EXTRA_VERSION=`echo ${RUSTC_VERSION} | cut -d . -f 3 | cut -d + -f 1`
_RUSTC_PATCH_VERSION=`echo ${_RUSTC_EXTRA_VERSION} | cut -d '-' -f 1`
AC_MSG_RESULT([$RUSTC_VERSION (v${_RUSTC_MAJOR_VERSION}.${_RUSTC_MINOR_VERSION}.${_RUSTC_PATCH_VERSION})])
AC_MSG_RESULT([${_RUSTC_MAJOR_VERSION}.${_RUSTC_MINOR_VERSION}.${_RUSTC_PATCH_VERSION} ($RUSTC_VERSION)])
fi
MOZ_ARG_ENABLE_BOOL([rust],
[ --enable-rust Include Rust language sources],

View File

@ -902,6 +902,7 @@ $(HOST_COBJS):
$(HOST_CPPOBJS):
$(REPORT_BUILD)
$(call BUILDSTATUS,OBJECT_FILE $@)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CMOBJS):
@ -954,6 +955,7 @@ $(SOBJS):
$(CPPOBJS):
$(REPORT_BUILD)
$(call BUILDSTATUS,OBJECT_FILE $@)
@$(MAKE_DEPS_AUTO_CXX)
$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)

View File

@ -3500,12 +3500,14 @@ AC_MSG_CHECKING([for YASM assembler])
AC_CHECK_PROGS(YASM, yasm, "")
if test -n "$YASM"; then
AC_MSG_CHECKING([yasm version])
dnl Pull out yasm's version string
YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
_YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
_YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
_YASM_RELEASE=` echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
_YASM_BUILD=` echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
AC_MSG_RESULT([$_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.$_YASM_RELEASE ($YASM_VERSION)])
fi
if test -z "$SKIP_LIBRARY_CHECKS"; then

View File

@ -5782,6 +5782,23 @@ nsDocShell::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetDevicePixelsPerDesktopPixel(double* aScale)
{
if (mParentWidget) {
*aScale = mParentWidget->GetDesktopToDeviceScale().scale;
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> ownerWindow(do_QueryInterface(mTreeOwner));
if (ownerWindow) {
return ownerWindow->GetDevicePixelsPerDesktopPixel(aScale);
}
*aScale = 1.0;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetPosition(int32_t aX, int32_t aY)
{

View File

@ -1812,6 +1812,10 @@ nsMessageManagerScriptExecutor::InitChildGlobalInternal(
options.creationOptions().setZone(JS::SystemZone);
options.behaviors().setVersion(JSVERSION_LATEST);
if (xpc::SharedMemoryEnabled()) {
options.creationOptions().setSharedMemoryAndAtomicsEnabled(true);
}
nsresult rv =
xpc->InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
flags, options, getter_AddRefs(mGlobal));

View File

@ -5029,25 +5029,30 @@ nsGlobalWindow::SetOuterHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
aValue, "outerHeight", aError);
}
nsIntPoint
DesktopIntPoint
nsGlobalWindow::GetScreenXY(ErrorResult& aError)
{
MOZ_ASSERT(IsOuterWindow());
// When resisting fingerprinting, always return (0,0)
if (nsContentUtils::ShouldResistFingerprinting(mDocShell)) {
return nsIntPoint(0, 0);
return DesktopIntPoint(0, 0);
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
if (!treeOwnerAsWin) {
aError.Throw(NS_ERROR_FAILURE);
return nsIntPoint(0, 0);
return DesktopIntPoint(0, 0);
}
int32_t x = 0, y = 0;
aError = treeOwnerAsWin->GetPosition(&x, &y);
return nsIntPoint(x, y);
nsCOMPtr<nsIWidget> widget = GetMainWidget();
DesktopToLayoutDeviceScale scale = widget ? widget->GetDesktopToDeviceScale()
: DesktopToLayoutDeviceScale(1.0);
DesktopPoint pt = LayoutDeviceIntPoint(x, y) / scale;
return DesktopIntPoint(NSToIntRound(pt.x), NSToIntRound(pt.y));
}
int32_t
@ -5055,7 +5060,7 @@ nsGlobalWindow::GetScreenXOuter(ErrorResult& aError)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
return DevToCSSIntPixels(GetScreenXY(aError).x);
return GetScreenXY(aError).x;
}
int32_t
@ -5299,7 +5304,7 @@ nsGlobalWindow::GetScreenYOuter(ErrorResult& aError)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
return DevToCSSIntPixels(GetScreenXY(aError).y);
return GetScreenXY(aError).y;
}
int32_t
@ -7002,13 +7007,15 @@ nsGlobalWindow::MoveToOuter(int32_t aXPos, int32_t aYPos, ErrorResult& aError, b
return;
}
// Mild abuse of a "size" object so we don't need more helper functions.
nsIntSize cssPos(aXPos, aYPos);
CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height, aCallerIsChrome);
DesktopIntPoint pt(aXPos, aYPos);
CheckSecurityLeftAndTop(&pt.x, &pt.y, aCallerIsChrome);
nsIntSize devPos = CSSToDevIntPixels(cssPos);
nsCOMPtr<nsIWidget> widget = GetMainWidget();
DesktopToLayoutDeviceScale scale = widget ? widget->GetDesktopToDeviceScale()
: DesktopToLayoutDeviceScale(1.0);
LayoutDevicePoint devPos = pt * scale;
aError = treeOwnerAsWin->SetPosition(devPos.width, devPos.height);
aError = treeOwnerAsWin->SetPosition(devPos.x, devPos.y);
}
void

View File

@ -1606,8 +1606,8 @@ protected:
// Outer windows only.
void PreloadLocalStorage();
// Returns device pixels. Outer windows only.
nsIntPoint GetScreenXY(mozilla::ErrorResult& aError);
// Returns desktop pixels. Outer windows only.
mozilla::DesktopIntPoint GetScreenXY(mozilla::ErrorResult& aError);
nsGlobalWindow* InnerForSetTimeoutOrInterval(mozilla::ErrorResult& aError);

View File

@ -3022,6 +3022,9 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
JS::MutableHandle<JSObject*> aGlobal)
{
aOptions.creationOptions().setTrace(CreateGlobalOptions<T>::TraceGlobal);
if (xpc::SharedMemoryEnabled()) {
aOptions.creationOptions().setSharedMemoryAndAtomicsEnabled(true);
}
aGlobal.set(JS_NewGlobalObject(aCx, aClass, aPrincipal,
JS::DontFireOnNewGlobalHook, aOptions));

View File

@ -833,27 +833,6 @@ DataTransfer::SetDragImage(nsIDOMElement* aImage, int32_t aX, int32_t aY)
return rv.StealNSResult();
}
static already_AddRefed<OSFileSystem>
MakeOrReuseFileSystem(const nsAString& aNewLocalRootPath,
OSFileSystem* aFS,
nsPIDOMWindow* aWindow)
{
MOZ_ASSERT(aWindow);
RefPtr<OSFileSystem> fs;
if (aFS) {
const nsAString& prevLocalRootPath = aFS->GetLocalRootPath();
if (aNewLocalRootPath == prevLocalRootPath) {
fs = aFS;
}
}
if (!fs) {
fs = new OSFileSystem(aNewLocalRootPath);
fs->Init(aWindow);
}
return fs.forget();
}
already_AddRefed<Promise>
DataTransfer::GetFilesAndDirectories(ErrorResult& aRv)
{
@ -890,9 +869,6 @@ DataTransfer::GetFilesAndDirectories(ErrorResult& aRv)
return p.forget();
}
nsPIDOMWindow* window = parentNode->OwnerDoc()->GetInnerWindow();
RefPtr<OSFileSystem> fs;
for (uint32_t i = 0; i < mFiles->Length(); ++i) {
if (mFiles->Item(i)->Impl()->IsDirectory()) {
#if defined(ANDROID) || defined(MOZ_B2G)
@ -909,7 +885,10 @@ DataTransfer::GetFilesAndDirectories(ErrorResult& aRv)
int32_t leafSeparatorIndex = path.RFind(FILE_PATH_SEPARATOR);
nsDependentSubstring dirname = Substring(path, 0, leafSeparatorIndex);
nsDependentSubstring basename = Substring(path, leafSeparatorIndex);
fs = MakeOrReuseFileSystem(dirname, fs, window);
RefPtr<OSFileSystem> fs = new OSFileSystem(dirname);
fs->Init(parentNode->OwnerDoc()->GetInnerWindow());
RefPtr<Directory> directory = new Directory(fs, basename);
directory->SetContentFilters(NS_LITERAL_STRING("filter-out-sensitive"));
filesAndDirsSeq[i].SetAsDirectory() = directory;

View File

@ -20,15 +20,20 @@
#include "nsContentUtils.h"
#include "nsContentPermissionHelper.h"
#include "nsIDocument.h"
#include "nsIDOMEvent.h"
#include "nsIObserverService.h"
#include "nsPIDOMWindow.h"
#include "nsThreadUtils.h"
#include "mozilla/HalWakeLock.h"
#include "mozilla/Hal.h"
#include "mozilla/Services.h"
#include "mozilla/unused.h"
#include "mozilla/Preferences.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/SettingChangeNotificationBinding.h"
#include "mozilla/dom/WakeLock.h"
#include "nsJSUtils.h"
#include "prdtoa.h"
@ -66,6 +71,7 @@ class nsIPrincipal;
using mozilla::Unused; // <snicker>
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::hal;
class nsGeolocationRequest final
: public nsIContentPermissionRequest
@ -499,6 +505,10 @@ nsGeolocationRequest::Allow(JS::HandleValue aChoices)
}
}
if (mLocator->ContainsRequest(this)) {
return NS_OK;
}
if (mIsWatchPositionRequest || !canUseCache) {
// let the locator know we're pending
// we will now be owned by the locator
@ -1044,6 +1054,16 @@ nsGeolocationService::StartDevice(nsIPrincipal *aPrincipal)
return NS_OK;
}
void
nsGeolocationService::StopDisconnectTimer()
{
if (mDisconnectTimer) {
mDisconnectTimer->Cancel();
mDisconnectTimer = nullptr;
}
}
void
nsGeolocationService::SetDisconnectTimer()
{
@ -1096,10 +1116,7 @@ nsGeolocationService::UpdateAccuracy(bool aForceHigh)
void
nsGeolocationService::StopDevice()
{
if(mDisconnectTimer) {
mDisconnectTimer->Cancel();
mDisconnectTimer = nullptr;
}
StopDisconnectTimer();
if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
@ -1209,6 +1226,14 @@ Geolocation::Init(nsIDOMWindow* aContentDom)
}
mPrincipal = doc->NodePrincipal();
if (XRE_IsContentProcess()) {
doc->AddSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
/* listener */ this,
/* use capture */ true,
/* wants untrusted */ false);
}
}
// If no aContentDom was passed into us, we are being used
@ -1221,6 +1246,58 @@ Geolocation::Init(nsIDOMWindow* aContentDom)
return NS_OK;
}
bool
Geolocation::ContainsRequest(nsGeolocationRequest* aRequest)
{
if (aRequest->IsWatch()) {
if (mWatchingCallbacks.Contains(aRequest)) {
return true;
}
} else {
if (mPendingCallbacks.Contains(aRequest)) {
return true;
}
}
return false;
}
NS_IMETHODIMP
Geolocation::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString type;
aEvent->GetType(type);
if (!type.EqualsLiteral("visibilitychange")) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
MOZ_ASSERT(doc);
if (doc->Hidden()) {
WakeLockInformation info;
GetWakeLockInfo(NS_LITERAL_STRING("gps"), &info);
MOZ_ASSERT(XRE_IsContentProcess());
ContentChild* cpc = ContentChild::GetSingleton();
if (!info.lockingProcesses().Contains(cpc->GetID())) {
cpc->SendRemoveGeolocationListener();
mService->StopDisconnectTimer();
}
} else {
mService->SetDisconnectTimer();
for (uint32_t i = 0, length = mWatchingCallbacks.Length(); i < length; ++i) {
mWatchingCallbacks[i]->Allow(JS::UndefinedHandleValue);
}
for (uint32_t i = 0, length = mPendingCallbacks.Length(); i < length; ++i) {
mPendingCallbacks[i]->Allow(JS::UndefinedHandleValue);
}
}
return NS_OK;
}
void
Geolocation::Shutdown()
{
@ -1228,6 +1305,18 @@ Geolocation::Shutdown()
mPendingCallbacks.Clear();
mWatchingCallbacks.Clear();
if (XRE_IsContentProcess()) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mOwner);
if (window) {
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (doc) {
doc->RemoveSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
this,
/* useCapture = */ true);
}
}
}
if (mService) {
mService->RemoveLocator(this);
mService->UpdateAccuracy();

View File

@ -22,6 +22,7 @@
#include "nsCycleCollectionParticipant.h"
#include "nsGeoPosition.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMGeoGeolocation.h"
#include "nsIDOMGeoPosition.h"
#include "nsIDOMGeoPositionError.h"
@ -91,6 +92,7 @@ public:
// create, or reinitalize the callback timer
void SetDisconnectTimer();
void StopDisconnectTimer();
// Update the accuracy and notify the provider if changed
void UpdateAccuracy(bool aForceHigh = false);
@ -128,7 +130,8 @@ namespace dom {
*/
class Geolocation final : public nsIDOMGeoGeolocation,
public nsIGeolocationUpdate,
public nsWrapperCache
public nsWrapperCache,
public nsIDOMEventListener
{
public:
@ -138,6 +141,8 @@ public:
NS_DECL_NSIGEOLOCATIONUPDATE
NS_DECL_NSIDOMGEOGEOLOCATION
NS_DECL_NSIDOMEVENTLISTENER
Geolocation();
nsresult Init(nsIDOMWindow* contentDom=nullptr);
@ -154,6 +159,9 @@ public:
// Register an allowed request
void NotifyAllowedRequest(nsGeolocationRequest* aRequest);
// Check if callbacks arrays already contain this request
bool ContainsRequest(nsGeolocationRequest* aRequest);
// Remove request from all callbacks arrays
void RemoveRequest(nsGeolocationRequest* request);

View File

@ -2487,7 +2487,8 @@ HTMLInputElement::GetFiles()
return nullptr;
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::directory)) {
if (Preferences::GetBool("dom.input.dirpicker", false) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::directory)) {
return nullptr;
}
@ -4872,27 +4873,6 @@ HTMLInputElement::ChooseDirectory(ErrorResult& aRv)
);
}
static already_AddRefed<OSFileSystem>
MakeOrReuseFileSystem(const nsAString& aNewLocalRootPath,
OSFileSystem* aFS,
nsPIDOMWindow* aWindow)
{
MOZ_ASSERT(aWindow);
RefPtr<OSFileSystem> fs;
if (aFS) {
const nsAString& prevLocalRootPath = aFS->GetLocalRootPath();
if (aNewLocalRootPath == prevLocalRootPath) {
fs = aFS;
}
}
if (!fs) {
fs = new OSFileSystem(aNewLocalRootPath);
fs->Init(aWindow);
}
return fs.forget();
}
already_AddRefed<Promise>
HTMLInputElement::GetFilesAndDirectories(ErrorResult& aRv)
{
@ -4925,8 +4905,6 @@ HTMLInputElement::GetFilesAndDirectories(ErrorResult& aRv)
return p.forget();
}
nsPIDOMWindow* window = OwnerDoc()->GetInnerWindow();
RefPtr<OSFileSystem> fs;
for (uint32_t i = 0; i < filesAndDirs.Length(); ++i) {
if (filesAndDirs[i]->IsDirectory()) {
#if defined(ANDROID) || defined(MOZ_B2G)
@ -4942,7 +4920,10 @@ HTMLInputElement::GetFilesAndDirectories(ErrorResult& aRv)
}
int32_t leafSeparatorIndex = path.RFind(FILE_PATH_SEPARATOR);
nsDependentSubstring dirname = Substring(path, 0, leafSeparatorIndex);
fs = MakeOrReuseFileSystem(dirname, fs, window);
RefPtr<OSFileSystem> fs = new OSFileSystem(dirname);
fs->Init(OwnerDoc()->GetInnerWindow());
nsAutoString dompath(NS_LITERAL_STRING(FILESYSTEM_DOM_PATH_SEPARATOR));
dompath.Append(Substring(path, leafSeparatorIndex + 1));
RefPtr<Directory> directory = new Directory(fs, dompath);

View File

@ -114,7 +114,9 @@ VPXDecoder::DoDecodeFrame(MediaRawData* aSample)
vpx_image_t *img;
while ((img = vpx_codec_get_frame(&mVPX, &iter))) {
NS_ASSERTION(img->fmt == VPX_IMG_FMT_I420, "WebM image format not I420");
NS_ASSERTION(img->fmt == VPX_IMG_FMT_I420 ||
img->fmt == VPX_IMG_FMT_I444,
"WebM image format not I420 or I444");
// Chroma shifts are rounded down as per the decoding examples in the SDK
VideoData::YCbCrBuffer b;
@ -126,16 +128,29 @@ VPXDecoder::DoDecodeFrame(MediaRawData* aSample)
b.mPlanes[1].mData = img->planes[1];
b.mPlanes[1].mStride = img->stride[1];
b.mPlanes[1].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
b.mPlanes[1].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = img->planes[2];
b.mPlanes[2].mStride = img->stride[2];
b.mPlanes[2].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
b.mPlanes[2].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
if (img->fmt == VPX_IMG_FMT_I420) {
b.mPlanes[1].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
b.mPlanes[1].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
b.mPlanes[2].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
b.mPlanes[2].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
} else if (img->fmt == VPX_IMG_FMT_I444) {
b.mPlanes[1].mHeight = img->d_h;
b.mPlanes[1].mWidth = img->d_w;
b.mPlanes[2].mHeight = img->d_h;
b.mPlanes[2].mWidth = img->d_w;
} else {
LOG("VPX Unknown image format");
return -1;
}
VideoInfo info;
info.mDisplay = mInfo.mDisplay;
RefPtr<VideoData> v = VideoData::Create(info,

View File

@ -21,6 +21,7 @@
#define AVPixelFormat PixelFormat
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
#define AV_PIX_FMT_NONE PIX_FMT_NONE
#endif
@ -33,17 +34,24 @@ namespace mozilla
/**
* FFmpeg calls back to this function with a list of pixel formats it supports.
* We choose a pixel format that we support and return it.
* For now, we just look for YUV420P as it is the only non-HW accelerated format
* supported by FFmpeg's H264 decoder.
* For now, we just look for YUV420P, YUVJ420P and YUV444 as those are the only
* only non-HW accelerated format supported by FFmpeg's H264 and VP9 decoder.
*/
static AVPixelFormat
ChoosePixelFormat(AVCodecContext* aCodecContext, const AVPixelFormat* aFormats)
{
FFMPEG_LOG("Choosing FFmpeg pixel format for video decoding.");
for (; *aFormats > -1; aFormats++) {
if (*aFormats == AV_PIX_FMT_YUV420P || *aFormats == AV_PIX_FMT_YUVJ420P) {
FFMPEG_LOG("Requesting pixel format YUV420P.");
return AV_PIX_FMT_YUV420P;
switch (*aFormats) {
case AV_PIX_FMT_YUV444P:
FFMPEG_LOG("Requesting pixel format YUV444P.");
return AV_PIX_FMT_YUV444P;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUVJ420P:
FFMPEG_LOG("Requesting pixel format YUV420P.");
return AV_PIX_FMT_YUV420P;
default:
break;
}
}
@ -267,23 +275,27 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
VideoData::YCbCrBuffer b;
b.mPlanes[0].mData = mFrame->data[0];
b.mPlanes[0].mStride = mFrame->linesize[0];
b.mPlanes[0].mHeight = mFrame->height;
b.mPlanes[0].mWidth = mFrame->width;
b.mPlanes[0].mOffset = b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mData = mFrame->data[1];
b.mPlanes[1].mStride = mFrame->linesize[1];
b.mPlanes[1].mHeight = (mFrame->height + 1) >> 1;
b.mPlanes[1].mWidth = (mFrame->width + 1) >> 1;
b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = mFrame->data[2];
b.mPlanes[0].mStride = mFrame->linesize[0];
b.mPlanes[1].mStride = mFrame->linesize[1];
b.mPlanes[2].mStride = mFrame->linesize[2];
b.mPlanes[2].mHeight = (mFrame->height + 1) >> 1;
b.mPlanes[2].mWidth = (mFrame->width + 1) >> 1;
b.mPlanes[0].mOffset = b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
b.mPlanes[0].mWidth = mFrame->width;
b.mPlanes[0].mHeight = mFrame->height;
if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P) {
b.mPlanes[1].mWidth = b.mPlanes[2].mWidth = mFrame->width;
b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = mFrame->height;
} else {
b.mPlanes[1].mWidth = b.mPlanes[2].mWidth = (mFrame->width + 1) >> 1;
b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = (mFrame->height + 1) >> 1;
}
RefPtr<VideoData> v = VideoData::Create(info,
mImageContainer,
aSample->mOffset,

View File

@ -437,6 +437,9 @@ DedicatedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
behaviors.setDiscardSource(discardSource)
.extraWarningsOverride().set(extraWarnings);
JS::CompartmentCreationOptions& creationOptions = options.creationOptions();
creationOptions.setSharedMemoryAndAtomicsEnabled(xpc::SharedMemoryEnabled());
return DedicatedWorkerGlobalScopeBinding_workers::Wrap(aCx, this, this,
options,
GetWorkerPrincipal(),

View File

@ -560,6 +560,17 @@ nsDocShellTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsDocShellTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale)
{
if (mWebBrowser) {
return mWebBrowser->GetDevicePixelsPerDesktopPixel(aScale);
}
*aScale = 1.0;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellTreeOwner::SetPosition(int32_t aX, int32_t aY)
{

View File

@ -1294,6 +1294,14 @@ nsWebBrowser::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsWebBrowser::GetDevicePixelsPerDesktopPixel(double* aScale)
{
*aScale = mParentWidget ? mParentWidget->GetDesktopToDeviceScale().scale
: 1.0;
return NS_OK;
}
NS_IMETHODIMP
nsWebBrowser::SetPosition(int32_t aX, int32_t aY)
{

View File

@ -108,8 +108,7 @@ SOURCES += [
'src/compiler/translator/glslang_tab.cpp',
]
if CONFIG['GNU_CXX']:
if CONFIG['GNU_CXX'] or CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-attributes',
'-Wno-shadow',
@ -117,16 +116,16 @@ if CONFIG['GNU_CXX']:
'-Wno-unknown-pragmas',
'-Wno-unreachable-code',
]
if CONFIG['CLANG_CXX']:
CXXFLAGS += [
'-Wno-inconsistent-missing-override',
'-Wno-unused-private-field',
]
else:
CXXFLAGS += [
'-Wno-shadow-compatible-local',
'-Wno-shadow-local',
]
if CONFIG['GNU_CXX'] and not CONFIG['CLANG_CXX'] and not CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-shadow-compatible-local',
'-Wno-shadow-local',
]
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-inconsistent-missing-override',
'-Wno-unused-private-field',
]
if CONFIG['MOZ_DIRECTX_SDK_PATH'] and not CONFIG['MOZ_HAS_WINSDK_WITH_D3D']:
LOCAL_INCLUDES += ['%' + '%s/include/' % CONFIG['MOZ_DIRECTX_SDK_PATH']]

View File

@ -220,7 +220,7 @@ if CONFIG['MOZ_TREE_FREETYPE']:
DEFINES['FT_LCD_FILTER_H'] = '%s/modules/freetype2/include/freetype/ftlcdfil.h' % TOPSRCDIR
# Suppress warnings in third-party code.
if CONFIG['GNU_CC']:
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-enum-compare',
'-Wno-int-to-pointer-cast',
@ -229,13 +229,19 @@ if CONFIG['GNU_CC']:
'-Wno-missing-field-initializers',
'-Wno-conversion',
]
if CONFIG['CLANG_CXX']:
CFLAGS += [
'-Wno-incompatible-pointer-types',
'-Wno-tautological-compare',
'-Wno-tautological-constant-out-of-range-compare',
'-Wno-error=uninitialized',
]
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-incompatible-pointer-types',
'-Wno-tautological-compare',
'-Wno-tautological-constant-out-of-range-compare',
'-Wno-error=uninitialized',
]
if CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-deprecated-register',
'-Wno-macro-redefined',
'-Wno-unused-variable',
]
# See bug 386897.
if CONFIG['GNU_CC'] and CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_OPTIMIZE']:

View File

@ -136,19 +136,23 @@ if use_arm_neon_gcc:
SOURCES['pixman-arm-neon.c'].flags += ['-mfpu=neon']
# Suppress warnings in third-party code.
if CONFIG['GNU_CC']:
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-address',
'-Wno-missing-field-initializers',
'-Wno-sign-compare',
'-Wno-unused', # too many unused warnings; ignore
]
if CONFIG['CLANG_CXX']:
CFLAGS += [
'-Wno-incompatible-pointer-types',
'-Wno-tautological-compare',
'-Wno-tautological-constant-out-of-range-compare',
]
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-incompatible-pointer-types',
'-Wno-tautological-compare',
'-Wno-tautological-constant-out-of-range-compare',
]
if CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-unused-variable',
]
# See bug 386897.
if CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_OPTIMIZE']:

View File

@ -1716,11 +1716,18 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
}
#endif
#ifdef MOZ_X11
if (mWorkAroundDriverBugs &&
mVendor == GLVendor::Nouveau) {
// see bug 814716. Clamp MaxCubeMapTextureSize at 2K for Nouveau.
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 2048);
mNeedsTextureSizeChecks = true;
if (mWorkAroundDriverBugs) {
if (mVendor == GLVendor::Nouveau) {
// see bug 814716. Clamp MaxCubeMapTextureSize at 2K for Nouveau.
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 2048);
mNeedsTextureSizeChecks = true;
} else if (mVendor == GLVendor::Intel) {
// Bug 1199923. Driver seems to report a larger max size than
// actually supported.
mMaxTextureSize /= 2;
mMaxRenderbufferSize /= 2;
mNeedsTextureSizeChecks = true;
}
}
#endif
if (mWorkAroundDriverBugs &&

View File

@ -181,7 +181,7 @@ APZEventState::ProcessSingleTap(const CSSPoint& aPoint,
LayoutDevicePoint currentPoint =
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid)
* widget->GetDefaultScale();;
* widget->GetDefaultScale();
if (!mActiveElementManager->ActiveElementUsesStyle()) {
// If the active element isn't visually affected by the :active style, we
// have no need to wait the extra sActiveDurationMs to make the activation

View File

@ -352,7 +352,6 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
// |dest| is a temporary surface.
RefPtr<DrawTarget> dest = buffer;
buffer->PushClipRect(aClipRect);
AutoRestoreTransform autoRestoreTransform(dest);
Matrix newTransform;
@ -375,6 +374,10 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
transformBounds = aTransform.TransformAndClipBounds(aRect, Rect(offset.x, offset.y, buffer->GetSize().width, buffer->GetSize().height));
transformBounds.RoundOut();
if (transformBounds.IsEmpty()) {
return;
}
// Propagate the coordinate offset to our 2D draw target.
newTransform = Matrix::Translation(transformBounds.x, transformBounds.y);
@ -383,6 +386,8 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
new3DTransform = Matrix4x4::Translation(aRect.x, aRect.y, 0) * aTransform;
}
buffer->PushClipRect(aClipRect);
newTransform.PostTranslate(-offset.x, -offset.y);
buffer->SetTransform(newTransform);

View File

@ -183,7 +183,6 @@ private:
static void DestroyTextureData(TextureData* aTextureData, ISurfaceAllocator* aAllocator,
bool aDeallocate, bool aMainThreadOnly)
{
MOZ_ASSERT(aTextureData);
if (!aTextureData) {
return;
}
@ -231,6 +230,11 @@ void DeallocateTextureClientSyncProxy(TextureDeallocParams params,
void
DeallocateTextureClient(TextureDeallocParams params)
{
if (!params.actor && !params.data) {
// Nothing to do
return;
}
TextureChild* actor = params.actor;
MessageLoop* ipdlMsgLoop = nullptr;

View File

@ -255,11 +255,6 @@ CompositableParentManager::DestroyActor(const OpDestroy& aOp)
void
CompositableParentManager::SendPendingAsyncMessages()
{
for (auto& actor : mDestroyedTextures) {
TextureHost::SendDeleteIPDLActor(actor);
}
mDestroyedTextures.clear();
if (mPendingAsyncMessage.empty()) {
return;
}

View File

@ -40,13 +40,14 @@ public:
*/
virtual base::ProcessId GetChildProcessId() = 0;
void DestroyActor(const OpDestroy& aOp);
protected:
/**
* Handle the IPDL messages that affect PCompositable actors.
*/
bool ReceiveCompositableUpdate(const CompositableOperation& aEdit,
EditReplyVector& replyv);
void DestroyActor(const OpDestroy& aOp);
bool IsOnCompositorSide() const override { return true; }
@ -59,7 +60,6 @@ protected:
virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) {}
std::vector<AsyncParentMessageData> mPendingAsyncMessage;
std::vector<PTextureParent*> mDestroyedTextures;
};
} // namespace layers

View File

@ -75,6 +75,7 @@
#ifdef MOZ_WIDGET_GONK
#include "GeckoTouchDispatcher.h"
#include "nsScreenManagerGonk.h"
#endif
#include "LayerScope.h"
@ -286,13 +287,18 @@ CompositorVsyncScheduler::Observer::Destroy()
CompositorVsyncScheduler::CompositorVsyncScheduler(CompositorParent* aCompositorParent, nsIWidget* aWidget)
: mCompositorParent(aCompositorParent)
, mLastCompose(TimeStamp::Now())
, mCurrentCompositeTask(nullptr)
, mIsObservingVsync(false)
, mNeedsComposite(0)
, mVsyncNotificationsSkipped(0)
, mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor")
, mCurrentCompositeTask(nullptr)
, mSetNeedsCompositeMonitor("SetNeedsCompositeMonitor")
, mSetNeedsCompositeTask(nullptr)
#ifdef MOZ_WIDGET_GONK
, mDisplayEnabled(false)
, mSetDisplayMonitor("SetDisplayMonitor")
, mSetDisplayTask(nullptr)
#endif
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWidget != nullptr);
@ -300,6 +306,9 @@ CompositorVsyncScheduler::CompositorVsyncScheduler(CompositorParent* aCompositor
mCompositorVsyncDispatcher = aWidget->GetCompositorVsyncDispatcher();
#ifdef MOZ_WIDGET_GONK
GeckoTouchDispatcher::GetInstance()->SetCompositorVsyncScheduler(this);
RefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
screenManager->SetCompositorVsyncScheduler(this);
#endif
// mAsapScheduling is set on the main thread during init,
@ -317,6 +326,52 @@ CompositorVsyncScheduler::~CompositorVsyncScheduler()
mCompositorVsyncDispatcher = nullptr;
}
#ifdef MOZ_WIDGET_GONK
void
CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
{
// SetDisplay() is usually called from nsScreenManager at main thread. Post
// to compositor thread if needs.
if (!CompositorParent::IsInCompositorThread()) {
MOZ_ASSERT(NS_IsMainThread());
MonitorAutoLock lock(mSetDisplayMonitor);
mSetDisplayTask = NewRunnableMethod(this,
&CompositorVsyncScheduler::SetDisplay,
aDisplayEnable);
ScheduleTask(mSetDisplayTask, 0);
return;
} else {
MonitorAutoLock lock(mSetDisplayMonitor);
mSetDisplayTask = nullptr;
}
if (mDisplayEnabled == aDisplayEnable) {
return;
}
mDisplayEnabled = aDisplayEnable;
if (!mDisplayEnabled) {
CancelCurrentSetNeedsCompositeTask();
CancelCurrentCompositeTask();
}
}
void
CompositorVsyncScheduler::CancelSetDisplayTask()
{
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
MonitorAutoLock lock(mSetDisplayMonitor);
if (mSetDisplayTask) {
mSetDisplayTask->Cancel();
mSetDisplayTask = nullptr;
}
// CancelSetDisplayTask is only be called in clean-up process, so
// mDisplayEnabled could be false there.
mDisplayEnabled = false;
}
#endif //MOZ_WIDGET_GONK
void
CompositorVsyncScheduler::Destroy()
{
@ -324,6 +379,10 @@ CompositorVsyncScheduler::Destroy()
UnobserveVsync();
mVsyncObserver->Destroy();
mVsyncObserver = nullptr;
#ifdef MOZ_WIDGET_GONK
CancelSetDisplayTask();
#endif
CancelCurrentSetNeedsCompositeTask();
CancelCurrentCompositeTask();
}
@ -396,6 +455,13 @@ CompositorVsyncScheduler::SetNeedsComposite()
mSetNeedsCompositeTask = nullptr;
}
#ifdef MOZ_WIDGET_GONK
// Skip composition when display off.
if (!mDisplayEnabled) {
return;
}
#endif
mNeedsComposite++;
if (!mIsObservingVsync && mNeedsComposite) {
ObserveVsync();

View File

@ -100,6 +100,15 @@ class CompositorVsyncScheduler
public:
explicit CompositorVsyncScheduler(CompositorParent* aCompositorParent, nsIWidget* aWidget);
#ifdef MOZ_WIDGET_GONK
// SetDisplay() and CancelSetDisplayTask() are used for the display on/off.
// It will clear all composition related task and flag, and skip another
// composition task during the display off. That could prevent the problem
// that compositor might show the old content at the first frame of display on.
void SetDisplay(bool aDisplayEnable);
#endif
bool NotifyVsync(TimeStamp aVsyncTimestamp);
void SetNeedsComposite();
void OnForceComposeToTarget();
@ -126,7 +135,7 @@ public:
return mExpectedComposeStartTime;
}
#endif
private:
virtual ~CompositorVsyncScheduler();
@ -136,6 +145,9 @@ private:
void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
void DispatchVREvents(TimeStamp aVsyncTimestamp);
void CancelCurrentSetNeedsCompositeTask();
#ifdef MOZ_WIDGET_GONK
void CancelSetDisplayTask();
#endif
class Observer final : public VsyncObserver
{
@ -153,7 +165,6 @@ private:
CompositorParent* mCompositorParent;
TimeStamp mLastCompose;
CancelableTask* mCurrentCompositeTask;
#ifdef COMPOSITOR_PERFORMANCE_WARNING
TimeStamp mExpectedComposeStartTime;
@ -167,9 +178,16 @@ private:
RefPtr<CompositorVsyncScheduler::Observer> mVsyncObserver;
mozilla::Monitor mCurrentCompositeTaskMonitor;
CancelableTask* mCurrentCompositeTask;
mozilla::Monitor mSetNeedsCompositeMonitor;
CancelableTask* mSetNeedsCompositeTask;
#ifdef MOZ_WIDGET_GONK
bool mDisplayEnabled;
mozilla::Monitor mSetDisplayMonitor;
CancelableTask* mSetDisplayTask;
#endif
};
class CompositorUpdateObserver

View File

@ -117,22 +117,30 @@ ImageBridgeParent::RecvImageBridgeThreadId(const PlatformThreadId& aThreadId)
class MOZ_STACK_CLASS AutoImageBridgeParentAsyncMessageSender
{
public:
explicit AutoImageBridgeParentAsyncMessageSender(ImageBridgeParent* aImageBridge)
: mImageBridge(aImageBridge) {}
explicit AutoImageBridgeParentAsyncMessageSender(ImageBridgeParent* aImageBridge,
InfallibleTArray<OpDestroy>* aToDestroy = nullptr)
: mImageBridge(aImageBridge)
, mToDestroy(aToDestroy) {}
~AutoImageBridgeParentAsyncMessageSender()
{
mImageBridge->SendPendingAsyncMessages();
if (mToDestroy) {
for (const auto& op : *mToDestroy) {
mImageBridge->DestroyActor(op);
}
}
}
private:
ImageBridgeParent* mImageBridge;
InfallibleTArray<OpDestroy>* mToDestroy;
};
bool
ImageBridgeParent::RecvUpdate(EditArray&& aEdits, OpDestroyArray&& aToDestroy,
EditReplyArray* aReply)
{
AutoImageBridgeParentAsyncMessageSender autoAsyncMessageSender(this);
AutoImageBridgeParentAsyncMessageSender autoAsyncMessageSender(this, &aToDestroy);
EditReplyVector replyv;
for (EditArray::index_type i = 0; i < aEdits.Length(); ++i) {
@ -141,10 +149,6 @@ ImageBridgeParent::RecvUpdate(EditArray&& aEdits, OpDestroyArray&& aToDestroy,
}
}
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
aReply->SetCapacity(replyv.size());
if (replyv.size() > 0) {
aReply->AppendElements(&replyv.front(), replyv.size());

View File

@ -207,16 +207,27 @@ LayerTransactionParent::RecvUpdateNoSwap(InfallibleTArray<Edit>&& cset,
class MOZ_STACK_CLASS AutoLayerTransactionParentAsyncMessageSender
{
public:
explicit AutoLayerTransactionParentAsyncMessageSender(LayerTransactionParent* aLayerTransaction)
: mLayerTransaction(aLayerTransaction) {}
explicit AutoLayerTransactionParentAsyncMessageSender(LayerTransactionParent* aLayerTransaction,
InfallibleTArray<OpDestroy>* aDestroyActors = nullptr)
: mLayerTransaction(aLayerTransaction)
, mActorsToDestroy(aDestroyActors)
{}
~AutoLayerTransactionParentAsyncMessageSender()
{
mLayerTransaction->SendPendingAsyncMessages();
ImageBridgeParent::SendPendingAsyncMessages(mLayerTransaction->GetChildProcessId());
if (mActorsToDestroy) {
// Destroy the actors after sending the async messages because the latter may contain
// references to some actors.
for (const auto& op : *mActorsToDestroy) {
mLayerTransaction->DestroyActor(op);
}
}
}
private:
LayerTransactionParent* mLayerTransaction;
InfallibleTArray<OpDestroy>* mActorsToDestroy;
};
bool
@ -247,12 +258,11 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray<Edit>&& cset,
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
return true;
}
AutoLayerTransactionParentAsyncMessageSender autoAsyncMessageSender(this, &aToDestroy);
EditReplyVector replyv;
AutoLayerTransactionParentAsyncMessageSender autoAsyncMessageSender(this);
{
AutoResolveRefLayers resolve(mShadowLayersManager->GetCompositionManager(this));
@ -600,10 +610,6 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray<Edit>&& cset,
}
}
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
mShadowLayersManager->ShadowLayersUpdated(this, aTransactionId, targetConfig,
aPlugins, isFirstPaint, scheduleComposite,
paintSequenceNumber, isRepeatTransaction,

View File

@ -106,32 +106,34 @@ elif CONFIG['CLANG_CL']:
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
if CONFIG['GNU_CXX'] and CONFIG['CPU_ARCH'] == 'arm':
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
DEFINES['SKIA_IMPLEMENTATION'] = 1
if not CONFIG['MOZ_ENABLE_SKIA_GPU']:
DEFINES['SK_SUPPORT_GPU'] = 0
if CONFIG['GNU_CXX']:
# Suppress warnings in third-party code.
if CONFIG['GNU_CXX'] or CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-deprecated-declarations',
'-Wno-overloaded-virtual',
'-Wno-sign-compare',
'-Wno-unused-function',
]
if CONFIG['CLANG_CXX']:
CXXFLAGS += [
'-Wno-implicit-fallthrough',
'-Wno-inconsistent-missing-override',
'-Wno-macro-redefined',
'-Wno-unused-private-field',
]
else:
CXXFLAGS += [
'-Wno-logical-op',
'-Wno-maybe-uninitialized',
]
if CONFIG['CPU_ARCH'] == 'arm':
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
if CONFIG['GNU_CXX'] and not CONFIG['CLANG_CXX'] and not CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-logical-op',
'-Wno-maybe-uninitialized',
]
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-implicit-fallthrough',
'-Wno-inconsistent-missing-override',
'-Wno-macro-redefined',
'-Wno-unused-private-field',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']

View File

@ -723,32 +723,34 @@ elif CONFIG['CLANG_CL']:
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
if CONFIG['GNU_CXX'] and CONFIG['CPU_ARCH'] == 'arm':
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
DEFINES['SKIA_IMPLEMENTATION'] = 1
if not CONFIG['MOZ_ENABLE_SKIA_GPU']:
DEFINES['SK_SUPPORT_GPU'] = 0
if CONFIG['GNU_CXX']:
# Suppress warnings in third-party code.
if CONFIG['GNU_CXX'] or CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-deprecated-declarations',
'-Wno-overloaded-virtual',
'-Wno-sign-compare',
'-Wno-unused-function',
]
if CONFIG['CLANG_CXX']:
CXXFLAGS += [
'-Wno-implicit-fallthrough',
'-Wno-inconsistent-missing-override',
'-Wno-macro-redefined',
'-Wno-unused-private-field',
]
else:
CXXFLAGS += [
'-Wno-logical-op',
'-Wno-maybe-uninitialized',
]
if CONFIG['CPU_ARCH'] == 'arm':
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
if CONFIG['GNU_CXX'] and not CONFIG['CLANG_CXX'] and not CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-logical-op',
'-Wno-maybe-uninitialized',
]
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
CXXFLAGS += [
'-Wno-implicit-fallthrough',
'-Wno-inconsistent-missing-override',
'-Wno-macro-redefined',
'-Wno-unused-private-field',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']

View File

@ -11,7 +11,7 @@
#if defined(SK_BUILD_FOR_MAC)
#include <malloc/malloc.h>
#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN32)
#include <malloc.h>
// #include <malloc.h>
#endif
struct SkVarAlloc::Block {

View File

@ -24,7 +24,11 @@ void SkTime::GetDateTime(DateTime* dt)
int offset = tstruct->tm_isdst == 1 ? 60 : 0;
// http://pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html
#if defined(__FreeBSD__)
dt->fTimeZoneMinutes = SkToS16(offset - tstruct->tm_gmtoff / 60);
#else
dt->fTimeZoneMinutes = SkToS16(offset - timezone / 60);
#endif
dt->fYear = tstruct->tm_year + 1900;
dt->fMonth = SkToU8(tstruct->tm_mon + 1);
dt->fDayOfWeek = SkToU8(tstruct->tm_wday);

View File

@ -658,6 +658,8 @@ nsDeviceContext::FindScreen(nsIScreen** outScreen)
return;
}
CheckDPIChange();
if (mWidget->GetOwningTabChild()) {
mScreenManager->ScreenForNativeWidget((void *)mWidget->GetOwningTabChild(),
outScreen);

View File

@ -59,6 +59,10 @@ public:
nsNativeWidget aNativeParent,
const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData = nullptr) override { return NS_OK; }
NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent,
const DesktopIntRect& aRect,
nsWidgetInitData* aInitData = nullptr) override { return NS_OK; }
NS_IMETHOD Show(bool aState) override { return NS_OK; }
virtual bool IsVisible() const override { return true; }
NS_IMETHOD ConstrainPosition(bool aAllowSlop,

View File

@ -1625,9 +1625,14 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh,
nextFont = 1;
}
// Pango, GLib, and Thebes (but not harfbuzz!) all happen to use the same
// script codes, so we can just cast the value here.
const PangoScript script = static_cast<PangoScript>(aRunScript);
// Our MOZ_SCRIPT_* codes may not match the PangoScript enumeration values
// (if we're using ICU's codes), so convert by mapping through ISO 15924 tag.
// Note that PangoScript is defined to be compatible with GUnicodeScript:
// https://developer.gnome.org/pango/stable/pango-Scripts-and-Languages.html#PangoScript
const hb_tag_t scriptTag = GetScriptTagForCode(aRunScript);
const PangoScript script =
(const PangoScript)g_unicode_script_from_iso15924(scriptTag);
// Might be nice to call pango_language_includes_script only once for the
// run rather than for each character.
PangoLanguage *scriptLang;
@ -1654,19 +1659,6 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh,
return nullptr;
}
// Sanity-check: spot-check a few constants to confirm that Thebes and
// Pango script codes really do match
#define CHECK_SCRIPT_CODE(script) \
PR_STATIC_ASSERT(int32_t(MOZ_SCRIPT_##script) == \
int32_t(PANGO_SCRIPT_##script))
CHECK_SCRIPT_CODE(COMMON);
CHECK_SCRIPT_CODE(INHERITED);
CHECK_SCRIPT_CODE(ARABIC);
CHECK_SCRIPT_CODE(LATIN);
CHECK_SCRIPT_CODE(UNKNOWN);
CHECK_SCRIPT_CODE(NKO);
/**
** gfxFcFont
**/

View File

@ -158,19 +158,11 @@ gfxScriptItemizer::Next(uint32_t& aRunStart, uint32_t& aRunLimit,
}
}
// Get the nsCharProps2 record for the current character,
// so we can read the script and (if needed) the gen category
// without needing to do two multi-level lookups.
// NOTE that this means we're relying on an implementation detail
// of the nsUnicodeProperties tables, and might have to revise this
// if the nsCharProps records used there are modified in future.
const nsCharProps2& charProps = GetCharProps2(ch);
// Initialize gc to UNASSIGNED; we'll only set it to the true GC
// if the character has script=COMMON, otherwise we don't care.
uint8_t gc = HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED;
sc = charProps.mScriptCode;
sc = GetScriptCode(ch);
if (sc == MOZ_SCRIPT_COMMON) {
/*
* Paired character handling:
@ -183,7 +175,7 @@ gfxScriptItemizer::Next(uint32_t& aRunStart, uint32_t& aRunLimit,
* We only do this if the script is COMMON; for chars with
* specific script assignments, we just use them as-is.
*/
gc = charProps.mCategory;
GetGeneralCategory(ch);
if (gc == HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION) {
uint32_t endPairChar = mozilla::unicode::GetMirroredChar(ch);
if (endPairChar != ch) {

View File

@ -425,12 +425,6 @@ gfxWindowsPlatform::~gfxWindowsPlatform()
CoUninitialize();
}
double
gfxWindowsPlatform::GetDPIScale()
{
return WinUtils::LogToPhysFactor();
}
bool
gfxWindowsPlatform::CanUseHardwareVideoDecoding()
{

View File

@ -167,13 +167,6 @@ public:
HRESULT CreateDevice(RefPtr<IDXGIAdapter1> &adapter1, int featureLevelIndex);
#endif
/**
* Return the resolution scaling factor to convert between "logical" or
* "screen" pixels as used by Windows (dependent on the DPI scaling option
* in the Display control panel) and actual device pixels.
*/
double GetDPIScale();
nsresult GetFontList(nsIAtom *aLangGroup,
const nsACString& aGenericFamily,
nsTArray<nsString>& aListOfFonts) override;

View File

@ -40,8 +40,9 @@
#
# (2) Run this tool using a command line of the form
#
# perl genUnicodePropertyData.pl \
# /path/to/harfbuzz/src \
# perl genUnicodePropertyData.pl \
# /path/to/harfbuzz/src \
# /path/to/icu/common/unicode \
# /path/to/UCD-directory
#
# This will generate (or overwrite!) the files
@ -54,15 +55,17 @@
use strict;
use List::Util qw(first);
if ($#ARGV != 1) {
if ($#ARGV != 2) {
print <<__EOT;
# Run this tool using a command line of the form
#
# perl genUnicodePropertyData.pl \\
# /path/to/harfbuzz/src \\
# perl genUnicodePropertyData.pl \\
# /path/to/harfbuzz/src \\
# /path/to/icu/common/unicode \\
# /path/to/UCD-directory
#
# where harfbuzz/src is the directory containing harfbuzz .cc and .hh files,
# icu/common/unicode is the directory containing ICU 'common' public headers,
# and UCD-directory is a directory containing the current Unicode Character
# Database files (UnicodeData.txt, etc), available from
# http://www.unicode.org/Public/UNIDATA/, with additional resources as
@ -78,190 +81,20 @@ __EOT
exit 0;
}
# load HB_Script and HB_Category constants
my $HARFBUZZ = $ARGV[0];
my $ICU = $ARGV[1];
my $UNICODE = $ARGV[2];
# NOTE that HB_SCRIPT_* constants are now "tag" values, NOT sequentially-allocated
# script codes as used by Glib/Pango/etc.
# We therefore define a set of MOZ_SCRIPT_* constants that are script _codes_
# compatible with those libraries, and map these to HB_SCRIPT_* _tags_ as needed.
# load HB_Category constants
# CHECK that this matches Pango source (as found for example at
# http://git.gnome.org/browse/pango/tree/pango/pango-script.h)
# for as many codes as that defines (currently up through Unicode 5.1)
# and the GLib enumeration
# http://developer.gnome.org/glib/2.30/glib-Unicode-Manipulation.html#GUnicodeScript
# (currently defined up through Unicode 6.0).
# Constants beyond these may be regarded as unstable for now, but we don't actually
# depend on the specific values.
my %scriptCode = (
INVALID => -1,
COMMON => 0,
INHERITED => 1,
ARABIC => 2,
ARMENIAN => 3,
BENGALI => 4,
BOPOMOFO => 5,
CHEROKEE => 6,
COPTIC => 7,
CYRILLIC => 8,
DESERET => 9,
DEVANAGARI => 10,
ETHIOPIC => 11,
GEORGIAN => 12,
GOTHIC => 13,
GREEK => 14,
GUJARATI => 15,
GURMUKHI => 16,
HAN => 17,
HANGUL => 18,
HEBREW => 19,
HIRAGANA => 20,
KANNADA => 21,
KATAKANA => 22,
KHMER => 23,
LAO => 24,
LATIN => 25,
MALAYALAM => 26,
MONGOLIAN => 27,
MYANMAR => 28,
OGHAM => 29,
OLD_ITALIC => 30,
ORIYA => 31,
RUNIC => 32,
SINHALA => 33,
SYRIAC => 34,
TAMIL => 35,
TELUGU => 36,
THAANA => 37,
THAI => 38,
TIBETAN => 39,
CANADIAN_ABORIGINAL => 40,
YI => 41,
TAGALOG => 42,
HANUNOO => 43,
BUHID => 44,
TAGBANWA => 45,
# unicode 4.0 additions
BRAILLE => 46,
CYPRIOT => 47,
LIMBU => 48,
OSMANYA => 49,
SHAVIAN => 50,
LINEAR_B => 51,
TAI_LE => 52,
UGARITIC => 53,
# unicode 4.1 additions
NEW_TAI_LUE => 54,
BUGINESE => 55,
GLAGOLITIC => 56,
TIFINAGH => 57,
SYLOTI_NAGRI => 58,
OLD_PERSIAN => 59,
KHAROSHTHI => 60,
# unicode 5.0 additions
UNKNOWN => 61,
BALINESE => 62,
CUNEIFORM => 63,
PHOENICIAN => 64,
PHAGS_PA => 65,
NKO => 66,
# unicode 5.1 additions
KAYAH_LI => 67,
LEPCHA => 68,
REJANG => 69,
SUNDANESE => 70,
SAURASHTRA => 71,
CHAM => 72,
OL_CHIKI => 73,
VAI => 74,
CARIAN => 75,
LYCIAN => 76,
LYDIAN => 77,
# unicode 5.2 additions
AVESTAN => 78,
BAMUM => 79,
EGYPTIAN_HIEROGLYPHS => 80,
IMPERIAL_ARAMAIC => 81,
INSCRIPTIONAL_PAHLAVI => 82,
INSCRIPTIONAL_PARTHIAN => 83,
JAVANESE => 84,
KAITHI => 85,
LISU => 86,
MEETEI_MAYEK => 87,
OLD_SOUTH_ARABIAN => 88,
OLD_TURKIC => 89,
SAMARITAN => 90,
TAI_THAM => 91,
TAI_VIET => 92,
# unicode 6.0 additions
BATAK => 93,
BRAHMI => 94,
MANDAIC => 95,
# unicode 6.1 additions
CHAKMA => 96,
MEROITIC_CURSIVE => 97,
MEROITIC_HIEROGLYPHS => 98,
MIAO => 99,
SHARADA => 100,
SORA_SOMPENG => 101,
TAKRI => 102,
# unicode 7.0 additions
BASSA_VAH => 103,
CAUCASIAN_ALBANIAN => 104,
DUPLOYAN => 105,
ELBASAN => 106,
GRANTHA => 107,
KHOJKI => 108,
KHUDAWADI => 109,
LINEAR_A => 110,
MAHAJANI => 111,
MANICHAEAN => 112,
MENDE_KIKAKUI => 113,
MODI => 114,
MRO => 115,
NABATAEAN => 116,
OLD_NORTH_ARABIAN => 117,
OLD_PERMIC => 118,
PAHAWH_HMONG => 119,
PALMYRENE => 120,
PAU_CIN_HAU => 121,
PSALTER_PAHLAVI => 122,
SIDDHAM => 123,
TIRHUTA => 124,
WARANG_CITI => 125,
# unicode 8.0 additions
AHOM => 126,
ANATOLIAN_HIEROGLYPHS => 127,
HATRAN => 128,
MULTANI => 129,
OLD_HUNGARIAN => 130,
SIGNWRITING => 131,
# additional "script" code, not from Unicode (but matches ISO 15924's Zmth tag)
MATHEMATICAL_NOTATION => 132,
);
my $sc = -1;
my $cc = -1;
my %catCode;
my @scriptCodeToTag;
my @scriptCodeToName;
sub readHarfBuzzHeader
{
my $file = shift;
open FH, "< $ARGV[0]/$file" or die "can't open harfbuzz header $ARGV[0]/$file\n";
open FH, "< $HARFBUZZ/$file" or die "can't open harfbuzz header $HARFBUZZ/$file\n";
while (<FH>) {
s/CANADIAN_SYLLABICS/CANADIAN_ABORIGINAL/; # harfbuzz and unicode disagree on this name :(
if (m/HB_SCRIPT_([A-Z_]+)\s*=\s*HB_TAG\s*\(('.','.','.','.')\)\s*,/) {
unless (exists $scriptCode{$1}) {
warn "unknown script name $1 found in $file\n";
next;
}
$sc = $scriptCode{$1};
$scriptCodeToTag[$sc] = $2;
$scriptCodeToName[$sc] = $1;
}
if (m/HB_UNICODE_GENERAL_CATEGORY_([A-Z_]+)/) {
$cc++;
$catCode{$1} = $cc;
@ -270,16 +103,40 @@ sub readHarfBuzzHeader
close FH;
}
&readHarfBuzzHeader("hb-common.h");
&readHarfBuzzHeader("hb-unicode.h");
die "didn't find HarfBuzz script codes\n" if $sc == -1;
die "didn't find HarfBuzz category codes\n" if $cc == -1;
# Additional code not present in HarfBuzz headers:
$sc = $scriptCode{"MATHEMATICAL_NOTATION"};
$scriptCodeToTag[$sc] = "'Z','m','t','h'";
$scriptCodeToName[$sc] = "MATHEMATICAL_NOTATION";
my %scriptCode;
my @scriptCodeToTag;
my @scriptCodeToName;
my $sc = -1;
sub readIcuHeader
{
my $file = shift;
open FH, "< $ICU/$file" or die "can't open ICU header $ICU/$file\n";
while (<FH>) {
# adjust for ICU vs UCD naming discrepancies
s/LANNA/TAI_THAM/;
s/MEITEI_MAYEK/MEETEI_MAYEK/;
s/ORKHON/OLD_TURKIC/;
s/MENDE/MENDE_KIKAKUI/;
s/SIGN_WRITING/SIGNWRITING/;
if (m|USCRIPT_([A-Z_]+)\s*=\s*([0-9]+),\s*/\*\s*([A-Z][a-z]{3})\s*\*/|) {
$sc = $2;
$scriptCode{$1} = $sc;
$scriptCodeToTag[$sc] = $3;
$scriptCodeToName[$sc] = $1;
}
}
close FH;
}
&readIcuHeader("uscript.h");
die "didn't find ICU script codes\n" if $sc == -1;
my %xidmodCode = (
'Recommended' => 0,
@ -317,9 +174,9 @@ my %bidicategoryCode = (
"PDF" => "16", # Pop Directional Format
"NSM" => "17", # Non-Spacing Mark
"BN" => "18", # Boundary Neutral
"LRI" => "19", # Left-to-Right Isolate
"RLI" => "20", # Right-to-left Isolate
"FSI" => "21", # First Strong Isolate
"FSI" => "19", # First Strong Isolate
"LRI" => "20", # Left-to-Right Isolate
"RLI" => "21", # Right-to-left Isolate
"PDI" => "22" # Pop Direcitonal Isolate
);
@ -404,7 +261,7 @@ my %ucd2hb = (
# read ReadMe.txt
my @versionInfo;
open FH, "< $ARGV[1]/ReadMe.txt" or die "can't open Unicode ReadMe.txt file\n";
open FH, "< $UNICODE/ReadMe.txt" or die "can't open Unicode ReadMe.txt file\n";
while (<FH>) {
chomp;
push @versionInfo, $_;
@ -418,7 +275,7 @@ my $kLowerToUpper = 0x10000000;
my $kCaseMapCharMask = 0x001fffff;
# read UnicodeData.txt
open FH, "< $ARGV[1]/UnicodeData.txt" or die "can't open UCD file UnicodeData.txt\n";
open FH, "< $UNICODE/UnicodeData.txt" or die "can't open UCD file UnicodeData.txt\n";
while (<FH>) {
chomp;
my @fields = split /;/;
@ -490,7 +347,7 @@ while (<FH>) {
close FH;
# read Scripts.txt
open FH, "< $ARGV[1]/Scripts.txt" or die "can't open UCD file Scripts.txt\n";
open FH, "< $UNICODE/Scripts.txt" or die "can't open UCD file Scripts.txt\n";
push @versionInfo, "";
while (<FH>) {
chomp;
@ -500,8 +357,8 @@ while (<FH>) {
while (<FH>) {
if (m/([0-9A-F]{4,6})(?:\.\.([0-9A-F]{4,6}))*\s+;\s+([^ ]+)/) {
my $script = uc($3);
warn "unknown script $script" unless exists $scriptCode{$script};
$script = $scriptCode{$script};
warn "unknown ICU script $script" unless exists $scriptCode{$script};
my $script = $scriptCode{$script};
my $start = hex "0x$1";
my $end = (defined $2) ? hex "0x$2" : $start;
for (my $i = $start; $i <= $end; ++$i) {
@ -515,7 +372,7 @@ close FH;
my @offsets = ();
push @offsets, 0;
open FH, "< $ARGV[1]/BidiMirroring.txt" or die "can't open UCD file BidiMirroring.txt\n";
open FH, "< $UNICODE/BidiMirroring.txt" or die "can't open UCD file BidiMirroring.txt\n";
push @versionInfo, "";
while (<FH>) {
chomp;
@ -543,7 +400,7 @@ my %pairedBracketTypeCode = (
'O' => 1,
'C' => 2
);
open FH, "< $ARGV[1]/BidiBrackets.txt" or die "can't open UCD file BidiBrackets.txt\n";
open FH, "< $UNICODE/BidiBrackets.txt" or die "can't open UCD file BidiBrackets.txt\n";
push @versionInfo, "";
while (<FH>) {
chomp;
@ -570,7 +427,7 @@ my %hangulType = (
'LV' => 0x03,
'LVT' => 0x07
);
open FH, "< $ARGV[1]/HangulSyllableType.txt" or die "can't open UCD file HangulSyllableType.txt\n";
open FH, "< $UNICODE/HangulSyllableType.txt" or die "can't open UCD file HangulSyllableType.txt\n";
push @versionInfo, "";
while (<FH>) {
chomp;
@ -593,7 +450,7 @@ while (<FH>) {
close FH;
# read xidmodifications.txt
open FH, "< $ARGV[1]/security/xidmodifications.txt" or die "can't open UCD file xidmodifications.txt\n";
open FH, "< $UNICODE/security/xidmodifications.txt" or die "can't open UCD file xidmodifications.txt\n";
push @versionInfo, "";
while (<FH>) {
chomp;
@ -616,7 +473,7 @@ while (<FH>) {
}
close FH;
open FH, "< $ARGV[1]/Unihan_Variants.txt" or die "can't open UCD file Unihan_Variants.txt (from Unihan.zip)\n";
open FH, "< $UNICODE/Unihan_Variants.txt" or die "can't open UCD file Unihan_Variants.txt (from Unihan.zip)\n";
push @versionInfo, "";
while (<FH>) {
chomp;
@ -653,7 +510,7 @@ while (<FH>) {
close FH;
# read VerticalOrientation-13.txt
open FH, "< $ARGV[1]/vertical/VerticalOrientation-13.txt" or die "can't open UTR50 data file VerticalOrientation-13.txt\n";
open FH, "< $UNICODE/vertical/VerticalOrientation-13.txt" or die "can't open UTR50 data file VerticalOrientation-13.txt\n";
push @versionInfo, "";
while (<FH>) {
chomp;
@ -732,21 +589,25 @@ $versionInfo
__END
print DATA_TABLES "#if !ENABLE_INTL_API\n";
print DATA_TABLES "static const uint32_t sScriptCodeToTag[] = {\n";
for (my $i = 0; $i < scalar @scriptCodeToTag; ++$i) {
printf DATA_TABLES " HB_TAG(%s)", $scriptCodeToTag[$i];
printf DATA_TABLES " HB_TAG('%c','%c','%c','%c')", unpack('cccc', $scriptCodeToTag[$i]);
print DATA_TABLES $i < $#scriptCodeToTag ? ",\n" : "\n";
}
print DATA_TABLES "};\n\n";
print DATA_TABLES "};\n";
print DATA_TABLES "#endif\n\n";
our $totalData = 0;
print DATA_TABLES "#if !ENABLE_INTL_API\n";
print DATA_TABLES "static const int16_t sMirrorOffsets[] = {\n";
for (my $i = 0; $i < scalar @offsets; ++$i) {
printf DATA_TABLES " $offsets[$i]";
print DATA_TABLES $i < $#offsets ? ",\n" : "\n";
}
print DATA_TABLES "};\n\n";
print DATA_TABLES "};\n";
print DATA_TABLES "#endif\n\n";
print HEADER "#pragma pack(1)\n\n";
@ -762,11 +623,26 @@ struct nsCharProps1 {
unsigned char mCombiningClass:8;
};
/;
print DATA_TABLES "#ifndef ENABLE_INTL_API\n";
&genTables("CharProp1", $type, "nsCharProps1", 11, 5, \&sprintCharProps1, 1, 2, 1);
print DATA_TABLES "#endif\n\n";
&genTables("#if !ENABLE_INTL_API", "#endif",
"CharProp1", $type, "nsCharProps1", 11, 5, \&sprintCharProps1, 1, 2, 1);
sub sprintCharProps2
sub sprintCharProps2_short
{
my $usv = shift;
return sprintf("{%d,%d,%d},",
$pairedBracketType[$usv], $verticalOrientation[$usv], $xidmod[$usv]);
}
$type = q/
struct nsCharProps2 {
unsigned char mPairedBracketType:2;
unsigned char mVertOrient:2;
unsigned char mXidmod:4;
};
/;
&genTables("#if ENABLE_INTL_API", "#endif",
"CharProp2", $type, "nsCharProps2", 9, 7, \&sprintCharProps2_short, 16, 1, 1);
sub sprintCharProps2_full
{
my $usv = shift;
return sprintf("{%d,%d,%d,%d,%d,%d,%d},",
@ -785,7 +661,8 @@ struct nsCharProps2 {
unsigned char mVertOrient:2;
};
|;
&genTables("CharProp2", $type, "nsCharProps2", 11, 5, \&sprintCharProps2, 16, 4, 1);
&genTables("#if !ENABLE_INTL_API", "#endif",
"CharProp2", $type, "nsCharProps2", 11, 5, \&sprintCharProps2_full, 16, 4, 1);
print HEADER "#pragma pack()\n\n";
@ -800,21 +677,22 @@ sub sprintHanVariants
}
return sprintf("0x%02x,", $val);
}
&genTables("HanVariant", "", "uint8_t", 9, 7, \&sprintHanVariants, 2, 1, 4);
## Han Variant data currently unused but may be needed in future, see bug 857481
## &genTables("", "", "HanVariant", "", "uint8_t", 9, 7, \&sprintHanVariants, 2, 1, 4);
sub sprintFullWidth
{
my $usv = shift;
return sprintf("0x%04x,", $fullWidth[$usv]);
}
&genTables("FullWidth", "", "uint16_t", 10, 6, \&sprintFullWidth, 0, 2, 1);
&genTables("", "", "FullWidth", "", "uint16_t", 10, 6, \&sprintFullWidth, 0, 2, 1);
sub sprintCasemap
{
my $usv = shift;
return sprintf("0x%08x,", $casemap[$usv]);
}
&genTables("CaseMap", "", "uint32_t", 11, 5, \&sprintCasemap, 1, 4, 1);
&genTables("", "", "CaseMap", "", "uint32_t", 11, 5, \&sprintCasemap, 1, 4, 1);
print STDERR "Total data = $totalData\n";
@ -826,8 +704,16 @@ printf DATA_TABLES "const uint32_t kCaseMapCharMask = 0x%08x;\n\n", $kCaseMapCha
sub genTables
{
my ($prefix, $typedef, $type, $indexBits, $charBits, $func, $maxPlane, $bytesPerEntry, $charsPerEntry) = @_;
my ($guardBegin, $guardEnd,
$prefix, $typedef, $type, $indexBits, $charBits, $func, $maxPlane, $bytesPerEntry, $charsPerEntry) = @_;
if ($typedef ne '') {
print HEADER "$guardBegin\n";
print HEADER "$typedef\n";
print HEADER "$guardEnd\n\n";
}
print DATA_TABLES "\n$guardBegin\n";
print DATA_TABLES "#define k${prefix}MaxPlane $maxPlane\n";
print DATA_TABLES "#define k${prefix}IndexBits $indexBits\n";
print DATA_TABLES "#define k${prefix}CharBits $charBits\n";
@ -888,8 +774,6 @@ sub genTables
}
print DATA_TABLES "};\n\n";
print HEADER "$typedef\n\n" if $typedef ne '';
my $pageLen = $charsPerPage / $charsPerEntry;
print DATA_TABLES "static const $type s${prefix}Values[$chCount][$pageLen] = {\n";
for (my $i = 0; $i < scalar @char; ++$i) {
@ -897,7 +781,8 @@ sub genTables
print DATA_TABLES $char[$i];
print DATA_TABLES $i < $#char ? "},\n" : "}\n";
}
print DATA_TABLES "};\n\n";
print DATA_TABLES "};\n";
print DATA_TABLES "$guardEnd\n";
my $dataSize = $pmCount * $indexLen * $pmBits/8 +
$chCount * $pageLen * $bytesPerEntry +

View File

@ -14,7 +14,8 @@
* for the detailed definition of the following categories
*
* The values here must match the equivalents in %bidicategorycode in
* mozilla/intl/unicharutil/tools/genUnicodePropertyData.pl
* mozilla/intl/unicharutil/tools/genUnicodePropertyData.pl,
* and must also match the values used by ICU's UCharDirection.
*/
enum nsCharType {
@ -37,9 +38,9 @@ enum nsCharType {
eCharType_PopDirectionalFormat = 16,
eCharType_DirNonSpacingMark = 17,
eCharType_BoundaryNeutral = 18,
eCharType_LeftToRightIsolate = 19,
eCharType_RightToLeftIsolate = 20,
eCharType_FirstStrongIsolate = 21,
eCharType_FirstStrongIsolate = 19,
eCharType_LeftToRightIsolate = 20,
eCharType_RightToLeftIsolate = 21,
eCharType_PopDirectionalIsolate = 22,
eCharType_CharTypeCount
};

View File

@ -11,12 +11,12 @@
#if ENABLE_INTL_API
#include "unicode/uchar.h"
#include "unicode/uscript.h"
#endif
#define UNICODE_BMP_LIMIT 0x10000
#define UNICODE_LIMIT 0x110000
#ifndef ENABLE_INTL_API
static const nsCharProps1&
GetCharProps1(uint32_t aCh)
@ -56,14 +56,21 @@ GetCharProps2(uint32_t aCh)
NS_NOTREACHED("Getting CharProps for codepoint outside Unicode range");
// Default values for unassigned
using namespace mozilla::unicode;
static const nsCharProps2 undefined = {
MOZ_SCRIPT_UNKNOWN, // Script code
0, // East Asian Width
HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED, // General Category
eCharType_LeftToRight, // Bidi Category
mozilla::unicode::XIDMOD_NOT_CHARS, // Xidmod
-1, // Numeric Value
mozilla::unicode::HVT_NotHan // Han variant
#if ENABLE_INTL_API
PAIRED_BRACKET_TYPE_NONE,
VERTICAL_ORIENTATION_R,
XIDMOD_NOT_CHARS
#else
MOZ_SCRIPT_UNKNOWN,
PAIRED_BRACKET_TYPE_NONE,
HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED,
eCharType_LeftToRight,
XIDMOD_NOT_CHARS,
-1, // Numeric Value
VERTICAL_ORIENTATION_R
#endif
};
return undefined;
}
@ -93,7 +100,7 @@ to provide the most compact storage, depending on the distribution
of values.
*/
nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[] = {
const nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[] = {
/*
* The order here corresponds to the HB_UNICODE_GENERAL_CATEGORY_* constants
* of the hb_unicode_general_category_t enum in gfx/harfbuzz/src/hb-unicode.h.
@ -130,6 +137,69 @@ nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[] = {
/* SPACE_SEPARATOR */ nsIUGenCategory::kSeparator
};
#ifdef ENABLE_INTL_API
const hb_unicode_general_category_t sICUtoHBcategory[U_CHAR_CATEGORY_COUNT] = {
HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED, // U_GENERAL_OTHER_TYPES = 0,
HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER, // U_UPPERCASE_LETTER = 1,
HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER, // U_LOWERCASE_LETTER = 2,
HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER, // U_TITLECASE_LETTER = 3,
HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER, // U_MODIFIER_LETTER = 4,
HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER, // U_OTHER_LETTER = 5,
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, // U_NON_SPACING_MARK = 6,
HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK, // U_ENCLOSING_MARK = 7,
HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, // U_COMBINING_SPACING_MARK = 8,
HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER, // U_DECIMAL_DIGIT_NUMBER = 9,
HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER, // U_LETTER_NUMBER = 10,
HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER, // U_OTHER_NUMBER = 11,
HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR, // U_SPACE_SEPARATOR = 12,
HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR, // U_LINE_SEPARATOR = 13,
HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR, // U_PARAGRAPH_SEPARATOR = 14,
HB_UNICODE_GENERAL_CATEGORY_CONTROL, // U_CONTROL_CHAR = 15,
HB_UNICODE_GENERAL_CATEGORY_FORMAT, // U_FORMAT_CHAR = 16,
HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE, // U_PRIVATE_USE_CHAR = 17,
HB_UNICODE_GENERAL_CATEGORY_SURROGATE, // U_SURROGATE = 18,
HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION, // U_DASH_PUNCTUATION = 19,
HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION, // U_START_PUNCTUATION = 20,
HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION, // U_END_PUNCTUATION = 21,
HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION, // U_CONNECTOR_PUNCTUATION = 22,
HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION, // U_OTHER_PUNCTUATION = 23,
HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL, // U_MATH_SYMBOL = 24,
HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL, // U_CURRENCY_SYMBOL = 25,
HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL, // U_MODIFIER_SYMBOL = 26,
HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL, // U_OTHER_SYMBOL = 27,
HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION, // U_INITIAL_PUNCTUATION = 28,
HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION, // U_FINAL_PUNCTUATION = 29,
};
#endif
uint8_t GetGeneralCategory(uint32_t aCh) {
#if ENABLE_INTL_API
return sICUtoHBcategory[u_charType(aCh)];
#else
return GetCharProps2(aCh).mCategory;
#endif
}
nsCharType GetBidiCat(uint32_t aCh) {
#if ENABLE_INTL_API
return nsCharType(u_charDirection(aCh));
#else
return nsCharType(GetCharProps2(aCh).mBidiCategory);
#endif
}
int8_t GetNumericValue(uint32_t aCh) {
#if ENABLE_INTL_API
UNumericType type =
UNumericType(u_getIntPropertyValue(aCh, UCHAR_NUMERIC_TYPE));
return type == U_NT_DECIMAL || type == U_NT_DIGIT
? int8_t(u_getNumericValue(aCh))
: -1;
#else
return GetCharProps2(aCh).mNumericValue;
#endif
}
uint32_t
GetMirroredChar(uint32_t aCh)
{
@ -160,14 +230,30 @@ GetCombiningClass(uint32_t aCh)
#endif
}
uint8_t
GetScriptCode(uint32_t aCh)
{
#if ENABLE_INTL_API
UErrorCode err = U_ZERO_ERROR;
return uscript_getScript(aCh, &err);
#else
return GetCharProps2(aCh).mScriptCode;
#endif
}
uint32_t
GetScriptTagForCode(int32_t aScriptCode)
{
#if ENABLE_INTL_API
const char* tag = uscript_getShortName(UScriptCode(aScriptCode));
return HB_TAG(tag[0], tag[1], tag[2], tag[3]);
#else
// this will safely return 0 for negative script codes, too :)
if (uint32_t(aScriptCode) > ArrayLength(sScriptCodeToTag)) {
return 0;
}
return sScriptCodeToTag[aScriptCode];
#endif
}
PairedBracketType GetPairedBracketType(uint32_t aCh)
@ -254,6 +340,7 @@ GetTitlecaseForAll(uint32_t aCh)
return aCh;
}
#if 0 // currently unused - bug 857481
HanVariantType
GetHanVariant(uint32_t aCh)
{
@ -272,6 +359,7 @@ GetHanVariant(uint32_t aCh)
// extract the appropriate 2-bit field from the value
return HanVariantType((v >> ((aCh & 3) * 2)) & 3);
}
#endif
uint32_t
GetFullWidth(uint32_t aCh)

View File

@ -16,7 +16,7 @@ namespace mozilla {
namespace unicode {
extern nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[];
extern const nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[];
// Return whether the char has a mirrored-pair counterpart.
uint32_t GetMirroredChar(uint32_t aCh);
@ -26,25 +26,19 @@ bool HasMirroredChar(uint32_t aChr);
uint8_t GetCombiningClass(uint32_t aCh);
// returns the detailed General Category in terms of HB_UNICODE_* values
inline uint8_t GetGeneralCategory(uint32_t aCh) {
return GetCharProps2(aCh).mCategory;
}
uint8_t GetGeneralCategory(uint32_t aCh);
// returns the simplified Gen Category as defined in nsIUGenCategory
inline nsIUGenCategory::nsUGenCategory GetGenCategory(uint32_t aCh) {
return sDetailedToGeneralCategory[GetGeneralCategory(aCh)];
}
inline uint8_t GetScriptCode(uint32_t aCh) {
return GetCharProps2(aCh).mScriptCode;
}
nsCharType GetBidiCat(uint32_t aCh);
uint8_t GetScriptCode(uint32_t aCh);
uint32_t GetScriptTagForCode(int32_t aScriptCode);
inline nsCharType GetBidiCat(uint32_t aCh) {
return nsCharType(GetCharProps2(aCh).mBidiCategory);
}
/* This MUST match the values assigned by genUnicodePropertyData.pl! */
enum VerticalOrientation {
VERTICAL_ORIENTATION_U = 0,
@ -93,10 +87,9 @@ inline XidmodType GetIdentifierModification(uint32_t aCh) {
* To restrict to decimal digits, the caller should also check whether
* GetGeneralCategory returns HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER
*/
inline int8_t GetNumericValue(uint32_t aCh) {
return GetCharProps2(aCh).mNumericValue;
}
int8_t GetNumericValue(uint32_t aCh);
#if 0 // currently unused - bug 857481
enum HanVariantType {
HVT_NotHan = 0x0,
HVT_SimplifiedOnly = 0x1,
@ -105,6 +98,7 @@ enum HanVariantType {
};
HanVariantType GetHanVariant(uint32_t aCh);
#endif
uint32_t GetFullWidth(uint32_t aCh);

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
*/
/*
* Created on Tue Nov 17 07:34:16 2015 from UCD data files with version info:
* Created on Thu Nov 26 21:24:13 2015 from UCD data files with version info:
*
# Date: 2015-06-16, 20:24:00 GMT [KW]
@ -64,6 +64,7 @@ Standard.
#pragma pack(1)
#if !ENABLE_INTL_API
struct nsCharProps1 {
unsigned char mMirrorOffsetIndex:5;
@ -71,7 +72,19 @@ struct nsCharProps1 {
unsigned char mCombiningClass:8;
};
#endif
#if ENABLE_INTL_API
struct nsCharProps2 {
unsigned char mPairedBracketType:2;
unsigned char mVertOrient:2;
unsigned char mXidmod:4;
};
#endif
#if !ENABLE_INTL_API
struct nsCharProps2 {
unsigned char mScriptCode:8;
@ -83,6 +96,7 @@ struct nsCharProps2 {
unsigned char mVertOrient:2;
};
#endif
#pragma pack()
@ -136,92 +150,126 @@ enum {
MOZ_SCRIPT_BRAILLE = 46,
MOZ_SCRIPT_CYPRIOT = 47,
MOZ_SCRIPT_LIMBU = 48,
MOZ_SCRIPT_OSMANYA = 49,
MOZ_SCRIPT_SHAVIAN = 50,
MOZ_SCRIPT_LINEAR_B = 51,
MOZ_SCRIPT_LINEAR_B = 49,
MOZ_SCRIPT_OSMANYA = 50,
MOZ_SCRIPT_SHAVIAN = 51,
MOZ_SCRIPT_TAI_LE = 52,
MOZ_SCRIPT_UGARITIC = 53,
MOZ_SCRIPT_NEW_TAI_LUE = 54,
MOZ_SCRIPT_KATAKANA_OR_HIRAGANA = 54,
MOZ_SCRIPT_BUGINESE = 55,
MOZ_SCRIPT_GLAGOLITIC = 56,
MOZ_SCRIPT_TIFINAGH = 57,
MOZ_SCRIPT_KHAROSHTHI = 57,
MOZ_SCRIPT_SYLOTI_NAGRI = 58,
MOZ_SCRIPT_OLD_PERSIAN = 59,
MOZ_SCRIPT_KHAROSHTHI = 60,
MOZ_SCRIPT_UNKNOWN = 61,
MOZ_SCRIPT_NEW_TAI_LUE = 59,
MOZ_SCRIPT_TIFINAGH = 60,
MOZ_SCRIPT_OLD_PERSIAN = 61,
MOZ_SCRIPT_BALINESE = 62,
MOZ_SCRIPT_CUNEIFORM = 63,
MOZ_SCRIPT_PHOENICIAN = 64,
MOZ_SCRIPT_PHAGS_PA = 65,
MOZ_SCRIPT_NKO = 66,
MOZ_SCRIPT_KAYAH_LI = 67,
MOZ_SCRIPT_LEPCHA = 68,
MOZ_SCRIPT_REJANG = 69,
MOZ_SCRIPT_SUNDANESE = 70,
MOZ_SCRIPT_SAURASHTRA = 71,
MOZ_SCRIPT_CHAM = 72,
MOZ_SCRIPT_OL_CHIKI = 73,
MOZ_SCRIPT_VAI = 74,
MOZ_SCRIPT_CARIAN = 75,
MOZ_SCRIPT_LYCIAN = 76,
MOZ_SCRIPT_LYDIAN = 77,
MOZ_SCRIPT_AVESTAN = 78,
MOZ_SCRIPT_BAMUM = 79,
MOZ_SCRIPT_EGYPTIAN_HIEROGLYPHS = 80,
MOZ_SCRIPT_IMPERIAL_ARAMAIC = 81,
MOZ_SCRIPT_INSCRIPTIONAL_PAHLAVI = 82,
MOZ_SCRIPT_INSCRIPTIONAL_PARTHIAN = 83,
MOZ_SCRIPT_JAVANESE = 84,
MOZ_SCRIPT_KAITHI = 85,
MOZ_SCRIPT_LISU = 86,
MOZ_SCRIPT_MEETEI_MAYEK = 87,
MOZ_SCRIPT_OLD_SOUTH_ARABIAN = 88,
MOZ_SCRIPT_OLD_TURKIC = 89,
MOZ_SCRIPT_SAMARITAN = 90,
MOZ_SCRIPT_TAI_THAM = 91,
MOZ_SCRIPT_TAI_VIET = 92,
MOZ_SCRIPT_BATAK = 93,
MOZ_SCRIPT_BRAHMI = 94,
MOZ_SCRIPT_MANDAIC = 95,
MOZ_SCRIPT_CHAKMA = 96,
MOZ_SCRIPT_MEROITIC_CURSIVE = 97,
MOZ_SCRIPT_MEROITIC_HIEROGLYPHS = 98,
MOZ_SCRIPT_MIAO = 99,
MOZ_SCRIPT_SHARADA = 100,
MOZ_SCRIPT_SORA_SOMPENG = 101,
MOZ_SCRIPT_TAKRI = 102,
MOZ_SCRIPT_BASSA_VAH = 103,
MOZ_SCRIPT_CAUCASIAN_ALBANIAN = 104,
MOZ_SCRIPT_DUPLOYAN = 105,
MOZ_SCRIPT_ELBASAN = 106,
MOZ_SCRIPT_GRANTHA = 107,
MOZ_SCRIPT_KHOJKI = 108,
MOZ_SCRIPT_KHUDAWADI = 109,
MOZ_SCRIPT_LINEAR_A = 110,
MOZ_SCRIPT_MAHAJANI = 111,
MOZ_SCRIPT_MANICHAEAN = 112,
MOZ_SCRIPT_MENDE_KIKAKUI = 113,
MOZ_SCRIPT_MODI = 114,
MOZ_SCRIPT_MRO = 115,
MOZ_SCRIPT_NABATAEAN = 116,
MOZ_SCRIPT_OLD_NORTH_ARABIAN = 117,
MOZ_SCRIPT_OLD_PERMIC = 118,
MOZ_SCRIPT_PAHAWH_HMONG = 119,
MOZ_SCRIPT_PALMYRENE = 120,
MOZ_SCRIPT_PAU_CIN_HAU = 121,
MOZ_SCRIPT_PSALTER_PAHLAVI = 122,
MOZ_SCRIPT_SIDDHAM = 123,
MOZ_SCRIPT_TIRHUTA = 124,
MOZ_SCRIPT_WARANG_CITI = 125,
MOZ_SCRIPT_AHOM = 126,
MOZ_SCRIPT_ANATOLIAN_HIEROGLYPHS = 127,
MOZ_SCRIPT_HATRAN = 128,
MOZ_SCRIPT_MULTANI = 129,
MOZ_SCRIPT_OLD_HUNGARIAN = 130,
MOZ_SCRIPT_SIGNWRITING = 131,
MOZ_SCRIPT_MATHEMATICAL_NOTATION = 132,
MOZ_SCRIPT_BATAK = 63,
MOZ_SCRIPT_BLISSYMBOLS = 64,
MOZ_SCRIPT_BRAHMI = 65,
MOZ_SCRIPT_CHAM = 66,
MOZ_SCRIPT_CIRTH = 67,
MOZ_SCRIPT_OLD_CHURCH_SLAVONIC_CYRILLIC = 68,
MOZ_SCRIPT_DEMOTIC_EGYPTIAN = 69,
MOZ_SCRIPT_HIERATIC_EGYPTIAN = 70,
MOZ_SCRIPT_EGYPTIAN_HIEROGLYPHS = 71,
MOZ_SCRIPT_KHUTSURI = 72,
MOZ_SCRIPT_SIMPLIFIED_HAN = 73,
MOZ_SCRIPT_TRADITIONAL_HAN = 74,
MOZ_SCRIPT_PAHAWH_HMONG = 75,
MOZ_SCRIPT_OLD_HUNGARIAN = 76,
MOZ_SCRIPT_HARAPPAN_INDUS = 77,
MOZ_SCRIPT_JAVANESE = 78,
MOZ_SCRIPT_KAYAH_LI = 79,
MOZ_SCRIPT_LATIN_FRAKTUR = 80,
MOZ_SCRIPT_LATIN_GAELIC = 81,
MOZ_SCRIPT_LEPCHA = 82,
MOZ_SCRIPT_LINEAR_A = 83,
MOZ_SCRIPT_MANDAIC = 84,
MOZ_SCRIPT_MAYAN_HIEROGLYPHS = 85,
MOZ_SCRIPT_MEROITIC_HIEROGLYPHS = 86,
MOZ_SCRIPT_NKO = 87,
MOZ_SCRIPT_OLD_TURKIC = 88,
MOZ_SCRIPT_OLD_PERMIC = 89,
MOZ_SCRIPT_PHAGS_PA = 90,
MOZ_SCRIPT_PHOENICIAN = 91,
MOZ_SCRIPT_MIAO = 92,
MOZ_SCRIPT_RONGORONGO = 93,
MOZ_SCRIPT_SARATI = 94,
MOZ_SCRIPT_ESTRANGELO_SYRIAC = 95,
MOZ_SCRIPT_WESTERN_SYRIAC = 96,
MOZ_SCRIPT_EASTERN_SYRIAC = 97,
MOZ_SCRIPT_TENGWAR = 98,
MOZ_SCRIPT_VAI = 99,
MOZ_SCRIPT_VISIBLE_SPEECH = 100,
MOZ_SCRIPT_CUNEIFORM = 101,
MOZ_SCRIPT_UNWRITTEN_LANGUAGES = 102,
MOZ_SCRIPT_UNKNOWN = 103,
MOZ_SCRIPT_CARIAN = 104,
MOZ_SCRIPT_JAPANESE = 105,
MOZ_SCRIPT_TAI_THAM = 106,
MOZ_SCRIPT_LYCIAN = 107,
MOZ_SCRIPT_LYDIAN = 108,
MOZ_SCRIPT_OL_CHIKI = 109,
MOZ_SCRIPT_REJANG = 110,
MOZ_SCRIPT_SAURASHTRA = 111,
MOZ_SCRIPT_SIGNWRITING = 112,
MOZ_SCRIPT_SUNDANESE = 113,
MOZ_SCRIPT_MOON = 114,
MOZ_SCRIPT_MEETEI_MAYEK = 115,
MOZ_SCRIPT_IMPERIAL_ARAMAIC = 116,
MOZ_SCRIPT_AVESTAN = 117,
MOZ_SCRIPT_CHAKMA = 118,
MOZ_SCRIPT_KOREAN = 119,
MOZ_SCRIPT_KAITHI = 120,
MOZ_SCRIPT_MANICHAEAN = 121,
MOZ_SCRIPT_INSCRIPTIONAL_PAHLAVI = 122,
MOZ_SCRIPT_PSALTER_PAHLAVI = 123,
MOZ_SCRIPT_BOOK_PAHLAVI = 124,
MOZ_SCRIPT_INSCRIPTIONAL_PARTHIAN = 125,
MOZ_SCRIPT_SAMARITAN = 126,
MOZ_SCRIPT_TAI_VIET = 127,
MOZ_SCRIPT_MATHEMATICAL_NOTATION = 128,
MOZ_SCRIPT_SYMBOLS = 129,
MOZ_SCRIPT_BAMUM = 130,
MOZ_SCRIPT_LISU = 131,
MOZ_SCRIPT_NAKHI_GEBA = 132,
MOZ_SCRIPT_OLD_SOUTH_ARABIAN = 133,
MOZ_SCRIPT_BASSA_VAH = 134,
MOZ_SCRIPT_DUPLOYAN = 135,
MOZ_SCRIPT_ELBASAN = 136,
MOZ_SCRIPT_GRANTHA = 137,
MOZ_SCRIPT_KPELLE = 138,
MOZ_SCRIPT_LOMA = 139,
MOZ_SCRIPT_MENDE_KIKAKUI = 140,
MOZ_SCRIPT_MEROITIC_CURSIVE = 141,
MOZ_SCRIPT_OLD_NORTH_ARABIAN = 142,
MOZ_SCRIPT_NABATAEAN = 143,
MOZ_SCRIPT_PALMYRENE = 144,
MOZ_SCRIPT_KHUDAWADI = 145,
MOZ_SCRIPT_WARANG_CITI = 146,
MOZ_SCRIPT_AFAKA = 147,
MOZ_SCRIPT_JURCHEN = 148,
MOZ_SCRIPT_MRO = 149,
MOZ_SCRIPT_NUSHU = 150,
MOZ_SCRIPT_SHARADA = 151,
MOZ_SCRIPT_SORA_SOMPENG = 152,
MOZ_SCRIPT_TAKRI = 153,
MOZ_SCRIPT_TANGUT = 154,
MOZ_SCRIPT_WOLEAI = 155,
MOZ_SCRIPT_ANATOLIAN_HIEROGLYPHS = 156,
MOZ_SCRIPT_KHOJKI = 157,
MOZ_SCRIPT_TIRHUTA = 158,
MOZ_SCRIPT_CAUCASIAN_ALBANIAN = 159,
MOZ_SCRIPT_MAHAJANI = 160,
MOZ_SCRIPT_AHOM = 161,
MOZ_SCRIPT_HATRAN = 162,
MOZ_SCRIPT_MODI = 163,
MOZ_SCRIPT_MULTANI = 164,
MOZ_SCRIPT_PAU_CIN_HAU = 165,
MOZ_SCRIPT_SIDDHAM = 166,
MOZ_NUM_SCRIPT_CODES = 133,
MOZ_NUM_SCRIPT_CODES = 167,
MOZ_SCRIPT_INVALID = -1
};

View File

@ -28,7 +28,7 @@
</ms_asmv3:trustInfo>
<ms_asmv3:application xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3">
<ms_asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
<dpiAware>True/PM</dpiAware>
</ms_asmv3:windowsSettings>
</ms_asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">

View File

@ -516,6 +516,8 @@ XPCShellEnvironment::Init()
JS::CompartmentOptions options;
options.creationOptions().setZone(JS::SystemZone);
options.behaviors().setVersion(JSVERSION_LATEST);
if (xpc::SharedMemoryEnabled())
options.creationOptions().setSharedMemoryAndAtomicsEnabled(true);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx,

View File

@ -2191,12 +2191,6 @@ class MOZ_STACK_CLASS ModuleValidator
}
bool startFunctionBodies() {
if (atomicsPresent_) {
#if !defined(ENABLE_SHARED_ARRAY_BUFFER)
return failOffset(parser_.tokenStream.currentToken().pos.begin,
"shared memory and atomics not supported by this build");
#endif
}
return true;
}
bool finishFunctionBodies() {

View File

@ -2143,11 +2143,7 @@ static bool
SharedMemoryEnabled(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
#ifdef ENABLE_SHARED_ARRAY_BUFFER
args.rval().setBoolean(true);
#else
args.rval().setBoolean(false);
#endif
args.rval().setBoolean(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
return true;
}

View File

@ -150,6 +150,19 @@ function GetIterator(obj, method) {
return iterator;
}
var _builtinCtorsCache = {__proto__: null};
function GetBuiltinConstructor(builtinName) {
var ctor = _builtinCtorsCache[builtinName] ||
(_builtinCtorsCache[builtinName] = GetBuiltinConstructorImpl(builtinName));
assert(ctor, `No builtin with name "${builtinName}" found`);
return ctor;
}
function GetBuiltinPrototype(builtinName) {
return (_builtinCtorsCache[builtinName] || GetBuiltinConstructor(builtinName)).prototype;
}
// ES6 draft 20150317 7.3.20.
function SpeciesConstructor(obj, defaultConstructor) {
// Step 1.

View File

@ -2685,7 +2685,8 @@ IntegerToString(IntegerType i, int radix, mozilla::Vector<CharType, N, AP>& resu
*--cp = '-';
MOZ_ASSERT(cp >= buffer);
result.append(cp, end);
if (!result.append(cp, end))
return;
}
template<class CharType>
@ -3731,12 +3732,10 @@ BuildDataSource(JSContext* cx,
double fp = *static_cast<type*>(data); \
ToCStringBuf cbuf; \
char* str = NumberToCString(cx, &cbuf, fp); \
if (!str) { \
if (!str || !result.append(str, strlen(str))) { \
JS_ReportOutOfMemory(cx); \
return false; \
} \
\
result.append(str, strlen(str)); \
break; \
}
CTYPES_FOR_EACH_FLOAT_TYPE(FLOAT_CASE)

View File

@ -77,7 +77,8 @@ template <class T, size_t N, size_t M, class AP>
void
AppendString(mozilla::Vector<T, N, AP>& v, mozilla::Vector<T, M, AP>& w)
{
v.append(w.begin(), w.length());
if (!v.append(w.begin(), w.length()))
return;
}
template <size_t N, class AP>
@ -89,10 +90,13 @@ AppendString(mozilla::Vector<char16_t, N, AP>& v, JSString* str)
if (!linear)
return;
JS::AutoCheckCannotGC nogc;
if (linear->hasLatin1Chars())
v.append(linear->latin1Chars(nogc), linear->length());
else
v.append(linear->twoByteChars(nogc), linear->length());
if (linear->hasLatin1Chars()) {
if (!v.append(linear->latin1Chars(nogc), linear->length()))
return;
} else {
if (!v.append(linear->twoByteChars(nogc), linear->length()))
return;
}
}
template <size_t N, class AP>

View File

@ -7338,6 +7338,76 @@ BytecodeEmitter::emitSelfHostedAllowContentSpread(ParseNode* pn)
return emitTree(pn->pn_head->pn_next);
}
bool
BytecodeEmitter::isRestParameter(ParseNode* pn, bool* result)
{
if (!sc->isFunctionBox()) {
*result = false;
return true;
}
RootedFunction fun(cx, sc->asFunctionBox()->function());
if (!fun->hasRest()) {
*result = false;
return true;
}
if (!pn->isKind(PNK_NAME)) {
if (emitterMode == BytecodeEmitter::SelfHosting && pn->isKind(PNK_CALL)) {
ParseNode* pn2 = pn->pn_head;
if (pn2->getKind() == PNK_NAME && pn2->name() == cx->names().allowContentSpread)
return isRestParameter(pn2->pn_next, result);
}
*result = false;
return true;
}
if (!bindNameToSlot(pn))
return false;
*result = pn->getOp() == JSOP_GETARG && pn->pn_scopecoord.slot() == fun->nargs() - 1;
return true;
}
bool
BytecodeEmitter::emitOptimizeSpread(ParseNode* arg0, ptrdiff_t* jmp, bool* emitted)
{
// Emit a pereparation code to optimize the spread call with a rest
// parameter:
//
// function f(...args) {
// g(...args);
// }
//
// If the spread operand is a rest parameter and it's optimizable array,
// skip spread operation and pass it directly to spread call operation.
// See the comment in OptimizeSpreadCall in Interpreter.cpp for the
// optimizable conditons.
bool result = false;
if (!isRestParameter(arg0, &result))
return false;
if (!result) {
*emitted = false;
return true;
}
if (!emitTree(arg0))
return false;
if (!emit1(JSOP_OPTIMIZE_SPREADCALL))
return false;
if (!emitJump(JSOP_IFNE, 0, jmp))
return false;
if (!emit1(JSOP_POP))
return false;
*emitted = true;
return true;
}
bool
BytecodeEmitter::emitCallOrNew(ParseNode* pn)
{
@ -7490,9 +7560,20 @@ BytecodeEmitter::emitCallOrNew(ParseNode* pn)
}
}
} else {
if (!emitArray(pn2->pn_next, argc, JSOP_SPREADCALLARRAY))
ParseNode* args = pn2->pn_next;
ptrdiff_t jmp;
bool optCodeEmitted = false;
if (argc == 1) {
if (!emitOptimizeSpread(args->pn_kid, &jmp, &optCodeEmitted))
return false;
}
if (!emitArray(args, argc, JSOP_SPREADCALLARRAY))
return false;
if (optCodeEmitted)
setJumpOffsetAt(jmp);
if (isNewOp) {
if (pn->isKind(PNK_SUPERCALL)) {
if (!emit1(JSOP_NEWTARGET))

View File

@ -609,6 +609,9 @@ struct BytecodeEmitter
bool emitConditionalExpression(ConditionalExpression& conditional);
bool isRestParameter(ParseNode* pn, bool* result);
bool emitOptimizeSpread(ParseNode* arg0, ptrdiff_t* jmp, bool* emitted);
bool emitCallOrNew(ParseNode* pn);
bool emitDebugOnlyCheckSelfHosted();
bool emitSelfHostedCallFunction(ParseNode* pn);

View File

@ -1,35 +1,77 @@
// Check gating of shared memory features in asm.js (bug 1171540,
// bug 1231624, bug 1231338).
// bug 1231624, bug 1231338, bug 1231335).
//
// In asm.js, importing any atomic is a signal that shared memory is
// being used. If an atomic is imported, and if shared memory is
// disabled in the build or in the run then a type error should be
// signaled for the module at the end of the declaration section and
// the module should not be an asm.js module.
// disabled in the build or in the run then an error should be
// signaled for the module.
//
// We check these constraints during linking: the linker checks that
// the buffer has the right type and that the Atomics - if used - have
// their expected values; if shared memory is disabled then the
// Atomics object will be absent from the global or it will have
// values that are not the expected built-in values and the link will
// fail as desired.
// Do not guard on the presence of SharedArrayBuffer, we test that later.
load(libdir + "asm.js");
if (!isAsmJSCompilationAvailable())
quit(0);
// This code is not run, we only care whether it compiles as asm.js.
if (!this.Atomics) {
this.Atomics = { load: function (x, y) { return 0 },
store: function (x, y, z) { return 0 },
exchange: function (x, y, z) { return 0 },
add: function (x, y, z) { return 0 },
sub: function (x, y, z) { return 0 },
and: function (x, y, z) { return 0 },
or: function (x, y, z) { return 0 },
xor: function (x, y, z) { return 0 },
compareExchange: function (x, y, z, w) { return 0 }
};
}
function module_a(stdlib, foreign, heap) {
"use asm";
var i32a = new stdlib.Int32Array(heap);
var ld = stdlib.Atomics.load;
// There should be a type error around this line if shared memory
// is not enabled.
function do_load() {
var v = 0;
v = ld(i32a, 0)|0; // It's not actually necessary to use the atomic op
return v|0;
}
return { load: do_load };
function f() { return 0; }
return { f:f };
}
assertEq(isAsmJSModule(module_a), !!this.SharedArrayBuffer);
function module_b(stdlib, foreign, heap) {
"use asm";
var ld = stdlib.Atomics.load;
var i32a = new stdlib.Int32Array(heap);
function f() { return 0; }
return { f:f };
}
function module_c(stdlib, foreign, heap) {
"use asm";
var i32a = new stdlib.Int32Array(heap);
function f() { return 0; }
return { f:f };
}
assertEq(isAsmJSModule(module_a), true);
assertEq(isAsmJSModule(module_b), true);
assertEq(isAsmJSModule(module_c), true);
if (!this.SharedArrayBuffer) {
assertAsmLinkFail(module_a, this, {}, new ArrayBuffer(65536)); // Buffer is ignored, Atomics are bad
} else {
asmLink(module_a, this, {}, new ArrayBuffer(65536)); // Buffer is ignored, Atomics are good
assertAsmLinkFail(module_b, this, {}, new ArrayBuffer(65536)); // Buffer is wrong type
}
asmLink(module_c, this, {}, new ArrayBuffer(65536)); // Buffer is right type
if (this.SharedArrayBuffer)
assertAsmLinkFail(module_c, this, {}, new SharedArrayBuffer(65536)); // Buffer is wrong type

View File

@ -0,0 +1,7 @@
var g = /1/g;
g.exec('1234561');
g.exec();
var r = /uDC38/ug;
r.lastIndex = 1;
var str = "\uD83D\uDC38";
r.exec(str);

View File

@ -0,0 +1,73 @@
// bug 1235092
// Optimize spread call with rest parameter.
load(libdir + "asserts.js");
function makeArray(...args) {
return args;
}
// Optimizable Case.
function test(...args) {
return makeArray(...args);
}
assertDeepEq(test(1, 2, 3), [1, 2, 3]);
// Not optimizable case 1: the array has hole.
function hole1(...args) {
args[4] = 5;
return makeArray(...args);
}
assertDeepEq(hole1(1, 2, 3), [1, 2, 3, undefined, 5]);
function hole2(...args) {
args.length = 5;
return makeArray(...args);
}
assertDeepEq(hole2(1, 2, 3), [1, 2, 3, undefined, undefined]);
function hole3(...args) {
delete args[1];
return makeArray(...args);
}
assertDeepEq(hole3(1, 2, 3), [1, undefined, 3]);
// Not optimizable case 2: array[@@iterator] is modified.
function modifiedIterator(...args) {
args[Symbol.iterator] = function*() {
for (let i = 0; i < this.length; i++)
yield this[i] * 10;
};
return makeArray(...args);
}
assertDeepEq(modifiedIterator(1, 2, 3), [10, 20, 30]);
// Not optimizable case 3: the array's prototype is modified.
function modifiedProto(...args) {
args.__proto__ = {
__proto__: Array.prototype,
*[Symbol.iterator]() {
for (let i = 0; i < this.length; i++)
yield this[i] * 10;
}
};
return makeArray(...args);
}
assertDeepEq(modifiedProto(1, 2, 3), [10, 20, 30]);
// Not optimizable case 4: Array.prototype[@@iterator] is modified.
let ArrayValues = Array.prototype[Symbol.iterator];
Array.prototype[Symbol.iterator] = function*() {
for (let i = 0; i < this.length; i++)
yield this[i] * 10;
};
assertDeepEq(test(1, 2, 3), [10, 20, 30]);
Array.prototype[Symbol.iterator] = ArrayValues;
// Not optimizable case 5: %ArrayIteratorPrototype%.next is modified.
let ArrayIteratorPrototype = Object.getPrototypeOf(Array.prototype[Symbol.iterator]());
let i = 1;
ArrayIteratorPrototype.next = function() {
return { done: i % 4 == 0, value: 10 * i++ };
};
assertDeepEq(test(1, 2, 3), [10, 20, 30]);

View File

@ -0,0 +1,14 @@
for (var i=0; i<2; i++) {
var o = {};
Object.setPrototypeOf(o, null);
o = Object.create(o);
var p = {};
Object.setPrototypeOf(p, o);
}
function f() {
for (var i=1; i<20; i++)
p[i] = i;
for (var i=0; i<1500; i++)
assertEq(p[0], undefined);
}
f();

View File

@ -0,0 +1,13 @@
let getCtor = getSelfHostedValue('GetBuiltinConstructor');
assertEq(getCtor('Array'), Array);
let origArray = Array;
Array = function(){};
assertEq(getCtor('Array') == Array, false);
assertEq(getCtor('Array'), origArray);
let origMap = Map;
Map = function(){};
assertEq(getCtor('Map') == Map, false);
assertEq(getCtor('Map'), origMap);

View File

@ -21,6 +21,7 @@
#endif
#include "jit/SharedICHelpers.h"
#include "jit/VMFunctions.h"
#include "vm/Interpreter.h"
#include "vm/ScopeObject.h"
#include "vm/TraceLogging.h"
@ -3190,6 +3191,27 @@ BaselineCompiler::emit_JSOP_STRICTSPREADEVAL()
return emitSpreadCall();
}
typedef bool (*OptimizeSpreadCallFn)(JSContext*, HandleValue, bool*);
static const VMFunction OptimizeSpreadCallInfo =
FunctionInfo<OptimizeSpreadCallFn>(OptimizeSpreadCall);
bool
BaselineCompiler::emit_JSOP_OPTIMIZE_SPREADCALL()
{
frame.syncStack(0);
masm.loadValue(frame.addressOfStackValue(frame.peek(-1)), R0);
prepareVMCall();
pushArg(R0);
if (!callVM(OptimizeSpreadCallInfo))
return false;
masm.boxNonDouble(JSVAL_TYPE_BOOLEAN, ReturnReg, R0);
frame.push(R0);
return true;
}
typedef bool (*ImplicitThisFn)(JSContext*, HandleObject, HandlePropertyName,
MutableHandleValue);
static const VMFunction ImplicitThisInfo = FunctionInfo<ImplicitThisFn>(ImplicitThisOperation);

View File

@ -167,6 +167,7 @@ namespace jit {
_(JSOP_SPREADNEW) \
_(JSOP_SPREADEVAL) \
_(JSOP_STRICTSPREADEVAL) \
_(JSOP_OPTIMIZE_SPREADCALL)\
_(JSOP_IMPLICITTHIS) \
_(JSOP_GIMPLICITTHIS) \
_(JSOP_INSTANCEOF) \

View File

@ -1124,7 +1124,7 @@ PrepareAndExecuteRegExp(JSContext* cx, MacroAssembler& masm, Register regexp, Re
masm.branch32(Assembler::Above, temp3, Imm32(unicode::LeadSurrogateMax), &done);
// Move lastIndex to lead surrogate.
masm.subPtr(Imm32(2), lastIndex);
masm.subPtr(Imm32(1), lastIndex);
masm.bind(&done);
}

View File

@ -3880,8 +3880,11 @@ GenerateDenseElementHole(JSContext* cx, MacroAssembler& masm, IonCache::StubAtta
MOZ_ASSERT(pobj->as<NativeObject>().lastProperty());
masm.movePtr(ImmGCPtr(pobj), scratchReg);
if (pobj->hasUncacheableProto()) {
MOZ_ASSERT(!pobj->isSingleton());
// Non-singletons with uncacheable protos can change their proto
// without a shape change, so also guard on the group (which determines
// the proto) in this case.
if (pobj->hasUncacheableProto() && !pobj->isSingleton()) {
Address groupAddr(scratchReg, JSObject::offsetOfGroup());
masm.branchPtr(Assembler::NotEqual, groupAddr, ImmGCPtr(pobj->group()), &failures);
}

View File

@ -240,7 +240,7 @@ js::jit::RegionLock::release(void* addr)
#elif defined(ENABLE_SHARED_ARRAY_BUFFER)
# error "Either disable JS shared memory, use GCC or Clang, or add code here"
# error "Either disable JS shared memory at compile time, use GCC or Clang, or add code here"
#endif

View File

@ -234,7 +234,7 @@ js::jit::RegionLock::release(void* addr)
#elif defined(ENABLE_SHARED_ARRAY_BUFFER)
# error "Either disable JS shared memory, use GCC or Clang, or add code here"
# error "Either disable JS shared memory at compile time, use GCC or Clang, or add code here"
#endif

View File

@ -595,7 +595,7 @@ js::jit::RegionLock::release(void* addr)
#elif defined(ENABLE_SHARED_ARRAY_BUFFER)
# error "Either disable JS shared memory, use GCC, Clang, or MSVC, or add code here"
# error "Either disable JS shared memory at compile time, use GCC, Clang, or MSVC, or add code here"
#endif // platform

View File

@ -5,6 +5,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/. */
#include "jscompartment.h"
#include "jsfriendapi.h"
#include "jsapi-tests/tests.h"
@ -53,7 +54,6 @@ BEGIN_TEST(testTypedArrays)
TestArrayFromBuffer<JS_NewFloat32ArrayWithBuffer, JS_NewFloat32ArrayFromArray, float, false, JS_GetFloat32ArrayData>(cx) &&
TestArrayFromBuffer<JS_NewFloat64ArrayWithBuffer, JS_NewFloat64ArrayFromArray, double, false, JS_GetFloat64ArrayData>(cx);
#ifdef ENABLE_SHARED_ARRAY_BUFFER
ok = ok &&
TestArrayFromBuffer<JS_NewInt8ArrayWithBuffer, JS_NewInt8ArrayFromArray, int8_t, true, JS_GetInt8ArrayData>(cx) &&
TestArrayFromBuffer<JS_NewUint8ArrayWithBuffer, JS_NewUint8ArrayFromArray, uint8_t, true, JS_GetUint8ArrayData>(cx) &&
@ -64,7 +64,6 @@ BEGIN_TEST(testTypedArrays)
TestArrayFromBuffer<JS_NewUint32ArrayWithBuffer, JS_NewUint32ArrayFromArray, uint32_t, true, JS_GetUint32ArrayData>(cx) &&
TestArrayFromBuffer<JS_NewFloat32ArrayWithBuffer, JS_NewFloat32ArrayFromArray, float, true, JS_GetFloat32ArrayData>(cx) &&
TestArrayFromBuffer<JS_NewFloat64ArrayWithBuffer, JS_NewFloat64ArrayFromArray, double, true, JS_GetFloat64ArrayData>(cx);
#endif // ENABLE_SHARED_ARRAY_BUFFER
return ok;
}
@ -116,6 +115,9 @@ template<JSObject* CreateWithBuffer(JSContext*, JS::HandleObject, uint32_t, int3
bool
TestArrayFromBuffer(JSContext* cx)
{
if (Shared && !cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled())
return true;
size_t elts = 8;
size_t nbytes = elts * sizeof(Element);
RootedObject buffer(cx, Shared ? JS_NewSharedArrayBuffer(cx, nbytes)

View File

@ -1096,6 +1096,15 @@ JS_ResolveStandardClass(JSContext* cx, HandleObject obj, HandleId id, bool* reso
if (!stdnm)
stdnm = LookupStdName(cx->names(), idAtom, builtin_property_names);
#ifdef ENABLE_SHARED_ARRAY_BUFFER
if (stdnm && !cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled() &&
(stdnm->atomOffset == NAME_OFFSET(Atomics) ||
stdnm->atomOffset == NAME_OFFSET(SharedArrayBuffer)))
{
stdnm = nullptr;
}
#endif
// If this class is anonymous, then it doesn't exist as a global
// property, so we won't resolve anything.
JSProtoKey key = stdnm ? stdnm->key : JSProto_Null;
@ -1831,6 +1840,25 @@ JS::CompartmentCreationOptionsRef(JSContext* cx)
return cx->compartment()->creationOptions();
}
bool
JS::CompartmentCreationOptions::getSharedMemoryAndAtomicsEnabled() const
{
#if defined(ENABLE_SHARED_ARRAY_BUFFER)
return sharedMemoryAndAtomics_;
#else
return false;
#endif
}
JS::CompartmentCreationOptions&
JS::CompartmentCreationOptions::setSharedMemoryAndAtomicsEnabled(bool flag)
{
#if defined(ENABLE_SHARED_ARRAY_BUFFER)
sharedMemoryAndAtomics_ = flag;
#endif
return *this;
}
JS::CompartmentBehaviors&
JS::CompartmentBehaviorsRef(JSCompartment* compartment)
{

View File

@ -2175,7 +2175,8 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
mergeable_(false),
preserveJitCode_(false),
cloneSingletons_(false),
experimentalDateTimeFormatFormatToPartsEnabled_(false)
experimentalDateTimeFormatFormatToPartsEnabled_(false),
sharedMemoryAndAtomics_(false)
{
zone_.spec = JS::FreshZone;
}
@ -2255,6 +2256,8 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
return *this;
}
bool getSharedMemoryAndAtomicsEnabled() const;
CompartmentCreationOptions& setSharedMemoryAndAtomicsEnabled(bool flag);
private:
JSAddonId* addonId_;
@ -2268,6 +2271,7 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
bool preserveJitCode_;
bool cloneSingletons_;
bool experimentalDateTimeFormatFormatToPartsEnabled_;
bool sharedMemoryAndAtomics_;
};
/**

View File

@ -1653,7 +1653,10 @@ JS_NewFloat64ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
uint32_t byteOffset, int32_t length);
/**
* Create a new SharedArrayBuffer with the given byte length.
* Create a new SharedArrayBuffer with the given byte length. This
* may only be called if
* JS::CompartmentCreationOptionsRef(cx).getSharedMemoryAndAtomicsEnabled() is
* true.
*/
extern JS_FRIEND_API(JSObject*)
JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes);

View File

@ -1925,6 +1925,9 @@ js::SetClassAndProto(JSContext* cx, HandleObject obj,
RootedObject oldproto(cx, obj);
while (oldproto && oldproto->isNative()) {
if (oldproto->isSingleton()) {
// We always generate a new shape if the object is a singleton,
// regardless of the uncacheable-proto flag. ICs may rely on
// this.
if (!oldproto->as<NativeObject>().generateOwnShape(cx))
return false;
} else {

View File

@ -247,12 +247,11 @@ class JSObject : public js::gc::Cell
// exist on the scope chain) are kept.
inline bool isUnqualifiedVarObj() const;
/*
* Objects with an uncacheable proto can have their prototype mutated
* without inducing a shape change on the object. Property cache entries
* and JIT inline caches should not be filled for lookups across prototype
* lookups on the object.
*/
// Objects with an uncacheable proto can have their prototype mutated
// without inducing a shape change on the object. JIT inline caches should
// do an explicit group guard to guard against this. Singletons always
// generate a new shape when their prototype changes, regardless of this
// hasUncacheableProto flag.
inline bool hasUncacheableProto() const;
bool setUncacheableProto(js::ExclusiveContext* cx) {
return setFlags(cx, js::BaseShape::UNCACHEABLE_PROTO, GENERATE_SHAPE);

View File

@ -132,6 +132,12 @@ static const size_t gMaxStackSize = 128 * sizeof(size_t) * 1024;
*/
static const double MAX_TIMEOUT_INTERVAL = 1800.0;
#ifdef NIGHTLY_BUILD
# define SHARED_MEMORY_DEFAULT 1
#else
# define SHARED_MEMORY_DEFAULT 0
#endif
// Per-runtime shell state.
struct ShellRuntime
{
@ -169,6 +175,7 @@ static bool enableIon = false;
static bool enableAsmJS = false;
static bool enableNativeRegExp = false;
static bool enableUnboxedArrays = false;
static bool enableSharedMemory = SHARED_MEMORY_DEFAULT;
#ifdef JS_GC_ZEAL
static char gZealStr[128];
#endif
@ -2614,6 +2621,13 @@ static const JSClass sandbox_class = {
JS_GlobalObjectTraceHook
};
static void
SetStandardCompartmentOptions(JS::CompartmentOptions& options)
{
options.behaviors().setVersion(JSVERSION_DEFAULT);
options.creationOptions().setSharedMemoryAndAtomicsEnabled(enableSharedMemory);
}
static JSObject*
NewSandbox(JSContext* cx, bool lazy)
{
@ -2776,7 +2790,7 @@ WorkerMain(void* arg)
JSAutoRequest ar(cx);
JS::CompartmentOptions compartmentOptions;
compartmentOptions.behaviors().setVersion(JSVERSION_DEFAULT);
SetStandardCompartmentOptions(compartmentOptions);
RootedObject global(cx, NewGlobalObject(cx, compartmentOptions, nullptr));
if (!global)
break;
@ -3972,11 +3986,10 @@ NewGlobal(JSContext* cx, unsigned argc, Value* vp)
JSPrincipals* principals = nullptr;
JS::CompartmentOptions options;
JS::CompartmentCreationOptions& creationOptions = options.creationOptions();
JS::CompartmentBehaviors& behaviors = options.behaviors();
behaviors.setVersion(JSVERSION_DEFAULT);
SetStandardCompartmentOptions(options);
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() == 1 && args[0].isObject()) {
@ -4334,6 +4347,9 @@ GetSharedArrayBuffer(JSContext* cx, unsigned argc, Value* vp)
SharedArrayRawBuffer* buf = sharedArrayBufferMailbox;
if (buf) {
buf->addReference();
// Shared memory is enabled globally in the shell: there can't be a worker
// that does not enable it if the main thread has it.
MOZ_ASSERT(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
newObj = SharedArrayBufferObject::New(cx, buf);
if (!newObj) {
buf->dropReference();
@ -6465,6 +6481,17 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
return false;
}
#ifdef ENABLE_SHARED_ARRAY_BUFFER
if (const char* str = op.getStringOption("shared-memory")) {
if (strcmp(str, "off") == 0)
enableSharedMemory = false;
else if (strcmp(str, "on") == 0)
enableSharedMemory = true;
else
return OptionFailure("shared-memory", str);
}
#endif
#if defined(JS_CODEGEN_ARM)
if (const char* str = op.getStringOption("arm-hwcap"))
jit::ParseARMHwCapFlags(str);
@ -6570,7 +6597,7 @@ Shell(JSContext* cx, OptionParser* op, char** envp)
disableOOMFunctions = true;
JS::CompartmentOptions options;
options.behaviors().setVersion(JSVERSION_DEFAULT);
SetStandardCompartmentOptions(options);
RootedObject glob(cx, NewGlobalObject(cx, options, nullptr));
if (!glob)
return 1;
@ -6694,6 +6721,16 @@ main(int argc, char** argv, char** envp)
|| !op.addBoolOption('\0', "no-native-regexp", "Disable native regexp compilation")
|| !op.addBoolOption('\0', "no-unboxed-objects", "Disable creating unboxed plain objects")
|| !op.addBoolOption('\0', "unboxed-arrays", "Allow creating unboxed arrays")
#ifdef ENABLE_SHARED_ARRAY_BUFFER
|| !op.addStringOption('\0', "shared-memory", "on/off",
"SharedArrayBuffer and Atomics "
# if SHARED_MEMORY_DEFAULT
"(default: on, off to disable)"
# else
"(default: off, on to enable)"
# endif
)
#endif
|| !op.addStringOption('\0', "ion-shared-stubs", "on/off",
"Use shared stubs (default: off, on to enable)")
|| !op.addStringOption('\0', "ion-scalar-replacement", "on/off",

View File

@ -1773,7 +1773,6 @@ CASE(JSOP_NOP)
CASE(JSOP_UNUSED14)
CASE(JSOP_UNUSED65)
CASE(JSOP_BACKPATCH)
CASE(JSOP_UNUSED178)
CASE(JSOP_UNUSED179)
CASE(JSOP_UNUSED180)
CASE(JSOP_UNUSED181)
@ -2892,6 +2891,18 @@ CASE(JSOP_FUNCALL)
ADVANCE_AND_DISPATCH(0);
}
CASE(JSOP_OPTIMIZE_SPREADCALL)
{
ReservedRooted<Value> val(&rootValue0, REGS.sp[-1]);
bool optimized = false;
if (!OptimizeSpreadCall(cx, val, &optimized))
goto error;
PUSH_BOOLEAN(optimized);
}
END_CASE(JSOP_OPTIMIZE_SPREADCALL)
CASE(JSOP_THROWMSG)
{
JS_ALWAYS_FALSE(ThrowMsgOperation(cx, GET_UINT16(REGS.pc)));
@ -4545,14 +4556,9 @@ js::SpreadCallOperation(JSContext* cx, HandleScript script, jsbytecode* pc, Hand
constructing ? CONSTRUCT : NO_CONSTRUCT);
}
#ifdef DEBUG
// The object must be an array with dense elements and no holes. Baseline's
// optimized spread call stubs rely on this.
MOZ_ASSERT(aobj->getDenseInitializedLength() == length);
MOZ_ASSERT(!aobj->isIndexed());
for (uint32_t i = 0; i < length; i++)
MOZ_ASSERT(!aobj->getDenseElement(i).isMagic());
#endif
MOZ_ASSERT(IsPackedArray(aobj));
if (constructing) {
if (!StackCheckIsConstructorCalleeNewTarget(cx, callee, newTarget))
@ -4605,6 +4611,35 @@ js::SpreadCallOperation(JSContext* cx, HandleScript script, jsbytecode* pc, Hand
return true;
}
bool
js::OptimizeSpreadCall(JSContext* cx, HandleValue arg, bool* optimized)
{
// Optimize spread call by skipping spread operation when following
// conditions are met:
// * the argument is an array
// * the array has no hole
// * array[@@iterator] is not modified
// * the array's prototype is Array.prototype
// * Array.prototype[@@iterator] is not modified
// * %ArrayIteratorPrototype%.next is not modified
if (!arg.isObject()) {
*optimized = false;
return true;
}
RootedObject obj(cx, &arg.toObject());
if (!IsPackedArray(obj)) {
*optimized = false;
return true;
}
ForOfPIC::Chain* stubChain = ForOfPIC::getOrCreate(cx);
if (!stubChain)
return false;
return stubChain->tryOptimizeArray(cx, obj.as<ArrayObject>(), optimized);
}
JSObject*
js::NewObjectOperation(JSContext* cx, HandleScript script, jsbytecode* pc,
NewObjectKind newKind /* = GenericObject */)

View File

@ -445,6 +445,9 @@ bool
SpreadCallOperation(JSContext* cx, HandleScript script, jsbytecode* pc, HandleValue thisv,
HandleValue callee, HandleValue arr, HandleValue newTarget, MutableHandleValue res);
bool
OptimizeSpreadCall(JSContext* cx, HandleValue arg, bool* optimized);
JSObject*
NewObjectOperation(JSContext* cx, HandleScript script, jsbytecode* pc,
NewObjectKind newKind = GenericObject);

View File

@ -590,6 +590,14 @@ ThrowIfNotConstructing(JSContext *cx, const CallArgs &args, const char *builtinN
JSMSG_BUILTIN_CTOR_NO_NEW, builtinName);
}
inline bool
IsPackedArray(JSObject* obj)
{
return obj->is<ArrayObject>() && !obj->hasLazyGroup() &&
!obj->group()->hasAllFlags(OBJECT_FLAG_NON_PACKED) &&
obj->as<ArrayObject>().getDenseInitializedLength() == obj->as<ArrayObject>().length();
}
} // namespace js
#endif /* vm_NativeObject_inl_h */

View File

@ -1818,7 +1818,16 @@
* Stack: checkVal => checkVal
*/ \
macro(JSOP_DEBUGCHECKSELFHOSTED, 177,"debug-checkselfhosted", NULL, 1, 1, 1, JOF_BYTE) \
macro(JSOP_UNUSED178, 178,"unused178", NULL, 1, 0, 0, JOF_BYTE) \
/*
* Pops the top stack value, pushes the value and a boolean value that
* indicates whether the spread operation for the value can be optimized
* in spread call.
* Category: Statements
* Type: Function
* Operands:
* Stack: arr => arr optimized
*/ \
macro(JSOP_OPTIMIZE_SPREADCALL,178,"optimize-spreadcall", NULL, 1, 1, 2, JOF_BYTE) \
macro(JSOP_UNUSED179, 179,"unused179", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED180, 180,"unused180", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED181, 181,"unused181", NULL, 1, 0, 0, JOF_BYTE) \

View File

@ -149,6 +149,41 @@ intrinsic_IsInstanceOfBuiltin(JSContext* cx, unsigned argc, Value* vp)
return true;
}
/**
* Self-hosting intrinsic returning the original constructor for a builtin
* the name of which is the first and only argument.
*
* The return value is guaranteed to be the original constructor even if
* content code changed the named binding on the global object.
*
* This intrinsic shouldn't be called directly. Instead, the
* `GetBuiltinConstructor` and `GetBuiltinPrototype` helper functions in
* Utilities.js should be used, as they cache results, improving performance.
*/
static bool
intrinsic_GetBuiltinConstructor(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 1);
RootedString str(cx, args[0].toString());
JSAtom* atom;
if (str->isAtom()) {
atom = &str->asAtom();
} else {
atom = AtomizeString(cx, str);
if (!atom)
return false;
}
RootedId id(cx, AtomToId(atom));
JSProtoKey key = JS_IdToProtoKey(cx, id);
MOZ_ASSERT(key != JSProto_Null);
RootedObject ctor(cx);
if (!GetBuiltinConstructor(cx, key, &ctor))
return false;
args.rval().setObject(*ctor);
return true;
}
static bool
intrinsic_SubstringKernel(JSContext* cx, unsigned argc, Value* vp)
{
@ -505,14 +540,7 @@ intrinsic_IsPackedArray(JSContext* cx, unsigned argc, Value* vp)
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 1);
MOZ_ASSERT(args[0].isObject());
JSObject* obj = &args[0].toObject();
bool isPacked = obj->is<ArrayObject>() && !obj->hasLazyGroup() &&
!obj->group()->hasAllFlags(OBJECT_FLAG_NON_PACKED) &&
obj->as<ArrayObject>().getDenseInitializedLength() ==
obj->as<ArrayObject>().length();
args.rval().setBoolean(isPacked);
args.rval().setBoolean(IsPackedArray(&args[0].toObject()));
return true;
}
@ -1609,6 +1637,7 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_FN("ToPropertyKey", intrinsic_ToPropertyKey, 1,0),
JS_INLINABLE_FN("IsCallable", intrinsic_IsCallable, 1,0, IntrinsicIsCallable),
JS_FN("IsConstructor", intrinsic_IsConstructor, 1,0),
JS_FN("GetBuiltinConstructorImpl", intrinsic_GetBuiltinConstructor, 1,0),
JS_FN("MakeConstructible", intrinsic_MakeConstructible, 2,0),
JS_FN("_ConstructFunction", intrinsic_ConstructFunction, 2,0),
JS_FN("ThrowRangeError", intrinsic_ThrowRangeError, 4,0),

View File

@ -266,6 +266,8 @@ SharedArrayBufferObject::New(JSContext* cx, uint32_t length, HandleObject proto)
SharedArrayBufferObject*
SharedArrayBufferObject::New(JSContext* cx, SharedArrayRawBuffer* buffer, HandleObject proto)
{
MOZ_ASSERT(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
AutoSetNewObjectMetadata metadata(cx);
Rooted<SharedArrayBufferObject*> obj(cx,
NewObjectWithClassProto<SharedArrayBufferObject>(cx, proto));
@ -430,6 +432,8 @@ js::GetSharedArrayBufferLengthAndData(JSObject* obj, uint32_t* length, bool* isS
JS_FRIEND_API(JSObject*)
JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes)
{
MOZ_ASSERT(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
MOZ_ASSERT(nbytes <= INT32_MAX);
return SharedArrayBufferObject::New(cx, nbytes, /* proto = */ nullptr);
}

View File

@ -1872,6 +1872,16 @@ JSStructuredCloneReader::readTransferMap()
obj = JS_NewMappedArrayBufferWithContents(cx, nbytes, content);
} else if (tag == SCTAG_TRANSFER_MAP_SHARED_BUFFER) {
MOZ_ASSERT(data == JS::SCTAG_TMO_SHARED_BUFFER);
// There's no guarantee that the receiving agent has enabled
// shared memory even if the transmitting agent has done so.
// Ideally we'd check at the transmission point, but that's
// tricky, and it will be a very rare problem in any case.
// Just fail at the receiving end if we can't handle it.
if (!context()->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled()) {
JS_ReportErrorNumber(context(), GetErrorMessage, nullptr,
JSMSG_SC_NOT_TRANSFERABLE);
return false;
}
obj = SharedArrayBufferObject::New(context(), (SharedArrayRawBuffer*)content);
} else {
if (!callbacks || !callbacks->readTransfer) {

View File

@ -29,7 +29,7 @@ namespace js {
*
* https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
*/
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 339;
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 340;
static const uint32_t XDR_BYTECODE_VERSION =
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);

View File

@ -550,6 +550,9 @@ mozJSComponentLoader::PrepareObjectForLocation(JSContext* aCx,
options.behaviors().setVersion(JSVERSION_LATEST);
if (xpc::SharedMemoryEnabled())
options.creationOptions().setSharedMemoryAndAtomicsEnabled(true);
// Defer firing OnNewGlobalObject until after the __URI__ property has
// been defined so the JS debugger can tell what module the global is
// for

View File

@ -117,6 +117,11 @@ bool xpc::ExtraWarningsForSystemJS() { return sExtraWarningsForSystemJS; }
bool xpc::ExtraWarningsForSystemJS() { return false; }
#endif
static mozilla::Atomic<bool> sSharedMemoryEnabled(false);
bool
xpc::SharedMemoryEnabled() { return sSharedMemoryEnabled; }
// *Some* NativeSets are referenced from mClassInfo2NativeSetMap.
// *All* NativeSets are referenced from mNativeSetMap.
// So, in mClassInfo2NativeSetMap we just clear references to the unmarked.
@ -1564,6 +1569,9 @@ ReloadPrefsCallback(const char* pref, void* data)
bool werror = Preferences::GetBool(JS_OPTIONS_DOT_STR "werror");
bool extraWarnings = Preferences::GetBool(JS_OPTIONS_DOT_STR "strict");
sSharedMemoryEnabled = Preferences::GetBool(JS_OPTIONS_DOT_STR "shared_memory");
#ifdef DEBUG
sExtraWarningsForSystemJS = Preferences::GetBool(JS_OPTIONS_DOT_STR "strict.debug");
#endif

View File

@ -1480,6 +1480,8 @@ XRE_XPCShellMain(int argc, char** argv, char** envp)
// System Zone) to improve cross-zone test coverage.
JS::CompartmentOptions options;
options.creationOptions().setZone(JS::FreshZone);
if (xpc::SharedMemoryEnabled())
options.creationOptions().setSharedMemoryAndAtomicsEnabled(true);
options.behaviors().setVersion(JSVERSION_LATEST);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx,

View File

@ -492,6 +492,9 @@ SimulateActivityCallback(bool aActive);
bool
ShouldDiscardSystemSource();
bool
SharedMemoryEnabled();
bool
SetAddonInterposition(const nsACString& addonId, nsIAddonInterposition* interposition);

View File

@ -32,6 +32,7 @@ struct CSSTransformedLayerPixel;
struct RenderTargetPixel;
struct ScreenPixel;
struct ParentLayerPixel;
struct DesktopPixel;
template<> struct IsPixel<CSSPixel> : TrueType {};
template<> struct IsPixel<LayoutDevicePixel> : TrueType {};
@ -40,6 +41,7 @@ template<> struct IsPixel<CSSTransformedLayerPixel> : TrueType {};
template<> struct IsPixel<RenderTargetPixel> : TrueType {};
template<> struct IsPixel<ScreenPixel> : TrueType {};
template<> struct IsPixel<ParentLayerPixel> : TrueType {};
template<> struct IsPixel<DesktopPixel> : TrueType {};
typedef gfx::CoordTyped<CSSPixel> CSSCoord;
typedef gfx::IntCoordTyped<CSSPixel> CSSIntCoord;
@ -123,6 +125,15 @@ typedef gfx::MarginTyped<ParentLayerPixel> ParentLayerMargin;
typedef gfx::IntMarginTyped<ParentLayerPixel> ParentLayerIntMargin;
typedef gfx::IntRegionTyped<ParentLayerPixel> ParentLayerIntRegion;
typedef gfx::CoordTyped<DesktopPixel> DesktopCoord;
typedef gfx::IntCoordTyped<DesktopPixel> DesktopIntCoord;
typedef gfx::PointTyped<DesktopPixel> DesktopPoint;
typedef gfx::IntPointTyped<DesktopPixel> DesktopIntPoint;
typedef gfx::SizeTyped<DesktopPixel> DesktopSize;
typedef gfx::IntSizeTyped<DesktopPixel> DesktopIntSize;
typedef gfx::RectTyped<DesktopPixel> DesktopRect;
typedef gfx::IntRectTyped<DesktopPixel> DesktopIntRect;
typedef gfx::ScaleFactor<CSSPixel, LayoutDevicePixel> CSSToLayoutDeviceScale;
typedef gfx::ScaleFactor<CSSPixel, LayerPixel> CSSToLayerScale;
typedef gfx::ScaleFactor<CSSPixel, ScreenPixel> CSSToScreenScale;
@ -144,6 +155,7 @@ typedef gfx::ScaleFactor<ScreenPixel, ParentLayerPixel> ScreenToParentLayerScale
typedef gfx::ScaleFactor<ParentLayerPixel, LayerPixel> ParentLayerToLayerScale;
typedef gfx::ScaleFactor<ParentLayerPixel, ScreenPixel> ParentLayerToScreenScale;
typedef gfx::ScaleFactor<ParentLayerPixel, ParentLayerPixel> ParentLayerToParentLayerScale;
typedef gfx::ScaleFactor<DesktopPixel, LayoutDevicePixel> DesktopToLayoutDeviceScale;
typedef gfx::ScaleFactors2D<CSSPixel, LayoutDevicePixel> CSSToLayoutDeviceScale2D;
typedef gfx::ScaleFactors2D<CSSPixel, LayerPixel> CSSToLayerScale2D;
@ -290,6 +302,10 @@ struct LayoutDevicePixel {
return LayoutDeviceIntRect::FromUnknownRect(aRect.ToNearestPixels(aAppUnitsPerDevPixel));
}
static LayoutDeviceIntRect FromAppUnitsToInside(const nsRect& aRect, nscoord aAppUnitsPerDevPixel) {
return LayoutDeviceIntRect::FromUnknownRect(aRect.ToInsidePixels(aAppUnitsPerDevPixel));
}
static LayoutDeviceIntSize FromAppUnitsRounded(const nsSize& aSize, nscoord aAppUnitsPerDevPixel) {
return LayoutDeviceIntSize(
NSAppUnitsToIntPixels(aSize.width, aAppUnitsPerDevPixel),
@ -385,6 +401,23 @@ struct ScreenPixel {
struct ParentLayerPixel {
};
/*
* Pixels in the coordinate space used by the host OS to manage windows on the
* desktop. What these mean varies between OSs:
* - by default (unless implemented differently in platform-specific widget
* code) they are the same as LayoutDevicePixels
* - on Mac OS X, they're "cocoa points", which correspond to device pixels
* on a non-Retina display, and to 2x device pixels on Retina
* - on Windows *without* per-monitor DPI support, they are Windows "logical
* pixels", i.e. device pixels scaled according to the Windows display DPI
* scaling factor (typically one of 1.25, 1.5, 1.75, 2.0...)
* - on Windows *with* per-monitor DPI support, they are physical device pixels
* on each screen; note that this means the scaling between CSS pixels and
* desktop pixels may vary across multiple displays.
*/
struct DesktopPixel {
};
// Operators to apply ScaleFactors directly to Coords, Points, Rects, Sizes and Margins
template<class src, class dst>

View File

@ -1428,8 +1428,17 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
// If a panel is being moved or has flip="none", don't constrain or flip it. But always do this for
// content shells, so that the popup doesn't extend outside the containing frame.
if (mInContentShell || (mFlip != FlipType_None && (!aIsMove || mPopupType != ePopupTypePanel))) {
nsRect screenRect = GetConstraintRect(anchorRect, rootScreenRect, popupLevel);
if (mInContentShell || (mFlip != FlipType_None &&
(!aIsMove || mPopupType != ePopupTypePanel))) {
int32_t appPerDev = presContext->AppUnitsPerDevPixel();
LayoutDeviceIntRect anchorRectDevPix =
LayoutDeviceIntRect::FromAppUnitsToNearest(anchorRect, appPerDev);
LayoutDeviceIntRect rootScreenRectDevPix =
LayoutDeviceIntRect::FromAppUnitsToNearest(rootScreenRect, appPerDev);
LayoutDeviceIntRect screenRectDevPix =
GetConstraintRect(anchorRectDevPix, rootScreenRectDevPix, popupLevel);
nsRect screenRect =
LayoutDeviceIntRect::ToAppUnits(screenRectDevPix, appPerDev);
// Ensure that anchorRect is on screen.
anchorRect = anchorRect.Intersect(screenRect);
@ -1527,13 +1536,12 @@ nsMenuPopupFrame::GetCurrentMenuItem()
return mCurrentMenu;
}
nsRect
nsMenuPopupFrame::GetConstraintRect(const nsRect& aAnchorRect,
const nsRect& aRootScreenRect,
LayoutDeviceIntRect
nsMenuPopupFrame::GetConstraintRect(const LayoutDeviceIntRect& aAnchorRect,
const LayoutDeviceIntRect& aRootScreenRect,
nsPopupLevel aPopupLevel)
{
nsIntRect screenRectPixels;
nsPresContext* presContext = PresContext();
LayoutDeviceIntRect screenRectPixels;
// determine the available screen space. It will be reduced by the OS chrome
// such as menubars. It addition, for content shells, it will be the area of
@ -1545,13 +1553,10 @@ nsMenuPopupFrame::GetConstraintRect(const nsRect& aAnchorRect,
// This is because we need to constrain the content to this content area,
// so we should use the same screen. Otherwise, use the screen where the
// anchor is located.
nsRect rect = mInContentShell ? aRootScreenRect : aAnchorRect;
// nsIScreenManager::ScreenForRect wants the coordinates in CSS pixels
int32_t width = std::max(1, nsPresContext::AppUnitsToIntCSSPixels(rect.width));
int32_t height = std::max(1, nsPresContext::AppUnitsToIntCSSPixels(rect.height));
sm->ScreenForRect(nsPresContext::AppUnitsToIntCSSPixels(rect.x),
nsPresContext::AppUnitsToIntCSSPixels(rect.y),
width, height, getter_AddRefs(screen));
LayoutDeviceIntRect rect = mInContentShell ? aRootScreenRect : aAnchorRect;
int32_t width = std::max(1, rect.width);
int32_t height = std::max(1, rect.height);
sm->ScreenForRect(rect.x, rect.y, width, height, getter_AddRefs(screen));
if (screen) {
// Non-top-level popups (which will always be panels)
// should never overlap the OS bar:
@ -1559,20 +1564,19 @@ nsMenuPopupFrame::GetConstraintRect(const nsRect& aAnchorRect,
// get the total screen area if the popup is allowed to overlap it.
if (!dontOverlapOSBar && mMenuCanOverlapOSBar && !mInContentShell)
screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,
&screenRectPixels.width, &screenRectPixels.height);
&screenRectPixels.width, &screenRectPixels.height);
else
screen->GetAvailRect(&screenRectPixels.x, &screenRectPixels.y,
&screenRectPixels.width, &screenRectPixels.height);
&screenRectPixels.width, &screenRectPixels.height);
}
}
nsRect screenRect = ToAppUnits(screenRectPixels, presContext->AppUnitsPerDevPixel());
if (mInContentShell) {
// for content shells, clip to the client area rather than the screen area
screenRect.IntersectRect(screenRect, aRootScreenRect);
screenRectPixels.IntersectRect(screenRectPixels, aRootScreenRect);
}
return screenRect;
return screenRectPixels;
}
void nsMenuPopupFrame::CanAdjustEdges(int8_t aHorizontalSide,

View File

@ -362,8 +362,11 @@ public:
// For non-toplevel popups (which will always be panels), we will also
// constrain them to the available screen rect, ie they will not fall
// underneath the taskbar, dock or other fixed OS elements.
nsRect GetConstraintRect(const nsRect& aAnchorRect, const nsRect& aRootScreenRect,
nsPopupLevel aPopupLevel);
// This operates in device pixels.
mozilla::LayoutDeviceIntRect
GetConstraintRect(const mozilla::LayoutDeviceIntRect& aAnchorRect,
const mozilla::LayoutDeviceIntRect& aRootScreenRect,
nsPopupLevel aPopupLevel);
// Determines whether the given edges of the popup may be moved, where
// aHorizontalSide and aVerticalSide are one of the NS_SIDE_* constants, or

View File

@ -228,12 +228,15 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();
nsPopupLevel popupLevel = menuPopupFrame->PopupLevel();
nsRect screenRect = menuPopupFrame->GetConstraintRect(frameRect, rootScreenRect, popupLevel);
// round using ToInsidePixels as it's better to be a pixel too small
// than be too large. If the popup is too large it could get flipped
// to the opposite side of the anchor point while resizing.
nsIntRect screenRectPixels = screenRect.ToInsidePixels(aPresContext->AppUnitsPerDevPixel());
rect.IntersectRect(rect, LayoutDeviceIntRect::FromUnknownRect(screenRectPixels));
int32_t appPerDev = aPresContext->AppUnitsPerDevPixel();
LayoutDeviceIntRect screenRect = menuPopupFrame->GetConstraintRect
(LayoutDeviceIntRect::FromAppUnitsToNearest(frameRect, appPerDev),
// round using ...ToInside as it's better to be a pixel too small
// than be too large. If the popup is too large it could get flipped
// to the opposite side of the anchor point while resizing.
LayoutDeviceIntRect::FromAppUnitsToInside(rootScreenRect, appPerDev),
popupLevel);
rect.IntersectRect(rect, screenRect);
}
if (contentToResize) {

View File

@ -29,7 +29,7 @@ else:
LOCAL_INCLUDES += ['/media/libav']
# Suppress warnings in third-party code.
if CONFIG['GNU_CC']:
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-parentheses',
'-Wno-pointer-sign',
@ -37,12 +37,12 @@ if CONFIG['GNU_CC']:
'-Wno-switch',
'-Wno-type-limits',
]
if CONFIG['CLANG_CXX']:
CFLAGS += [
'-Wno-incompatible-pointer-types-discards-qualifiers',
'-Wno-logical-op-parentheses',
]
elif CONFIG['_MSC_VER']:
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-incompatible-pointer-types-discards-qualifiers',
'-Wno-logical-op-parentheses',
]
if CONFIG['_MSC_VER'] and not CONFIG['CLANG_CL']:
CFLAGS += [
'-wd4090', # 'return' : different 'const' qualifiers
'-wd4018', # '>' : signed/unsigned mismatch

View File

@ -22,10 +22,15 @@ FINAL_LIBRARY = 'gkmedias'
DEFINES['THEORA_DISABLE_ENCODE'] = True
# Suppress warnings in third-party code.
if CONFIG['GNU_CC']:
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
CFLAGS += ['-Wno-type-limits']
if CONFIG['CLANG_CXX']:
CFLAGS += ['-Wno-tautological-compare']
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
CFLAGS += ['-Wno-tautological-compare']
if CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-pointer-sign',
'-Wno-shift-op-parentheses',
]
UNIFIED_SOURCES += [
'lib/apiwrapper.c',

View File

@ -82,7 +82,7 @@ if CONFIG['CLANG_CL'] or not CONFIG['_MSC_VER']:
SOURCES[f].flags += ['-mavx2']
# Suppress warnings in third-party code.
if CONFIG['GNU_CC']:
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-sign-compare',
'-Wno-unused-function', # so many of these warnings; just ignore them

View File

@ -1168,6 +1168,12 @@ pref("javascript.options.mem.gc_max_empty_chunk_count", 30);
pref("javascript.options.showInConsole", false);
#ifdef NIGHTLY_BUILD
pref("javascript.options.shared_memory", true);
#else
pref("javascript.options.shared_memory", false);
#endif
// advanced prefs
pref("advanced.mailftp", false);
pref("image.animation_mode", "normal");

View File

@ -1783,6 +1783,8 @@ CacheFile::DataSize(int64_t* aSize)
bool
CacheFile::IsDoomed()
{
CacheFileAutoLock lock(this);
if (!mHandle)
return false;

View File

@ -549,6 +549,8 @@ nsHttpHandler::GetCookieService()
nsresult
nsHttpHandler::GetIOService(nsIIOService** result)
{
NS_ENSURE_ARG_POINTER(result);
NS_ADDREF(*result = mIOService);
return NS_OK;
}

Some files were not shown because too many files have changed in this diff Show More