Merge mozilla-central to b2g-inbound

This commit is contained in:
Carsten "Tomcat" Book 2016-01-04 13:52:00 +01:00
commit 8f85c8232a
63 changed files with 656 additions and 619 deletions

View File

@ -1444,65 +1444,35 @@ if test "$GNU_CC"; then
fi
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
# -Wchar-subscripts - catches array index using signed char
# -Wcomment - catches nested comments
# https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Warning-Options.html
# -Wall - lots of useful warnings
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
# -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
# -Wenum-compare - catches comparison of different enum types
# -Wignored-qualifiers - catches returns types with qualifiers like const
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
# -Wmultichar - catches multicharacter integer constants like 'THIS'
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Wnonnull - catches NULL used with functions arguments marked as non-null
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
# -Wpointer-sign - catches mixing pointers to signed and unsigned types
# -Wpointer-to-int-cast - catches casts from pointer to different sized int
# -Wreturn-type - catches missing returns, zero false positives
# -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
# -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
# -Wunknown-pragmas - catches unexpected #pragma directives
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wempty-body"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wpointer-to-int-cast"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wsign-compare"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wignored-qualifiers"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wpointer-arith"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
# Treat some warnings as errors if --enable-warnings-as-errors:
if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=char-subscripts"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=comment"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=endif-labels"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=enum-compare"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=ignored-qualifiers"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=int-to-pointer-cast"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=multichar"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=nonnull"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-arith"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-sign"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=return-type"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=sequence-point"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=trigraphs"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=uninitialized"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=unknown-pragmas"
MOZ_C_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_c_has_werror_non_literal_null_conversion)
MOZ_C_SUPPORTS_WARNING(-Werror=, sometimes-uninitialized, ac_c_has_sometimes_uninitialized)
fi
# Turn off the following warnings that -Wall turns on:
# -Wno-unused - lots of violations in third-party code
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Wsometimes-initialized - catches some uninitialized values
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_cxx_has_wno_unused_local_typedef)
# XXX: at the time of writing, the version of clang used on the OS X test
# machines has a bug that causes it to reject some valid files if both
# -Wnon-literal-null-conversion and -Wsometimes-uninitialized are
# specified. We work around this by instead using
# -Werror=non-literal-null-conversion, but we only do that when
# --enable-warnings-as-errors is specified so that no unexpected fatal
# warnings are produced.
if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
MOZ_C_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_c_has_non_literal_null_conversion)
fi
MOZ_C_SUPPORTS_WARNING(-W, sometimes-uninitialized, ac_c_has_sometimes_uninitialized)
# -Wcast-align - catches problems with cast alignment
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1515,8 +1485,17 @@ if test "$GNU_CC"; then
esac
fi
# Turn off some non-useful warnings that -Wall turns on.
# -Wno-unused - lots of violations in third-party code
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
MOZ_C_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_c_has_wno_unused_local_typedef)
_DEFINES_CFLAGS='-include $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
elif test "$SOLARIS_SUNPRO_CC"; then
@ -1548,65 +1527,37 @@ if test "$GNU_CXX"; then
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
# https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Warning-Options.html
# -Wall - lots of useful warnings
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
# -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
# -Wmissing-braces - catches aggregate initializers missing nested braces
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Woverloaded-virtual - function declaration hides virtual function from base class
# -Wparentheses - catches `if (a=b)` and operator precedence bugs
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
# -Wrange-loop-analysis - catches copies during range-based for loops.
# -Wreturn-type - catches missing returns, zero false positives
# -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
# -Wswitch - catches switches without all enum cases or default case
# -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
# -Wunused-label - catches unused goto labels
# -Wwrite-strings - catches non-const char* pointers to string literals
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wempty-body"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Woverloaded-virtual"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wsign-compare"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wwrite-strings"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wpointer-arith"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wtype-limits"
# Treat some warnings as errors if --enable-warnings-as-errors:
if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=endif-labels"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=int-to-pointer-cast"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=missing-braces"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=parentheses"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=pointer-arith"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=sequence-point"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=switch"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=trigraphs"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=type-limits"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=uninitialized"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-label"
MOZ_CXX_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_cxx_has_werror_non_literal_null_conversion)
MOZ_CXX_SUPPORTS_WARNING(-Werror=, range-loop-analysis, ac_cxx_has_range_loop_analysis)
MOZ_CXX_SUPPORTS_WARNING(-Werror=, sometimes-uninitialized, ac_cxx_has_sometimes_uninitialized)
fi
# Turn off the following warnings that -Wall turns on:
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
# -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
# for performance reasons, and because GCC and clang accept it (though
# clang warns about it).
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Wrange-loop-analysis - catches copies during range-based for loops.
# -Wsometimes-initialized - catches some uninitialized values
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, inline-new-delete, ac_cxx_has_wno_inline_new_delete)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_cxx_has_wno_unused_local_typedef)
# XXX: at the time of writing, the version of clang used on the OS X test
# machines has a bug that causes it to reject some valid files if both
# -Wnon-literal-null-conversion and -Wsometimes-uninitialized are
# specified. We work around this by instead using
# -Werror=non-literal-null-conversion, but we only do that when
# --enable-warnings-as-errors is specified so that no unexpected fatal
# warnings are produced.
if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
MOZ_CXX_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_cxx_has_non_literal_null_conversion)
fi
MOZ_CXX_SUPPORTS_WARNING(-W, range-loop-analysis, ac_cxx_has_range_loop_analysis)
MOZ_CXX_SUPPORTS_WARNING(-W, sometimes-uninitialized, ac_cxx_has_sometimes_uninitialized)
# -Wcast-align - catches problems with cast alignment
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1619,8 +1570,15 @@ if test "$GNU_CXX"; then
esac
fi
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(topobjdir)/mozilla-config.h'
_USE_CPP_INCLUDE_FLAG=1
# Turn off some non-useful warnings that -Wall turns on.
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
# -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
MOZ_CXX_SUPPORTS_WARNING(-Wno-, inline-new-delete, ac_cxx_has_wno_inline_new_delete)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_cxx_has_wno_unused_local_typedef)
# Recent clang and gcc support C++11 deleted functions without warnings if
# compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
@ -1633,6 +1591,9 @@ if test "$GNU_CXX"; then
MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
fi
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(topobjdir)/mozilla-config.h'
_USE_CPP_INCLUDE_FLAG=1
else
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
fi
@ -3006,7 +2967,7 @@ dnl Checks for library functions.
dnl ========================================================
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf)
AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo)
dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<iframe style="display:none" srcdoc="
<html>
<head>
<script type='text/javascript'>
function boom() {
var gl = canvas.getContext('experimental-webgl');
video.srcObject = canvas.captureStream(0);
}
</script>
</head>
<body onload='boom();'>
<video id='video' width='256' height='256'></video>
<canvas id='canvas' width='256' height='256'></canvas>
</body>
</html>
"></iframe>

View File

@ -26,4 +26,5 @@ load 1190705.html
load 1223740-1.html
load 1225381-1.html
load 1229932-1.html
load 1233613.html
load texImage2D.html

View File

@ -683,7 +683,13 @@ HTMLCanvasElement::CaptureStream(const Optional<double>& aFrameRate,
}
stream->CreateOwnDOMTrack(videoTrackId, MediaSegment::VIDEO);
RegisterFrameCaptureListener(stream->FrameCaptureListener());
rv = RegisterFrameCaptureListener(stream->FrameCaptureListener());
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return stream.forget();
}
@ -1128,38 +1134,52 @@ HTMLCanvasElement::IsContextCleanForFrameCapture()
return mCurrentContext && mCurrentContext->IsContextCleanForFrameCapture();
}
void
nsresult
HTMLCanvasElement::RegisterFrameCaptureListener(FrameCaptureListener* aListener)
{
WeakPtr<FrameCaptureListener> listener = aListener;
if (mRequestedFrameListeners.Contains(listener)) {
return;
return NS_OK;
}
mRequestedFrameListeners.AppendElement(listener);
if (!mRequestedFrameRefreshObserver) {
nsIDocument* doc = OwnerDoc();
MOZ_RELEASE_ASSERT(doc);
if (!doc) {
return NS_ERROR_FAILURE;
}
while (doc->GetParentDocument()) {
doc = doc->GetParentDocument();
}
nsIPresShell* shell = doc->GetShell();
MOZ_RELEASE_ASSERT(shell);
if (!shell) {
return NS_ERROR_FAILURE;
}
nsPresContext* context = shell->GetPresContext();
MOZ_RELEASE_ASSERT(context);
if (!context) {
return NS_ERROR_FAILURE;
}
context = context->GetRootPresContext();
MOZ_RELEASE_ASSERT(context);
if (!context) {
return NS_ERROR_FAILURE;
}
nsRefreshDriver* driver = context->RefreshDriver();
MOZ_RELEASE_ASSERT(driver);
if (!driver) {
return NS_ERROR_FAILURE;
}
mRequestedFrameRefreshObserver =
new RequestedFrameRefreshObserver(this, driver);
}
mRequestedFrameListeners.AppendElement(listener);
mRequestedFrameRefreshObserver->Register();
return NS_OK;
}
bool

View File

@ -266,7 +266,7 @@ public:
* caller's responsibility to keep them alive. Once a registered
* FrameCaptureListener is destroyed it will be automatically deregistered.
*/
void RegisterFrameCaptureListener(FrameCaptureListener* aListener);
nsresult RegisterFrameCaptureListener(FrameCaptureListener* aListener);
/*
* Returns true when there is at least one registered FrameCaptureListener

View File

@ -1560,4 +1560,8 @@ function isSlowPlatform() {
return SpecialPowers.Services.appinfo.name == "B2G" || getAndroidVersion() == 10;
}
SimpleTest.requestFlakyTimeout("untriaged");
// Could be undefined in a page opened by the parent test page
// like file_access_controls.html.
if ("SimpleTest" in window) {
SimpleTest.requestFlakyTimeout("untriaged");
}

View File

@ -190,7 +190,6 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
mPhase = PHASE_CONSTRUCTION;
MOZ_ASSERT(mKeepAlive.IsEmpty(), "uncommitted txn?");
RefPtr<gfxContext> targetContext = aTarget;
// If the last transaction was incomplete (a failed DoEmptyTransaction),
// don't signal a new transaction to ShadowLayerForwarder. Carry on adding

View File

@ -56,7 +56,7 @@ static void DrawDebugOverlay(mozilla::gfx::DrawTarget* dt, int x, int y, int wid
// Draw text using cairo toy text API
// XXX: this drawing will silently fail if |dt| doesn't have a Cairo backend
cairo_t* cr = gfxContext::RefCairo(dt);
cairo_t* cr = gfxFont::RefCairo(dt);
cairo_set_font_size(cr, 25);
cairo_text_extents_t extents;
cairo_text_extents(cr, ss.str().c_str(), &extents);
@ -1328,8 +1328,6 @@ ClientMultiTiledLayerBuffer::ValidateTile(TileClient& aTile,
RefPtr<DrawTarget> drawTarget = backBuffer->BorrowDrawTarget();
drawTarget->SetTransform(Matrix());
RefPtr<gfxContext> ctxt = new gfxContext(drawTarget);
// XXX Perhaps we should just copy the bounding rectangle here?
RefPtr<gfx::SourceSurface> source = mSinglePaintDrawTarget->Snapshot();
nsIntRegionRectIterator it(aDirtyRegion);
@ -1363,7 +1361,6 @@ ClientMultiTiledLayerBuffer::ValidateTile(TileClient& aTile,
aTileOrigin.y * GetPresShellResolution(), GetTileLength(), GetTileLength());
#endif
ctxt = nullptr;
drawTarget = nullptr;
nsIntRegion tileRegion =

View File

@ -129,40 +129,6 @@ gfxContext::CurrentSurface(gfxFloat *dx, gfxFloat *dy)
return nullptr;
}
static void
DestroyRefCairo(void* aData)
{
cairo_t* refCairo = static_cast<cairo_t*>(aData);
MOZ_ASSERT(refCairo);
cairo_destroy(refCairo);
}
/* static */ cairo_t *
gfxContext::RefCairo(DrawTarget* aDT)
{
// DrawTargets that don't use a Cairo backend can be given a 1x1 "reference"
// |cairo_t*|, stored in the DrawTarget's user data, for doing font-related
// operations.
static UserDataKey sRefCairo;
cairo_t* refCairo = nullptr;
if (aDT->GetBackendType() == BackendType::CAIRO) {
refCairo = static_cast<cairo_t*>
(aDT->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
if (refCairo) {
return refCairo;
}
}
refCairo = static_cast<cairo_t*>(aDT->GetUserData(&sRefCairo));
if (!refCairo) {
refCairo = cairo_create(gfxPlatform::GetPlatform()->ScreenReferenceSurface()->CairoSurface());
aDT->AddUserData(&sRefCairo, refCairo, DestroyRefCairo);
}
return refCairo;
}
void
gfxContext::Save()
{
@ -1296,86 +1262,3 @@ gfxContext::PushNewDT(gfxContentType content)
mDT = newDT;
}
/**
* Work out whether cairo will snap inter-glyph spacing to pixels.
*
* Layout does not align text to pixel boundaries, so, with font drawing
* backends that snap glyph positions to pixels, it is important that
* inter-glyph spacing within words is always an integer number of pixels.
* This ensures that the drawing backend snaps all of the word's glyphs in the
* same direction and so inter-glyph spacing remains the same.
*/
void
gfxContext::GetRoundOffsetsToPixels(bool *aRoundX, bool *aRoundY)
{
*aRoundX = false;
// Could do something fancy here for ScaleFactors of
// AxisAlignedTransforms, but we leave things simple.
// Not much point rounding if a matrix will mess things up anyway.
// Also return false for non-cairo contexts.
if (CurrentMatrix().HasNonTranslation()) {
*aRoundY = false;
return;
}
// All raster backends snap glyphs to pixels vertically.
// Print backends set CAIRO_HINT_METRICS_OFF.
*aRoundY = true;
cairo_t *cr = gfxContext::RefCairo(GetDrawTarget());
cairo_scaled_font_t *scaled_font = cairo_get_scaled_font(cr);
// bug 1198921 - this sometimes fails under Windows for whatver reason
NS_ASSERTION(scaled_font, "null cairo scaled font should never be returned "
"by cairo_get_scaled_font");
if (!scaled_font) {
*aRoundX = true; // default to the same as the fallback path below
return;
}
// Sometimes hint metrics gets set for us, most notably for printing.
cairo_font_options_t *font_options = cairo_font_options_create();
cairo_scaled_font_get_font_options(scaled_font, font_options);
cairo_hint_metrics_t hint_metrics =
cairo_font_options_get_hint_metrics(font_options);
cairo_font_options_destroy(font_options);
switch (hint_metrics) {
case CAIRO_HINT_METRICS_OFF:
*aRoundY = false;
return;
case CAIRO_HINT_METRICS_DEFAULT:
// Here we mimic what cairo surface/font backends do. Printing
// surfaces have already been handled by hint_metrics. The
// fallback show_glyphs implementation composites pixel-aligned
// glyph surfaces, so we just pick surface/font combinations that
// override this.
switch (cairo_scaled_font_get_type(scaled_font)) {
#if CAIRO_HAS_DWRITE_FONT // dwrite backend is not in std cairo releases yet
case CAIRO_FONT_TYPE_DWRITE:
// show_glyphs is implemented on the font and so is used for
// all surface types; however, it may pixel-snap depending on
// the dwrite rendering mode
if (!cairo_dwrite_scaled_font_get_force_GDI_classic(scaled_font) &&
gfxWindowsPlatform::GetPlatform()->DWriteMeasuringMode() ==
DWRITE_MEASURING_MODE_NATURAL) {
return;
}
MOZ_FALLTHROUGH;
#endif
case CAIRO_FONT_TYPE_QUARTZ:
// Quartz surfaces implement show_glyphs for Quartz fonts
if (cairo_surface_get_type(cairo_get_target(cr)) ==
CAIRO_SURFACE_TYPE_QUARTZ) {
return;
}
break;
default:
break;
}
break;
case CAIRO_HINT_METRICS_ON:
break;
}
*aRoundX = true;
}

View File

@ -85,12 +85,6 @@ public:
return CurrentSurface(nullptr, nullptr);
}
/**
* Return the reference cairo_t object from aDT.
* XXX this should be moved into gfxFont at some point.
*/
static cairo_t* RefCairo(mozilla::gfx::DrawTarget* aDT);
mozilla::gfx::DrawTarget *GetDrawTarget() { return mDT; }
/**
@ -445,9 +439,6 @@ public:
mozilla::gfx::Point GetDeviceOffset() const;
// Work out whether cairo will snap inter-glyph spacing to pixels.
void GetRoundOffsetsToPixels(bool *aRoundX, bool *aRoundY);
#ifdef MOZ_DUMP_PAINTING
/**
* Debug functions to encode the current surface as a PNG and export it.

View File

@ -454,7 +454,7 @@ gfxDWriteFont::GetSpaceGlyph()
}
bool
gfxDWriteFont::SetupCairoFont(gfxContext *aContext)
gfxDWriteFont::SetupCairoFont(DrawTarget* aDrawTarget)
{
cairo_scaled_font_t *scaledFont = GetCairoScaledFont();
if (cairo_scaled_font_status(scaledFont) != CAIRO_STATUS_SUCCESS) {
@ -462,8 +462,7 @@ gfxDWriteFont::SetupCairoFont(gfxContext *aContext)
// the cairo_t, precluding any further drawing.
return false;
}
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
scaledFont);
cairo_set_scaled_font(gfxFont::RefCairo(aDrawTarget), scaledFont);
return true;
}

View File

@ -33,7 +33,7 @@ public:
virtual uint32_t GetSpaceGlyph() override;
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
virtual bool AllowSubpixelAA() override
{ return mAllowManualShowGlyphs; }

View File

@ -176,7 +176,7 @@ gfxFT2FontBase::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
}
bool
gfxFT2FontBase::SetupCairoFont(gfxContext *aContext)
gfxFT2FontBase::SetupCairoFont(DrawTarget* aDrawTarget)
{
// The scaled font ctm is not relevant right here because
// cairo_set_scaled_font does not record the scaled font itself, but
@ -210,7 +210,6 @@ gfxFT2FontBase::SetupCairoFont(gfxContext *aContext)
// what is set here. It's too late to change things here as measuring has
// already taken place. We should really be measuring with a different
// font for pdf and ps surfaces (bug 403513).
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
cairoFont);
cairo_set_scaled_font(gfxFont::RefCairo(aDrawTarget), cairoFont);
return true;
}

View File

@ -30,7 +30,7 @@ public:
uint16_t aGID) override;
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; };
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
virtual FontType GetType() const override { return FONT_TYPE_FT2; }

View File

@ -55,8 +55,8 @@ gfxFT2Font::ShapeText(gfxContext *aContext,
aVertical, aShapedText)) {
// harfbuzz must have failed(?!), just render raw glyphs
AddRange(aText, aOffset, aLength, aShapedText);
PostShapingFixup(aContext, aText, aOffset, aLength, aVertical,
aShapedText);
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset, aLength,
aVertical, aShapedText);
}
return true;

View File

@ -549,6 +549,90 @@ gfxFontShaper::MergeFontFeatures(
}
}
// Work out whether cairo will snap inter-glyph spacing to pixels.
//
// Layout does not align text to pixel boundaries, so, with font drawing
// backends that snap glyph positions to pixels, it is important that
// inter-glyph spacing within words is always an integer number of pixels.
// This ensures that the drawing backend snaps all of the word's glyphs in the
// same direction and so inter-glyph spacing remains the same.
//
/* static */ void
gfxFontShaper::GetRoundOffsetsToPixels(DrawTarget* aDrawTarget,
bool* aRoundX, bool* aRoundY)
{
*aRoundX = false;
// Could do something fancy here for ScaleFactors of
// AxisAlignedTransforms, but we leave things simple.
// Not much point rounding if a matrix will mess things up anyway.
// Also return false for non-cairo contexts.
if (aDrawTarget->GetTransform().HasNonTranslation()) {
*aRoundY = false;
return;
}
// All raster backends snap glyphs to pixels vertically.
// Print backends set CAIRO_HINT_METRICS_OFF.
*aRoundY = true;
cairo_t* cr = gfxFont::RefCairo(aDrawTarget);
cairo_scaled_font_t *scaled_font = cairo_get_scaled_font(cr);
// bug 1198921 - this sometimes fails under Windows for whatver reason
NS_ASSERTION(scaled_font, "null cairo scaled font should never be returned "
"by cairo_get_scaled_font");
if (!scaled_font) {
*aRoundX = true; // default to the same as the fallback path below
return;
}
// Sometimes hint metrics gets set for us, most notably for printing.
cairo_font_options_t *font_options = cairo_font_options_create();
cairo_scaled_font_get_font_options(scaled_font, font_options);
cairo_hint_metrics_t hint_metrics =
cairo_font_options_get_hint_metrics(font_options);
cairo_font_options_destroy(font_options);
switch (hint_metrics) {
case CAIRO_HINT_METRICS_OFF:
*aRoundY = false;
return;
case CAIRO_HINT_METRICS_DEFAULT:
// Here we mimic what cairo surface/font backends do. Printing
// surfaces have already been handled by hint_metrics. The
// fallback show_glyphs implementation composites pixel-aligned
// glyph surfaces, so we just pick surface/font combinations that
// override this.
switch (cairo_scaled_font_get_type(scaled_font)) {
#if CAIRO_HAS_DWRITE_FONT // dwrite backend is not in std cairo releases yet
case CAIRO_FONT_TYPE_DWRITE:
// show_glyphs is implemented on the font and so is used for
// all surface types; however, it may pixel-snap depending on
// the dwrite rendering mode
if (!cairo_dwrite_scaled_font_get_force_GDI_classic(scaled_font) &&
gfxWindowsPlatform::GetPlatform()->DWriteMeasuringMode() ==
DWRITE_MEASURING_MODE_NATURAL) {
return;
}
MOZ_FALLTHROUGH;
#endif
case CAIRO_FONT_TYPE_QUARTZ:
// Quartz surfaces implement show_glyphs for Quartz fonts
if (cairo_surface_get_type(cairo_get_target(cr)) ==
CAIRO_SURFACE_TYPE_QUARTZ) {
return;
}
break;
default:
break;
}
break;
case CAIRO_HINT_METRICS_ON:
break;
}
*aRoundX = true;
}
void
gfxShapedText::SetupClusterBoundaries(uint32_t aOffset,
const char16_t *aString,
@ -781,7 +865,7 @@ gfxFont::~gfxFont()
gfxFloat
gfxFont::GetGlyphHAdvance(gfxContext *aCtx, uint16_t aGID)
{
if (!SetupCairoFont(aCtx)) {
if (!SetupCairoFont(aCtx->GetDrawTarget())) {
return 0;
}
if (ProvidesGlyphWidths()) {
@ -1642,10 +1726,10 @@ private:
// the second draw occurs at a constant offset in device pixels.
double
gfxFont::CalcXScale(gfxContext *aContext)
gfxFont::CalcXScale(DrawTarget* aDrawTarget)
{
// determine magnitude of a 1px x offset in device space
Size t = aContext->UserToDevice(Size(1.0, 0.0));
Size t = aDrawTarget->GetTransform() * Size(1.0, 0.0);
if (t.width == 1.0 && t.height == 0.0) {
// short-circuit the most common case to avoid sqrt() and division
return 1.0;
@ -1716,8 +1800,9 @@ gfxFont::DrawOneGlyph(uint32_t aGlyphID, double aAdvance, gfxPoint *aPt,
}
if (fontParams.haveColorGlyphs &&
RenderColorGlyph(runParams.context, fontParams.scaledFont,
fontParams.renderingOptions, fontParams.drawOptions,
RenderColorGlyph(runParams.dt,
fontParams.scaledFont, fontParams.renderingOptions,
fontParams.drawOptions,
fontParams.matInv * gfx::Point(devPt.x, devPt.y),
aGlyphID)) {
return;
@ -1969,7 +2054,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
// Synthetic-bold strikes are each offset one device pixel in run direction.
// (these values are only needed if IsSyntheticBold() is true)
if (IsSyntheticBold()) {
double xscale = CalcXScale(aRunParams.context);
double xscale = CalcXScale(aRunParams.context->GetDrawTarget());
fontParams.synBoldOnePixelOffset = aRunParams.direction * xscale;
if (xscale != 0.0) {
// use as many strikes as needed for the the increased advance
@ -2098,7 +2183,7 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMod
}
bool
gfxFont::RenderColorGlyph(gfxContext* aContext,
gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget,
mozilla::gfx::ScaledFont* scaledFont,
GlyphRenderingOptions* aRenderingOptions,
mozilla::gfx::DrawOptions aDrawOptions,
@ -2112,7 +2197,6 @@ gfxFont::RenderColorGlyph(gfxContext* aContext,
return false;
}
RefPtr<DrawTarget> dt = aContext->GetDrawTarget();
for (uint32_t layerIndex = 0; layerIndex < layerGlyphs.Length();
layerIndex++) {
Glyph glyph;
@ -2123,9 +2207,9 @@ gfxFont::RenderColorGlyph(gfxContext* aContext,
buffer.mGlyphs = &glyph;
buffer.mNumGlyphs = 1;
dt->FillGlyphs(scaledFont, buffer,
ColorPattern(layerColors[layerIndex]),
aDrawOptions, aRenderingOptions);
aDrawTarget->FillGlyphs(scaledFont, buffer,
ColorPattern(layerColors[layerIndex]),
aDrawOptions, aRenderingOptions);
}
return true;
}
@ -2577,26 +2661,26 @@ gfxFont::ShapeText(gfxContext *aContext,
NS_WARN_IF_FALSE(ok, "shaper failed, expect scrambled or missing text");
PostShapingFixup(aContext, aText, aOffset, aLength, aVertical,
aShapedText);
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset, aLength,
aVertical, aShapedText);
return ok;
}
void
gfxFont::PostShapingFixup(gfxContext *aContext,
const char16_t *aText,
uint32_t aOffset,
uint32_t aLength,
bool aVertical,
gfxShapedText *aShapedText)
gfxFont::PostShapingFixup(DrawTarget* aDrawTarget,
const char16_t* aText,
uint32_t aOffset,
uint32_t aLength,
bool aVertical,
gfxShapedText* aShapedText)
{
if (IsSyntheticBold()) {
const Metrics& metrics =
GetMetrics(aVertical ? eVertical : eHorizontal);
if (metrics.maxAdvance > metrics.aveCharWidth) {
float synBoldOffset =
GetSyntheticBoldOffset() * CalcXScale(aContext);
GetSyntheticBoldOffset() * CalcXScale(aDrawTarget);
aShapedText->AdjustAdvancesForSyntheticBold(synBoldOffset,
aOffset, aLength);
}
@ -3172,6 +3256,40 @@ gfxFont::GetSubSuperscriptFont(int32_t aAppUnitsPerDevPixel)
return fe->FindOrMakeFont(&style, needsBold, mUnicodeRangeMap);
}
static void
DestroyRefCairo(void* aData)
{
cairo_t* refCairo = static_cast<cairo_t*>(aData);
MOZ_ASSERT(refCairo);
cairo_destroy(refCairo);
}
/* static */ cairo_t *
gfxFont::RefCairo(DrawTarget* aDT)
{
// DrawTargets that don't use a Cairo backend can be given a 1x1 "reference"
// |cairo_t*|, stored in the DrawTarget's user data, for doing font-related
// operations.
static UserDataKey sRefCairo;
cairo_t* refCairo = nullptr;
if (aDT->GetBackendType() == BackendType::CAIRO) {
refCairo = static_cast<cairo_t*>
(aDT->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
if (refCairo) {
return refCairo;
}
}
refCairo = static_cast<cairo_t*>(aDT->GetUserData(&sRefCairo));
if (!refCairo) {
refCairo = cairo_create(gfxPlatform::GetPlatform()->ScreenReferenceSurface()->CairoSurface());
aDT->AddUserData(&sRefCairo, refCairo, DestroyRefCairo);
}
return refCairo;
}
gfxGlyphExtents *
gfxFont::GetOrCreateGlyphExtents(int32_t aAppUnitsPerDevUnit) {
uint32_t i, count = mGlyphExtentsArray.Length();
@ -3190,16 +3308,12 @@ gfxFont::GetOrCreateGlyphExtents(int32_t aAppUnitsPerDevUnit) {
}
void
gfxFont::SetupGlyphExtents(gfxContext *aContext,
uint32_t aGlyphID, bool aNeedTight,
gfxGlyphExtents *aExtents)
gfxFont::SetupGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphID,
bool aNeedTight, gfxGlyphExtents *aExtents)
{
gfxContextMatrixAutoSaveRestore matrixRestore(aContext);
aContext->SetMatrix(gfxMatrix());
gfxRect svgBounds;
if (mFontEntry->TryGetSVGData(this) && mFontEntry->HasSVGGlyph(aGlyphID) &&
mFontEntry->GetSVGGlyphExtents(aContext, aGlyphID, &svgBounds)) {
mFontEntry->GetSVGGlyphExtents(aDrawTarget, aGlyphID, &svgBounds)) {
gfxFloat d2a = aExtents->GetAppUnitsPerDevUnit();
aExtents->SetTightGlyphExtents(aGlyphID,
gfxRect(svgBounds.x * d2a,
@ -3214,8 +3328,7 @@ gfxFont::SetupGlyphExtents(gfxContext *aContext,
glyph.x = 0;
glyph.y = 0;
cairo_text_extents_t extents;
cairo_glyph_extents(gfxContext::RefCairo(aContext->GetDrawTarget()),
&glyph, 1, &extents);
cairo_glyph_extents(gfxFont::RefCairo(aDrawTarget), &glyph, 1, &extents);
const Metrics& fontMetrics = GetMetrics(eHorizontal);
int32_t appUnitsPerDevUnit = aExtents->GetAppUnitsPerDevUnit();

View File

@ -29,6 +29,7 @@
#include "harfbuzz/hb.h"
#include "mozilla/gfx/2D.h"
typedef struct _cairo cairo_t;
typedef struct _cairo_scaled_font cairo_scaled_font_t;
//typedef struct gr_face gr_face;
@ -612,6 +613,8 @@ protected:
class gfxFontShaper {
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
explicit gfxFontShaper(gfxFont *aFont)
: mFont(aFont)
{
@ -644,6 +647,10 @@ public:
void* aHandleFeatureData);
protected:
// Work out whether cairo will snap inter-glyph spacing to pixels.
static void GetRoundOffsetsToPixels(DrawTarget* aDrawTarget,
bool* aRoundX, bool* aRoundY);
// the font this shaper is working with. The font owns a nsAutoPtr reference
// to this object, and will destroy it before it dies. Thus, mFont will always
// be valid.
@ -1655,12 +1662,12 @@ public:
gfxGlyphExtents *GetOrCreateGlyphExtents(int32_t aAppUnitsPerDevUnit);
// You need to call SetupCairoFont on the aCR just before calling this
virtual void SetupGlyphExtents(gfxContext *aContext, uint32_t aGlyphID,
// You need to call SetupCairoFont on aDrawTarget just before calling this.
virtual void SetupGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphID,
bool aNeedTight, gfxGlyphExtents *aExtents);
// This is called by the default Draw() implementation above.
virtual bool SetupCairoFont(gfxContext *aContext) = 0;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) = 0;
virtual bool AllowSubpixelAA() { return true; }
@ -1842,6 +1849,11 @@ public:
virtual already_AddRefed<gfxFont>
GetSubSuperscriptFont(int32_t aAppUnitsPerDevPixel);
/**
* Return the reference cairo_t object from aDT.
*/
static cairo_t* RefCairo(mozilla::gfx::DrawTarget* aDT);
protected:
virtual const Metrics& GetHorizontalMetrics() = 0;
@ -1926,12 +1938,12 @@ protected:
// Helper to adjust for synthetic bold and set character-type flags
// in the shaped text; implementations of ShapeText should call this
// after glyph shaping has been completed.
void PostShapingFixup(gfxContext *aContext,
const char16_t *aText,
uint32_t aOffset, // position within aShapedText
uint32_t aLength,
bool aVertical,
gfxShapedText *aShapedText);
void PostShapingFixup(DrawTarget* aContext,
const char16_t* aText,
uint32_t aOffset, // position within aShapedText
uint32_t aLength,
bool aVertical,
gfxShapedText* aShapedText);
// Shape text directly into a range within a textrun, without using the
// font's word cache. Intended for use when the font has layout features
@ -2125,7 +2137,7 @@ protected:
gfxTextRunDrawCallbacks *aCallbacks,
bool& aEmittedGlyphs) const;
bool RenderColorGlyph(gfxContext* aContext,
bool RenderColorGlyph(DrawTarget* aDrawTarget,
mozilla::gfx::ScaledFont* scaledFont,
mozilla::gfx::GlyphRenderingOptions* renderingOptions,
mozilla::gfx::DrawOptions drawOptions,
@ -2139,7 +2151,7 @@ protected:
// the second draw occurs at a constant offset in device pixels.
// This helper calculates the scale factor we need to apply to the
// synthetic-bold offset.
static double CalcXScale(gfxContext *aContext);
static double CalcXScale(DrawTarget* aDrawTarget);
};
// proportion of ascent used for x-height, if unable to read value from font

View File

@ -333,7 +333,7 @@ gfxFontEntry::HasSVGGlyph(uint32_t aGlyphId)
}
bool
gfxFontEntry::GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
gfxFontEntry::GetSVGGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphId,
gfxRect *aResult)
{
MOZ_ASSERT(mSVGInitialized,
@ -342,8 +342,7 @@ gfxFontEntry::GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
"font has invalid unitsPerEm");
cairo_matrix_t fontMatrix;
cairo_get_font_matrix(gfxContext::RefCairo(aContext->GetDrawTarget()),
&fontMatrix);
cairo_get_font_matrix(gfxFont::RefCairo(aDrawTarget), &fontMatrix);
gfxMatrix svgToAppSpace(fontMatrix.xx, fontMatrix.yx,
fontMatrix.xy, fontMatrix.yy,

View File

@ -97,6 +97,8 @@ private:
class gfxFontEntry {
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
NS_INLINE_DECL_REFCOUNTING(gfxFontEntry)
explicit gfxFontEntry(const nsAString& aName, bool aIsStandardFace = false);
@ -180,7 +182,7 @@ public:
bool TryGetSVGData(gfxFont* aFont);
bool HasSVGGlyph(uint32_t aGlyphId);
bool GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
bool GetSVGGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphId,
gfxRect *aResult);
bool RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId, int aDrawMode,
gfxTextContextPaint *aContextPaint);

View File

@ -98,7 +98,7 @@ gfxGDIFont::ShapeText(gfxContext *aContext,
// creating a "toy" font internally (see bug 544617).
// We must check that this succeeded, otherwise we risk cairo creating the
// wrong kind of font internally as a fallback (bug 744480).
if (!SetupCairoFont(aContext)) {
if (!SetupCairoFont(aContext->GetDrawTarget())) {
return false;
}
@ -125,7 +125,7 @@ gfxGDIFont::GetSpaceGlyph()
}
bool
gfxGDIFont::SetupCairoFont(gfxContext *aContext)
gfxGDIFont::SetupCairoFont(DrawTarget* aDrawTarget)
{
if (!mMetrics) {
Initialize();
@ -136,8 +136,7 @@ gfxGDIFont::SetupCairoFont(gfxContext *aContext)
// the cairo_t, precluding any further drawing.
return false;
}
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
mScaledFont);
cairo_set_scaled_font(gfxFont::RefCairo(aDrawTarget), mScaledFont);
return true;
}

View File

@ -42,7 +42,7 @@ public:
/* overrides for the pure virtual methods in gfxFont */
virtual uint32_t GetSpaceGlyph() override;
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
/* override Measure to add padding for antialiasing */
virtual RunMetrics Measure(gfxTextRun *aTextRun,

View File

@ -45,11 +45,11 @@ gfxGlyphExtents::GetTightGlyphExtentsAppUnits(gfxFont *aFont,
return false;
}
if (aFont->SetupCairoFont(aContext)) {
if (aFont->SetupCairoFont(aContext->GetDrawTarget())) {
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
++gGlyphExtentsSetupLazyTight;
#endif
aFont->SetupGlyphExtents(aContext, aGlyphID, true, this);
aFont->SetupGlyphExtents(aContext->GetDrawTarget(), aGlyphID, true, this);
entry = mTightGlyphExtents.GetEntry(aGlyphID);
}
if (!entry) {

View File

@ -91,7 +91,7 @@ gfxGraphiteShaper::ShapeText(gfxContext *aContext,
gfxShapedText *aShapedText)
{
// some font back-ends require this in order to get proper hinted metrics
if (!mFont->SetupCairoFont(aContext)) {
if (!mFont->SetupCairoFont(aContext->GetDrawTarget())) {
return false;
}
@ -268,9 +268,8 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxContext *aContext,
}
}
bool roundX;
bool roundY;
aContext->GetRoundOffsetsToPixels(&roundX, &roundY);
bool roundX, roundY;
GetRoundOffsetsToPixels(aContext->GetDrawTarget(), &roundX, &roundY);
gfxShapedText::CompressedGlyph *charGlyphs =
aShapedText->GetCharacterGlyphs() + aOffset;

View File

@ -1471,7 +1471,7 @@ gfxHarfBuzzShaper::ShapeText(gfxContext *aContext,
gfxShapedText *aShapedText)
{
// some font back-ends require this in order to get proper hinted metrics
if (!mFont->SetupCairoFont(aContext)) {
if (!mFont->SetupCairoFont(aContext->GetDrawTarget())) {
return false;
}
@ -1617,12 +1617,12 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
int32_t glyphStart = 0; // looking for a clump that starts at this glyph
int32_t charStart = 0; // and this char index within the range of the run
bool roundI;
bool roundB;
bool roundI, roundB;
DrawTarget* drawTarget = aContext->GetDrawTarget();
if (aVertical) {
aContext->GetRoundOffsetsToPixels(&roundB, &roundI);
GetRoundOffsetsToPixels(drawTarget, &roundB, &roundI);
} else {
aContext->GetRoundOffsetsToPixels(&roundI, &roundB);
GetRoundOffsetsToPixels(drawTarget, &roundI, &roundB);
}
int32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit();

View File

@ -142,8 +142,8 @@ gfxMacFont::ShapeText(gfxContext *aContext,
}
if (mCoreTextShaper->ShapeText(aContext, aText, aOffset, aLength,
aScript, aVertical, aShapedText)) {
PostShapingFixup(aContext, aText, aOffset, aLength, aVertical,
aShapedText);
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset,
aLength, aVertical, aShapedText);
return true;
}
}
@ -153,15 +153,14 @@ gfxMacFont::ShapeText(gfxContext *aContext,
}
bool
gfxMacFont::SetupCairoFont(gfxContext *aContext)
gfxMacFont::SetupCairoFont(DrawTarget* aDrawTarget)
{
if (cairo_scaled_font_status(mScaledFont) != CAIRO_STATUS_SUCCESS) {
// Don't cairo_set_scaled_font as that would propagate the error to
// the cairo_t, precluding any further drawing.
return false;
}
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
mScaledFont);
cairo_set_scaled_font(gfxFont::RefCairo(aDrawTarget), mScaledFont);
return true;
}

View File

@ -28,7 +28,7 @@ public:
return mSpaceGlyph;
}
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
/* override Measure to add padding for antialiasing */
virtual RunMetrics Measure(gfxTextRun *aTextRun,

View File

@ -211,8 +211,7 @@ gfxTextRun::ReleaseFontGroup()
bool
gfxTextRun::SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
uint8_t *aBreakBefore,
gfxContext *aRefContext)
uint8_t *aBreakBefore)
{
NS_ASSERTION(aStart + aLength <= GetLength(), "Overflow");
@ -1411,7 +1410,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
uint32_t glyphIndex = glyphData->GetSimpleGlyph();
if (!extents->IsGlyphKnown(glyphIndex)) {
if (!fontIsSetup) {
if (!font->SetupCairoFont(aRefContext)) {
if (!font->SetupCairoFont(aRefContext->GetDrawTarget())) {
NS_WARNING("failed to set up font for glyph extents");
break;
}
@ -1420,7 +1419,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
++gGlyphExtentsSetupEagerSimple;
#endif
font->SetupGlyphExtents(aRefContext,
font->SetupGlyphExtents(aRefContext->GetDrawTarget(),
glyphIndex, false, extents);
}
}
@ -1437,7 +1436,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
uint32_t glyphIndex = details->mGlyphID;
if (!extents->IsGlyphKnownWithTightExtents(glyphIndex)) {
if (!fontIsSetup) {
if (!font->SetupCairoFont(aRefContext)) {
if (!font->SetupCairoFont(aRefContext->GetDrawTarget())) {
NS_WARNING("failed to set up font for glyph extents");
break;
}
@ -1446,7 +1445,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
++gGlyphExtentsSetupEagerTight;
#endif
font->SetupGlyphExtents(aRefContext,
font->SetupGlyphExtents(aRefContext->GetDrawTarget(),
glyphIndex, true, extents);
}
}

View File

@ -153,8 +153,7 @@ public:
* breaks are the same as the old
*/
virtual bool SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
uint8_t *aBreakBefore,
gfxContext *aRefContext);
uint8_t *aBreakBefore);
/**
* Layout provides PropertyProvider objects. These allow detection of

View File

@ -732,6 +732,7 @@ function ArrayValuesAt(n) {
function ArrayValues() {
return CreateArrayIterator(this, ITEM_KIND_VALUE);
}
_SetCanonicalName(ArrayValues, "values");
function ArrayEntries() {
return CreateArrayIterator(this, ITEM_KIND_KEY_AND_VALUE);

View File

@ -88,6 +88,7 @@ function LegacyGeneratorNext(val) {
throw e;
}
}
_SetCanonicalName(LegacyGeneratorNext, "next");
function LegacyGeneratorThrow(val) {
if (!IsObject(this) || !IsLegacyGeneratorObject(this))

View File

@ -100,8 +100,8 @@ function removeUnicodeExtensions(locale) {
if (pos < 0)
pos = locale.length;
var left = callFunction(std_String_substring, locale, 0, pos);
var right = callFunction(std_String_substring, locale, pos);
var left = callFunction(String_substring, locale, 0, pos);
var right = callFunction(String_substring, locale, pos);
var extensions;
var unicodeLocaleExtensionSequenceRE = getUnicodeLocaleExtensionSequenceRE();
@ -332,7 +332,7 @@ function IsStructurallyValidLanguageTag(locale) {
return true;
var pos = callFunction(std_String_indexOf, locale, "-x-");
if (pos !== -1)
locale = callFunction(std_String_substring, locale, 0, pos);
locale = callFunction(String_substring, locale, 0, pos);
// Check for duplicate variant or singleton subtags.
var duplicateVariantRE = getDuplicateVariantRE();
@ -401,7 +401,7 @@ function CanonicalizeLanguageTag(locale) {
// 4-character subtags are script codes; their first character
// needs to be capitalized. "hans" -> "Hans"
subtag = callFunction(std_String_toUpperCase, subtag[0]) +
callFunction(std_String_substring, subtag, 1);
callFunction(String_substring, subtag, 1);
} else if (i !== 0 && subtag.length === 2) {
// 2-character subtags that are not in initial position are region
// codes; they need to be upper case. "bu" -> "BU"
@ -678,7 +678,7 @@ function CanonicalizeLocaleList(locales) {
if (!IsStructurallyValidLanguageTag(tag))
ThrowRangeError(JSMSG_INVALID_LANGUAGE_TAG, tag);
tag = CanonicalizeLanguageTag(tag);
if (callFunction(std_Array_indexOf, seen, tag) === -1)
if (callFunction(ArrayIndexOf, seen, tag) === -1)
callFunction(std_Array_push, seen, tag);
}
k++;
@ -726,7 +726,7 @@ function BestAvailableLocaleHelper(availableLocales, locale, considerDefaultLoca
if (pos >= 2 && candidate[pos - 2] === "-")
pos -= 2;
candidate = callFunction(std_String_substring, candidate, 0, pos);
candidate = callFunction(String_substring, candidate, 0, pos);
}
}
@ -879,7 +879,7 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
// Step 11.g.
if (extensionSubtags !== undefined) {
// Step 11.g.i.
var keyPos = callFunction(std_Array_indexOf, extensionSubtags, key);
var keyPos = callFunction(ArrayIndexOf, extensionSubtags, key);
// Step 11.g.ii.
if (keyPos !== -1) {
@ -891,7 +891,7 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
var requestedValue = extensionSubtags[keyPos + 1];
// Step 11.g.ii.1.b.
valuePos = callFunction(std_Array_indexOf, keyLocaleData, requestedValue);
valuePos = callFunction(ArrayIndexOf, keyLocaleData, requestedValue);
// Step 11.g.ii.1.c.
if (valuePos !== -1) {
@ -905,7 +905,7 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
// and true is an allowed value, it's used.
// Step 11.g.ii.2.a.
valuePos = callFunction(std_Array_indexOf, keyLocaleData, "true");
valuePos = callFunction(ArrayIndexOf, keyLocaleData, "true");
// Step 11.g.ii.2.b.
if (valuePos !== -1)
@ -921,7 +921,7 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
// Step 11.h, 11.h.ii.
if (optionsValue !== undefined &&
callFunction(std_Array_indexOf, keyLocaleData, optionsValue) !== -1)
callFunction(ArrayIndexOf, keyLocaleData, optionsValue) !== -1)
{
// Step 11.h.ii.1.
if (optionsValue !== value) {
@ -938,8 +938,8 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
// Step 12.
if (supportedExtension.length > 2) {
var preExtension = callFunction(std_String_substring, foundLocale, 0, extensionIndex);
var postExtension = callFunction(std_String_substring, foundLocale, extensionIndex);
var preExtension = callFunction(String_substring, foundLocale, 0, extensionIndex);
var postExtension = callFunction(String_substring, foundLocale, extensionIndex);
foundLocale = preExtension + supportedExtension + postExtension;
}
@ -1060,7 +1060,7 @@ function GetOption(options, property, type, values, fallback) {
assert(false, "GetOption");
// Step 2.d.
if (values !== undefined && callFunction(std_Array_indexOf, values, value) === -1)
if (values !== undefined && callFunction(ArrayIndexOf, values, value) === -1)
ThrowRangeError(JSMSG_INVALID_OPTION_VALUE, property, value);
// Step 2.e.
@ -2612,8 +2612,8 @@ function BasicFormatMatcher(options, formats) {
score -= removalPenalty;
} else {
// Step 11.c.vi.
var optionsPropIndex = callFunction(std_Array_indexOf, values, optionsProp);
var formatPropIndex = callFunction(std_Array_indexOf, values, formatProp);
var optionsPropIndex = callFunction(ArrayIndexOf, values, optionsProp);
var formatPropIndex = callFunction(ArrayIndexOf, values, formatProp);
var delta = std_Math_max(std_Math_min(formatPropIndex - optionsPropIndex, 2), -2);
if (delta === 2)
score -= longMorePenalty;

View File

@ -25,7 +25,7 @@ function MapForEach(callbackfn, thisArg = undefined) {
/* Step 6-8. */
var entries = callFunction(std_Map_iterator, M);
while (true) {
var result = callFunction(std_Map_iterator_next, entries);
var result = callFunction(MapIteratorNext, entries);
if (result.done)
break;
var entry = result.value;
@ -88,3 +88,4 @@ function MapSpecies() {
// Step 1.
return this;
}
_SetCanonicalName(MapSpecies, "get [Symbol.species]");

View File

@ -35,6 +35,7 @@ function RegExpFlagsGetter() {
// Step 19.
return result;
}
_SetCanonicalName(RegExpFlagsGetter, "get flags");
// ES6 draft rc1 21.2.5.14.
function RegExpToString()
@ -53,3 +54,4 @@ function RegExpToString()
// Step 7.
return '/' + pattern + '/' + flags;
}
_SetCanonicalName(RegExpToString, "toString");

View File

@ -34,6 +34,11 @@
// stored.
#define LAZY_FUNCTION_NAME_SLOT 0
// The extended slot which contains a boolean value that indicates whether
// that the canonical name of the self-hosted builtins is set in self-hosted
// global. This slot is used only in debug build.
#define HAS_SELFHOSTED_CANONICAL_NAME_SLOT 0
// Stores the private WeakMap slot used for WeakSets
#define WEAKSET_MAP_SLOT 0

View File

@ -38,3 +38,4 @@ function SetSpecies() {
// Step 1.
return this;
}
_SetCanonicalName(SetSpecies, "get [Symbol.species]");

View File

@ -228,7 +228,7 @@ function StringIteratorNext() {
}
UnsafeSetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX, index + charCount);
result.value = callFunction(std_String_substring, S, index, index + charCount);
result.value = callFunction(String_substring, S, index, index + charCount);
return result;
}
@ -433,14 +433,14 @@ function EscapeAttributeValue(v) {
var chunkStart = 0;
for (var i = 0; i < inputLen; i++) {
if (inputStr[i] === '"') {
outputStr += callFunction(std_String_substring, inputStr, chunkStart, i) + '&quot;';
outputStr += callFunction(String_substring, inputStr, chunkStart, i) + '&quot;';
chunkStart = i + 1;
}
}
if (chunkStart === 0)
return inputStr;
if (chunkStart < inputLen)
outputStr += callFunction(std_String_substring, inputStr, chunkStart);
outputStr += callFunction(String_substring, inputStr, chunkStart);
return outputStr;
}

View File

@ -964,6 +964,7 @@ function TypedArrayValues() {
// Step 7.
return CreateArrayIterator(O, ITEM_KIND_VALUE);
}
_SetCanonicalName(TypedArrayValues, "values");
// Proposed for ES7:
// https://github.com/tc39/Array.prototype.includes/blob/7c023c19a0/spec.md

View File

@ -36,15 +36,13 @@
// code are installed via the std_functions JSFunctionSpec[] in
// SelfHosting.cpp.
//
// The few items below here are either self-hosted or installing them under a
// std_Foo name would require ugly contortions, so they just get aliased here.
var std_Array_indexOf = ArrayIndexOf;
var std_String_substring = String_substring;
// Do not create an alias to a self-hosted builtin, otherwise it will be cloned
// twice.
//
// WeakMap is a bare constructor without properties or methods.
var std_WeakMap = WeakMap;
// StopIteration is a bare constructor without properties or methods.
var std_StopIteration = StopIteration;
var std_Map_iterator_next = MapIteratorNext;
/********** List specification type **********/

View File

@ -1187,79 +1187,35 @@ if test "$GNU_CC"; then
LDFLAGS=$_SAVE_LDFLAGS)
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
# -Waddress - catches suspicious uses of memory addresses
# -Wchar-subscripts - catches array index using signed char
# -Wcomment - catches nested comments
# https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Warning-Options.html
# -Wall - lots of useful warnings
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
# -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
# -Wenum-compare - catches comparison of different enum types
# -Wignored-qualifiers - catches returns types with qualifiers like const
# -Wimplicit-function-declaration - catches missing C function prototypes
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
# -Wmissing-braces - catches aggregate initializers missing nested braces
# -Wmultichar - catches multicharacter integer constants like 'THIS'
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Wnonnull - catches NULL used with functions arguments marked as non-null
# -Wparentheses - catches `if (a=b)` and operator precedence bugs
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
# -Wpointer-sign - catches mixing pointers to signed and unsigned types
# -Wpointer-to-int-cast - catches casts from pointer to different sized int
# -Wreturn-type - catches missing returns, zero false positives
# -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
# -Wswitch - catches switches without all enum cases or default case
# -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
# -Wunknown-pragmas - catches unexpected #pragma directives
# -Wwrite-strings - catches non-const char* pointers to string literals
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wsign-compare"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wempty-body"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wignored-qualifiers"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wpointer-arith"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
# Treat some warnings as errors if --enable-warnings-as-errors:
if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=address"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=char-subscripts"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=comment"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=empty-body"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=endif-labels"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=enum-compare"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=ignored-qualifiers"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=implicit-function-declaration"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=int-to-pointer-cast"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=missing-braces"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=multichar"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=nonnull"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=parentheses"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-arith"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-sign"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-to-int-cast"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=return-type"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=sequence-point"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=switch"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=trigraphs"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=uninitialized"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=unknown-pragmas"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=write-strings"
MOZ_C_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_c_has_werror_non_literal_null_conversion)
MOZ_C_SUPPORTS_WARNING(-Werror=, sometimes-uninitialized, ac_c_has_sometimes_uninitialized)
fi
# Turn off the following warnings that -Wall turns on:
# -Wno-unused - lots of violations in third-party code
# -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Wsometimes-initialized - catches some uninitialized values
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, inline-new-delete, ac_cxx_has_wno_inline_new_delete)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_cxx_has_wno_unused_local_typedef)
# XXX: at the time of writing, the version of clang used on the OS X test
# machines has a bug that causes it to reject some valid files if both
# -Wnon-literal-null-conversion and -Wsometimes-uninitialized are
# specified. We work around this by instead using
# -Werror=non-literal-null-conversion, but we only do that when
# --enable-warnings-as-errors is specified so that no unexpected fatal
# warnings are produced.
if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
MOZ_C_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_c_has_non_literal_null_conversion)
fi
MOZ_C_SUPPORTS_WARNING(-W, sometimes-uninitialized, ac_c_has_sometimes_uninitialized)
# -Wcast-align - catches problems with cast alignment
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1272,6 +1228,14 @@ if test "$GNU_CC"; then
esac
fi
# Turn off some non-useful warnings that -Wall turns on.
# -Wno-unused - lots of violations in third-party code
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
MOZ_C_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_c_has_wno_unused_local_typedef)
_DEFINES_CFLAGS='-include $(topobjdir)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
@ -1301,77 +1265,40 @@ fi
if test "$GNU_CXX"; then
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
# -Wchar-subscripts - catches array index using signed char
# -Wcomment - catches nested comments
# -Wconversion-null - catches conversions between NULL and non-pointer types
# https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Warning-Options.html
# -Wall - lots of useful warnings
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
# -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
# -Wignored-qualifiers - catches returns types with qualifiers like const
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
# -Wmissing-braces - catches aggregate initializers missing nested braces
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Woverloaded-virtual - function declaration hides virtual function from base class
# -Wparentheses - catches `if (a=b)` and operator precedence bugs
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
# -Wpointer-to-int-cast - catches casts from pointer to different sized int
# -Wrange-loop-analysis - catches copies during range-based for loops.
# -Wreorder - catches ctor initializer list not matching class definition order
# -Wreturn-type - catches missing returns, zero false positives
# -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
# -Wswitch - catches switches without all enum cases or default case
# -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
# -Wunknown-pragmas - catches unexpected #pragma directives
# -Wunused-label - catches unused goto labels
# -Wunused-value - catches unused expression results
# -Wwrite-strings - catches non-const char* pointers to string literals
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wsign-compare"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wempty-body"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Woverloaded-virtual"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wpointer-arith"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wtype-limits"
# -Wclass-varargs - ???
# -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
# -Wrange-loop-analysis - catches copies during range-based for loops.
# -Wsometimes-initialized - catches some uninitialized values
#
# XXX: at the time of writing, the version of clang used on the OS X test
# machines has a bug that causes it to reject some valid files if both
# -Wnon-literal-null-conversion and -Wsometimes-uninitialized are
# specified. We work around this by instead using
# -Werror=non-literal-null-conversion, but we only do that when
# --enable-warnings-as-errors is specified so that no unexpected fatal
# warnings are produced.
MOZ_CXX_SUPPORTS_WARNING(-W, class-varargs, ac_cxx_has_wclass_varargs)
# Treat some warnings as errors if --enable-warnings-as-errors:
if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=char-subscripts"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=comment"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=endif-labels"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=ignored-qualifiers"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=int-to-pointer-cast"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=missing-braces"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=overloaded-virtual"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=parentheses"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=pointer-arith"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=reorder"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=sequence-point"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=switch"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=trigraphs"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=uninitialized"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unknown-pragmas"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-label"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-value"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=write-strings"
MOZ_CXX_SUPPORTS_WARNING(-Werror=, conversion-null, ac_cxx_has_werror_conversion_null)
MOZ_CXX_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_cxx_has_werror_non_literal_null_conversion)
MOZ_CXX_SUPPORTS_WARNING(-Werror=, range-loop-analysis, ac_cxx_has_range_loop_analysis)
MOZ_CXX_SUPPORTS_WARNING(-Werror=, sometimes-uninitialized, ac_cxx_has_sometimes_uninitialized)
MOZ_CXX_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_cxx_has_non_literal_null_conversion)
fi
MOZ_CXX_SUPPORTS_WARNING(-W, range-loop-analysis, ac_cxx_has_range_loop_analysis)
MOZ_CXX_SUPPORTS_WARNING(-W, sometimes-uninitialized, ac_cxx_has_sometimes_uninitialized)
# Turn off the following warnings that -Wall turns on:
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_cxx_has_wno_unused_local_typedef)
# -Wcast-align - catches problems with cast alignment
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1384,8 +1311,15 @@ if test "$GNU_CXX"; then
esac
fi
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(topobjdir)/js/src/js-confdefs.h'
_USE_CPP_INCLUDE_FLAG=1
# Turn off some non-useful warnings that -Wall turns on.
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
# -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
# -Wno-unused-local-typedef - catches unused typedefs, which are commonly used in assertion macros
MOZ_CXX_SUPPORTS_WARNING(-Wno-, inline-new-delete, ac_cxx_has_wno_inline_new_delete)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, unused-local-typedef, ac_cxx_has_wno_unused_local_typedef)
# Recent clang and gcc support C++11 deleted functions without warnings if
# compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
@ -1398,6 +1332,9 @@ if test "$GNU_CXX"; then
MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
fi
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(topobjdir)/js/src/js-confdefs.h'
_USE_CPP_INCLUDE_FLAG=1
else
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_JS_CONFDEFS_H_ $(ACDEFINES)'
fi

View File

@ -30,6 +30,7 @@
#include "asmjs/AsmJS.h"
#include "builtin/ModuleObject.h"
#include "builtin/SelfHostingDefines.h"
#include "frontend/BytecodeCompiler.h"
#include "frontend/FoldConstants.h"
#include "frontend/ParseMaps.h"
@ -1593,6 +1594,9 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
gc::AllocKind allocKind = gc::AllocKind::FUNCTION;
JSFunction::Flags flags;
#ifdef DEBUG
bool isGlobalSelfHostedBuiltin = false;
#endif
switch (kind) {
case Expression:
flags = (generatorKind == NotGenerator
@ -1626,6 +1630,13 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
allocKind = gc::AllocKind::FUNCTION_EXTENDED;
break;
default:
MOZ_ASSERT(kind == Statement);
#ifdef DEBUG
if (options().selfHostingMode && !pc->sc->isFunctionBox()) {
isGlobalSelfHostedBuiltin = true;
allocKind = gc::AllocKind::FUNCTION_EXTENDED;
}
#endif
flags = (generatorKind == NotGenerator
? JSFunction::INTERPRETED_NORMAL
: JSFunction::INTERPRETED_GENERATOR);
@ -1635,8 +1646,13 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
allocKind, TenuredObject);
if (!fun)
return nullptr;
if (options().selfHostingMode)
if (options().selfHostingMode) {
fun->setIsSelfHostedBuiltin();
#ifdef DEBUG
if (isGlobalSelfHostedBuiltin)
fun->setExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT, BooleanValue(false));
#endif
}
return fun;
}

View File

@ -658,16 +658,37 @@ GlobalObject::getSelfHostedFunction(JSContext* cx, Handle<GlobalObject*> global,
HandlePropertyName selfHostedName, HandleAtom name,
unsigned nargs, MutableHandleValue funVal)
{
if (GlobalObject::maybeGetIntrinsicValue(cx, global, selfHostedName, funVal))
return true;
if (GlobalObject::maybeGetIntrinsicValue(cx, global, selfHostedName, funVal)) {
RootedFunction fun(cx, &funVal.toObject().as<JSFunction>());
if (fun->atom() == name)
return true;
JSFunction* fun =
NewScriptedFunction(cx, nargs, JSFunction::INTERPRETED_LAZY,
name, gc::AllocKind::FUNCTION_EXTENDED, SingletonObject);
if (!fun)
if (fun->atom() == selfHostedName) {
// This function was initially cloned because it was called by
// other self-hosted code, so the clone kept its self-hosted name,
// instead of getting the name it's intended to have in content
// compartments. This can happen when a lazy builtin is initialized
// after self-hosted code for another builtin used the same
// function. In that case, we need to change the function's name,
// which is ok because it can't have been exposed to content
// before.
fun->initAtom(name);
return true;
}
// The function might be installed multiple times on the same or
// different builtins, under different property names, so its name
// might be neither "selfHostedName" nor "name". In that case, its
// canonical name must've been set using the `_SetCanonicalName`
// intrinsic.
cx->runtime()->assertSelfHostedFunctionHasCanonicalName(cx, selfHostedName);
return true;
}
RootedFunction fun(cx);
if (!cx->runtime()->createLazySelfHostedFunctionClone(cx, selfHostedName, name, nargs, &fun))
return false;
fun->setIsSelfHostedBuiltin();
fun->setExtendedSlot(LAZY_FUNCTION_NAME_SLOT, StringValue(selfHostedName));
funVal.setObject(*fun);
return GlobalObject::addIntrinsicValue(cx, global, selfHostedName, funVal);

View File

@ -952,6 +952,10 @@ struct JSRuntime : public JS::shadow::Runtime,
static js::GlobalObject*
createSelfHostingGlobal(JSContext* cx);
bool getUnclonedSelfHostedValue(JSContext* cx, js::HandlePropertyName name,
js::MutableHandleValue vp);
JSFunction* getUnclonedSelfHostedFunction(JSContext* cx, js::HandlePropertyName name);
/* Space for interpreter frames. */
js::InterpreterStack interpreterStack_;
@ -983,10 +987,14 @@ struct JSRuntime : public JS::shadow::Runtime,
}
bool isSelfHostingCompartment(JSCompartment* comp) const;
bool isSelfHostingZone(const JS::Zone* zone) const;
bool createLazySelfHostedFunctionClone(JSContext* cx, js::HandlePropertyName selfHostedName,
js::HandleAtom name, unsigned nargs,
js::MutableHandleFunction fun);
bool cloneSelfHostedFunctionScript(JSContext* cx, js::Handle<js::PropertyName*> name,
js::Handle<JSFunction*> targetFun);
bool cloneSelfHostedValue(JSContext* cx, js::Handle<js::PropertyName*> name,
js::MutableHandleValue vp);
void assertSelfHostedFunctionHasCanonicalName(JSContext* cx, js::HandlePropertyName name);
//-------------------------------------------------------------------------
// Locale information

View File

@ -15,6 +15,7 @@
#include "jscompartment.h"
#include "jsdate.h"
#include "jsfriendapi.h"
#include "jsfun.h"
#include "jshashutil.h"
#include "jsweakmap.h"
#include "jswrapper.h"
@ -538,6 +539,26 @@ intrinsic_ActiveFunction(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
intrinsic_SetCanonicalName(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 2);
RootedFunction fun(cx, &args[0].toObject().as<JSFunction>());
MOZ_ASSERT(fun->isSelfHostedBuiltin());
RootedAtom atom(cx, AtomizeString(cx, args[1].toString()));
if (!atom)
return false;
fun->initAtom(atom);
#ifdef DEBUG
fun->setExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT, BooleanValue(true));
#endif
args.rval().setUndefined();
return true;
}
static bool
intrinsic_StarGeneratorObjectIsClosed(JSContext* cx, unsigned argc, Value* vp)
{
@ -1519,6 +1540,8 @@ static const JSFunctionSpec intrinsic_functions[] = {
CallNonGenericSelfhostedMethod<Is<ListIteratorObject>>, 2,0),
JS_FN("ActiveFunction", intrinsic_ActiveFunction, 0,0),
JS_FN("_SetCanonicalName", intrinsic_SetCanonicalName, 2,0),
JS_INLINABLE_FN("IsArrayIterator",
intrinsic_IsInstanceOfBuiltin<ArrayIteratorObject>, 1,0,
IntrinsicIsArrayIterator),
@ -1985,8 +2008,10 @@ CloneObject(JSContext* cx, HandleNativeObject selfHostedObject)
staticGlobalLexical, kind);
// To be able to re-lazify the cloned function, its name in the
// self-hosting compartment has to be stored on the clone.
if (clone && hasName)
clone->as<JSFunction>().setExtendedSlot(0, StringValue(selfHostedFunction->atom()));
if (clone && hasName) {
clone->as<JSFunction>().setExtendedSlot(LAZY_FUNCTION_NAME_SLOT,
StringValue(selfHostedFunction->atom()));
}
} else if (selfHostedObject->is<RegExpObject>()) {
RegExpObject& reobj = selfHostedObject->as<RegExpObject>();
RootedAtom source(cx, reobj.getSource());
@ -2053,16 +2078,37 @@ CloneValue(JSContext* cx, HandleValue selfHostedValue, MutableHandleValue vp)
return true;
}
bool
JSRuntime::createLazySelfHostedFunctionClone(JSContext* cx, HandlePropertyName selfHostedName,
HandleAtom name, unsigned nargs,
MutableHandleFunction fun)
{
RootedAtom funName(cx, name);
JSFunction* selfHostedFun = getUnclonedSelfHostedFunction(cx, selfHostedName);
if (!selfHostedFun)
return false;
if (selfHostedFun->atom() != selfHostedName) {
MOZ_ASSERT(selfHostedFun->getExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT).toBoolean());
funName = selfHostedFun->atom();
}
fun.set(NewScriptedFunction(cx, nargs, JSFunction::INTERPRETED_LAZY,
funName, gc::AllocKind::FUNCTION_EXTENDED, SingletonObject));
if (!fun)
return false;
fun->setIsSelfHostedBuiltin();
fun->setExtendedSlot(LAZY_FUNCTION_NAME_SLOT, StringValue(selfHostedName));
return true;
}
bool
JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name,
HandleFunction targetFun)
{
RootedId id(cx, NameToId(name));
RootedValue funVal(cx);
if (!GetUnclonedValue(cx, HandleNativeObject::fromMarkedLocation(&selfHostingGlobal_), id, &funVal))
RootedFunction sourceFun(cx, getUnclonedSelfHostedFunction(cx, name));
if (!sourceFun)
return false;
RootedFunction sourceFun(cx, &funVal.toObject().as<JSFunction>());
// JSFunction::generatorKind can't handle lazy self-hosted functions, so we make sure there
// aren't any.
MOZ_ASSERT(!sourceFun->isGenerator());
@ -2092,11 +2138,28 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name,
}
bool
JSRuntime::cloneSelfHostedValue(JSContext* cx, HandlePropertyName name, MutableHandleValue vp)
JSRuntime::getUnclonedSelfHostedValue(JSContext* cx, HandlePropertyName name,
MutableHandleValue vp)
{
RootedId id(cx, NameToId(name));
return GetUnclonedValue(cx, HandleNativeObject::fromMarkedLocation(&selfHostingGlobal_), id, vp);
}
JSFunction*
JSRuntime::getUnclonedSelfHostedFunction(JSContext* cx, HandlePropertyName name)
{
RootedValue selfHostedValue(cx);
if (!GetUnclonedValue(cx, HandleNativeObject::fromMarkedLocation(&selfHostingGlobal_), id, &selfHostedValue))
if (!getUnclonedSelfHostedValue(cx, name, &selfHostedValue))
return nullptr;
return &selfHostedValue.toObject().as<JSFunction>();
}
bool
JSRuntime::cloneSelfHostedValue(JSContext* cx, HandlePropertyName name, MutableHandleValue vp)
{
RootedValue selfHostedValue(cx);
if (!getUnclonedSelfHostedValue(cx, name, &selfHostedValue))
return false;
/*
@ -2112,6 +2175,16 @@ JSRuntime::cloneSelfHostedValue(JSContext* cx, HandlePropertyName name, MutableH
return CloneValue(cx, selfHostedValue, vp);
}
void
JSRuntime::assertSelfHostedFunctionHasCanonicalName(JSContext* cx, HandlePropertyName name)
{
#ifdef DEBUG
JSFunction* selfHostedFun = getUnclonedSelfHostedFunction(cx, name);
MOZ_ASSERT(selfHostedFun);
MOZ_ASSERT(selfHostedFun->getExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT).toBoolean());
#endif
}
JSFunction*
js::SelfHostedFunction(JSContext* cx, HandlePropertyName propName)
{

View File

@ -5736,15 +5736,15 @@ FrameLayerBuilder::PaintItems(nsTArray<ClippedDisplayItem>& aItems,
* items separately for each rect in the visible region rather
* than clipping to a complex region.
*/
static bool ShouldDrawRectsSeparately(gfxContext* aContext, DrawRegionClip aClip)
static bool
ShouldDrawRectsSeparately(DrawTarget* aDrawTarget, DrawRegionClip aClip)
{
if (!gfxPrefs::LayoutPaintRectsSeparately() ||
aClip == DrawRegionClip::NONE) {
return false;
}
DrawTarget *dt = aContext->GetDrawTarget();
return !dt->SupportsRegionClipping();
return !aDrawTarget->SupportsRegionClipping();
}
static void DrawForcedBackgroundColor(DrawTarget& aDrawTarget,
@ -5821,7 +5821,8 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
(aLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
NS_ASSERTION(userData, "where did our user data go?");
bool shouldDrawRectsSeparately = ShouldDrawRectsSeparately(aContext, aClip);
bool shouldDrawRectsSeparately =
ShouldDrawRectsSeparately(&aDrawTarget, aClip);
if (!shouldDrawRectsSeparately) {
if (aClip == DrawRegionClip::DRAW) {

View File

@ -929,10 +929,9 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
Float(width / twipsPerPixel) };
// start drawing
gfxContext *ctx = aRenderingContext.ThebesContext();
nsCSSBorderRenderer br(aPresContext->Type(),
ctx->GetDrawTarget(),
aRenderingContext.GetDrawTarget(),
oRect,
outlineStyles,
outlineWidths,

View File

@ -778,7 +778,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
"Dropped characters or break-before values somewhere!");
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
canBreakBeforeArray.Elements(), aRefContext);
canBreakBeforeArray.Elements());
if (transformedChild) {
transformedChild->FinishSettingProperties(aRefContext, aMFR);
}

View File

@ -975,7 +975,7 @@ public:
virtual void SetBreaks(uint32_t aOffset, uint32_t aLength,
uint8_t* aBreakBefore) override {
if (mTextRun->SetPotentialLineBreaks(aOffset + mOffsetIntoTextRun, aLength,
aBreakBefore, mContext)) {
aBreakBefore)) {
// Be conservative and assume that some breaks have been set
mTextRun->ClearFlagBits(nsTextFrameUtils::TEXT_NO_BREAKS);
}
@ -989,7 +989,7 @@ public:
nsTransformedTextRun* transformedTextRun =
static_cast<nsTransformedTextRun*>(mTextRun);
transformedTextRun->SetCapitalization(aOffset + mOffsetIntoTextRun, aLength,
aCapitalize, mContext);
aCapitalize);
}
}

View File

@ -57,8 +57,7 @@ nsTransformedTextRun::Create(const gfxTextRunFactory::Parameters* aParams,
void
nsTransformedTextRun::SetCapitalization(uint32_t aStart, uint32_t aLength,
bool* aCapitalization,
gfxContext* aRefContext)
bool* aCapitalization)
{
if (mCapitalize.IsEmpty()) {
if (!mCapitalize.AppendElements(GetLength()))
@ -71,11 +70,10 @@ nsTransformedTextRun::SetCapitalization(uint32_t aStart, uint32_t aLength,
bool
nsTransformedTextRun::SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
uint8_t* aBreakBefore,
gfxContext* aRefContext)
uint8_t* aBreakBefore)
{
bool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength,
aBreakBefore, aRefContext);
bool changed =
gfxTextRun::SetPotentialLineBreaks(aStart, aLength, aBreakBefore);
if (changed) {
mNeedsRebuild = true;
}
@ -648,7 +646,7 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
"Dropped characters or break-before values somewhere!");
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
canBreakBeforeArray.Elements(), aRefContext);
canBreakBeforeArray.Elements());
if (transformedChild) {
transformedChild->FinishSettingProperties(aRefContext, aMFR);
}

View File

@ -129,11 +129,9 @@ public:
}
void SetCapitalization(uint32_t aStart, uint32_t aLength,
bool* aCapitalization,
gfxContext* aRefContext);
bool* aCapitalization);
virtual bool SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
uint8_t* aBreakBefore,
gfxContext* aRefContext);
uint8_t* aBreakBefore);
/**
* Called after SetCapitalization and SetPotentialLineBreaks
* are done and before we request any data from the textrun. Also always

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<style>
button { -moz-appearance: none; }
button::-moz-focus-inner { border-width: 2px; }
</style>
<body>
<button>hello</button>

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<style>
button { -moz-appearance: none; }
</style>
<body onload="document.querySelector('button').focus()">
<button>hello</button>

View File

@ -1944,3 +1944,4 @@ fuzzy(1,74) fuzzy-if(gtkWidget,6,79) == 1174332-1.html 1174332-1-ref.html
== 1222226-1.html 1222226-1-ref.html
pref(layout.css.overflow-clip-box.enabled,true) == 1226278.html 1226278-ref.html
== 1230466.html about:blank
# pref(browser.display.focus_ring_width,2) == 1234758-1.html 1234758-1-ref.html # disabled until a followup fix in bug 1234758

View File

@ -4,9 +4,6 @@
/* This sheet is added to the style set for documents with frames disabled */
/* Until bug 1194856 is fixed, if you update this file you should also update
the data: URL in nsLayoutStylesheetCache::NoFramesSheet(). */
noframes {
display: block;
}

View File

@ -4,9 +4,6 @@
/* This sheet is added to the style set for documents with script disabled */
/* Until bug 1194856 is fixed, if you update this file you should also update
the data: URL in nsLayoutStylesheetCache::NoScriptSheet(). */
noscript {
display: none !important;
}

View File

@ -14661,8 +14661,7 @@ CSSParserImpl::ParseTextEmphasis()
}
if (!(found & 1)) { // Provide default text-emphasis-style
values[0].SetIntValue(NS_STYLE_TEXT_EMPHASIS_STYLE_NONE,
eCSSUnit_Enumerated);
values[0].SetNoneValue();
}
if (!(found & 2)) { // Provide default text-emphasis-color
values[1].SetIntValue(NS_COLOR_CURRENTCOLOR, eCSSUnit_EnumColor);

View File

@ -193,13 +193,7 @@ nsLayoutStylesheetCache::NoScriptSheet()
EnsureGlobal();
if (!gStyleCache->mNoScriptSheet) {
// If you update the data: URL, also update noscript.css (See bug 1194856.)
LoadSheetURL(
#ifdef RELEASE_BUILD
"data:text/css,noscript { display%3A none !important%3B }",
#else
"resource://gre-resources/noscript.css",
#endif
LoadSheetURL("resource://gre-resources/noscript.css",
gStyleCache->mNoScriptSheet, eAgentSheetFeatures);
}
@ -212,14 +206,7 @@ nsLayoutStylesheetCache::NoFramesSheet()
EnsureGlobal();
if (!gStyleCache->mNoFramesSheet) {
// If you update the data: URL, also update noframes.css (See bug 1194856.)
LoadSheetURL(
#ifdef RELEASE_BUILD
"data:text/css,noframes { display%3A block%3B } "
"frame%2C frameset%2C iframe { display%3A none !important%3B }",
#else
"resource://gre-resources/noframes.css",
#endif
LoadSheetURL("resource://gre-resources/noframes.css",
gStyleCache->mNoFramesSheet, eAgentSheetFeatures);
}
@ -817,25 +804,6 @@ nsLayoutStylesheetCache::InvalidatePreferenceSheets()
gStyleCache->mChromePreferenceSheet = nullptr;
}
/* static */ void
nsLayoutStylesheetCache::AppendPreferenceRule(CSSStyleSheet* aSheet,
const nsAString& aString)
{
uint32_t result;
aSheet->InsertRuleInternal(aString, aSheet->StyleRuleCount(), &result);
}
/* static */ void
nsLayoutStylesheetCache::AppendPreferenceColorRule(CSSStyleSheet* aSheet,
const char* aString,
nscolor aColor)
{
nsAutoString rule;
rule.AppendPrintf(
aString, NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor));
AppendPreferenceRule(aSheet, rule);
}
void
nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<CSSStyleSheet>& aSheet,
nsPresContext* aPresContext)
@ -849,29 +817,37 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<CSSStyleSheet>& aSheet,
aSheet->SetURIs(uri, uri, uri);
aSheet->SetComplete();
AppendPreferenceRule(aSheet,
NS_LITERAL_STRING("@namespace url(http://www.w3.org/1999/xhtml);"));
AppendPreferenceRule(aSheet,
NS_LITERAL_STRING("@namespace svg url(http://www.w3.org/2000/svg);"));
static const uint32_t kPreallocSize = 1024;
nsString sheetText;
sheetText.SetCapacity(kPreallocSize);
#define NS_GET_R_G_B(color_) \
NS_GET_R(color_), NS_GET_G(color_), NS_GET_B(color_)
sheetText.AppendLiteral(
"@namespace url(http://www.w3.org/1999/xhtml);\n"
"@namespace svg url(http://www.w3.org/2000/svg);\n");
// Rules for link styling.
nscolor linkColor = aPresContext->DefaultLinkColor();
nscolor activeColor = aPresContext->DefaultActiveLinkColor();
nscolor visitedColor = aPresContext->DefaultVisitedLinkColor();
AppendPreferenceColorRule(aSheet,
"*|*:link { color: #%02x%02x%02x; }",
aPresContext->DefaultLinkColor());
AppendPreferenceColorRule(aSheet,
"*|*:-moz-any-link:active { color: #%02x%02x%02x; }",
aPresContext->DefaultActiveLinkColor());
AppendPreferenceColorRule(aSheet,
"*|*:visited { color: #%02x%02x%02x; }",
aPresContext->DefaultVisitedLinkColor());
sheetText.AppendPrintf(
"*|*:link { color: #%02x%02x%02x; }\n"
"*|*:-moz-any-link:active { color: #%02x%02x%02x; }\n"
"*|*:visited { color: #%02x%02x%02x; }\n",
NS_GET_R_G_B(linkColor),
NS_GET_R_G_B(activeColor),
NS_GET_R_G_B(visitedColor));
AppendPreferenceRule(aSheet,
aPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks) ?
NS_LITERAL_STRING(
"*|*:-moz-any-link:not(svg|a) { text-decoration: underline; }") :
NS_LITERAL_STRING(
"*|*:-moz-any-link{ text-decoration: none; }"));
bool underlineLinks =
aPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks);
sheetText.AppendPrintf(
"*|*:-moz-any-link%s { text-decoration: %s; }\n",
underlineLinks ? ":not(svg|a)" : "",
underlineLinks ? "underline" : "none");
// Rules for focus styling.
@ -883,54 +859,52 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<CSSStyleSheet>& aSheet,
if (focusRingWidth != 1) {
// If the focus ring width is different from the default, fix buttons
// with rings.
nsString rule;
rule.AppendPrintf(
sheetText.AppendPrintf(
"button::-moz-focus-inner, input[type=\"reset\"]::-moz-focus-inner, "
"input[type=\"button\"]::-moz-focus-inner, "
"input[type=\"submit\"]::-moz-focus-inner { "
"padding: 1px 2px 1px 2px; "
"border: %d %s transparent !important; }",
"border: %dpx %s transparent !important; }\n",
focusRingWidth,
focusRingWidth == 0 ? (const char*) "solid" : (const char*) "dotted");
AppendPreferenceRule(aSheet, rule);
focusRingStyle == 0 ? "solid" : "dotted");
// NS_LITERAL_STRING doesn't work with concatenated string literals, hence
// the newline escaping.
AppendPreferenceRule(aSheet, NS_LITERAL_STRING("\
button:focus::-moz-focus-inner, \
input[type=\"reset\"]:focus::-moz-focus-inner, \
input[type=\"button\"]:focus::-moz-focus-inner, \
input[type=\"submit\"]:focus::-moz-focus-inner { \
border-color: ButtonText !important; }"));
sheetText.AppendLiteral(
"button:focus::-moz-focus-inner, "
"input[type=\"reset\"]:focus::-moz-focus-inner, "
"input[type=\"button\"]:focus::-moz-focus-inner, "
"input[type=\"submit\"]:focus::-moz-focus-inner { "
"border-color: ButtonText !important; }\n");
}
nsString rule;
if (focusRingOnAnything) {
rule.AppendLiteral(":focus");
} else {
rule.AppendLiteral("*|*:link:focus, *|*:visited:focus");
}
rule.AppendPrintf(" { outline: %dpx ", focusRingWidth);
if (focusRingStyle == 0) { // solid
rule.AppendLiteral("solid -moz-mac-focusring !important; "
"-moz-outline-radius: 3px; outline-offset: 1px; }");
} else {
rule.AppendLiteral("dotted WindowText !important; }");
}
AppendPreferenceRule(aSheet, rule);
sheetText.AppendPrintf(
"%s { outline: %dpx %s !important; %s}\n",
focusRingOnAnything ?
":focus" :
"*|*:link:focus, *|*:visited:focus",
focusRingWidth,
focusRingStyle == 0 ? // solid
"solid -moz-mac-focusring" : "dotted WindowText",
focusRingStyle == 0 ? // solid
"-moz-outline-radius: 3px; outline-offset: 1px; " : "");
}
if (aPresContext->GetUseFocusColors()) {
nsString rule;
nscolor focusText = aPresContext->FocusTextColor();
nscolor focusBG = aPresContext->FocusBackgroundColor();
rule.AppendPrintf(
sheetText.AppendPrintf(
"*:focus, *:focus > font { color: #%02x%02x%02x !important; "
"background-color: #%02x%02x%02x !important; }",
NS_GET_R(focusText), NS_GET_G(focusText), NS_GET_B(focusText),
NS_GET_R(focusBG), NS_GET_G(focusBG), NS_GET_B(focusBG));
AppendPreferenceRule(aSheet, rule);
"background-color: #%02x%02x%02x !important; }\n",
NS_GET_R_G_B(focusText),
NS_GET_R_G_B(focusBG));
}
NS_ASSERTION(sheetText.Length() <= kPreallocSize,
"kPreallocSize should be big enough to build preference style "
"sheet without reallocation");
aSheet->ReparseSheet(sheetText);
#undef NS_GET_R_G_B
}
mozilla::StaticRefPtr<nsLayoutStylesheetCache>

View File

@ -77,10 +77,6 @@ private:
static void DependentPrefChanged(const char* aPref, void* aData);
void BuildPreferenceSheet(RefPtr<mozilla::CSSStyleSheet>& aSheet,
nsPresContext* aPresContext);
static void AppendPreferenceRule(mozilla::CSSStyleSheet* aSheet,
const nsAString& aRule);
static void AppendPreferenceColorRule(mozilla::CSSStyleSheet* aSheet,
const char* aString, nscolor aColor);
static mozilla::StaticRefPtr<nsLayoutStylesheetCache> gStyleCache;
static mozilla::css::Loader* gCSSLoader;

View File

@ -1746,7 +1746,8 @@ struct nsStyleText {
nsChangeHint CalcDifference(const nsStyleText& aOther) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_UpdateSubtreeOverflow;
nsChangeHint_UpdateSubtreeOverflow |
nsChangeHint_NeutralChange;
}
static nsChangeHint DifferenceAlwaysHandledForDescendants() {
// CalcDifference never returns the reflow hints that are sometimes

View File

@ -7055,9 +7055,10 @@ if (IsCSSPropertyPrefEnabled("layout.css.text-emphasis.enabled")) {
domProp: "textEmphasis",
inherited: true,
type: CSS_TYPE_TRUE_SHORTHAND,
prerequisites: { "color": "black" },
subproperties: [ "text-emphasis-style", "text-emphasis-color" ],
initial_values: [ "none currentColor", "currentColor none", "none", "currentColor" ],
other_values: [ "filled dot black", "#f00 circle open", "sesame filled rgba(0,0,255,0.5)", "red", "none black", "green none", "currentColor filled", "currentColor open" ],
initial_values: [ "none currentColor", "currentColor none", "none", "currentColor", "none black" ],
other_values: [ "filled dot black", "#f00 circle open", "sesame filled rgba(0,0,255,0.5)", "red", "green none", "currentColor filled", "currentColor open" ],
invalid_values: [ "filled black dot", "filled filled red", "open open circle #000", "circle dot #f00", "rubbish" ]
};
gCSSProperties["text-emphasis-color"] = {
@ -7065,7 +7066,7 @@ if (IsCSSPropertyPrefEnabled("layout.css.text-emphasis.enabled")) {
inherited: true,
type: CSS_TYPE_LONGHAND,
prerequisites: { "color": "black" },
initial_values: [ "currentColor", "-moz-use-text-color" ],
initial_values: [ "currentColor", "black", "rgb(0,0,0)" ],
other_values: [ "red", "rgba(255,255,255,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000", "ff00ff", "rgb(255,xxx,255)" ]
};

View File

@ -235,6 +235,8 @@ var supported_properties = {
test_border_color_shorthand_transition ],
"text-decoration-color": [ test_color_transition,
test_border_color_transition ],
"text-emphasis-color": [ test_color_transition,
test_border_color_transition ],
"text-indent": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition,
test_length_unclamped, test_percent_unclamped ],

View File

@ -476,7 +476,6 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
presContext->RoundAppUnitsToNearestDevPixels(aTextRect.y + ascent);
}
RefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
Point pt(presContext->AppUnitsToGfxUnits(aTextRect.x),
presContext->AppUnitsToGfxUnits(aTextRect.y));
Float width = presContext->AppUnitsToGfxUnits(aTextRect.width);

View File

@ -2413,7 +2413,7 @@ pref("layout.css.control-characters.visible", true);
#endif
// Is support for text-emphasis enabled?
pref("layout.css.text-emphasis.enabled", false);
pref("layout.css.text-emphasis.enabled", true);
// pref for which side vertical scrollbars should be on
// 0 = end-side in UI direction

View File

@ -153,6 +153,7 @@ ResidentUniqueDistinguishedAmount(int64_t* aN)
return GetProcSelfSmapsPrivate(aN);
}
#ifdef HAVE_MALLINFO
#define HAVE_SYSTEM_HEAP_REPORTER 1
nsresult
SystemHeapSize(int64_t* aSizeOut)
@ -172,6 +173,7 @@ SystemHeapSize(int64_t* aSizeOut)
*aSizeOut = size_t(info.hblkhd) + size_t(info.uordblks);
return NS_OK;
}
#endif
#elif defined(__DragonFly__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__) \