merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2016-06-21 11:56:06 +02:00
commit 26ac166ea9
175 changed files with 3331 additions and 2179 deletions

View File

@ -237,6 +237,9 @@ endif
# with no regard for PGO passes. This decision could probably be revisited.
recurse_pre-export:: install-dist/sdk
recurse_artifact:
$(topsrcdir)/mach --log-no-times artifact install
ifndef JS_STANDALONE
ifdef ENABLE_TESTS
# Additional makefile targets to call automated test suites

View File

@ -36,52 +36,10 @@ TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents) :
Controller()->RootEventTree().Log();
logging::MsgEnd();
logging::MsgBegin("EVENTS_TREE", "Container tree");
if (logging::IsEnabled(logging::eVerbose)) {
nsAutoString level;
Accessible* root = mParent->Document();
do {
const char* prefix = "";
if (mParent == root) {
prefix = "_X_";
}
else {
const EventTree& ret = Controller()->RootEventTree();
if (ret.Find(root)) {
prefix = "_с_";
}
}
printf("%s", NS_ConvertUTF16toUTF8(level).get());
logging::AccessibleInfo(prefix, root);
if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
level.Append(NS_LITERAL_STRING(" "));
root = root->FirstChild();
continue;
}
int32_t idxInParent = root->mParent ?
root->mParent->mChildren.IndexOf(root) : -1;
if (idxInParent != -1 &&
idxInParent < static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
continue;
}
while ((root = root->Parent()) && !root->IsDoc()) {
level.Cut(0, 2);
int32_t idxInParent = root->mParent ?
root->mParent->mChildren.IndexOf(root) : -1;
if (idxInParent != -1 &&
idxInParent < static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
break;
}
}
}
while (root && !root->IsDoc());
logging::Tree("EVENTS_TREE", "Container tree", mParent->Document(),
PrefixLog, static_cast<void*>(this));
}
logging::MsgEnd();
}
#endif
@ -173,6 +131,22 @@ TreeMutation::Done()
#endif
}
#ifdef A11Y_LOG
const char*
TreeMutation::PrefixLog(void* aData, Accessible* aAcc)
{
TreeMutation* thisObj = reinterpret_cast<TreeMutation*>(aData);
if (thisObj->mParent == aAcc) {
return "_X_";
}
const EventTree& ret = thisObj->Controller()->RootEventTree();
if (ret.Find(aAcc)) {
return "_с_";
}
return "";
}
#endif
////////////////////////////////////////////////////////////////////////////////
// EventTree

View File

@ -39,6 +39,10 @@ private:
static EventTree* const kNoEventTree;
#ifdef A11Y_LOG
static const char* PrefixLog(void* aData, Accessible*);
#endif
Accessible* mParent;
uint32_t mStartIdx;
uint32_t mStateFlagsCopy;

View File

@ -673,6 +673,47 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent)
}
}
void
logging::Tree(const char* aTitle, const char* aMsgText,
DocAccessible* aDocument, GetTreePrefix aPrefixFunc,
void* aGetTreePrefixData)
{
logging::MsgBegin(aTitle, aMsgText);
nsAutoString level;
Accessible* root = aDocument;
do {
const char* prefix = aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
printf("%s", NS_ConvertUTF16toUTF8(level).get());
logging::AccessibleInfo(prefix, root);
if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
level.Append(NS_LITERAL_STRING(" "));
root = root->FirstChild();
continue;
}
int32_t idxInParent = !root->IsDoc() && root->mParent ?
root->mParent->mChildren.IndexOf(root) : -1;
if (idxInParent != -1 &&
idxInParent < static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
continue;
}
while (!root->IsDoc() && (root = root->Parent())) {
level.Cut(0, 2);
int32_t idxInParent = !root->IsDoc() && root->mParent ?
root->mParent->mChildren.IndexOf(root) : -1;
if (idxInParent != -1 &&
idxInParent < static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
break;
}
}
}
while (root && !root->IsDoc());
logging::MsgEnd();
}
void
logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
{

View File

@ -139,6 +139,13 @@ void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
const char* aMsg2, nsINode* aNode);
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
/**
* Log the accessible tree.
*/
typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
void Tree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc,
GetTreePrefix aPrefixFunc = nullptr, void* aGetTreePrefixData = nullptr);
/**
* Log the message ('title: text' format) on new line. Print the start and end
* boundaries of the message body designated by '{' and '}' (2 spaces indent for

View File

@ -50,6 +50,14 @@ class TextLeafAccessible;
class XULLabelAccessible;
class XULTreeAccessible;
#ifdef A11Y_LOG
namespace logging {
typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
void Tree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc,
GetTreePrefix aPrefixFunc, void* GetTreePrefixData);
};
#endif
/**
* Name type flags.
*/
@ -1120,6 +1128,12 @@ protected:
void StaticAsserts() const;
#ifdef A11Y_LOG
friend void logging::Tree(const char* aTitle, const char* aMsgText,
DocAccessible* aDoc,
logging::GetTreePrefix aPrefixFunc,
void* aGetTreePrefixData);
#endif
friend class DocAccessible;
friend class xpcAccessible;
friend class TreeMutation;

View File

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows' and CONFIG['COMPILE_ENVIRONMENT']:
DIRS += ['msaa', 'ia2']
XPIDL_SOURCES += [

View File

@ -181,7 +181,7 @@ function readURI(uri) {
let stream = NetUtil.newChannel({
uri: NetUtil.newURI(uri, 'UTF-8'),
loadUsingSystemPrincipal: true}
).open();
).open2();
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, {
charset: 'UTF-8'

View File

@ -95,30 +95,6 @@ dnl =
dnl ========================================================
AC_DEFUN([MOZ_DEBUGGING_OPTS],
[
dnl Debug info is ON by default.
if test -z "$MOZ_DEBUG_FLAGS"; then
if test -n "$_MSC_VER"; then
MOZ_DEBUG_FLAGS="-Zi"
else
MOZ_DEBUG_FLAGS="-g"
fi
fi
AC_SUBST(MOZ_DEBUG_FLAGS)
MOZ_ARG_ENABLE_STRING(debug,
[ --enable-debug[=DBG] Enable building with developer debug info
(using compiler flags DBG)],
[ if test "$enableval" != "no"; then
MOZ_DEBUG=1
if test -n "$enableval" -a "$enableval" != "yes"; then
MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
_MOZ_DEBUG_FLAGS_SET=1
fi
else
MOZ_DEBUG=
fi ],
MOZ_DEBUG=)
if test -z "$MOZ_DEBUG" -o -n "$MOZ_ASAN"; then
MOZ_NO_DEBUG_RTL=1
@ -156,31 +132,6 @@ fi
AC_SUBST_LIST(MOZ_DEBUG_DEFINES)
dnl ========================================================
dnl = Enable generation of debug symbols
dnl ========================================================
MOZ_ARG_ENABLE_STRING(debug-symbols,
[ --enable-debug-symbols[=DBG]
Enable debugging symbols (using compiler flags DBG)],
[ if test "$enableval" != "no"; then
MOZ_DEBUG_SYMBOLS=1
if test -n "$enableval" -a "$enableval" != "yes"; then
if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
else
AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
fi
fi
else
MOZ_DEBUG_SYMBOLS=
fi ],
MOZ_DEBUG_SYMBOLS=1)
if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
AC_DEFINE(MOZ_DEBUG_SYMBOLS)
export MOZ_DEBUG_SYMBOLS
fi
])
dnl A high level macro for selecting compiler options.

View File

@ -172,9 +172,7 @@ def old_configure_options(*options):
'--enable-ctypes',
'--enable-dbm',
'--enable-dbus',
'--enable-debug',
'--enable-debug-js-modules',
'--enable-debug-symbols',
'--enable-directshow',
'--enable-dtrace',
'--enable-dump-painting',

View File

@ -604,3 +604,39 @@ host_c_compiler = compiler('C', host, other_compiler=c_compiler)
host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
other_compiler=cxx_compiler,
other_c_compiler=c_compiler)
@depends(c_compiler)
def default_debug_flags(compiler_info):
# Debug info is ON by default.
if compiler_info.type == 'msvc':
return '-Zi'
return '-g'
option(env='MOZ_DEBUG_FLAGS',
nargs=1,
help='Debug compiler flags')
imply_option('--enable-debug-symbols',
depends_if('--enable-debug')(lambda v: v))
js_option('--enable-debug-symbols',
nargs='?',
default=True,
help='Enable debug symbols using the given compiler flags')
set_config('MOZ_DEBUG_SYMBOLS',
depends_if('--enable-debug-symbols')(lambda _: True))
@depends('MOZ_DEBUG_FLAGS', '--enable-debug-symbols', default_debug_flags)
def debug_flags(env_debug_flags, enable_debug_flags, default_debug_flags):
# If MOZ_DEBUG_FLAGS is set, and --enable-debug-symbols is set to a value,
# --enable-debug-symbols takes precedence. Note, the value of
# --enable-debug-symbols may be implied by --enable-debug.
if len(enable_debug_flags):
return enable_debug_flags[0]
if env_debug_flags:
return env_debug_flags[0]
return default_debug_flags
set_config('MOZ_DEBUG_FLAGS', debug_flags)
add_old_configure_assignment('MOZ_DEBUG_FLAGS', debug_flags)

View File

@ -45,7 +45,7 @@ endif # WINNT
ifndef INCLUDED_AUTOCONF_MK
default::
else
TIERS := pre-export export $(if $(COMPILE_ENVIRONMENT),compile )misc libs tools
TIERS := $(if $(MOZ_ARTIFACT_BUILDS),artifact )pre-export export $(if $(COMPILE_ENVIRONMENT),compile )misc libs tools
endif
# These defines are used to support the twin-topsrcdir model for comm-central.

View File

@ -1696,7 +1696,7 @@ nsSHistory::CompareFrames(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry,
aParent->GetChildAt(i, getter_AddRefs(treeItem));
nsCOMPtr<nsIDocShell> shell = do_QueryInterface(treeItem);
if (shell) {
docshells.AppendObject(shell);
docshells.AppendElement(shell.forget());
}
}

View File

@ -268,29 +268,6 @@ GetWebIDLCallerPrincipal()
}
AutoEntryScript* aes = static_cast<AutoEntryScript*>(entry);
// We can't yet rely on the Script Settings Stack to properly determine the
// entry script, because there are still lots of places in the tree where we
// don't yet use an AutoEntryScript (bug 951991 tracks this work). In the
// mean time though, we can make some observations to hack around the
// problem:
//
// (1) All calls into JS-implemented WebIDL go through CallSetup, which goes
// through AutoEntryScript.
// (2) The top candidate entry point in the Script Settings Stack is the
// entry point if and only if no other JSContexts have been pushed on
// top of the push made by that entry's AutoEntryScript.
//
// Because of (1), all of the cases where we might return a non-null
// WebIDL Caller are guaranteed to have put an entry on the Script Settings
// Stack, so we can restrict our search to that. Moreover, (2) gives us a
// criterion to determine whether an entry in the Script Setting Stack means
// that we should return a non-null WebIDL Caller.
//
// Once we fix bug 951991, this can all be simplified.
if (!aes->CxPusherIsStackTop()) {
return nullptr;
}
return aes->mWebIDLCallerPrincipal;
}
@ -755,9 +732,9 @@ danger::AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
XPCJSContextStack *stack = XPCJSRuntime::Get()->GetJSContextStack();
stack->Push(cx);
mStackDepthAfterPush = stack->Count();
#ifdef DEBUG
mStackDepthAfterPush = stack->Count();
mPushedContext = cx;
mCompartmentDepthOnEntry = cx ? js::GetEnterCompartmentDepth(cx) : 0;
#endif
@ -781,11 +758,11 @@ danger::AutoCxPusher::~AutoCxPusher()
// pop is the same as it was right after we pushed.
MOZ_ASSERT_IF(mPushedContext, mCompartmentDepthOnEntry ==
js::GetEnterCompartmentDepth(mPushedContext));
DebugOnly<JSContext*> stackTop;
MOZ_ASSERT(mPushedContext == nsXPConnect::XPConnect()->GetCurrentJSContext());
XPCJSRuntime::Get()->GetJSContextStack()->Pop();
}
#ifdef DEBUG
bool
danger::AutoCxPusher::IsStackTop() const
{
@ -793,6 +770,7 @@ danger::AutoCxPusher::IsStackTop() const
MOZ_ASSERT(currentDepth >= mStackDepthAfterPush);
return currentDepth == mStackDepthAfterPush;
}
#endif
} // namespace dom

View File

@ -46,8 +46,8 @@ public:
private:
mozilla::Maybe<JSAutoRequest> mAutoRequest;
uint32_t mStackDepthAfterPush;
#ifdef DEBUG
uint32_t mStackDepthAfterPush;
JSContext* mPushedContext;
unsigned mCompartmentDepthOnEntry;
#endif
@ -262,7 +262,9 @@ public:
return mCx;
}
#ifdef DEBUG
bool CxPusherIsStackTop() const { return mCxPusher->IsStackTop(); }
#endif
// If HasException, report it. Otherwise, a no-op.
void ReportException();

View File

@ -123,6 +123,51 @@ using namespace mozilla::gfx;
class gfxContext;
class OldWindowSize : public LinkedListElement<OldWindowSize>
{
public:
static void Set(nsIWeakReference* aWindowRef, const nsSize& aSize)
{
OldWindowSize* item = GetItem(aWindowRef);
if (item) {
item->mSize = aSize;
} else {
item = new OldWindowSize(aWindowRef, aSize);
sList.insertBack(item);
}
}
static nsSize GetAndRemove(nsIWeakReference* aWindowRef)
{
nsSize result;
if (OldWindowSize* item = GetItem(aWindowRef)) {
result = item->mSize;
delete item;
}
return result;
}
private:
explicit OldWindowSize(nsIWeakReference* aWindowRef, const nsSize& aSize)
: mWindowRef(aWindowRef), mSize(aSize) { }
~OldWindowSize() { };
static OldWindowSize* GetItem(nsIWeakReference* aWindowRef)
{
OldWindowSize* item = sList.getFirst();
while (item && item->mWindowRef != aWindowRef) {
item = item->getNext();
}
return item;
}
static LinkedList<OldWindowSize> sList;
nsWeakPtr mWindowRef;
nsSize mSize;
};
LinkedList<OldWindowSize> OldWindowSize::sList;
NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWindowUtils)
NS_INTERFACE_MAP_ENTRY(nsIDOMWindowUtils)
@ -141,6 +186,7 @@ nsDOMWindowUtils::nsDOMWindowUtils(nsGlobalWindow *aWindow)
nsDOMWindowUtils::~nsDOMWindowUtils()
{
OldWindowSize::GetAndRemove(mWindow);
}
nsIPresShell*
@ -3104,62 +3150,6 @@ PrepareForFullscreenChange(nsIPresShell* aPresShell, const nsSize& aSize,
}
}
class OldWindowSize : public LinkedListElement<OldWindowSize>
{
public:
static void Set(nsPIDOMWindowOuter* aWindow, const nsSize& aSize)
{
OldWindowSize* item = GetItem(aWindow);
if (item) {
item->mSize = aSize;
} else if (aWindow) {
item = new OldWindowSize(do_GetWeakReference(aWindow), aSize);
sList.insertBack(item);
}
}
static nsSize GetAndRemove(nsPIDOMWindowOuter* aWindow)
{
nsSize result;
if (OldWindowSize* item = GetItem(aWindow)) {
result = item->mSize;
delete item;
}
return result;
}
private:
explicit OldWindowSize(already_AddRefed<nsIWeakReference>&& aWindow,
const nsSize& aSize)
: mWindow(Move(aWindow)), mSize(aSize) { }
~OldWindowSize() { };
static OldWindowSize* GetItem(nsPIDOMWindowOuter* aWindow)
{
OldWindowSize* item = sList.getFirst();
while (item) {
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(item->mWindow);
if (!window) {
OldWindowSize* thisItem = item;
item = thisItem->getNext();
delete thisItem;
continue;
}
if (window == aWindow) {
break;
}
item = item->getNext();
}
return item;
}
static LinkedList<OldWindowSize> sList;
nsWeakPtr mWindow;
nsSize mSize;
};
LinkedList<OldWindowSize> OldWindowSize::sList;
NS_IMETHODIMP
nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal)
{
@ -3177,7 +3167,7 @@ nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal)
}
nsSize oldSize;
PrepareForFullscreenChange(GetPresShell(), screenRect.Size(), &oldSize);
OldWindowSize::Set(doc->GetWindow(), oldSize);
OldWindowSize::Set(mWindow, oldSize);
*aRetVal = nsIDocument::HandlePendingFullscreenRequests(doc);
return NS_OK;
@ -3192,7 +3182,7 @@ nsDOMWindowUtils::ExitFullscreen()
// Although we would not use the old size if we have already exited
// fullscreen, we still want to cleanup in case we haven't.
nsSize oldSize = OldWindowSize::GetAndRemove(doc->GetWindow());
nsSize oldSize = OldWindowSize::GetAndRemove(mWindow);
if (!doc->GetFullscreenElement()) {
return NS_OK;
}

View File

@ -898,7 +898,7 @@ ResolveRequestedModules(nsModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls
nsresult rv = RequestedModuleIsInAncestorList(aRequest, uri, &isAncestor);
NS_ENSURE_SUCCESS(rv, rv);
if (!isAncestor) {
aUrls.AppendElement(uri);
aUrls.AppendElement(uri.forget());
}
}

View File

@ -1559,7 +1559,7 @@ EventListenerManager::GetListenerInfo(nsCOMArray<nsIEventListenerInfo>* aList)
listener.mFlags.mCapture,
listener.mFlags.mAllowUntrustedEvents,
listener.mFlags.mInSystemGroup);
aList->AppendObject(info);
aList->AppendElement(info.forget());
}
return NS_OK;
}

View File

@ -2525,13 +2525,11 @@ ContentChild::RecvAddPermission(const IPC::Permission& permission)
MOZ_ASSERT(permissionManager,
"We have no permissionManager in the Content process !");
// note we do not need to force mUserContextId to the default here because
// the permission manager does that internally.
nsAutoCString originNoSuffix;
PrincipalOriginAttributes attrs;
attrs.PopulateFromOrigin(permission.origin, originNoSuffix);
// we're doing this because we currently don't support isolating permissions
// by userContextId.
MOZ_ASSERT(attrs.mUserContextId == nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID,
"permission user context should be set to default!");
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);

View File

@ -1921,8 +1921,13 @@ TabChild::RecvRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId)
{
if (aInputBlockId) {
MOZ_ASSERT(aEvent.mFlags.mHandledByAPZ);
// Mouse events like eMouseEnterIntoWidget, that are created in the parent
// process EventStateManager code, have an input block id which they get from
// the InputAPZContext in the parent process stack. However, they did not
// actually go through the APZ code and so their mHandledByAPZ flag is false.
// Since thos events didn't go through APZ, we don't need to send notifications
// for them.
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
nsCOMPtr<nsIDocument> document(GetDocument());
APZCCallbackHelper::SendSetTargetAPZCNotification(
mPuppetWidget, document, aEvent, aGuid, aInputBlockId);
@ -1937,8 +1942,7 @@ TabChild::RecvRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
mPuppetWidget->GetDefaultScale());
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
if (aInputBlockId) {
MOZ_ASSERT(aEvent.mFlags.mHandledByAPZ);
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessMouseEvent(aEvent, aGuid, aInputBlockId);
}
return true;
@ -1949,8 +1953,7 @@ TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId)
{
if (aInputBlockId) {
MOZ_ASSERT(aEvent.mFlags.mHandledByAPZ);
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
nsCOMPtr<nsIDocument> document(GetDocument());
APZCCallbackHelper::SendSetTargetAPZCNotification(
mPuppetWidget, document, aEvent, aGuid, aInputBlockId);
@ -1966,8 +1969,7 @@ TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent,
SendRespondStartSwipeEvent(aInputBlockId, localEvent.TriggersSwipe());
}
if (aInputBlockId) {
MOZ_ASSERT(aEvent.mFlags.mHandledByAPZ);
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessWheelEvent(localEvent, aGuid, aInputBlockId);
}
return true;

View File

@ -312,7 +312,8 @@ function setupEnvironment() {
defaultMochitestPrefs.set.push(
["media.navigator.video.default_width", 320],
["media.navigator.video.default_height", 240],
["media.navigator.video.max_fr", 10]
["media.navigator.video.max_fr", 10],
["media.autoplay.enabled", true]
);
}

View File

@ -2016,7 +2016,7 @@ GetExtensionDirectories(nsCOMArray<nsIFile>& dirs)
nsCOMPtr<nsIFile> file = do_QueryInterface(next);
if (file) {
file->Normalize();
dirs.AppendElement(file);
dirs.AppendElement(file.forget());
}
}
}

View File

@ -122,6 +122,9 @@ GetOriginFromPrincipal(nsIPrincipal* aPrincipal, nsACString& aOrigin)
// any knowledge of private browsing. Allowing it to be true changes the suffix being hashed.
attrs.mPrivateBrowsingId = 0;
// set to default to disable user context isolation for permissions
attrs.mUserContextId = nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID;
attrs.CreateSuffix(suffix);
aOrigin.Append(suffix);
return NS_OK;

View File

@ -40,9 +40,6 @@ public:
const HANDLE mShareHandle;
protected:
RefPtr<IDXGIKeyedMutex> mKeyedMutex;
RefPtr<IDXGIKeyedMutex> mConsumerKeyedMutex;
RefPtr<ID3D11Texture2D> mConsumerTexture;
const GLuint mFence;
SharedSurface_ANGLEShareHandle(GLContext* gl,
@ -67,10 +64,6 @@ public:
virtual void ProducerReadAcquireImpl() override;
virtual void ProducerReadReleaseImpl() override;
const RefPtr<ID3D11Texture2D>& GetConsumerTexture() const {
return mConsumerTexture;
}
virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override;
virtual bool ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface) override;

View File

@ -32,9 +32,6 @@ public:
protected:
RefPtr<IDXGIKeyedMutex> mKeyedMutex;
RefPtr<IDXGIKeyedMutex> mConsumerKeyedMutex;
RefPtr<ID3D11Texture2D> mConsumerTexture;
bool mLockedForGL;
public:

View File

@ -9,6 +9,7 @@
#include "FrameMetrics.h" // for FrameMetrics, etc
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/gfx/Point.h" // for IntSize, etc
#include "mozilla/gfx/TiledRegion.h" // for TiledRegion
#include "mozilla/gfx/Types.h" // for SamplingFilter, SurfaceFormat
#include "mozilla/layers/CompositorTypes.h" // for TextureFlags
#include "nsAString.h"
@ -110,6 +111,18 @@ AppendToString(std::stringstream& aStream, const mozilla::gfx::IntRegionTyped<un
aStream << sfx;
}
template <typename T>
void
AppendToString(std::stringstream& aStream, const mozilla::gfx::TiledRegion<T>& r,
const char* pfx="", const char* sfx="")
{
aStream << pfx;
AppendToString(aStream, r.GetRegion());
aStream << " (bounds=";
AppendToString(aStream, r.GetBounds());
aStream << ", covers=" << r.CoversBounds() << ")" << sfx;
}
void
AppendToString(std::stringstream& aStream, const EventRegions& e,
const char* pfx="", const char* sfx="");

View File

@ -526,8 +526,13 @@ ClientLayerManager::MakeSnapshotIfRequired()
mForwarder->AllocSurfaceDescriptor(bounds.Size(),
gfxContentType::COLOR_ALPHA,
&inSnapshot)) {
// Make a copy of |inSnapshot| because the call to send it over IPC
// will call forget() on the Shmem inside, and zero it out.
SurfaceDescriptor outSnapshot = inSnapshot;
if (remoteRenderer->SendMakeSnapshot(inSnapshot, bounds)) {
RefPtr<DataSourceSurface> surf = GetSurfaceForDescriptor(inSnapshot);
RefPtr<DataSourceSurface> surf = GetSurfaceForDescriptor(outSnapshot);
DrawTarget* dt = mShadowTarget->GetDrawTarget();
Rect dstRect(bounds.x, bounds.y, bounds.width, bounds.height);
@ -544,7 +549,7 @@ ClientLayerManager::MakeSnapshotIfRequired()
DrawOptions(1.0f, CompositionOp::OP_OVER));
dt->SetTransform(oldMatrix);
}
mForwarder->DestroySurfaceDescriptor(&inSnapshot);
mForwarder->DestroySurfaceDescriptor(&outSnapshot);
}
}
}

View File

@ -343,10 +343,11 @@ ImageBridgeChild::NotifyNotUsedToNonRecycle(uint64_t aTextureId, uint64_t aTrans
mTexturesWaitingFenceHandle.Remove(aTextureId);
// Release TextureClient on allocator's message loop.
TextureClientReleaseTask* task = new TextureClientReleaseTask(client);
RefPtr<TextureClientReleaseTask> task =
MakeAndAddRef<TextureClientReleaseTask>(client);
RefPtr<ClientIPCAllocator> allocator = client->GetAllocator();
client = nullptr;
allocator->AsClientAllocator()->GetMessageLoop()->PostTask(FROM_HERE, task);
allocator->AsClientAllocator()->GetMessageLoop()->PostTask(task.forget());
#else
NS_RUNTIMEABORT("not reached");
#endif

View File

@ -14,6 +14,7 @@ namespace mozilla {
namespace gfx {
static const int32_t kTileSize = 256;
static const size_t kMaxTiles = 100;
/**
* TiledRegionImpl stores an array of non-empty rectangles (pixman_box32_ts) to
@ -282,7 +283,8 @@ TiledRegionImpl::AddRect(const pixman_box32_t& aRect)
// existing rectangle to include the intersection of aRect with the tile.
return ProcessIntersectedTiles(aRect, mRects,
[&aRect](nsTArray<pixman_box32_t>& rects, size_t& rectIndex, TileRange emptyTiles) {
if (!rects.InsertElementsAt(rectIndex, emptyTiles.Length(), fallible)) {
if (rects.Length() + emptyTiles.Length() >= kMaxTiles ||
!rects.InsertElementsAt(rectIndex, emptyTiles.Length(), fallible)) {
return IterationAction::STOP;
}
for (TileIterator tileIt = emptyTiles.Begin();

View File

@ -94,10 +94,6 @@ public:
if (mCoversBounds) {
return;
}
if (ExceedsMaximumSize()) {
FallBackToBounds();
return;
}
if (!mImpl.AddRect(RectToBox(aRect))) {
FallBackToBounds();
@ -111,10 +107,6 @@ public:
if (mCoversBounds) {
return;
}
if (ExceedsMaximumSize()) {
FallBackToBounds();
return;
}
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
RectT r = iter.Get();
@ -136,6 +128,7 @@ public:
}
RectT GetBounds() const { return mBounds; }
bool CoversBounds() const { return mCoversBounds; }
bool Intersects(const RectT& aRect) const
{
@ -162,12 +155,6 @@ public:
private:
bool ExceedsMaximumSize() const
{
// This stops us from allocating insane numbers of tiles.
return mBounds.width >= 50 * 256 || mBounds.height >= 50 * 256;
}
void FallBackToBounds()
{
mCoversBounds = true;

View File

@ -495,6 +495,8 @@ nsGIFDecoder2::WriteInternal(const char* aBuffer, uint32_t aCount)
return ReadImageDataSubBlock(aData);
case State::LZW_DATA:
return ReadLZWData(aData, aLength);
case State::SKIP_LZW_DATA:
return Transition::ContinueUnbuffered(State::SKIP_LZW_DATA);
case State::FINISHED_LZW_DATA:
return Transition::To(State::IMAGE_DATA_SUB_BLOCK, SUB_BLOCK_HEADER_LEN);
case State::SKIP_SUB_BLOCKS:
@ -987,8 +989,9 @@ nsGIFDecoder2::ReadImageDataSubBlock(const char* aData)
}
if (mGIFStruct.pixels_remaining == 0) {
// We've already written to the entire image. |subBlockLength| should've
// been zero.
// We've already written to the entire image; we should've hit the block
// terminator at this point. This image is corrupt, but we'll tolerate it.
if (subBlockLength == GIF_TRAILER) {
// This GIF is missing the block terminator for the final block; we'll put
// up with it.
@ -996,7 +999,10 @@ nsGIFDecoder2::ReadImageDataSubBlock(const char* aData)
return Transition::TerminateSuccess();
}
return Transition::To(State::IMAGE_DATA_SUB_BLOCK, SUB_BLOCK_HEADER_LEN);
// We're not at the end of the image, so just skip the extra data.
return Transition::ToUnbuffered(State::FINISHED_LZW_DATA,
State::SKIP_LZW_DATA,
subBlockLength);
}
// Handle the standard case: there's data in the sub-block and pixels left to

View File

@ -90,6 +90,7 @@ private:
IMAGE_DATA_BLOCK,
IMAGE_DATA_SUB_BLOCK,
LZW_DATA,
SKIP_LZW_DATA,
FINISHED_LZW_DATA,
SKIP_SUB_BLOCKS,
SKIP_DATA_THEN_SKIP_SUB_BLOCKS,

View File

@ -15,8 +15,6 @@
#include "gfxUtils.h"
#include "gfxAlphaRecovery.h"
static bool gDisableOptimize = false;
#include "GeckoProfiler.h"
#include "mozilla/Likely.h"
#include "MainThreadUtils.h"
@ -149,13 +147,6 @@ imgFrame::imgFrame()
, mSinglePixel(false)
, mCompositingFailed(false)
{
static bool hasCheckedOptimize = false;
if (!hasCheckedOptimize) {
if (PR_GetEnv("MOZ_DISABLE_IMAGE_OPTIMIZE")) {
gDisableOptimize = true;
}
hasCheckedOptimize = true;
}
}
imgFrame::~imgFrame()
@ -339,6 +330,16 @@ imgFrame::Optimize()
MOZ_ASSERT(mLockCount == 1,
"Should only optimize when holding the lock exclusively");
// Check whether image optimization is disabled -- not thread safe!
static bool gDisableOptimize = false;
static bool hasCheckedOptimize = false;
if (!hasCheckedOptimize) {
if (PR_GetEnv("MOZ_DISABLE_IMAGE_OPTIMIZE")) {
gDisableOptimize = true;
}
hasCheckedOptimize = true;
}
// Don't optimize during shutdown because gfxPlatform may not be available.
if (ShutdownTracker::ShutdownHasStarted()) {
return NS_OK;

View File

@ -533,6 +533,14 @@ ImageTestCase NoFrameDelayGIFTestCase()
return ImageTestCase("no-frame-delay.gif", "image/gif", IntSize(100, 100));
}
ImageTestCase ExtraImageSubBlocksAnimatedGIFTestCase()
{
// This is a corrupt GIF that has extra image sub blocks between the first and
// second frame.
return ImageTestCase("animated-with-extra-image-sub-blocks.gif", "image/gif",
IntSize(100, 100));
}
ImageTestCase DownscaledPNGTestCase()
{
// This testcase (and all the other "downscaled") testcases) consists of 25

View File

@ -332,6 +332,7 @@ ImageTestCase TransparentPNGTestCase();
ImageTestCase TransparentGIFTestCase();
ImageTestCase FirstFramePaddingGIFTestCase();
ImageTestCase NoFrameDelayGIFTestCase();
ImageTestCase ExtraImageSubBlocksAnimatedGIFTestCase();
ImageTestCase TransparentBMPWhenBMPAlphaEnabledTestCase();
ImageTestCase RLE4BMPTestCase();

View File

@ -349,3 +349,72 @@ TEST(ImageDecoders, CorruptMultiChunk)
{
CheckDecoderMultiChunk(CorruptTestCase());
}
TEST(ImageDecoders, AnimatedGIFWithExtraImageSubBlocks)
{
ImageTestCase testCase = ExtraImageSubBlocksAnimatedGIFTestCase();
// Verify that we can decode this test case and get two frames, even though
// there are extra image sub blocks between the first and second frame. The
// extra data shouldn't confuse the decoder or cause the decode to fail.
// Create an image.
RefPtr<Image> image =
ImageFactory::CreateAnonymousImage(nsDependentCString(testCase.mMimeType));
ASSERT_TRUE(!image->HasError());
nsCOMPtr<nsIInputStream> inputStream = LoadFile(testCase.mPath);
ASSERT_TRUE(inputStream);
// Figure out how much data we have.
uint64_t length;
nsresult rv = inputStream->Available(&length);
ASSERT_TRUE(NS_SUCCEEDED(rv));
// Write the data into the image.
rv = image->OnImageDataAvailable(nullptr, nullptr, inputStream, 0,
static_cast<uint32_t>(length));
ASSERT_TRUE(NS_SUCCEEDED(rv));
// Let the image know we've sent all the data.
rv = image->OnImageDataComplete(nullptr, nullptr, NS_OK, true);
ASSERT_TRUE(NS_SUCCEEDED(rv));
RefPtr<ProgressTracker> tracker = image->GetProgressTracker();
tracker->SyncNotifyProgress(FLAG_LOAD_COMPLETE);
// Use GetFrame() to force a sync decode of the image.
RefPtr<SourceSurface> surface =
image->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE);
// Ensure that the image's metadata meets our expectations.
IntSize imageSize(0, 0);
rv = image->GetWidth(&imageSize.width);
EXPECT_TRUE(NS_SUCCEEDED(rv));
rv = image->GetHeight(&imageSize.height);
EXPECT_TRUE(NS_SUCCEEDED(rv));
EXPECT_EQ(testCase.mSize.width, imageSize.width);
EXPECT_EQ(testCase.mSize.height, imageSize.height);
Progress imageProgress = tracker->GetProgress();
EXPECT_TRUE(bool(imageProgress & FLAG_HAS_TRANSPARENCY) == false);
EXPECT_TRUE(bool(imageProgress & FLAG_IS_ANIMATED) == true);
// Ensure that we decoded both frames of the image.
LookupResult firstFrameLookupResult =
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
/* aFrameNum = */ 0));
EXPECT_EQ(MatchType::EXACT, firstFrameLookupResult.Type());
LookupResult secondFrameLookupResult =
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
/* aFrameNum = */ 1));
EXPECT_EQ(MatchType::EXACT, secondFrameLookupResult.Type());
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

View File

@ -30,6 +30,7 @@ SOURCES += [
]
TEST_HARNESS_FILES.gtest += [
'animated-with-extra-image-sub-blocks.gif',
'corrupt.jpg',
'downscaled.bmp',
'downscaled.gif',

View File

@ -586,7 +586,7 @@ namespace js {
// After switching to MSVC2015, this can be eliminated and replaced with
// alignas(n) everywhere.
#ifdef XP_WIN
#if defined(_MSC_VER) && (_MSC_VER < 1900)
# define JS_ALIGNAS(n) __declspec(align(n))
#else
# define JS_ALIGNAS(n) alignas(n)

View File

@ -183,6 +183,9 @@ using mozilla::Move;
using mozilla::RangedPtr;
using mozilla::Variant;
template <typename T>
using Vector = mozilla::Vector<T, 0, js::SystemAllocPolicy>;
/*** ubi::StackFrame ******************************************************************************/
// Concrete JS::ubi::StackFrame instances backed by a live SavedFrame object

View File

@ -94,10 +94,10 @@ class JS_PUBLIC_API(DominatorTree)
{
friend class DominatedSetRange;
const mozilla::Vector<Node>& postOrder;
const JS::ubi::Vector<Node>& postOrder;
const uint32_t* ptr;
DominatedNodePtr(const mozilla::Vector<Node>& postOrder, const uint32_t* ptr)
DominatedNodePtr(const JS::ubi::Vector<Node>& postOrder, const uint32_t* ptr)
: postOrder(postOrder)
, ptr(ptr)
{ }
@ -118,11 +118,11 @@ class JS_PUBLIC_API(DominatorTree)
{
friend class DominatedSets;
const mozilla::Vector<Node>& postOrder;
const JS::ubi::Vector<Node>& postOrder;
const uint32_t* beginPtr;
const uint32_t* endPtr;
DominatedSetRange(mozilla::Vector<Node>& postOrder, const uint32_t* begin, const uint32_t* end)
DominatedSetRange(JS::ubi::Vector<Node>& postOrder, const uint32_t* begin, const uint32_t* end)
: postOrder(postOrder)
, beginPtr(begin)
, endPtr(end)
@ -179,10 +179,10 @@ class JS_PUBLIC_API(DominatorTree)
*/
class DominatedSets
{
mozilla::Vector<uint32_t> dominated;
mozilla::Vector<uint32_t> indices;
JS::ubi::Vector<uint32_t> dominated;
JS::ubi::Vector<uint32_t> indices;
DominatedSets(mozilla::Vector<uint32_t>&& dominated, mozilla::Vector<uint32_t>&& indices)
DominatedSets(JS::ubi::Vector<uint32_t>&& dominated, JS::ubi::Vector<uint32_t>&& indices)
: dominated(mozilla::Move(dominated))
, indices(mozilla::Move(indices))
{ }
@ -210,7 +210,7 @@ class JS_PUBLIC_API(DominatorTree)
* immediate dominator. Returns `Some` on success, `Nothing` on OOM
* failure.
*/
static mozilla::Maybe<DominatedSets> Create(const mozilla::Vector<uint32_t>& doms) {
static mozilla::Maybe<DominatedSets> Create(const JS::ubi::Vector<uint32_t>& doms) {
auto length = doms.length();
MOZ_ASSERT(length < UINT32_MAX);
@ -235,8 +235,8 @@ class JS_PUBLIC_API(DominatorTree)
// filled in. After having filled in all of a bucket's entries,
// the index points to the start of the bucket.
mozilla::Vector<uint32_t> dominated;
mozilla::Vector<uint32_t> indices;
JS::ubi::Vector<uint32_t> dominated;
JS::ubi::Vector<uint32_t> indices;
if (!dominated.growBy(length) || !indices.growBy(length))
return mozilla::Nothing();
@ -278,7 +278,7 @@ class JS_PUBLIC_API(DominatorTree)
* Get the set of nodes immediately dominated by the node at
* `postOrder[nodeIndex]`.
*/
DominatedSetRange dominatedSet(mozilla::Vector<Node>& postOrder, uint32_t nodeIndex) const {
DominatedSetRange dominatedSet(JS::ubi::Vector<Node>& postOrder, uint32_t nodeIndex) const {
MOZ_ASSERT(postOrder.length() == indices.length());
MOZ_ASSERT(nodeIndex < indices.length());
auto end = nodeIndex == indices.length() - 1
@ -290,11 +290,11 @@ class JS_PUBLIC_API(DominatorTree)
private:
// Data members.
mozilla::Vector<Node> postOrder;
JS::ubi::Vector<Node> postOrder;
NodeToIndexMap nodeToPostOrderIndex;
mozilla::Vector<uint32_t> doms;
JS::ubi::Vector<uint32_t> doms;
DominatedSets dominatedSets;
mozilla::Maybe<mozilla::Vector<JS::ubi::Node::Size>> retainedSizes;
mozilla::Maybe<JS::ubi::Vector<JS::ubi::Node::Size>> retainedSizes;
private:
// We use `UNDEFINED` as a sentinel value in the `doms` vector to signal
@ -302,8 +302,8 @@ class JS_PUBLIC_API(DominatorTree)
// index in `postOrder` yet.
static const uint32_t UNDEFINED = UINT32_MAX;
DominatorTree(mozilla::Vector<Node>&& postOrder, NodeToIndexMap&& nodeToPostOrderIndex,
mozilla::Vector<uint32_t>&& doms, DominatedSets&& dominatedSets)
DominatorTree(JS::ubi::Vector<Node>&& postOrder, NodeToIndexMap&& nodeToPostOrderIndex,
JS::ubi::Vector<uint32_t>&& doms, DominatedSets&& dominatedSets)
: postOrder(mozilla::Move(postOrder))
, nodeToPostOrderIndex(mozilla::Move(nodeToPostOrderIndex))
, doms(mozilla::Move(doms))
@ -311,7 +311,7 @@ class JS_PUBLIC_API(DominatorTree)
, retainedSizes(mozilla::Nothing())
{ }
static uint32_t intersect(mozilla::Vector<uint32_t>& doms, uint32_t finger1, uint32_t finger2) {
static uint32_t intersect(JS::ubi::Vector<uint32_t>& doms, uint32_t finger1, uint32_t finger2) {
while (finger1 != finger2) {
if (finger1 < finger2)
finger1 = doms[finger1];
@ -324,7 +324,7 @@ class JS_PUBLIC_API(DominatorTree)
// Do the post order traversal of the heap graph and populate our
// predecessor sets.
static MOZ_MUST_USE bool doTraversal(JSRuntime* rt, AutoCheckCannotGC& noGC, const Node& root,
mozilla::Vector<Node>& postOrder,
JS::ubi::Vector<Node>& postOrder,
PredecessorSets& predecessorSets) {
uint32_t nodeCount = 0;
auto onNode = [&](const Node& node) {
@ -357,7 +357,7 @@ class JS_PUBLIC_API(DominatorTree)
// Populates the given `map` with an entry for each node to its index in
// `postOrder`.
static MOZ_MUST_USE bool mapNodesToTheirIndices(mozilla::Vector<Node>& postOrder,
static MOZ_MUST_USE bool mapNodesToTheirIndices(JS::ubi::Vector<Node>& postOrder,
NodeToIndexMap& map) {
MOZ_ASSERT(!map.initialized());
MOZ_ASSERT(postOrder.length() < UINT32_MAX);
@ -373,10 +373,10 @@ class JS_PUBLIC_API(DominatorTree)
// form.
static MOZ_MUST_USE bool convertPredecessorSetsToVectors(
const Node& root,
mozilla::Vector<Node>& postOrder,
JS::ubi::Vector<Node>& postOrder,
PredecessorSets& predecessorSets,
NodeToIndexMap& nodeToPostOrderIndex,
mozilla::Vector<mozilla::Vector<uint32_t>>& predecessorVectors)
JS::ubi::Vector<JS::ubi::Vector<uint32_t>>& predecessorVectors)
{
MOZ_ASSERT(postOrder.length() < UINT32_MAX);
uint32_t length = postOrder.length();
@ -410,7 +410,7 @@ class JS_PUBLIC_API(DominatorTree)
// Initialize `doms` such that the immediate dominator of the `root` is the
// `root` itself and all others are `UNDEFINED`.
static MOZ_MUST_USE bool initializeDominators(mozilla::Vector<uint32_t>& doms,
static MOZ_MUST_USE bool initializeDominators(JS::ubi::Vector<uint32_t>& doms,
uint32_t length) {
MOZ_ASSERT(doms.length() == 0);
if (!doms.growByUninitialized(length))
@ -514,7 +514,7 @@ class JS_PUBLIC_API(DominatorTree)
*/
static mozilla::Maybe<DominatorTree>
Create(JSRuntime* rt, AutoCheckCannotGC& noGC, const Node& root) {
mozilla::Vector<Node> postOrder;
JS::ubi::Vector<Node> postOrder;
PredecessorSets predecessorSets;
if (!predecessorSets.init() || !doTraversal(rt, noGC, root, postOrder, predecessorSets))
return mozilla::Nothing();
@ -533,12 +533,12 @@ class JS_PUBLIC_API(DominatorTree)
if (!mapNodesToTheirIndices(postOrder, nodeToPostOrderIndex))
return mozilla::Nothing();
mozilla::Vector<mozilla::Vector<uint32_t>> predecessorVectors;
JS::ubi::Vector<JS::ubi::Vector<uint32_t>> predecessorVectors;
if (!convertPredecessorSetsToVectors(root, postOrder, predecessorSets, nodeToPostOrderIndex,
predecessorVectors))
return mozilla::Nothing();
mozilla::Vector<uint32_t> doms;
JS::ubi::Vector<uint32_t> doms;
if (!initializeDominators(doms, length))
return mozilla::Nothing();

View File

@ -69,7 +69,7 @@ struct JS_PUBLIC_API(BackEdge)
/**
* A path is a series of back edges from which we discovered a target node.
*/
using Path = mozilla::Vector<BackEdge*>;
using Path = JS::ubi::Vector<BackEdge*>;
/**
* The `JS::ubi::ShortestPaths` type represents a collection of up to N shortest
@ -81,7 +81,7 @@ struct JS_PUBLIC_API(ShortestPaths)
private:
// Types, type aliases, and data members.
using BackEdgeVector = mozilla::Vector<BackEdge::Ptr>;
using BackEdgeVector = JS::ubi::Vector<BackEdge::Ptr>;
using NodeToBackEdgeVectorMap = js::HashMap<Node, BackEdgeVector, js::DefaultHasher<Node>,
js::SystemAllocPolicy>;

View File

@ -2662,11 +2662,16 @@ FindPath(JSContext* cx, unsigned argc, Value* vp)
heaptools::FindPathHandler handler(cx, start, target, &nodes, edges);
heaptools::FindPathHandler::Traversal traversal(cx->runtime(), handler, autoCannotGC);
if (!traversal.init() || !traversal.addStart(start))
if (!traversal.init() || !traversal.addStart(start)) {
ReportOutOfMemory(cx);
return false;
}
if (!traversal.traverse())
if (!traversal.traverse()) {
if (!cx->isExceptionPending())
ReportOutOfMemory(cx);
return false;
}
if (!handler.foundPath) {
// We didn't find any paths from the start to the target.
@ -3349,6 +3354,11 @@ SetGCCallback(JSContext* cx, unsigned argc, Value* vp)
if (strcmp(action.ptr(), "minorGC") == 0) {
auto info = js_new<gcCallback::MinorGC>();
if (!info) {
ReportOutOfMemory(cx);
return false;
}
info->phases = phases;
info->active = true;
JS_SetGCCallback(cx->runtime(), gcCallback::minorGC, info);
@ -3366,6 +3376,11 @@ SetGCCallback(JSContext* cx, unsigned argc, Value* vp)
}
auto info = js_new<gcCallback::MajorGC>();
if (!info) {
ReportOutOfMemory(cx);
return false;
}
info->phases = phases;
info->depth = depth;
JS_SetGCCallback(cx->runtime(), gcCallback::majorGC, info);

View File

@ -162,6 +162,9 @@ class LifoAlloc
size_t defaultChunkSize_;
size_t curSize_;
size_t peakSize_;
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
bool fallibleScope_;
#endif
void operator=(const LifoAlloc&) = delete;
LifoAlloc(const LifoAlloc&) = delete;
@ -231,6 +234,9 @@ class LifoAlloc
public:
explicit LifoAlloc(size_t defaultChunkSize)
: peakSize_(0)
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
, fallibleScope_(true)
#endif
{
reset(defaultChunkSize);
}
@ -270,19 +276,17 @@ class LifoAlloc
MOZ_ALWAYS_INLINE
void* alloc(size_t n) {
JS_OOM_POSSIBLY_FAIL();
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
// Only simulate OOMs when we are not using the LifoAlloc as an
// infallible allocator.
if (fallibleScope_)
JS_OOM_POSSIBLY_FAIL();
#endif
return allocImpl(n);
}
MOZ_ALWAYS_INLINE
void* allocInfallibleOrAssert(size_t n) {
void* result = allocImpl(n);
MOZ_RELEASE_ASSERT(result, "[OOM] Is it really infallible?");
return result;
}
MOZ_ALWAYS_INLINE
void* allocInfallibleOrCrash(size_t n) {
void* allocInfallible(size_t n) {
AutoEnterOOMUnsafeRegion oomUnsafe;
if (void* result = allocImpl(n))
return result;
@ -290,16 +294,12 @@ class LifoAlloc
return nullptr;
}
MOZ_ALWAYS_INLINE
void* allocInfallible(size_t n) {
return allocInfallibleOrCrash(n);
}
// Ensures that enough space exists to satisfy N bytes worth of
// allocation requests, not necessarily contiguous. Note that this does
// not guarantee a successful single allocation of N bytes.
MOZ_ALWAYS_INLINE
MOZ_MUST_USE bool ensureUnusedApproximate(size_t n) {
AutoFallibleScope fallibleAllocator(this);
size_t total = 0;
for (BumpChunk* chunk = latest; chunk; chunk = chunk->next()) {
total += chunk->unused();
@ -314,6 +314,36 @@ class LifoAlloc
return true;
}
MOZ_ALWAYS_INLINE
void setAsInfallibleByDefault() {
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
fallibleScope_ = false;
#endif
}
class MOZ_NON_TEMPORARY_CLASS AutoFallibleScope {
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
LifoAlloc* lifoAlloc_;
bool prevFallibleScope_;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
explicit AutoFallibleScope(LifoAlloc* lifoAlloc MOZ_GUARD_OBJECT_NOTIFIER_PARAM) {
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
lifoAlloc_ = lifoAlloc;
prevFallibleScope_ = lifoAlloc->fallibleScope_;
lifoAlloc->fallibleScope_ = true;
}
~AutoFallibleScope() {
lifoAlloc_->fallibleScope_ = prevFallibleScope_;
}
#else
public:
explicit AutoFallibleScope(LifoAlloc*) {}
#endif
};
template <typename T>
T* newArray(size_t count) {
static_assert(mozilla::IsPod<T>::value,
@ -499,6 +529,7 @@ class MOZ_NON_TEMPORARY_CLASS LifoAllocScope
{
LifoAlloc* lifoAlloc;
LifoAlloc::Mark mark;
LifoAlloc::AutoFallibleScope fallibleScope;
bool shouldRelease;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
@ -507,6 +538,7 @@ class MOZ_NON_TEMPORARY_CLASS LifoAllocScope
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: lifoAlloc(lifoAlloc),
mark(lifoAlloc->mark()),
fallibleScope(lifoAlloc),
shouldRelease(true)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;

View File

@ -9352,7 +9352,12 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
return null();
tokenStream.consumeKnownToken(TOK_ASSIGN);
bool saved = pc->inDeclDestructuring;
// Setting `inDeclDestructuring` to false allows name use to be noted
// in `identifierName` See Bug: 1255167.
pc->inDeclDestructuring = false;
Node rhs = assignExpr(InAllowed, yieldHandling, TripledotProhibited);
pc->inDeclDestructuring = saved;
if (!rhs)
return null();

View File

@ -194,13 +194,13 @@ static ExtraPhaseInfo phaseExtra[PHASE_LIMIT] = { { 0, 0 } };
// Mapping from all nodes with a multi-parented child to a Vector of all
// multi-parented children and their descendants. (Single-parented children will
// not show up in this list.)
static mozilla::Vector<Phase> dagDescendants[Statistics::NumTimingArrays];
static mozilla::Vector<Phase, 0, SystemAllocPolicy> dagDescendants[Statistics::NumTimingArrays];
struct AllPhaseIterator {
int current;
int baseLevel;
size_t activeSlot;
mozilla::Vector<Phase>::Range descendants;
mozilla::Vector<Phase, 0, SystemAllocPolicy>::Range descendants;
explicit AllPhaseIterator(const Statistics::PhaseTimeTable table)
: current(0)
@ -829,7 +829,7 @@ Statistics::initialize()
// Fill in the depth of each node in the tree. Multi-parented nodes
// have depth 0.
mozilla::Vector<Phase> stack;
mozilla::Vector<Phase, 0, SystemAllocPolicy> stack;
if (!stack.append(PHASE_LIMIT)) // Dummy entry to avoid special-casing the first node
return false;
for (int i = 0; i < PHASE_LIMIT; i++) {

View File

@ -1720,6 +1720,12 @@ RegExpCompiler::Assemble(JSContext* cx,
macro_assembler_ = assembler;
macro_assembler_->set_slow_safe(false);
// The LifoAlloc used by the regexp compiler is infallible and is currently
// expected to crash on OOM. Thus we have to disable the assertions made to
// prevent us from allocating any new chunk in the LifoAlloc. This is needed
// because the jit::MacroAssembler turns these assertions on by default.
LifoAlloc::AutoFallibleScope fallibleAllocator(alloc());
jit::Label fail;
macro_assembler_->PushBacktrack(&fail);
Trace new_trace;

View File

@ -0,0 +1,6 @@
if (!('oomTest' in this))
quit();
var x = [];
oomTest(() => setGCCallback({ action: "minorGC" }));
oomTest(() => setGCCallback({ action: "majorGC" }));

View File

@ -0,0 +1,19 @@
if (!('oomTest' in this))
quit();
oomTest(() => byteSize({}));
oomTest(() => byteSize({ w: 1, x: 2, y: 3 }));
oomTest(() => byteSize({ w:1, x:2, y:3, z:4, a:6, 0:0, 1:1, 2:2 }));
oomTest(() => byteSize([1, 2, 3]));
oomTest(() => byteSize(function () {}));
function f1() {
return 42;
}
oomTest(() => byteSizeOfScript(f1));
oomTest(() => byteSize("1234567"));
oomTest(() => byteSize("千早ぶる神代"));
let s = Symbol();
oomTest(() => byteSize(s));

View File

@ -0,0 +1,19 @@
if (!('oomTest' in this))
quit();
var o = { w: { x: { y: { z: {} } } } };
oomTest(() => findPath(o, o.w.x.y.z));
var a = [ , o ];
oomTest(() => findPath(a, o));
function C() {}
C.prototype.obj = {};
var c = new C;
oomTest(() => findPath(c, c.obj));
function f(x) { return function g(y) { return x+y; }; }
var o = {}
var gc = f(o);
oomTest(() => findPath(gc, o));

View File

@ -0,0 +1,9 @@
// |jit-test| error: ReferenceError
var N = 70 * 1000;
var x = build("&&")();
function build(operation) {
var a = [];
for (var i = 1; i != N - 1; ++i) a.push("f()");
return new Function(a.join(operation));
}

View File

@ -0,0 +1,21 @@
if (!('oomTest' in this))
quit();
loadFile(`
T = TypedObject
ObjectStruct = new T.StructType({f: T.Object})
var o = new ObjectStruct
function testGC(p) {
for (; i < 5; i++)
whatever.push;
}
testGC(o)
function writeObject()
o.f = v
writeObject({function() { } })
for (var i ; i < 5 ; ++i)
try {} catch (StringStruct) {}
`);
function loadFile(lfVarx) {
oomTest(Function(lfVarx));
}

View File

@ -0,0 +1,8 @@
if (!('oomTest' in this))
quit();
oomTest(function() {
m = parseModule(`while (x && NaN) prototype; let x`);
m.declarationInstantiation();
m.evaluation();
})

View File

@ -766,7 +766,13 @@ IonBuilder::pushLoop(CFGState::State initial, jsbytecode* stopAt, MBasicBlock* e
bool
IonBuilder::init()
{
if (!TypeScript::FreezeTypeSets(constraints(), script(), &thisTypes, &argTypes, &typeArray))
{
LifoAlloc::AutoFallibleScope fallibleAllocator(alloc().lifoAlloc());
if (!TypeScript::FreezeTypeSets(constraints(), script(), &thisTypes, &argTypes, &typeArray))
return false;
}
if (!alloc().ensureBallast())
return false;
if (inlineCallInfo_) {
@ -1408,6 +1414,9 @@ IonBuilder::maybeAddOsrTypeBarriers()
if (info().isSlotAliasedAtOsr(slot))
continue;
if (!alloc().ensureBallast())
return false;
MInstruction* def = osrBlock->getSlot(slot)->toInstruction();
MPhi* preheaderPhi = preheader->getSlot(slot)->toPhi();
MPhi* headerPhi = headerRp->getOperand(slot)->toPhi();

View File

@ -34,15 +34,18 @@ class TempAllocator
explicit TempAllocator(LifoAlloc* lifoAlloc)
: lifoScope_(lifoAlloc)
{ }
{
lifoAlloc->setAsInfallibleByDefault();
}
void* allocateInfallible(size_t bytes)
{
return lifoScope_.alloc().allocInfallibleOrAssert(bytes);
return lifoScope_.alloc().allocInfallible(bytes);
}
void* allocate(size_t bytes)
MOZ_MUST_USE void* allocate(size_t bytes)
{
LifoAlloc::AutoFallibleScope fallibleAllocator(lifoAlloc());
void* p = lifoScope_.alloc().alloc(bytes);
if (!ensureBallast())
return nullptr;
@ -50,8 +53,9 @@ class TempAllocator
}
template <typename T>
T* allocateArray(size_t n)
MOZ_MUST_USE T* allocateArray(size_t n)
{
LifoAlloc::AutoFallibleScope fallibleAllocator(lifoAlloc());
size_t bytes;
if (MOZ_UNLIKELY(!CalculateAllocSize<T>(n, &bytes)))
return nullptr;
@ -65,12 +69,12 @@ class TempAllocator
struct Fallible { TempAllocator& alloc; };
Fallible fallible() { return { *this }; }
LifoAlloc* lifoAlloc()
{
LifoAlloc* lifoAlloc() {
return &lifoScope_.alloc();
}
MOZ_MUST_USE bool ensureBallast() {
JS_OOM_POSSIBLY_FAIL_BOOL();
return lifoScope_.alloc().ensureUnusedApproximate(BallastSize);
}
};
@ -150,7 +154,7 @@ class AutoJitContextAlloc
struct TempObject
{
inline void* operator new(size_t nbytes, TempAllocator::Fallible view) noexcept {
inline void* operator new(size_t nbytes, TempAllocator::Fallible view) throw() {
return view.alloc.allocate(nbytes);
}
inline void* operator new(size_t nbytes, TempAllocator& alloc) {

View File

@ -526,6 +526,8 @@ IonBuilder::inlineArray(CallInfo& callInfo)
if (callInfo.argc() >= 2) {
JSValueType unboxedType = GetBoxedOrUnboxedType(templateObject);
for (uint32_t i = 0; i < initLength; i++) {
if (!alloc().ensureBallast())
return InliningStatus_Error;
MDefinition* value = callInfo.getArg(i);
if (!initializeArrayElement(array, i, value, unboxedType, /* addResumePoint = */ false))
return InliningStatus_Error;

View File

@ -7156,6 +7156,9 @@ class MPhi final
static MPhi* New(TempAllocator& alloc, MIRType resultType = MIRType::Value) {
return new(alloc) MPhi(alloc, resultType);
}
static MPhi* New(TempAllocator::Fallible alloc, MIRType resultType = MIRType::Value) {
return new(alloc) MPhi(alloc.alloc, resultType);
}
void removeOperand(size_t index);
void removeAllOperands();

View File

@ -558,7 +558,9 @@ MBasicBlock::inherit(TempAllocator& alloc, BytecodeAnalysis* analysis, MBasicBlo
if (kind_ == PENDING_LOOP_HEADER) {
size_t i = 0;
for (i = 0; i < info().firstStackSlot(); i++) {
MPhi* phi = MPhi::New(alloc);
MPhi* phi = MPhi::New(alloc.fallible());
if (!phi)
return false;
phi->addInlineInput(pred->getSlot(i));
addPhi(phi);
setSlot(i, phi);
@ -578,7 +580,9 @@ MBasicBlock::inherit(TempAllocator& alloc, BytecodeAnalysis* analysis, MBasicBlo
}
for (; i < stackDepth(); i++) {
MPhi* phi = MPhi::New(alloc);
MPhi* phi = MPhi::New(alloc.fallible());
if (!phi)
return false;
phi->addInlineInput(pred->getSlot(i));
addPhi(phi);
setSlot(i, phi);
@ -1193,9 +1197,11 @@ MBasicBlock::addPredecessorPopN(TempAllocator& alloc, MBasicBlock* pred, uint32_
// Otherwise, create a new phi node.
MPhi* phi;
if (mine->type() == other->type())
phi = MPhi::New(alloc, mine->type());
phi = MPhi::New(alloc.fallible(), mine->type());
else
phi = MPhi::New(alloc);
phi = MPhi::New(alloc.fallible());
if (!phi)
return false;
addPhi(phi);
// Prime the phi for each predecessor, so input(x) comes from

View File

@ -456,5 +456,5 @@ Assembler::UpdateBoundsCheck(uint8_t* patchAt, uint32_t heapLength)
InstImm* i1 = (InstImm*) i0->next();
// Replace with new value
Assembler::UpdateLuiOriValue(i0, i1, heapSize);
Assembler::UpdateLuiOriValue(i0, i1, heapLength);
}

View File

@ -59,6 +59,7 @@ class FloatRegisters : public FloatRegistersMIPSShared
static const SetType AllPhysMask = ((SetType(1) << TotalPhys) - 1);
static const SetType AllMask = AllPhysMask * Spread;
static const SetType AllSingleMask = AllPhysMask * SpreadSingle;
static const SetType AllDoubleMask = AllPhysMask * SpreadDouble;
static const SetType NonVolatileMask =

View File

@ -9,6 +9,9 @@
#include "mozilla/IntegerRange.h"
#include "mozilla/Move.h"
#include "mozilla/Vector.h"
#include "jsalloc.h"
#include "jsapi-tests/tests.h"
#include "threading/Thread.h"
@ -62,7 +65,7 @@ BEGIN_TEST(testThreadingThreadVectorMoveConstruct)
{
const static size_t N = 10;
mozilla::Atomic<int> count(0);
mozilla::Vector<js::Thread> v;
mozilla::Vector<js::Thread, 0, js::SystemAllocPolicy> v;
for (auto i : mozilla::MakeRange(N)) {
CHECK(v.emplaceBack([](mozilla::Atomic<int>* countp){(*countp)++;}, &count));
CHECK(v.length() == i + 1);

View File

@ -6150,6 +6150,8 @@ struct PerformanceGroup {
uint64_t refCount_;
};
using PerformanceGroupVector = mozilla::Vector<RefPtr<js::PerformanceGroup>, 0, SystemAllocPolicy>;
/**
* Commit any Performance Monitoring data.
*
@ -6208,12 +6210,12 @@ extern JS_PUBLIC_API(bool)
SetStopwatchStartCallback(JSRuntime*, StopwatchStartCallback, void*);
typedef bool
(*StopwatchCommitCallback)(uint64_t, mozilla::Vector<RefPtr<PerformanceGroup>>&, void*);
(*StopwatchCommitCallback)(uint64_t, PerformanceGroupVector&, void*);
extern JS_PUBLIC_API(bool)
SetStopwatchCommitCallback(JSRuntime*, StopwatchCommitCallback, void*);
typedef bool
(*GetGroupsCallback)(JSContext*, mozilla::Vector<RefPtr<PerformanceGroup>>&, void*);
(*GetGroupsCallback)(JSContext*, PerformanceGroupVector&, void*);
extern JS_PUBLIC_API(bool)
SetGetPerformanceGroupsCallback(JSRuntime*, GetGroupsCallback, void*);

View File

@ -972,7 +972,7 @@ GCRuntime::parseAndSetZeal(const char* str)
{
int frequency = -1;
bool foundFrequency = false;
mozilla::Vector<int> zeals;
mozilla::Vector<int, 0, SystemAllocPolicy> zeals;
static const struct {
const char* const zealMode;
@ -2643,8 +2643,9 @@ GCRuntime::releaseHeldRelocatedArenas()
{
#ifdef DEBUG
unprotectHeldRelocatedArenas();
releaseRelocatedArenas(relocatedArenasToRelease);
Arena* arenas = relocatedArenasToRelease;
relocatedArenasToRelease = nullptr;
releaseRelocatedArenas(arenas);
#endif
}
@ -3134,7 +3135,7 @@ GCRuntime::decommitArenas(AutoLockGC& lock)
// Build a Vector of all current available Chunks. Since we release the
// gc lock while doing the decommit syscall, it is dangerous to iterate
// the available list directly, as concurrent operations can modify it.
mozilla::Vector<Chunk*> toDecommit;
mozilla::Vector<Chunk*, 0, SystemAllocPolicy> toDecommit;
MOZ_ASSERT(availableChunks(lock).verify());
for (ChunkPool::Iter iter(availableChunks(lock)); !iter.done(); iter.next()) {
if (!toDecommit.append(iter.get())) {

View File

@ -2432,7 +2432,6 @@ AC_SUBST(IMPLIB)
AC_SUBST(FILTER)
AC_SUBST(BIN_FLAGS)
AC_SUBST(MOZ_DEBUG)
AC_SUBST(MOZ_DEBUG_SYMBOLS)
AC_SUBST(MOZ_DEBUG_LDFLAGS)
AC_SUBST(WARNINGS_AS_ERRORS)
AC_SUBST(LIBICONV)

View File

@ -5222,8 +5222,8 @@ WasmLoop(JSContext* cx, unsigned argc, Value* vp)
return false;
Rooted<TypedArrayObject*> typedArray(cx, &ret->as<TypedArrayObject>());
RootedObject exportObj(cx);
if (!wasm::Eval(cx, typedArray, importObj, &exportObj)) {
RootedWasmInstanceObject instanceObj(cx);
if (!wasm::Eval(cx, typedArray, importObj, &instanceObj)) {
// Clear any pending exceptions, we don't care about them
cx->clearPendingException();
}

View File

@ -123,5 +123,14 @@ assertEq((({a = 0} = {}) => a)({a: 1}), 1);
assertEq(j, 2);
}
// Default destructuring values, which are variables, should be defined
// within closures (Bug 1255167).
{
let f = function(a){
return (function({aa = a}){ return aa; })({});
};
assertEq(f(9999), 9999);
}
if (typeof reportCompare == "function")
reportCompare(true, true);

View File

@ -152,7 +152,7 @@ PerformanceMonitoring::commit()
return true;
}
GroupVector recentGroups;
PerformanceGroupVector recentGroups;
recentGroups_.swap(recentGroups);
bool success = true;
@ -200,7 +200,7 @@ PerformanceGroupHolder::unlink()
groups_.clear();
}
const GroupVector*
const PerformanceGroupVector*
PerformanceGroupHolder::getGroups(JSContext* cx)
{
if (initialized_)
@ -233,7 +233,7 @@ AutoStopwatch::AutoStopwatch(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IM
JSRuntime* runtime = cx_->runtime();
iteration_ = runtime->performanceMonitoring.iteration();
const GroupVector* groups = compartment->performanceMonitoring.getGroups(cx);
const PerformanceGroupVector* groups = compartment->performanceMonitoring.getGroups(cx);
if (!groups) {
// Either the embedding has not provided any performance
// monitoring logistics or there was an error that prevents

View File

@ -19,8 +19,6 @@
namespace js {
typedef mozilla::Vector<RefPtr<js::PerformanceGroup>> GroupVector;
/**
* A container for performance groups.
*
@ -43,7 +41,7 @@ struct PerformanceGroupHolder {
* May return `nullptr` if the embedding has not initialized
* support for performance groups.
*/
const GroupVector* getGroups(JSContext*);
const PerformanceGroupVector* getGroups(JSContext*);
explicit PerformanceGroupHolder(JSRuntime* runtime)
: runtime_(runtime)
@ -59,7 +57,7 @@ struct PerformanceGroupHolder {
// The groups to which this compartment belongs. Filled if and only
// if `initialized_` is `true`.
GroupVector groups_;
PerformanceGroupVector groups_;
};
/**
@ -292,7 +290,7 @@ struct PerformanceMonitoring {
/**
* Groups used in the current iteration.
*/
GroupVector recentGroups_;
PerformanceGroupVector recentGroups_;
/**
* The highest value of the timestamp counter encountered
@ -344,7 +342,7 @@ class AutoStopwatch final {
// if `isMonitoringJank_` is `true`.
cpuid_t cpuStart_;
mozilla::Vector<RefPtr<js::PerformanceGroup>> groups_;
PerformanceGroupVector groups_;
public:
// If the stopwatch is active, constructing an instance of

View File

@ -127,7 +127,7 @@ SimpleCount::report(JSContext* cx, CountBase& countBase, MutableHandleValue repo
class BucketCount : public CountType {
struct Count : CountBase {
mozilla::Vector<JS::ubi::Node::Id> ids_;
JS::ubi::Vector<JS::ubi::Node::Id> ids_;
explicit Count(BucketCount& count)
: CountBase(count),
@ -349,7 +349,7 @@ countMapToObject(JSContext* cx, Map& map, GetName getName) {
// that to build the result object. This makes the ordering of entries
// more interesting, and a little less non-deterministic.
mozilla::Vector<typename Map::Entry*> entries;
JS::ubi::Vector<typename Map::Entry*> entries;
if (!entries.reserve(map.count())) {
ReportOutOfMemory(cx);
return nullptr;
@ -570,7 +570,7 @@ ByUbinodeType::report(JSContext* cx, CountBase& countBase, MutableHandleValue re
// Build a vector of pointers to entries; sort by total; and then use
// that to build the result object. This makes the ordering of entries
// more interesting, and a little less non-deterministic.
mozilla::Vector<Entry*> entries;
JS::ubi::Vector<Entry*> entries;
if (!entries.reserve(count.table.count()))
return false;
for (Table::Range r = count.table.all(); !r.empty(); r.popFront())
@ -736,7 +736,7 @@ ByAllocationStack::report(JSContext* cx, CountBase& countBase, MutableHandleValu
// Build a vector of pointers to entries; sort by total; and then use
// that to build the result object. This makes the ordering of entries
// more interesting, and a little less non-deterministic.
mozilla::Vector<Entry*> entries;
JS::ubi::Vector<Entry*> entries;
if (!entries.reserve(count.table.count()))
return false;
for (Table::Range r = count.table.all(); !r.empty(); r.popFront())

View File

@ -32,6 +32,8 @@
using namespace mozilla;
using namespace mozilla::gfx;
#define MAX_COMPOSITE_BORDER_WIDTH LayoutDeviceIntCoord(10000)
/**
* nsCSSRendering::PaintBorder
* nsCSSRendering::PaintOutline
@ -1373,9 +1375,16 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
// color is used for the remainder of the border's size. Just
// hand off to another function to do all that.
if (compositeColors) {
DrawBorderSidesCompositeColors(aSides, compositeColors);
return;
}
Float maxBorderWidth(0);
NS_FOR_CSS_SIDES (i) {
maxBorderWidth = std::max(maxBorderWidth, mBorderWidths[i]);
}
if (maxBorderWidth <= MAX_COMPOSITE_BORDER_WIDTH) {
DrawBorderSidesCompositeColors(aSides, compositeColors);
return;
}
NS_WARNING("DrawBorderSides: too large border width for composite colors");
}
// We're not doing compositeColors, so we can calculate the
// borderColorStyle based on the specified style. The

View File

@ -1876,7 +1876,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
MOZ_ASSERT(req, "Unable to retrieve the image request");
nsCOMPtr<imgIContainer> image;
if (NS_SUCCEEDED(req->GetImage(getter_AddRefs(image)))) {
imagesToRefresh.AppendElement(image);
imagesToRefresh.AppendElement(image.forget());
}
}

View File

@ -1081,6 +1081,7 @@ struct nsGridContainerFrame::Tracks
{
explicit Tracks(LogicalAxis aAxis)
: mAxis(aAxis)
, mCanResolveLineRangeSize(false)
{
mBaselineSubtreeAlign[BaselineSharingGroup::eFirst] = NS_STYLE_ALIGN_AUTO;
mBaselineSubtreeAlign[BaselineSharingGroup::eLast] = NS_STYLE_ALIGN_AUTO;
@ -1482,8 +1483,9 @@ struct nsGridContainerFrame::Tracks
* Apply 'align/justify-content', whichever is relevant for this axis.
* https://drafts.csswg.org/css-align-3/#propdef-align-content
*/
void AlignJustifyContent(const nsHTMLReflowState& aReflowState,
const LogicalSize& aContainerSize);
void AlignJustifyContent(const nsStylePosition* aStyle,
WritingMode aWM,
const LogicalSize& aContainerSize);
nscoord GridLineEdge(uint32_t aLine, GridLineSide aSide) const
{
@ -1554,6 +1556,15 @@ struct nsGridContainerFrame::Tracks
}
}
nscoord ResolveSize(const LineRange& aRange) const
{
MOZ_ASSERT(mCanResolveLineRangeSize);
MOZ_ASSERT(aRange.Extent() > 0, "grid items cover at least one track");
nscoord pos, size;
aRange.ToPositionAndLength(mSizes, &pos, &size);
return size;
}
#ifdef DEBUG
void Dump() const
{
@ -1574,6 +1585,8 @@ struct nsGridContainerFrame::Tracks
// no baseline-aligned items in any track in that axis.
// There is one alignment value for each BaselineSharingGroup.
uint8_t mBaselineSubtreeAlign[2];
// True if track positions and sizes are final in this axis.
bool mCanResolveLineRangeSize;
};
/**
@ -1815,6 +1828,8 @@ private:
}
};
using GridReflowState = nsGridContainerFrame::GridReflowState;
/**
* The Grid implements grid item placement and the state of the grid -
* the size of the explicit/implicit grid, which cells are occupied etc.
@ -2199,6 +2214,9 @@ nsGridContainerFrame::GridReflowState::CalculateTrackSizes(
mCols.CalculateSizes(*this, mGridItems, mColFunctions,
aContentBox.ISize(mWM), &GridArea::mCols,
aConstraint);
mCols.AlignJustifyContent(mGridStyle, mWM, aContentBox);
// Column positions and sizes are now final.
mCols.mCanResolveLineRangeSize = true;
mRows.CalculateSizes(*this, mGridItems, mRowFunctions,
aContentBox.BSize(mWM), &GridArea::mRows,
@ -3394,7 +3412,7 @@ MeasuringReflow(nsIFrame* aChild,
*/
static nscoord
ContentContribution(const GridItemInfo& aGridItem,
const nsHTMLReflowState* aReflowState,
const GridReflowState& aState,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis,
@ -3408,8 +3426,19 @@ ContentContribution(const GridItemInfo& aGridItem,
if (size == NS_INTRINSIC_WIDTH_UNKNOWN) {
// We need to reflow the child to find its BSize contribution.
// XXX this will give mostly correct results for now (until bug 1174569).
LogicalSize availableSize(child->GetWritingMode(), INFINITE_ISIZE_COORD, NS_UNCONSTRAINEDSIZE);
size = ::MeasuringReflow(child, aReflowState, aRC, availableSize);
nscoord cbISize = INFINITE_ISIZE_COORD;
nscoord cbBSize = NS_UNCONSTRAINEDSIZE;
auto childWM = child->GetWritingMode();
if (aState.mCols.mCanResolveLineRangeSize) {
nscoord sz = aState.mCols.ResolveSize(aGridItem.mArea.mCols);
if (childWM.IsOrthogonalTo(aCBWM)) {
cbBSize = sz;
} else {
cbISize = sz;
}
}
LogicalSize availableSize(childWM, cbISize, cbBSize);
size = ::MeasuringReflow(child, aState.mReflowState, aRC, availableSize);
nsIFrame::IntrinsicISizeOffsetData offsets = child->IntrinsicBSizeOffsets();
size += offsets.hMargin;
size = nsLayoutUtils::AddPercents(aConstraint, size, offsets.hPctMargin);
@ -3424,33 +3453,33 @@ ContentContribution(const GridItemInfo& aGridItem,
}
static nscoord
MinContentContribution(const GridItemInfo& aGridItem,
const nsHTMLReflowState* aRS,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
MinContentContribution(const GridItemInfo& aGridItem,
const GridReflowState& aState,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
{
return ContentContribution(aGridItem, aRS, aRC, aCBWM, aAxis,
return ContentContribution(aGridItem, aState, aRC, aCBWM, aAxis,
nsLayoutUtils::MIN_ISIZE);
}
static nscoord
MaxContentContribution(const GridItemInfo& aGridItem,
const nsHTMLReflowState* aRS,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
MaxContentContribution(const GridItemInfo& aGridItem,
const GridReflowState& aState,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
{
return ContentContribution(aGridItem, aRS, aRC, aCBWM, aAxis,
return ContentContribution(aGridItem, aState, aRC, aCBWM, aAxis,
nsLayoutUtils::PREF_ISIZE);
}
static nscoord
MinSize(const GridItemInfo& aGridItem,
const nsHTMLReflowState* aRS,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
MinSize(const GridItemInfo& aGridItem,
const GridReflowState& aState,
nsRenderingContext* aRC,
WritingMode aCBWM,
LogicalAxis aAxis)
{
nsIFrame* child = aGridItem.mFrame;
PhysicalAxis axis(aCBWM.PhysicalAxis(aAxis));
@ -3477,7 +3506,7 @@ MinSize(const GridItemInfo& aGridItem,
child->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE)) {
// Now calculate the "content size" part and return whichever is smaller.
MOZ_ASSERT(unit != eStyleUnit_Enumerated || sz == NS_UNCONSTRAINEDSIZE);
sz = std::min(sz, ContentContribution(aGridItem, aRS, aRC, aCBWM, aAxis,
sz = std::min(sz, ContentContribution(aGridItem, aState, aRC, aCBWM, aAxis,
nsLayoutUtils::MIN_ISIZE,
nsLayoutUtils::MIN_INTRINSIC_ISIZE));
}
@ -3552,26 +3581,25 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSizeStep1(
// min sizing
TrackSize& sz = mSizes[aRange.mStart];
WritingMode wm = aState.mWM;
const nsHTMLReflowState* rs = aState.mReflowState;
nsRenderingContext* rc = &aState.mRenderingContext;
if (sz.mState & TrackSize::eAutoMinSizing) {
nscoord s = MinSize(aGridItem, rs, rc, wm, mAxis);
nscoord s = MinSize(aGridItem, aState, rc, wm, mAxis);
sz.mBase = std::max(sz.mBase, s);
} else if ((sz.mState & TrackSize::eMinContentMinSizing) ||
(aConstraint == nsLayoutUtils::MIN_ISIZE &&
(sz.mState & TrackSize::eFlexMinSizing))) {
nscoord s = MinContentContribution(aGridItem, rs, rc, wm, mAxis);
nscoord s = MinContentContribution(aGridItem, aState, rc, wm, mAxis);
minContentContribution.emplace(s);
sz.mBase = std::max(sz.mBase, minContentContribution.value());
} else if (sz.mState & TrackSize::eMaxContentMinSizing) {
nscoord s = MaxContentContribution(aGridItem, rs, rc, wm, mAxis);
nscoord s = MaxContentContribution(aGridItem, aState, rc, wm, mAxis);
maxContentContribution.emplace(s);
sz.mBase = std::max(sz.mBase, maxContentContribution.value());
}
// max sizing
if (sz.mState & TrackSize::eMinContentMaxSizing) {
if (minContentContribution.isNothing()) {
nscoord s = MinContentContribution(aGridItem, rs, rc, wm, mAxis);
nscoord s = MinContentContribution(aGridItem, aState, rc, wm, mAxis);
minContentContribution.emplace(s);
}
if (sz.mLimit == NS_UNCONSTRAINEDSIZE) {
@ -3582,7 +3610,7 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSizeStep1(
} else if (sz.mState & (TrackSize::eAutoMaxSizing |
TrackSize::eMaxContentMaxSizing)) {
if (maxContentContribution.isNothing()) {
nscoord s = MaxContentContribution(aGridItem, rs, rc, wm, mAxis);
nscoord s = MaxContentContribution(aGridItem, aState, rc, wm, mAxis);
maxContentContribution.emplace(s);
}
if (sz.mLimit == NS_UNCONSTRAINEDSIZE) {
@ -3924,18 +3952,18 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize(
stateBitsPerSpan[span] |= state;
nscoord minSize = 0;
if (state & (flexMin | TrackSize::eIntrinsicMinSizing)) { // for 2.1
minSize = MinSize(gridItem, aState.mReflowState, rc, wm, mAxis);
minSize = MinSize(gridItem, aState, rc, wm, mAxis);
}
nscoord minContent = 0;
if (state & (flexMin | TrackSize::eMinOrMaxContentMinSizing | // for 2.2
TrackSize::eIntrinsicMaxSizing)) { // for 2.5
minContent = MinContentContribution(gridItem, aState.mReflowState,
minContent = MinContentContribution(gridItem, aState,
rc, wm, mAxis);
}
nscoord maxContent = 0;
if (state & (TrackSize::eMaxContentMinSizing | // for 2.3
TrackSize::eAutoOrMaxContentMaxSizing)) { // for 2.6
maxContent = MaxContentContribution(gridItem, aState.mReflowState,
maxContent = MaxContentContribution(gridItem, aState,
rc, wm, mAxis);
}
step2Items.AppendElement(
@ -4189,7 +4217,6 @@ nsGridContainerFrame::Tracks::FindUsedFlexFraction(
}
WritingMode wm = aState.mWM;
nsRenderingContext* rc = &aState.mRenderingContext;
const nsHTMLReflowState* rs = aState.mReflowState;
GridItemCSSOrderIterator& iter = aState.mIter;
iter.Reset();
// ... the result of 'finding the size of an fr' for each item that spans
@ -4197,7 +4224,7 @@ nsGridContainerFrame::Tracks::FindUsedFlexFraction(
for (; !iter.AtEnd(); iter.Next()) {
const GridItemInfo& item = aGridItems[iter.GridItemIndex()];
if (item.mState[mAxis] & ItemState::eIsFlexing) {
nscoord spaceToFill = MaxContentContribution(item, rs, rc, wm, mAxis);
nscoord spaceToFill = MaxContentContribution(item, aState, rc, wm, mAxis);
if (spaceToFill <= 0) {
continue;
}
@ -4253,7 +4280,8 @@ nsGridContainerFrame::Tracks::StretchFlexibleTracks(
void
nsGridContainerFrame::Tracks::AlignJustifyContent(
const nsHTMLReflowState& aReflowState,
const nsStylePosition* aStyle,
WritingMode aWM,
const LogicalSize& aContainerSize)
{
if (mSizes.IsEmpty()) {
@ -4261,12 +4289,10 @@ nsGridContainerFrame::Tracks::AlignJustifyContent(
}
const bool isAlign = mAxis == eLogicalAxisBlock;
auto stylePos = aReflowState.mStylePosition;
auto valueAndFallback = isAlign ? stylePos->ComputedAlignContent() :
stylePos->ComputedJustifyContent();
WritingMode wm = aReflowState.GetWritingMode();
auto valueAndFallback = isAlign ? aStyle->ComputedAlignContent() :
aStyle->ComputedJustifyContent();
bool overflowSafe;
auto alignment = ::GetAlignJustifyValue(valueAndFallback, wm, isAlign,
auto alignment = ::GetAlignJustifyValue(valueAndFallback, aWM, isAlign,
&overflowSafe);
if (alignment == NS_STYLE_ALIGN_NORMAL) {
MOZ_ASSERT(valueAndFallback == NS_STYLE_ALIGN_NORMAL,
@ -4286,13 +4312,13 @@ nsGridContainerFrame::Tracks::AlignJustifyContent(
++numAutoTracks;
}
}
nscoord cbSize = isAlign ? aContainerSize.BSize(wm)
: aContainerSize.ISize(wm);
nscoord cbSize = isAlign ? aContainerSize.BSize(aWM)
: aContainerSize.ISize(aWM);
space = cbSize - trackSizeSum - SumOfGridGaps();
// Use the fallback value instead when applicable.
if (space < 0 ||
(alignment == NS_STYLE_ALIGN_SPACE_BETWEEN && mSizes.Length() == 1)) {
auto fallback = ::GetAlignJustifyFallbackIfAny(valueAndFallback, wm,
auto fallback = ::GetAlignJustifyFallbackIfAny(valueAndFallback, aWM,
isAlign, &overflowSafe);
if (fallback) {
alignment = fallback;
@ -5543,8 +5569,8 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
if (!prevInFlow) {
// Apply 'align/justify-content' to the grid.
gridReflowState.mCols.AlignJustifyContent(aReflowState, contentArea.Size(wm));
gridReflowState.mRows.AlignJustifyContent(aReflowState, contentArea.Size(wm));
// CalculateTrackSizes did the columns.
gridReflowState.mRows.AlignJustifyContent(stylePos, wm, contentArea.Size(wm));
}
bSize = ReflowChildren(gridReflowState, contentArea, aDesiredSize, aStatus);

View File

@ -107,6 +107,7 @@ public:
struct TrackSize;
struct GridItemInfo;
struct GridReflowState;
protected:
static const uint32_t kAutoLine;
// The maximum line number, in the zero-based translated grid.
@ -121,7 +122,6 @@ protected:
struct Grid;
struct GridArea;
class GridItemCSSOrderIterator;
struct GridReflowState;
class LineNameMap;
struct LineRange;
struct SharedGridData;

View File

@ -5518,9 +5518,7 @@ nsTextFrame::DrawSelectionDecorations(gfxContext* aContext,
params.context = aContext;
params.dirtyRect = aDirtyRect;
params.pt = aPt;
params.lineSize = Size(
aWidth, ComputeSelectionUnderlineHeight(aTextPaintStyle.PresContext(),
aFontMetrics, aSelectionType));
params.lineSize.width = aWidth;
params.ascent = aAscent;
params.offset = aDecoration == NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE ?
aFontMetrics.underlineOffset : aFontMetrics.maxAscent;
@ -5533,34 +5531,42 @@ nsTextFrame::DrawSelectionDecorations(gfxContext* aContext,
aFontMetrics);
float relativeSize;
int32_t index =
nsTextPaintStyle::GetUnderlineStyleIndexForSelectionType(aSelectionType);
bool weDefineSelectionUnderline =
aTextPaintStyle.GetSelectionUnderlineForPaint(index, &params.color,
&relativeSize, &params.style);
switch (aSelectionType) {
case SelectionType::eIMERawClause:
case SelectionType::eIMESelectedRawClause:
case SelectionType::eIMEConvertedClause:
case SelectionType::eIMESelectedClause: {
// IME decoration lines should not be drawn on the both ends, i.e., we
// need to cut both edges of the decoration lines. Because same style
// IME selections can adjoin, but the users need to be able to know
// where are the boundaries of the selections.
//
// X: underline
//
// IME selection #1 IME selection #2 IME selection #3
// | | |
// | XXXXXXXXXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXX
// +---------------------+----------------------+--------------------
// ^ ^ ^ ^ ^
// gap gap gap
params.pt.x += 1.0;
params.lineSize.width -= 2.0;
if (aRangeStyle.IsDefined()) {
case SelectionType::eIMESelectedClause:
case SelectionType::eSpellCheck: {
int32_t index = nsTextPaintStyle::
GetUnderlineStyleIndexForSelectionType(aSelectionType);
bool weDefineSelectionUnderline =
aTextPaintStyle.GetSelectionUnderlineForPaint(index, &params.color,
&relativeSize,
&params.style);
params.lineSize.height =
ComputeSelectionUnderlineHeight(aTextPaintStyle.PresContext(),
aFontMetrics, aSelectionType);
bool isIMEType = aSelectionType != SelectionType::eSpellCheck;
if (isIMEType) {
// IME decoration lines should not be drawn on the both ends, i.e., we
// need to cut both edges of the decoration lines. Because same style
// IME selections can adjoin, but the users need to be able to know
// where are the boundaries of the selections.
//
// X: underline
//
// IME selection #1 IME selection #2 IME selection #3
// | | |
// | XXXXXXXXXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXX
// +---------------------+----------------------+--------------------
// ^ ^ ^ ^ ^
// gap gap gap
params.pt.x += 1.0;
params.lineSize.width -= 2.0;
}
if (isIMEType && aRangeStyle.IsDefined()) {
// If IME defines the style, that should override our definition.
if (aRangeStyle.IsLineStyleDefined()) {
if (aRangeStyle.mLineStyle == TextRangeStyle::LINESTYLE_NONE) {
@ -5600,10 +5606,6 @@ nsTextFrame::DrawSelectionDecorations(gfxContext* aContext,
}
break;
}
case SelectionType::eSpellCheck:
if (!weDefineSelectionUnderline)
return;
break;
case SelectionType::eURLStrikeout: {
nscoord inflationMinFontSize =
nsLayoutUtils::InflationMinFontSizeFor(this);
@ -5613,6 +5615,9 @@ nsTextFrame::DrawSelectionDecorations(gfxContext* aContext,
GetFirstFontMetrics(GetFontGroupForFrame(this, inflation), aVertical);
relativeSize = 2.0f;
aTextPaintStyle.GetURLSecondaryColor(&params.color);
params.style = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
params.lineSize.height = metrics.strikeoutSize;
params.offset = metrics.strikeoutOffset + 0.5;
params.decoration = NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH;
break;
@ -7076,7 +7081,9 @@ nsTextFrame::CombineSelectionUnderlineRect(nsPresContext* aPresContext,
SelectionDetails *details = GetSelectionDetails();
for (SelectionDetails *sd = details; sd; sd = sd->mNext) {
if (sd->mStart == sd->mEnd ||
!(sd->mSelectionType & kRawSelectionTypesWithDecorations)) {
!(sd->mSelectionType & kRawSelectionTypesWithDecorations) ||
// URL strikeout does not use underline.
sd->mSelectionType == SelectionType::eURLStrikeout) {
continue;
}

View File

@ -1262,7 +1262,7 @@ inDOMView::AppendKidsToArray(nsIDOMNodeList* aKids,
}
}
aArray.AppendObject(kid);
aArray.AppendElement(kid.forget());
}
}
@ -1278,7 +1278,7 @@ inDOMView::AppendAttrsToArray(nsIDOMMozNamedAttrMap* aAttributes,
nsCOMPtr<nsIDOMAttr> attribute;
for (uint32_t i = 0; i < l; ++i) {
aAttributes->Item(i, getter_AddRefs(attribute));
aArray.AppendObject(attribute);
aArray.AppendElement(attribute.forget());
}
return NS_OK;
}

View File

@ -896,7 +896,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
}
nsChangeHint
nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
nsStyleContext::CalcStyleDifference(nsStyleContext* aNewContext,
nsChangeHint aParentHintsNotHandledForDescendants,
uint32_t* aEqualStructs,
uint32_t* aSamePointerStructs)
@ -914,7 +914,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
*aEqualStructs = 0;
nsChangeHint hint = NS_STYLE_HINT_NONE;
NS_ENSURE_TRUE(aOther, hint);
NS_ENSURE_TRUE(aNewContext, hint);
// We must always ensure that we populate the structs on the new style
// context that are filled in on the old context, so that if we get
// two style changes in succession, the second of which causes a real
@ -937,7 +937,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
// (Things like 'em' units are handled by the change hint produced
// by font-size changing, so we don't need to worry about them like
// we worry about 'inherit' values.)
bool compare = mSource != aOther->mSource;
bool compare = mSource != aNewContext->mSource;
DebugOnly<uint32_t> structsFound = 0;
@ -947,7 +947,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
const nsStyleVariables* thisVariables = PeekStyleVariables();
if (thisVariables) {
structsFound |= NS_STYLE_INHERIT_BIT(Variables);
const nsStyleVariables* otherVariables = aOther->StyleVariables();
const nsStyleVariables* otherVariables = aNewContext->StyleVariables();
if (thisVariables->mVariables == otherVariables->mVariables) {
*aEqualStructs |= NS_STYLE_INHERIT_BIT(Variables);
} else {
@ -964,7 +964,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
const nsStyle##struct_* this##struct_ = PeekStyle##struct_(); \
if (this##struct_) { \
structsFound |= NS_STYLE_INHERIT_BIT(struct_); \
const nsStyle##struct_* other##struct_ = aOther->Style##struct_(); \
const nsStyle##struct_* other##struct_ = aNewContext->Style##struct_(); \
nsChangeHint maxDifference = nsStyle##struct_::MaxDifference(); \
nsChangeHint differenceAlwaysHandledForDescendants = \
nsStyle##struct_::DifferenceAlwaysHandledForDescendants(); \
@ -1065,7 +1065,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
#define STYLE_STRUCT(name_, callback_) \
{ \
const nsStyle##name_* data = PeekStyle##name_(); \
if (!data || data == aOther->Style##name_()) { \
if (!data || data == aNewContext->Style##name_()) { \
*aSamePointerStructs |= NS_STYLE_INHERIT_BIT(name_); \
} \
}
@ -1073,7 +1073,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
#undef STYLE_STRUCT
// Note that we do not check whether this->RelevantLinkVisited() !=
// aOther->RelevantLinkVisited(); we don't need to since
// aNewContext->RelevantLinkVisited(); we don't need to since
// nsCSSFrameConstructor::DoContentStateChanged always adds
// nsChangeHint_RepaintFrame for NS_EVENT_STATE_VISITED changes (and
// needs to, since HasStateDependentStyle probably doesn't work right
@ -1089,7 +1089,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
// things that can depend on :visited) for the properties on which we
// call GetVisitedDependentColor.
nsStyleContext *thisVis = GetStyleIfVisited(),
*otherVis = aOther->GetStyleIfVisited();
*otherVis = aNewContext->GetStyleIfVisited();
if (!thisVis != !otherVis) {
// One style context has a style-if-visited and the other doesn't.
// Presume a difference.

View File

@ -376,7 +376,7 @@ public:
/**
* Compute the style changes needed during restyling when this style
* context is being replaced by aOther. (This is nonsymmetric since
* context is being replaced by aNewContext. (This is nonsymmetric since
* we optimize by skipping comparison for styles that have never been
* requested.)
*
@ -393,7 +393,7 @@ public:
* aEqualStructs must not be null. Into it will be stored a bitfield
* representing which structs were compared to be non-equal.
*/
nsChangeHint CalcStyleDifference(nsStyleContext* aOther,
nsChangeHint CalcStyleDifference(nsStyleContext* aNewContext,
nsChangeHint aParentHintsNotHandledForDescendants,
uint32_t* aEqualStructs,
uint32_t* aSamePointerStructs);

File diff suppressed because it is too large Load Diff

View File

@ -119,7 +119,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont
MOZ_COUNT_DTOR(nsStyleFont);
}
nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
nsChangeHint CalcDifference(const nsStyleFont& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_REFLOW |
nsChangeHint_NeutralChange;
@ -387,7 +387,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColor
MOZ_COUNT_DTOR(nsStyleColor);
}
nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
nsChangeHint CalcDifference(const nsStyleColor& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint_RepaintFrame;
}
@ -692,7 +692,7 @@ struct nsStyleImageLayers {
// Compute the change hint required by changes in just this layer.
// aPositionChangeHint indicates the hint for position change.
nsChangeHint CalcDifference(const Layer& aOther,
nsChangeHint CalcDifference(const Layer& aNewLayer,
nsChangeHint aPositionChangeHint) const;
// An equality operator that compares the images using URL-equality
@ -741,7 +741,7 @@ struct nsStyleImageLayers {
mLayers[i].UntrackImages(aContext);
}
nsChangeHint CalcDifference(const nsStyleImageLayers& aOther,
nsChangeHint CalcDifference(const nsStyleImageLayers& aNewLayers,
nsChangeHint aPositionChangeHint) const;
bool HasLayerWithImage() const;
@ -769,7 +769,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBackground {
}
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
nsChangeHint CalcDifference(const nsStyleBackground& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint_UpdateEffects |
nsChangeHint_RepaintFrame |
@ -825,7 +825,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleMargin
}
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
nsChangeHint CalcDifference(const nsStyleMargin& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint_NeedReflow |
nsChangeHint_ReflowChangesSizeOrPosition |
@ -872,7 +872,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePadding
}
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
nsChangeHint CalcDifference(const nsStylePadding& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_REFLOW & ~nsChangeHint_ClearDescendantIntrinsics;
}
@ -1074,7 +1074,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder
}
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
nsChangeHint CalcDifference(const nsStyleBorder& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_REFLOW |
nsChangeHint_UpdateOverflow |
@ -1308,7 +1308,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline
}
void RecalcData();
nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
nsChangeHint CalcDifference(const nsStyleOutline& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint_UpdateOverflow |
nsChangeHint_SchedulePaint |
@ -1420,7 +1420,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList
FreeByObjectID(mozilla::eArenaObjectID_nsStyleList, this);
}
nsChangeHint CalcDifference(const nsStyleList& aOther) const;
nsChangeHint CalcDifference(const nsStyleList& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_NeutralChange;
@ -1645,7 +1645,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition
FreeByObjectID(mozilla::eArenaObjectID_nsStylePosition, this);
}
nsChangeHint CalcDifference(const nsStylePosition& aOther,
nsChangeHint CalcDifference(const nsStylePosition& aNewData,
const nsStyleVisibility* aOldStyleVisibility) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_REFLOW |
@ -1940,7 +1940,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset
mTextDecorationStyle |= BORDER_COLOR_FOREGROUND;
}
nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
nsChangeHint CalcDifference(const nsStyleTextReset& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint(
NS_STYLE_HINT_REFLOW |
@ -1981,7 +1981,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText
FreeByObjectID(mozilla::eArenaObjectID_nsStyleText, this);
}
nsChangeHint CalcDifference(const nsStyleText& aOther) const;
nsChangeHint CalcDifference(const nsStyleText& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_UpdateSubtreeOverflow |
@ -2200,7 +2200,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility
FreeByObjectID(mozilla::eArenaObjectID_nsStyleVisibility, this);
}
nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
nsChangeHint CalcDifference(const nsStyleVisibility& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_NeutralChange;
@ -2481,7 +2481,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
FreeByObjectID(mozilla::eArenaObjectID_nsStyleDisplay, this);
}
nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
nsChangeHint CalcDifference(const nsStyleDisplay& aNewData) const;
static nsChangeHint MaxDifference() {
// All the parts of FRAMECHANGE are present in CalcDifference.
return nsChangeHint(NS_STYLE_HINT_FRAMECHANGE |
@ -2753,7 +2753,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTable
FreeByObjectID(mozilla::eArenaObjectID_nsStyleTable, this);
}
nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
nsChangeHint CalcDifference(const nsStyleTable& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
@ -2786,7 +2786,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTableBorder
FreeByObjectID(mozilla::eArenaObjectID_nsStyleTableBorder, this);
}
nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
nsChangeHint CalcDifference(const nsStyleTableBorder& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
@ -2882,7 +2882,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleContent
}
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
nsChangeHint CalcDifference(const nsStyleContent& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
@ -2997,7 +2997,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset
FreeByObjectID(mozilla::eArenaObjectID_nsStyleUIReset, this);
}
nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
nsChangeHint CalcDifference(const nsStyleUIReset& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
@ -3063,7 +3063,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUserInterface
FreeByObjectID(mozilla::eArenaObjectID_nsStyleUserInterface, this);
}
nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
nsChangeHint CalcDifference(const nsStyleUserInterface& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_UpdateCursor |
@ -3114,7 +3114,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleXUL
FreeByObjectID(mozilla::eArenaObjectID_nsStyleXUL, this);
}
nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
nsChangeHint CalcDifference(const nsStyleXUL& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
@ -3152,7 +3152,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn
FreeByObjectID(mozilla::eArenaObjectID_nsStyleColumn, this);
}
nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
nsChangeHint CalcDifference(const nsStyleColumn& aNewData) const;
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_NeutralChange;
@ -3249,7 +3249,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG
FreeByObjectID(mozilla::eArenaObjectID_nsStyleSVG, this);
}
nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
nsChangeHint CalcDifference(const nsStyleSVG& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint_UpdateEffects |
nsChangeHint_NeedReflow |
@ -3577,7 +3577,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVGReset
}
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
nsChangeHint CalcDifference(const nsStyleSVGReset& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint_UpdateEffects |
nsChangeHint_UpdateOverflow |
@ -3632,7 +3632,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVariables
FreeByObjectID(mozilla::eArenaObjectID_nsStyleVariables, this);
}
nsChangeHint CalcDifference(const nsStyleVariables& aOther) const;
nsChangeHint CalcDifference(const nsStyleVariables& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint(0);
}
@ -3662,7 +3662,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects
FreeByObjectID(mozilla::eArenaObjectID_nsStyleEffects, this);
}
nsChangeHint CalcDifference(const nsStyleEffects& aOther) const;
nsChangeHint CalcDifference(const nsStyleEffects& aNewData) const;
static nsChangeHint MaxDifference() {
return nsChangeHint_AllReflowHints |
nsChangeHint_UpdateOverflow |

View File

@ -5063,7 +5063,8 @@ Version 1.6.15beta04 [November 4, 2014]
Version 1.6.15beta05 [November 5, 2014]
Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
example.c, pngtest.c, and applications in the contrib directory.
Avoid out-of-bounds memory access in png_user_version_check().
Fixed an out-of-range read in png_user_version_check() (Bug report from
Qixue Xiao, CVE-2015-8540).
Simplified and future-proofed png_user_version_check().
Fixed GCC unsigned int->float warnings. Various versions of GCC
seem to generate warnings when an unsigned value is implicitly
@ -5484,6 +5485,117 @@ Version 1.6.21rc02 [January 7, 2016]
Version 1.6.21 [January 15, 2016]
Worked around a false-positive Coverity issue in pngvalid.c.
Version 1.6.22beta01 [January 23, 2016]
Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate
"tmpfile()" implementation in contrib/libtests/pngstest.c
Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io()
if there is no stdio.h support.
Added a png_image_write_to_memory() API and a number of assist macros
to allow an application that uses the simplified API write to bypass
stdio and write directly to memory.
Added some warnings (png.h) and some check code to detect *possible*
overflow in the ROW_STRIDE and simplified image SIZE macros. This
disallows image width/height/format that *might* overflow. This is
a quiet API change that limits in-memory image size (uncompressed) to
less than 4GByte and image row size (stride) to less than 2GByte.
Revised workaround for false-positive Coverity issue in pngvalid.c.
Version 1.6.22beta02 [February 8, 2016]
Only use exit(77) in configure builds.
Corrected error in PNG_IMAGE_PNG_SIZE_MAX. This new macro underreported
the palette size because it failed to take into account that the memory
palette has to be expanded to full RGB when it is written to PNG.
Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in
and test.cmake.in (Roger Leigh).
Relaxed limit checks on gamma values in pngrtran.c. As suggested in
the comments gamma values outside the range currently permitted
by png_set_alpha_mode are useful for HDR data encoding. These values
are already permitted by png_set_gamma so it is reasonable caution to
extend the png_set_alpha_mode range as HDR imaging systems are starting
to emerge.
Version 1.6.22beta03 [March 9, 2016]
Added a common-law trademark notice and export control information
to the LICENSE file, png.h, and the man page.
Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
were accidentally removed from libpng-1.6.17.
Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
(Robert C. Seacord).
Removed dubious "#if INT_MAX" test from png.h that was added to
libpng-1.6.19beta02 (John Bowler).
Add ${INCLUDES} in scripts/genout.cmake.in (Bug report by Nixon Kwok).
Updated LICENSE to say files in the contrib directory are not
necessarily under the libpng license, and that some makefiles have
other copyright owners.
Added INTEL-SSE2 support (Mike Klein and Matt Sarett, Google, Inc.).
Made contrib/libtests/timepng more robust. The code no longer gives
up/fails on invalid PNG data, it just skips it (with error messages).
The code no longer fails on PNG files with data beyond IEND. Options
exist to use png_read_png (reading the whole image, not by row) and, in
that case, to apply any of the supported transforms. This makes for
more realistic testing; the decoded data actually gets used in a
meaningful fashion (John Bowler).
Fixed some misleading indentation (Krishnaraj Bhat).
Version 1.6.22beta04 [April 5, 2016]
Force GCC compilation to C89 if needed (Dagobert Michelsen).
SSE filter speed improvements for bpp=3:
memcpy-free implementations of load3() / store3().
call load3() only when needed at the end of a scanline.
Version 1.6.22beta05 [April 27, 2016]
Added PNG_FAST_FILTERS macro (defined as
PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP).
Various fixes for contrib/libtests/timepng.c
Moved INTEL-SSE code from pngpriv.h into contrib/intel/intel_sse.patch.
Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
(Bug report by Y.Ohashik).
Version 1.6.22beta06 [May 5, 2016]
Rebased contrib/intel_sse.patch.
Quieted two Coverity issues in contrib/libtests/timepng.c.
Fixed issues with scripts/genout.cmake.in (David Capello, Nixon Kwok):
Added support to use multiple directories in ZLIBINCDIR variable,
Fixed CMAKE_C_FLAGS with multiple values when genout is compiled on MSVC,
Fixed pnglibconf.c compilation on OS X including the sysroot path.
Version 1.6.22rc01 [May 14, 2016]
No changes.
Version 1.6.22rc02 [May 16, 2016]
Removed contrib/timepng from default build; it does not build on platforms
that don't supply clock_gettime().
Version 1.6.22rc03 [May 17, 2016]
Restored contrib/timepng to default build but check for the presence
of clock_gettime() in configure.ac and Makefile.am.
Version 1.6.22 [May 26, 2016]
No changes.
Version 1.6.23beta01 [May 29, 2016]
Stop a potential memory leak in png_set_tRNS() (Bug report by Ted Ying).
Fixed the progressive reader to handle empty first IDAT chunk properly
(patch by Timothy Nikkel). This bug was introduced in libpng-1.6.0 and
only affected the libpng16 branch.
Added tests in pngvalid.c to check zero-length IDAT chunks in various
positions. Fixed the sequential reader to handle these more robustly
(John Bowler).
Version 1.6.23rc01 [June 2, 2016]
Corrected progressive read input buffer in pngvalid.c. The previous version
the code invariably passed just one byte at a time to libpng. The intent
was to pass a random number of bytes in the range 0..511.
Moved sse2 prototype from pngpriv.h to contrib/intel/intel_sse.patch.
Added missing ")" in pngerror.c (Matt Sarrett).
Version 1.6.23rc02 [June 4, 2016]
Fixed undefined behavior in png_push_save_buffer(). Do not call
memcpy() with a null source, even if count is zero (Leon Scroggins III).
Version 1.6.23 [June 9, 2016]
Fixed bad link to RFC2083 in png.5 (Nikola Forro).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@ -14,13 +14,13 @@ obtain one at http://mozilla.org/MPL/2.0/.
This modified version of libpng code adds animated PNG support and is
released under the libpng license described below. The modifications are
Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2015 Max Stepin,
Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2016 Max Stepin,
and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
surrounding them in the modified libpng source files.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
@ -42,6 +42,10 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
@ -65,6 +69,9 @@ Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -105,18 +112,29 @@ appreciated.
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
TRADEMARK:
printf("%s", png_get_copyright(NULL));
The name "libpng" has not been registered by the Copyright owner
as a trademark in any jurisdiction. However, because libpng has
been distributed and maintained world-wide, continually since 1995,
the Copyright owner claims "common-law trademark protection" in any
jurisdiction where common-law trademark is recognized.
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
OSI CERTIFICATION:
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
EXPORT CONTROL:
The Copyright owner believes that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because
it is open source, publicly available software, that does not contain
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
734.7(b).
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
January 15, 2016
June 9, 2016

View File

@ -1,6 +1,8 @@
Changes made to pristine libpng source by mozilla.org developers.
2016/06/09 -- Synced with libpng-1.6.23 (bug #1275901).
2016/01/16 -- Synced with libpng-1.6.21 (bug #1230757).
2015/11/12 -- Synced with libpng-1.6.19 (bug #1224244).

View File

@ -1,4 +1,4 @@
README for libpng version 1.6.21 - January 15, 2016 (shared library 16.0)
README for libpng version 1.6.23 - June 9, 2016 (shared library 16.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.

View File

@ -8,18 +8,18 @@ Index: LICENSE
+This modified version of libpng code adds animated PNG support and is
+released under the libpng license described below. The modifications are
+Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2015 Max Stepin,
+Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2016 Max Stepin,
+and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
+surrounding them in the modified libpng source files.
+
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
Index: pngread.c
===================================================================
--- pngread.c
+++ pngread.c
@@ -158,6 +158,9 @@
@@ -161,6 +161,9 @@
else if (chunk_name == png_IDAT)
{
@ -29,7 +29,7 @@ Index: pngread.c
png_ptr->idat_size = length;
break;
}
@@ -247,6 +250,17 @@
@@ -250,6 +253,17 @@
png_handle_iTXt(png_ptr, info_ptr, length);
#endif
@ -47,7 +47,7 @@ Index: pngread.c
else
png_handle_unknown(png_ptr, info_ptr, length,
PNG_HANDLE_CHUNK_AS_DEFAULT);
@@ -254,6 +268,72 @@
@@ -257,6 +271,72 @@
}
#endif /* SEQUENTIAL_READ */
@ -299,8 +299,8 @@ Index: png.c
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
- "libpng version 1.6.21 - January 15, 2016" PNG_STRING_NEWLINE \
+ "libpng version 1.6.21+apng - January 15, 2016" PNG_STRING_NEWLINE \
- "libpng version 1.6.23 - June 9, 2016" PNG_STRING_NEWLINE \
+ "libpng version 1.6.23+apng - June 9, 2016" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
@ -308,16 +308,16 @@ Index: png.c
- PNG_STRING_NEWLINE;
+ PNG_STRING_NEWLINE \
+ "Portions Copyright (c) 2006-2007 Andrew Smith" PNG_STRING_NEWLINE \
+ "Portions Copyright (c) 2008-2015 Max Stepin" PNG_STRING_NEWLINE ;
+ "Portions Copyright (c) 2008-2016 Max Stepin" PNG_STRING_NEWLINE ;
# else
- return "libpng version 1.6.21 - January 15, 2016\
+ return "libpng version 1.6.21+apng - January 15, 2016\
- return "libpng version 1.6.23 - June 9, 2016\
+ return "libpng version 1.6.23+apng - June 9, 2016\
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
- Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
+ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\
+ Portions Copyright (c) 2006-2007 Andrew Smith\
+ Portions Copyright (c) 2008-2015 Max Stepin";
+ Portions Copyright (c) 2008-2016 Max Stepin";
# endif
#endif
}
@ -331,26 +331,26 @@ Index: png.h
*
+ * This modified version of libpng code adds animated PNG support and is
+ * released under the libpng license described below. The modifications are
+ * Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2015 Max Stepin,
+ * Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2016 Max Stepin,
+ * and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
+ * surrounding them in the modified libpng source files.
+ *
* This code is released under the libpng license.
*
* libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
@@ -282,9 +288,9 @@
* Some files in the "contrib" directory and some configure-generated
@@ -313,9 +319,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.21"
+#define PNG_LIBPNG_VER_STRING "1.6.21+apng"
-#define PNG_LIBPNG_VER_STRING "1.6.23"
+#define PNG_LIBPNG_VER_STRING "1.6.23+apng"
#define PNG_HEADER_VERSION_STRING \
- " libpng version 1.6.21 - January 15, 2016\n"
+ " libpng version 1.6.21+apng - January 15, 2016\n"
- " libpng version 1.6.23 - June 9, 2016\n"
+ " libpng version 1.6.23+apng - June 9, 2016\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -335,6 +341,10 @@
@@ -366,6 +372,10 @@
# include "pnglibconf.h"
#endif
@ -361,7 +361,7 @@ Index: png.h
#ifndef PNG_VERSION_INFO_ONLY
/* Machine specific configuration. */
# include "pngconf.h"
@@ -430,6 +440,17 @@
@@ -461,6 +471,17 @@
* See pngconf.h for base types that vary by machine/system
*/
@ -379,10 +379,10 @@ Index: png.h
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
@@ -752,6 +773,10 @@
#if INT_MAX >= 0x8000 /* else this might break */
#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
#endif
@@ -781,6 +802,10 @@
#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */
#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
+#ifdef PNG_APNG_SUPPORTED
+#define PNG_INFO_acTL 0x10000
+#define PNG_INFO_fcTL 0x20000
@ -390,7 +390,7 @@ Index: png.h
/* This is used for the transformation routines, as some of them
* change these values for the row. It also should enable using
@@ -789,6 +814,10 @@
@@ -818,6 +843,10 @@
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
@ -401,7 +401,7 @@ Index: png.h
/* The following callback receives png_uint_32 row_number, int pass for the
* png_bytep data of the row. When transforming an interlaced image the
@@ -3110,6 +3139,75 @@
@@ -3237,6 +3266,75 @@
* END OF HARDWARE AND SOFTWARE OPTIONS
******************************************************************************/
@ -477,14 +477,14 @@ Index: png.h
/* Maintainer: Put new public prototypes here ^, in libpng.3, in project
* defs, and in scripts/symbols.def.
*/
@@ -3118,7 +3216,11 @@
@@ -3245,7 +3343,11 @@
* one to use is one more than this.)
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
+#ifdef PNG_APNG_SUPPORTED
+ PNG_EXPORT_LAST_ORDINAL(264);
+ PNG_EXPORT_LAST_ORDINAL(265);
+#else
PNG_EXPORT_LAST_ORDINAL(244);
PNG_EXPORT_LAST_ORDINAL(245);
+#endif /* APNG */
#endif
@ -653,9 +653,9 @@ Index: pngwrite.c
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
if (png_ptr->num_palette_max > png_ptr->num_palette)
png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
@@ -2227,4 +2236,42 @@
@@ -2380,4 +2389,42 @@
}
# endif /* STDIO */
#endif /* SIMPLIFIED_WRITE_STDIO */
#endif /* SIMPLIFIED_WRITE */
+
+#ifdef PNG_WRITE_APNG_SUPPORTED
@ -790,7 +790,7 @@ Index: pngpread.c
if (chunk_name == png_IDAT)
{
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
@@ -258,6 +341,9 @@
@@ -260,6 +343,9 @@
else if (chunk_name == png_IDAT)
{
@ -800,7 +800,7 @@ Index: pngpread.c
png_ptr->idat_size = png_ptr->push_length;
png_ptr->process_mode = PNG_READ_IDAT_MODE;
png_push_have_info(png_ptr, info_ptr);
@@ -404,6 +490,20 @@
@@ -406,6 +492,20 @@
}
#endif
@ -821,7 +821,7 @@ Index: pngpread.c
else
{
PNG_PUSH_SAVE_BUFFER_IF_FULL
@@ -533,7 +633,11 @@
@@ -538,7 +638,11 @@
png_byte chunk_tag[4];
/* TODO: this code can be commoned up with the same code in push_read */
@ -833,7 +833,7 @@ Index: pngpread.c
png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
@@ -541,17 +645,60 @@
@@ -546,17 +650,60 @@
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
@ -894,7 +894,7 @@ Index: pngpread.c
}
if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
@@ -625,6 +772,16 @@
@@ -630,6 +777,16 @@
if (!(buffer_length > 0) || buffer == NULL)
png_error(png_ptr, "No IDAT data (internal error)");
@ -911,7 +911,7 @@ Index: pngpread.c
/* This routine must process all the data it has been given
* before returning, calling the row callback as required to
* handle the uncompressed results.
@@ -1074,6 +1231,18 @@
@@ -1079,6 +1236,18 @@
png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
}
@ -946,7 +946,7 @@ Index: pngset.c
}
#ifdef PNG_oFFs_SUPPORTED
@@ -1094,6 +1099,146 @@
@@ -1096,6 +1101,146 @@
}
#endif /* sPLT */
@ -1603,27 +1603,27 @@ Index: scripts/symbols.def
===================================================================
--- scripts/symbols.def
+++ scripts/symbols.def
@@ -249,3 +249,23 @@
png_set_check_for_invalid_index @242
@@ -250,3 +250,23 @@
png_get_palette_max @243
png_set_option @244
+ png_get_acTL @245
+ png_set_acTL @246
+ png_get_num_frames @247
+ png_get_num_plays @248
+ png_get_next_frame_fcTL @249
+ png_set_next_frame_fcTL @250
+ png_get_next_frame_width @251
+ png_get_next_frame_height @252
+ png_get_next_frame_x_offset @253
+ png_get_next_frame_y_offset @254
+ png_get_next_frame_delay_num @255
+ png_get_next_frame_delay_den @256
+ png_get_next_frame_dispose_op @257
+ png_get_next_frame_blend_op @258
+ png_get_first_frame_is_hidden @259
+ png_set_first_frame_is_hidden @260
+ png_read_frame_head @261
+ png_set_progressive_frame_fn @262
+ png_write_frame_head @263
+ png_write_frame_tail @264
png_image_write_to_memory @245
+ png_get_acTL @246
+ png_set_acTL @247
+ png_get_num_frames @248
+ png_get_num_plays @249
+ png_get_next_frame_fcTL @250
+ png_set_next_frame_fcTL @251
+ png_get_next_frame_width @252
+ png_get_next_frame_height @253
+ png_get_next_frame_x_offset @254
+ png_get_next_frame_y_offset @255
+ png_get_next_frame_delay_num @256
+ png_get_next_frame_delay_den @257
+ png_get_next_frame_dispose_op @258
+ png_get_next_frame_blend_op @259
+ png_get_first_frame_is_hidden @260
+ png_set_first_frame_is_hidden @261
+ png_read_frame_head @262
+ png_set_progressive_frame_fn @263
+ png_write_frame_head @264
+ png_write_frame_tail @265

View File

@ -1,9 +1,9 @@
/* arm_init.c - NEON optimised filter functions
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.16 [December 22, 2014]
* Last changed in libpng 1.6.22 [May 24, 2016]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -66,6 +66,7 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
* as documented in png.h
*/
png_debug(1, "in png_init_filter_functions_neon");
#ifdef PNG_ARM_NEON_API_SUPPORTED
switch ((pp->options >> PNG_ARM_NEON) & 3)
{

View File

@ -1,11 +1,11 @@
/* filter_neon_intrinsics.c - NEON optimised filter functions
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
* Written by James Yu <james.yu at linaro.org>, October 2013.
* Based on filter_neon.S, written by Mans Rullgard, 2011.
*
* Last changed in libpng 1.6.16 [December 22, 2014]
* Last changed in libpng 1.6.22 [May 24, 2016]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -47,6 +47,8 @@ png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row,
png_bytep rp_stop = row + row_info->rowbytes;
png_const_bytep pp = prev_row;
png_debug(1, "in png_read_filter_row_up_neon");
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint8x16_t qrp, qpp;
@ -72,6 +74,8 @@ png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_sub3_neon");
for (; rp < rp_stop;)
{
uint8x8_t vtmp1, vtmp2;
@ -113,6 +117,8 @@ png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_sub4_neon");
for (; rp < rp_stop; rp += 16)
{
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
@ -148,6 +154,8 @@ png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
png_debug(1, "in png_read_filter_row_avg3_neon");
for (; rp < rp_stop; pp += 12)
{
uint8x8_t vtmp1, vtmp2, vtmp3;
@ -207,6 +215,8 @@ png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_avg4_neon");
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint32x2x4_t vtmp;
@ -280,6 +290,8 @@ png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row,
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
png_debug(1, "in png_read_filter_row_paeth3_neon");
for (; rp < rp_stop; pp += 12)
{
uint8x8x2_t *vppt;
@ -339,6 +351,8 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_paeth4_neon");
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint32x2x4_t vtmp;

View File

@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.21 - January 15, 2016
libpng version 1.6.23 - June 9, 2016
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2016 Glenn Randers-Pehrson
@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.6.21 - January 15, 2016
libpng versions 0.97, January 1998, through 1.6.23 - June 9, 2016
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2016 Glenn Randers-Pehrson
@ -2842,7 +2842,7 @@ filter types.
PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
PNG_ALL_FILTERS);
PNG_ALL_FILTERS | PNG_FAST_FILTERS);
If an application wants to start and stop using particular filters during
compression, it should start out with all of the filters (to ensure that
@ -4103,6 +4103,13 @@ be written:
Write the image to the named file.
int png_image_write_to_memory (png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes,
int convert_to_8_bit, const void *buffer, ptrdiff_t row_stride,
const void *colormap));
Write the image to memory.
int png_image_write_to_stdio(png_imagep image, FILE *file,
int convert_to_8_bit, const void *buffer,
png_int_32 row_stride, const void *colormap)
@ -4380,8 +4387,9 @@ for any images with bit depths less than 8 bits/pixel.
The 'method' parameter sets the main filtering method, which is
currently only '0' in the PNG 1.2 specification. The 'filters'
parameter sets which filter(s), if any, should be used for each
scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
to turn filtering on and off, respectively.
scanline. Possible values are PNG_ALL_FILTERS, PNG_NO_FILTERS,
or PNG_FAST_FILTERS to turn filtering on and off, or to turn on
just the fast-decoding subset of filters, respectively.
Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
@ -4395,12 +4403,19 @@ means the first row must always be adaptively filtered, because libpng
currently does not allocate the filter buffers until png_write_row()
is called for the first time.)
filters = PNG_FILTER_NONE | PNG_FILTER_SUB
filters = PNG_NO_FILTERS;
filters = PNG_ALL_FILTERS;
filters = PNG_FAST_FILTERS;
or
filters = PNG_FILTER_NONE | PNG_FILTER_SUB |
PNG_FILTER_UP | PNG_FILTER_AVG |
PNG_FILTER_PAETH | PNG_ALL_FILTERS;
PNG_FILTER_PAETH;
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
filters);
The second parameter can also be
PNG_INTRAPIXEL_DIFFERENCING if you are
writing a PNG to be embedded in a MNG
@ -4775,7 +4790,8 @@ There are no substantial API changes between the non-deprecated parts of
the 1.4.5 API and the 1.5.0 API; however, the ability to directly access
members of the main libpng control structures, png_struct and png_info,
deprecated in earlier versions of libpng, has been completely removed from
libpng 1.5.
libpng 1.5, and new private "pngstruct.h", "pnginfo.h", and "pngdebug.h"
header files were created.
We no longer include zlib.h in png.h. The include statement has been moved
to pngstruct.h, where it is not accessible by applications. Applications that
@ -5015,6 +5031,7 @@ includes the following:
png_image_free()
write functions
png_image_write_to_file()
png_image_write_to_memory()
png_image_write_to_stdio()
Starting with libpng-1.6.0, you can configure libpng to prefix all exported
@ -5328,7 +5345,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.6.21 are Y2K compliant. It is my belief that earlier
upward through 1.6.23 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer

View File

@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_21 Your_png_h_is_not_version_1_6_21;
typedef png_libpng_version_1_6_23 Your_png_h_is_not_version_1_6_23;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@ -775,21 +775,21 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.6.21+apng - January 15, 2016" PNG_STRING_NEWLINE \
"libpng version 1.6.23+apng - June 9, 2016" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE \
"Portions Copyright (c) 2006-2007 Andrew Smith" PNG_STRING_NEWLINE \
"Portions Copyright (c) 2008-2015 Max Stepin" PNG_STRING_NEWLINE ;
"Portions Copyright (c) 2008-2016 Max Stepin" PNG_STRING_NEWLINE ;
# else
return "libpng version 1.6.21+apng - January 15, 2016\
return "libpng version 1.6.23+apng - June 9, 2016\
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\
Portions Copyright (c) 2006-2007 Andrew Smith\
Portions Copyright (c) 2008-2015 Max Stepin";
Portions Copyright (c) 2008-2016 Max Stepin";
# endif
#endif
}

View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.6.21, January 15, 2016
* libpng version 1.6.23, June 9, 2016
*
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -12,7 +12,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.21, January 15, 2016:
* libpng versions 0.97, January 1998, through 1.6.23, June 9, 2016:
* Glenn Randers-Pehrson.
* See also "Contributing Authors", below.
*/
@ -25,13 +25,17 @@
*
* This modified version of libpng code adds animated PNG support and is
* released under the libpng license described below. The modifications are
* Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2015 Max Stepin,
* Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2016 Max Stepin,
* and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
* surrounding them in the modified libpng source files.
*
* This code is released under the libpng license.
*
* libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
* Some files in the "contrib" directory and some configure-generated
* files that are distributed with libpng have other copyright owners and
* are released under other open source licenses.
*
* libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
* derived from libpng-1.0.6, and are distributed according to the same
* disclaimer and license as libpng-1.0.6 with the following individuals
@ -53,6 +57,10 @@
* risk of satisfactory quality, performance, accuracy, and effort is with
* the user.
*
* Some files in the "contrib" directory have other copyright owners and
* are released under other open source licenses.
*
*
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
* libpng-0.96, and are distributed according to the same disclaimer and
@ -63,6 +71,9 @@
* Glenn Randers-Pehrson
* Willem van Schaik
*
* Some files in the "scripts" directory have different copyright owners
* but are also released under this license.
*
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
* and are distributed according to the same disclaimer and license as
@ -76,6 +87,9 @@
* Greg Roelofs
* Tom Tanner
*
* Some files in the "scripts" directory have other copyright owners
* but are released under this license.
*
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
*
@ -115,6 +129,29 @@
* appreciated.
*
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
*
* TRADEMARK:
*
* The name "libpng" has not been registered by the Copyright owner
* as a trademark in any jurisdiction. However, because libpng has
* been distributed and maintained world-wide, continually since 1995,
* the Copyright owner claims "common-law trademark protection" in any
* jurisdiction where common-law trademark is recognized.
*
* OSI CERTIFICATION:
*
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
* a certification mark of the Open Source Initiative. OSI has not addressed
* the additional disclaimers inserted at version 1.0.7.
*
* EXPORT CONTROL:
*
* The Copyright owner believes that the Export Control Classification
* Number (ECCN) for libpng is EAR99, which means not subject to export
* controls or International Traffic in Arms Regulations (ITAR) because
* it is open source, publicly available software, that does not contain
* any encryption software. See the EAR, paragraphs 734.3(b)(3) and
* 734.7(b).
*/
/*
@ -127,12 +164,6 @@
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
*/
/*
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
* a certification mark of the Open Source Initiative. OSI has not addressed
* the additional disclaimers inserted at version 1.0.7.
*/
/*
* The contributing authors would like to thank all those who helped
* with testing, bug fixes, and patience. This wouldn't have been
@ -188,11 +219,11 @@
* ...
* 1.0.19 10 10019 10.so.0.19[.0]
* ...
* 1.2.53 13 10253 12.so.0.53[.0]
* 1.2.56 13 10256 12.so.0.56[.0]
* ...
* 1.5.23 15 10523 15.so.15.23[.0]
* 1.5.27 15 10527 15.so.15.27[.0]
* ...
* 1.6.21 16 10621 16.so.16.21[.0]
* 1.6.23 16 10623 16.so.16.23[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -220,13 +251,13 @@
* Y2K compliance in libpng:
* =========================
*
* January 15, 2016
* June 9, 2016
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.6.21 are Y2K compliant. It is my belief that
* upward through 1.6.23 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@ -288,9 +319,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.21+apng"
#define PNG_LIBPNG_VER_STRING "1.6.23+apng"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.21+apng - January 15, 2016\n"
" libpng version 1.6.23+apng - June 9, 2016\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@ -298,7 +329,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 21
#define PNG_LIBPNG_VER_RELEASE 23
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
@ -329,7 +360,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
#define PNG_LIBPNG_VER 10621 /* 1.6.21 */
#define PNG_LIBPNG_VER 10623 /* 1.6.23 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@ -454,7 +485,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef char* png_libpng_version_1_6_21;
typedef char* png_libpng_version_1_6_23;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@ -755,24 +786,22 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
* data in the info_struct to be written into the output file. The values
* of the PNG_INFO_<chunk> defines should NOT be changed.
*/
#define PNG_INFO_gAMA 0x0001
#define PNG_INFO_sBIT 0x0002
#define PNG_INFO_cHRM 0x0004
#define PNG_INFO_PLTE 0x0008
#define PNG_INFO_tRNS 0x0010
#define PNG_INFO_bKGD 0x0020
#define PNG_INFO_hIST 0x0040
#define PNG_INFO_pHYs 0x0080
#define PNG_INFO_oFFs 0x0100
#define PNG_INFO_tIME 0x0200
#define PNG_INFO_pCAL 0x0400
#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
#if INT_MAX >= 0x8000 /* else this might break */
#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
#endif
#define PNG_INFO_gAMA 0x0001U
#define PNG_INFO_sBIT 0x0002U
#define PNG_INFO_cHRM 0x0004U
#define PNG_INFO_PLTE 0x0008U
#define PNG_INFO_tRNS 0x0010U
#define PNG_INFO_bKGD 0x0020U
#define PNG_INFO_hIST 0x0040U
#define PNG_INFO_pHYs 0x0080U
#define PNG_INFO_oFFs 0x0100U
#define PNG_INFO_tIME 0x0200U
#define PNG_INFO_pCAL 0x0400U
#define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */
#define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */
#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */
#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
#ifdef PNG_APNG_SUPPORTED
#define PNG_INFO_acTL 0x10000
#define PNG_INFO_fcTL 0x20000
@ -1351,7 +1380,7 @@ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
/* Strip the second byte of information from a 16-bit depth file. */
PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
#endif
@ -1502,8 +1531,8 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
#define PNG_FILTER_UP 0x20
#define PNG_FILTER_AVG 0x40
#define PNG_FILTER_PAETH 0x80
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
PNG_FILTER_AVG | PNG_FILTER_PAETH)
#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP)
#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH)
/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
* These defines should NOT be changed.
@ -1780,21 +1809,21 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
#define PNG_SET_WILL_FREE_DATA 1
#define PNG_USER_WILL_FREE_DATA 2
/* Flags for png_ptr->free_me and info_ptr->free_me */
#define PNG_FREE_HIST 0x0008
#define PNG_FREE_ICCP 0x0010
#define PNG_FREE_SPLT 0x0020
#define PNG_FREE_ROWS 0x0040
#define PNG_FREE_PCAL 0x0080
#define PNG_FREE_SCAL 0x0100
#define PNG_FREE_HIST 0x0008U
#define PNG_FREE_ICCP 0x0010U
#define PNG_FREE_SPLT 0x0020U
#define PNG_FREE_ROWS 0x0040U
#define PNG_FREE_PCAL 0x0080U
#define PNG_FREE_SCAL 0x0100U
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_FREE_UNKN 0x0200
# define PNG_FREE_UNKN 0x0200U
#endif
/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */
#define PNG_FREE_PLTE 0x1000
#define PNG_FREE_TRNS 0x2000
#define PNG_FREE_TEXT 0x4000
#define PNG_FREE_ALL 0x7fff
#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
/* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */
#define PNG_FREE_PLTE 0x1000U
#define PNG_FREE_TRNS 0x2000U
#define PNG_FREE_TEXT 0x4000U
#define PNG_FREE_ALL 0x7fffU
#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#ifdef PNG_USER_MEM_SUPPORTED
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
@ -2918,12 +2947,19 @@ typedef struct
* is the minimum 'row stride', the minimum count of components between each
* row. For a color-mapped image this is the minimum number of bytes in a
* row.
*
* WARNING: this macro overflows for some images with more than one component
* and very large image widths. libpng will refuse to process an image where
* this macro would overflow.
*/
#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
(PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
/* Return the size, in bytes, of an image buffer given a png_image and a row
* stride - the number of components to leave space for in each row.
*
* WARNING: this macro overflows a 32-bit integer for some large PNG images,
* libpng will refuse to process an image where such an overflow would occur.
*/
#define PNG_IMAGE_SIZE(image)\
@ -3044,7 +3080,6 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
#endif /* SIMPLIFIED_READ */
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
#ifdef PNG_STDIO_SUPPORTED
/* WRITE APIS
* ----------
* For write you must initialize a png_image structure to describe the image to
@ -3061,6 +3096,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
* values do not correspond to the colors in sRGB.
* colormap_entries: set to the number of entries in the color-map (0 to 256)
*/
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
const char *file, int convert_to_8bit, const void *buffer,
png_int_32 row_stride, const void *colormap));
@ -3070,8 +3106,9 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
const void *colormap));
/* Write the image to the given (FILE*). */
#endif /* SIMPLIFIED_WRITE_STDIO */
/* With both write APIs if image is in one of the linear formats with 16-bit
/* With all write APIs if image is in one of the linear formats with 16-bit
* data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
* gamma encoded according to the sRGB specification, otherwise a 16-bit linear
* encoded PNG file is written.
@ -3083,13 +3120,103 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
*
* With all APIs row_stride is handled as in the read APIs - it is the spacing
* from one row to the next in component sized units (1 or 2 bytes) and if
* negative indicates a bottom-up row layout in the buffer. If row_stride is zero,
* libpng will calculate it for you from the image width and number of channels.
* negative indicates a bottom-up row layout in the buffer. If row_stride is
* zero, libpng will calculate it for you from the image width and number of
* channels.
*
* Note that the write API does not support interlacing, sub-8-bit pixels, indexed
* PNG (color_type 3) or most ancillary chunks.
* Note that the write API does not support interlacing, sub-8-bit pixels or
* most ancillary chunks. If you need to write text chunks (e.g. for copyright
* notices) you need to use one of the other APIs.
*/
#endif /* STDIO */
PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit,
const void *buffer, png_int_32 row_stride, const void *colormap));
/* Write the image to the given memory buffer. The function both writes the
* whole PNG data stream to *memory and updates *memory_bytes with the count
* of bytes written.
*
* 'memory' may be NULL. In this case *memory_bytes is not read however on
* success the number of bytes which would have been written will still be
* stored in *memory_bytes. On failure *memory_bytes will contain 0.
*
* If 'memory' is not NULL it must point to memory[*memory_bytes] of
* writeable memory.
*
* If the function returns success memory[*memory_bytes] (if 'memory' is not
* NULL) contains the written PNG data. *memory_bytes will always be less
* than or equal to the original value.
*
* If the function returns false and *memory_bytes was not changed an error
* occured during write. If *memory_bytes was changed, or is not 0 if
* 'memory' was NULL, the write would have succeeded but for the memory
* buffer being too small. *memory_bytes contains the required number of
* bytes and will be bigger that the original value.
*/
#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\
row_stride, colormap)\
png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\
row_stride, colormap)
/* Return the amount of memory in 'size' required to compress this image.
* The png_image structure 'image' must be filled in as in the above
* function and must not be changed before the actual write call, the buffer
* and all other parameters must also be identical to that in the final
* write call. The 'size' variable need not be initialized.
*
* NOTE: the macro returns true/false, if false is returned 'size' will be
* set to zero and the write failed and probably will fail if tried again.
*/
/* You can pre-allocate the buffer by making sure it is of sufficient size
* regardless of the amount of compression achieved. The buffer size will
* always be bigger than the original image and it will never be filled. The
* following macros are provided to assist in allocating the buffer.
*/
#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height)
/* The number of uncompressed bytes in the PNG byte encoding of the image;
* uncompressing the PNG IDAT data will give this number of bytes.
*
* NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this
* macro can because of the extra bytes used in the PNG byte encoding. You
* need to avoid this macro if your image size approaches 2^30 in width or
* height. The same goes for the remainder of these macros; they all produce
* bigger numbers than the actual in-memory image size.
*/
#ifndef PNG_ZLIB_MAX_SIZE
# define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U)
/* An upper bound on the number of compressed bytes given 'b' uncompressed
* bytes. This is based on deflateBounds() in zlib; different
* implementations of zlib compression may conceivably produce more data so
* if your zlib implementation is not zlib itself redefine this macro
* appropriately.
*/
#endif
#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\
PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image))
/* An upper bound on the size of the data in the PNG IDAT chunks. */
#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
(((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
12U+3U*(image).colormap_entries/*PLTE data*/+\
(((image).format&PNG_FORMAT_FLAG_ALPHA)?\
12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
/* A helper for the following macro; if your compiler cannot handle the
* following macro use this one with the result of
* PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
* compilers should handle this just fine.)
*/
#define PNG_IMAGE_PNG_SIZE_MAX(image)\
PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image))
/* An upper bound on the total length of the PNG data stream for 'image'.
* The result is of type png_alloc_size_t, on 32-bit systems this may
* overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will
* run out of buffer space but return a corrected size which should work.
*/
#endif /* SIMPLIFIED_WRITE */
/*******************************************************************************
* END OF SIMPLIFIED API
@ -3217,9 +3344,9 @@ PNG_EXPORT(264, void, png_write_frame_tail, (png_structp png_ptr,
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
#ifdef PNG_APNG_SUPPORTED
PNG_EXPORT_LAST_ORDINAL(264);
PNG_EXPORT_LAST_ORDINAL(265);
#else
PNG_EXPORT_LAST_ORDINAL(244);
PNG_EXPORT_LAST_ORDINAL(245);
#endif /* APNG */
#endif

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.6.21, January 15, 2016
* libpng version 1.6.23, June 9, 2016
*
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -44,7 +44,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
if (png_ptr != NULL)
{
if ((png_ptr->flags &
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
{
if (*error_message == PNG_LITERAL_SHARP)
{

View File

@ -456,11 +456,11 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
return (retval);
}
#endif /* pHYs */
#endif /* INCH_CONVERSIONS */
#endif /* INCH_CONVERSIONS */
/* png_get_channels really belongs in here, too, but it's been around longer */
#endif /* EASY_ACCESS */
#endif /* EASY_ACCESS */
png_byte PNGAPI
@ -1142,19 +1142,19 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
return 0;
#ifdef PNG_WRITE_SUPPORTED
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
#endif
{
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
return png_ptr->IDAT_read_size;
return png_ptr->IDAT_read_size;
#else
return PNG_IDAT_READ_SIZE;
return PNG_IDAT_READ_SIZE;
#endif
}
#ifdef PNG_WRITE_SUPPORTED
else
return png_ptr->zbuffer_size;
else
return png_ptr->zbuffer_size;
#endif
}

View File

@ -1,8 +1,8 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.6.18 [July 23, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.23 [June 9, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -293,12 +293,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
(png_ptr->mode & PNG_HAVE_PLTE) == 0)
png_error(png_ptr, "Missing PLTE before IDAT");
png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->process_mode = PNG_READ_IDAT_MODE;
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
if (png_ptr->push_length == 0)
return;
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
if (png_ptr->push_length == 0)
return;
png_ptr->mode |= PNG_HAVE_IDAT;
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
@ -599,7 +601,10 @@ png_push_save_buffer(png_structrp png_ptr)
png_error(png_ptr, "Insufficient memory for save_buffer");
}
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
if (old_buffer)
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
else if (png_ptr->save_buffer_size)
png_error(png_ptr, "save_buffer error");
png_free(png_ptr, old_buffer);
png_ptr->save_buffer_max = new_max;
}

View File

@ -1,8 +1,8 @@
/* pngpriv.h - private declarations for use inside libpng
*
* Last changed in libpng 1.6.21 [January 15, 2016]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.22 [May 26, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*

View File

@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.6.17 [March 26, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.23 [June 9, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -127,7 +127,10 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
}
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
png_ptr->mode |= PNG_AFTER_IDAT;
}
/* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search.
@ -865,6 +868,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_uint_32 length = png_read_chunk_header(png_ptr);
png_uint_32 chunk_name = png_ptr->chunk_name;
if (chunk_name != png_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
if (chunk_name == png_IEND)
png_handle_IEND(png_ptr, info_ptr, length);
@ -879,9 +885,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
{
if (chunk_name == png_IDAT)
{
if ((length > 0) ||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, ".Too many IDATs found");
}
png_handle_unknown(png_ptr, info_ptr, length, keep);
if (chunk_name == png_PLTE)
@ -892,10 +898,14 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
else if (chunk_name == png_IDAT)
{
/* Zero length IDATs are legal after the last IDAT has been
* read, but not after other chunks have been read.
* read, but not after other chunks have been read. 1.6 does not
* always read all the deflate data; specifically it cannot be relied
* upon to read the Adler32 at the end. If it doesn't ignore IDAT
* chunks which are longer than zero as well:
*/
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "..Too many IDATs found");
png_crc_finish(png_ptr, length);
}
@ -3928,16 +3938,16 @@ png_image_read_direct(png_voidp argument)
else
filler = 255;
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
where = PNG_FILLER_BEFORE;
change &= ~PNG_FORMAT_FLAG_AFIRST;
}
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
where = PNG_FILLER_BEFORE;
change &= ~PNG_FORMAT_FLAG_AFIRST;
}
else
# endif
where = PNG_FILLER_AFTER;
else
#endif
where = PNG_FILLER_AFTER;
png_set_add_alpha(png_ptr, filler, where);
}
@ -4045,12 +4055,12 @@ png_image_read_direct(png_voidp argument)
if (info_ptr->bit_depth == 16)
info_format |= PNG_FORMAT_FLAG_LINEAR;
# ifdef PNG_FORMAT_BGR_SUPPORTED
if ((png_ptr->transformations & PNG_BGR) != 0)
info_format |= PNG_FORMAT_FLAG_BGR;
# endif
#ifdef PNG_FORMAT_BGR_SUPPORTED
if ((png_ptr->transformations & PNG_BGR) != 0)
info_format |= PNG_FORMAT_FLAG_BGR;
#endif
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
if (do_local_background == 2)
{
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
@ -4151,58 +4161,84 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
{
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
png_uint_32 check;
/* Check for row_stride overflow. This check is not performed on the
* original PNG format because it may not occur in the output PNG format
* and libpng deals with the issues of reading the original.
*/
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
if (row_stride == 0)
row_stride = PNG_IMAGE_ROW_STRIDE(*image);
if (row_stride < 0)
check = -row_stride;
else
check = row_stride;
if (image->opaque != NULL && buffer != NULL &&
check >= PNG_IMAGE_ROW_STRIDE(*image))
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
{
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
(image->colormap_entries > 0 && colormap != NULL))
png_uint_32 check;
const png_uint_32 png_row_stride = image->width * channels;
if (row_stride == 0)
row_stride = (png_int_32)/*SAFE*/png_row_stride;
if (row_stride < 0)
check = -row_stride;
else
check = row_stride;
if (image->opaque != NULL && buffer != NULL && check >= png_row_stride)
{
int result;
png_image_read_control display;
memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;
display.colormap = colormap;
display.background = background;
display.local_row = NULL;
/* Choose the correct 'end' routine; for the color-map case all the
* setup has already been done.
/* Now check for overflow of the image buffer calculation; this
* limits the whole image size to 32 bits for API compatibility with
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
*/
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
result =
png_safe_execute(image, png_image_read_colormap, &display) &&
png_safe_execute(image, png_image_read_colormapped, &display);
if (image->height <= 0xFFFFFFFF/png_row_stride)
{
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
(image->colormap_entries > 0 && colormap != NULL))
{
int result;
png_image_read_control display;
memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;
display.colormap = colormap;
display.background = background;
display.local_row = NULL;
/* Choose the correct 'end' routine; for the color-map case
* all the setup has already been done.
*/
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
result = png_safe_execute(image,
png_image_read_colormap, &display) &&
png_safe_execute(image,
png_image_read_colormapped, &display);
else
result =
png_safe_execute(image,
png_image_read_direct, &display);
png_image_free(image);
return result;
}
else
return png_image_error(image,
"png_image_finish_read[color-map]: no color-map");
}
else
result =
png_safe_execute(image, png_image_read_direct, &display);
png_image_free(image);
return result;
return png_image_error(image,
"png_image_finish_read: image too large");
}
else
return png_image_error(image,
"png_image_finish_read[color-map]: no color-map");
"png_image_finish_read: invalid argument");
}
else
return png_image_error(image,
"png_image_finish_read: invalid argument");
"png_image_finish_read: row_stride too large");
}
else if (image != NULL)

View File

@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.6.19 [November 12, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.22 [May 26, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -159,7 +159,7 @@ png_set_background(png_structrp png_ptr,
png_set_background_fixed(png_ptr, background_color, background_gamma_code,
need_expand, png_fixed(png_ptr, background_gamma, "png_set_background"));
}
# endif /* FLOATING_POINT */
# endif /* FLOATING_POINT */
#endif /* READ_BACKGROUND */
/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the
@ -289,9 +289,12 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
* is expected to be 1 or greater, but this range test allows for some
* viewing correction values. The intent is to weed out users of this API
* who use the inverse of the gamma value accidentally! Since some of these
* values are reasonable this may have to be changed.
* values are reasonable this may have to be changed:
*
* 1.6.x: changed from 0.07..3 to 0.01..100 (to accomodate the optimal 16-bit
* gamma of 36, and its reciprocal.)
*/
if (output_gamma < 70000 || output_gamma > 300000)
if (output_gamma < 1000 || output_gamma > 10000000)
png_error(png_ptr, "output gamma out of expected range");
/* The default file gamma is the inverse of the output gamma; the output
@ -1912,7 +1915,7 @@ png_init_read_transformations(png_structrp png_ptr)
png_ptr->palette[i].blue = (png_byte)component;
}
}
#endif /* READ_SHIFT */
#endif /* READ_SHIFT */
}
/* Modify the info structure to reflect the transformations. The

View File

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.6.21 [January 15, 2016]
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.23 [June 9, 2016]
* Copyright (c) 1998-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -957,12 +957,14 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
{
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
}
png_ptr->trans_alpha = info_ptr->trans_alpha;
}
if (trans_color != NULL)

View File

@ -12,9 +12,9 @@
*/
#include "pngpriv.h"
#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
# include <errno.h>
#endif
#endif /* SIMPLIFIED_WRITE_STDIO */
#ifdef PNG_WRITE_SUPPORTED
@ -1461,7 +1461,6 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
# ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */
/* Initialize the write structure - general purpose utility. */
static int
png_image_write_init(png_imagep image)
@ -1513,6 +1512,10 @@ typedef struct
png_const_voidp first_row;
ptrdiff_t row_bytes;
png_voidp local_row;
/* Byte count for memory writing */
png_bytep memory;
png_alloc_size_t memory_bytes; /* not used for STDIO */
png_alloc_size_t output_bytes; /* running total */
} png_image_write_control;
/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to
@ -1940,9 +1943,43 @@ png_image_write_main(png_voidp argument)
png_set_benign_errors(png_ptr, 0/*error*/);
# endif
/* Default the 'row_stride' parameter if required. */
if (display->row_stride == 0)
display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);
/* Default the 'row_stride' parameter if required, also check the row stride
* and total image size to ensure that they are within the system limits.
*/
{
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
{
png_uint_32 check;
const png_uint_32 png_row_stride = image->width * channels;
if (display->row_stride == 0)
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
if (display->row_stride < 0)
check = -display->row_stride;
else
check = display->row_stride;
if (check >= png_row_stride)
{
/* Now check for overflow of the image buffer calculation; this
* limits the whole image size to 32 bits for API compatibility with
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
*/
if (image->height > 0xFFFFFFFF/png_row_stride)
png_error(image->opaque->png_ptr, "memory image too large");
}
else
png_error(image->opaque->png_ptr, "supplied row stride too small");
}
else
png_error(image->opaque->png_ptr, "image row stride too large");
}
/* Set the required transforms then write the rows in the correct order. */
if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
@ -2119,6 +2156,122 @@ png_image_write_main(png_voidp argument)
return 1;
}
static void (PNGCBAPI
image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data,
png_size_t size)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
const png_alloc_size_t ob = display->output_bytes;
/* Check for overflow; this should never happen: */
if (size <= ((png_alloc_size_t)-1) - ob)
{
/* I don't think libpng ever does this, but just in case: */
if (size > 0)
{
if (display->memory_bytes >= ob+size) /* writing */
memcpy(display->memory+ob, data, size);
/* Always update the size: */
display->output_bytes = ob+size;
}
}
else
png_error(png_ptr, "png_image_write_to_memory: PNG too big");
}
static void (PNGCBAPI
image_memory_flush)(png_structp png_ptr)
{
PNG_UNUSED(png_ptr)
}
static int
png_image_write_memory(png_voidp argument)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
argument);
/* The rest of the memory-specific init and write_main in an error protected
* environment. This case needs to use callbacks for the write operations
* since libpng has no built in support for writing to memory.
*/
png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/,
image_memory_write, image_memory_flush);
return png_image_write_main(display);
}
int PNGAPI
png_image_write_to_memory(png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
const void *buffer, png_int_32 row_stride, const void *colormap)
{
/* Write the image to the given buffer, or count the bytes if it is NULL */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
if (memory_bytes != NULL && buffer != NULL)
{
/* This is to give the caller an easier error detection in the NULL
* case and guard against uninitialized variable problems:
*/
if (memory == NULL)
*memory_bytes = 0;
if (png_image_write_init(image) != 0)
{
png_image_write_control display;
int result;
memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;
display.colormap = colormap;
display.convert_to_8bit = convert_to_8bit;
display.memory = png_voidcast(png_bytep, memory);
display.memory_bytes = *memory_bytes;
display.output_bytes = 0;
result = png_safe_execute(image, png_image_write_memory, &display);
png_image_free(image);
/* write_memory returns true even if we ran out of buffer. */
if (result)
{
/* On out-of-buffer this function returns '0' but still updates
* memory_bytes:
*/
if (memory != NULL && display.output_bytes > *memory_bytes)
result = 0;
*memory_bytes = display.output_bytes;
}
return result;
}
else
return 0;
}
else
return png_image_error(image,
"png_image_write_to_memory: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
else
return 0;
}
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
int PNGAPI
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
const void *buffer, png_int_32 row_stride, const void *colormap)
@ -2126,7 +2279,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
/* Write the image to the given (FILE*). */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
if (file != NULL)
if (file != NULL && buffer != NULL)
{
if (png_image_write_init(image) != 0)
{
@ -2176,7 +2329,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
/* Write the image to the named file. */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
if (file_name != NULL)
if (file_name != NULL && buffer != NULL)
{
FILE *fp = fopen(file_name, "wb");
@ -2234,7 +2387,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
else
return 0;
}
# endif /* STDIO */
#endif /* SIMPLIFIED_WRITE_STDIO */
#endif /* SIMPLIFIED_WRITE */
#ifdef PNG_WRITE_APNG_SUPPORTED

View File

@ -1,8 +1,8 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.6.21 [January 15, 2016]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.22 [May 26, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -23,10 +23,10 @@
void PNGAPI
png_save_uint_32(png_bytep buf, png_uint_32 i)
{
buf[0] = (png_byte)(i >> 24);
buf[1] = (png_byte)(i >> 16);
buf[2] = (png_byte)(i >> 8);
buf[3] = (png_byte)(i );
buf[0] = (png_byte)((i >> 24) & 0xffU);
buf[1] = (png_byte)((i >> 16) & 0xffU);
buf[2] = (png_byte)((i >> 8) & 0xffU);
buf[3] = (png_byte)( i & 0xffU);
}
/* Place a 16-bit number into a buffer in PNG byte order.
@ -36,8 +36,8 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
void PNGAPI
png_save_uint_16(png_bytep buf, unsigned int i)
{
buf[0] = (png_byte)(i >> 8);
buf[1] = (png_byte)(i );
buf[0] = (png_byte)((i >> 8) & 0xffU);
buf[1] = (png_byte)( i & 0xffU);
}
#endif

View File

@ -14,8 +14,4 @@ The in-tree copy is updated by running
sh update.sh
from within the modules/brotli directory.
Current version: [commit 33aa40220b96cf95ad2b9ba61dc8d7fd2f964f2c].
dec/port.h was patched to fix false positive warning in Brotli and a
corresponding change will be done upstream.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1247301
Current version: [commit 29d31d5921b0a2b323ac24e7f7d0cdc9a3c0dd08].

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