This commit is contained in:
Ehsan Akhgari 2011-04-13 14:09:09 -04:00
Родитель 436a7a6900 b47034f361
Коммит 0727df7bf4
68 изменённых файлов: 1719 добавлений и 1114 удалений

Просмотреть файл

@ -38,6 +38,9 @@
#include "nsAccessNodeWrap.h"
#include "nsApplicationAccessibleWrap.h"
#include "nsMaiInterfaceText.h"
PRBool nsAccessNodeWrap::gHaveNewTextSignals = PR_FALSE;
/* For documentation of the accessibility architecture,
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
@ -68,6 +71,7 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
gHaveNewTextSignals = g_signal_lookup("text-insert", ATK_TYPE_TEXT);
}
void nsAccessNodeWrap::ShutdownAccessibility()

Просмотреть файл

@ -53,6 +53,13 @@ public: // construction, destruction
static void InitAccessibility();
static void ShutdownAccessibility();
/*
* do we have text-remove and text-insert signals if not we need to use
* text-changed see nsAccessibleWrap::FireAtkTextChangedEvent() and
* bug 619002
*/
static PRBool gHaveNewTextSignals;
};
#endif

Просмотреть файл

@ -1361,14 +1361,27 @@ nsAccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
PRInt32 start = event->GetStartOffset();
PRUint32 length = event->GetLength();
PRBool isInserted = event->IsTextInserted();
PRBool isFromUserInput = aEvent->IsFromUserInput();
char* signal_name = nsnull;
char *signal_name = g_strconcat(isInserted ? "text_changed::insert" : "text_changed::delete",
isFromUserInput ? "" : kNonUserInputEvent, NULL);
g_signal_emit_by_name(aObject, signal_name, start, length);
g_free (signal_name);
if (gHaveNewTextSignals) {
nsAutoString text;
event->GetModifiedText(text);
signal_name = g_strconcat(isInserted ? "text-insert" : "text-remove",
isFromUserInput ? "" : "::system", NULL);
g_signal_emit_by_name(aObject, signal_name, start, length,
NS_ConvertUTF16toUTF8(text).get());
} else {
// XXX remove this code and the gHaveNewTextSignals check when we can
// stop supporting old atk since it doesn't really work anyway
// see bug 619002
signal_name = g_strconcat(isInserted ? "text_changed::insert" :
"text_changed::delete",
isFromUserInput ? "" : kNonUserInputEvent, NULL);
g_signal_emit_by_name(aObject, signal_name, start, length);
}
g_free(signal_name);
return NS_OK;
}

Просмотреть файл

@ -171,11 +171,10 @@ let TabView = {
show: function() {
if (this.isVisible())
return;
let self = this;
this._initFrame(function() {
let event = document.createEvent("Events");
event.initEvent("tabviewshow", false, false);
dispatchEvent(event);
self._window.UI.showTabView(true);
});
},
@ -184,9 +183,7 @@ let TabView = {
if (!this.isVisible())
return;
let event = document.createEvent("Events");
event.initEvent("tabviewhide", false, false);
dispatchEvent(event);
this._window.UI.exit();
},
// ----------

Просмотреть файл

@ -132,7 +132,7 @@ var TabUtils = {
// of active Panoramas as well as for windows in which
// Panorama has yet to be activated. We uses object sniffing to
// determine the type of tab and then returns its name.
return tab.label != undefined ? tab.label : tab.$tabTitle[0].innerHTML;
return tab.label != undefined ? tab.label : tab.$tabTitle[0].textContent;
},
// ---------

Просмотреть файл

@ -163,11 +163,6 @@ let UI = {
this._storageSanity(data);
this._pageBounds = data.pageBounds;
// ___ hook into the browser
gWindow.addEventListener("tabviewshow", function() {
self.showTabView(true);
}, false);
// ___ currentTab
this._currentTab = gBrowser.selectedTab;
@ -226,10 +221,6 @@ let UI = {
self.uninit();
});
gWindow.addEventListener("tabviewhide", function() {
self.exit();
}, false);
// ___ setup key handlers
this._setTabViewFrameKeyHandlers();

Просмотреть файл

@ -25,8 +25,10 @@ function onTabViewWindowLoaded() {
window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
ok(TabView.isVisible(), "Tab View is visible");
let contentWindow = document.getElementById("tab-view").contentWindow;
testOne(contentWindow);
afterAllTabItemsUpdated(function() {
let contentWindow = document.getElementById("tab-view").contentWindow;
testOne(contentWindow);
});
}
function testOne(contentWindow) {

Просмотреть файл

@ -760,6 +760,3 @@ function countTabs() {
return [needsRestore, isRestoring, wasRestored];
}
function r() {
return "" + Date.now() + Math.random();
}

Просмотреть файл

@ -170,8 +170,3 @@ function test() {
// Restore state
ss.setBrowserState(JSON.stringify(state));
}
// Helper function to create a random value
function r() {
return "" + Date.now() + Math.random();
}

Просмотреть файл

@ -50,54 +50,6 @@ function testBug600545() {
// Set the pref to false to cause non-app tabs to be stripped out on a save
Services.prefs.setBoolPref("browser.sessionstore.resume_from_crash", false);
// Need to wait for SessionStore's saveState function to be called
// so that non-pinned tabs will be stripped from non-active window
function waitForSaveState(aSaveStateCallback) {
let topic = "sessionstore-state-write";
Services.obs.addObserver(function() {
Services.obs.removeObserver(arguments.callee, topic, false);
executeSoon(aSaveStateCallback);
}, topic, false);
};
// Need to wait for all tabs to be restored before reading browser state
function waitForBrowserState(aState, aSetStateCallback) {
let tabsRestored = 0;
let expectedTabs = getStateTabCount(aState);
// We know that there are only 2 windows total, so just be specific
let newWin;
// Used to determine when tabs have been restored
function onTabRestored(aEvent) {
if (++tabsRestored == expectedTabs) {
gBrowser.tabContainer.removeEventListener("SSTabRestored", onTabRestored, true);
newWin.gBrowser.tabContainer.removeEventListener("SSTabRestored", onTabRestored, true);
executeSoon(aSetStateCallback);
}
}
// We also want to catch the 2nd window, so we need to observe domwindowopened
function windowObserver(aSubject, aTopic, aData) {
let theWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
if (aTopic == "domwindowopened") {
theWin.addEventListener("load", function() {
theWin.removeEventListener("load", arguments.callee, false);
// So we can remove the event listener in onTabRestored
newWin = theWin;
Services.ww.unregisterNotification(windowObserver);
theWin.gBrowser.tabContainer.addEventListener("SSTabRestored", onTabRestored, true);
}, false);
}
}
Services.ww.registerNotification(windowObserver);
gBrowser.tabContainer.addEventListener("SSTabRestored", onTabRestored, true);
ss.setBrowserState(JSON.stringify(aState));
}
// This tests the following use case:
// When multiple windows are open and browser.sessionstore.resume_from_crash
// preference is false, tab session data for non-active window is stripped for
@ -124,6 +76,8 @@ function testBug600545() {
] };
waitForBrowserState(state, function() {
// Need to wait for SessionStore's saveState function to be called
// so that non-pinned tabs will be stripped from non-active window
waitForSaveState(function () {
let expectedNumberOfTabs = getStateTabCount(state);
let retrievedState = JSON.parse(ss.getBrowserState());

Просмотреть файл

@ -148,7 +148,3 @@ function test() {
ss.setBrowserState(JSON.stringify(state));
}
// Helper function to create a random value
function r() {
return "" + Date.now() + Math.random();
}

Просмотреть файл

@ -80,19 +80,6 @@ function runNextTest() {
}
}
// helper, works only for single window
function waitForBrowserState(aState, aSetStateCallback) {
let tabsRestored = 0;
gBrowser.tabContainer.addEventListener("SSTabRestored", function() {
if (++tabsRestored == aState.windows[0].tabs.length) {
gBrowser.tabContainer.removeEventListener("SSTabRestored", arguments.callee, true);
executeSoon(aSetStateCallback);
}
}, true);
ss.setBrowserState(JSON.stringify(aState));
}
function test_setup() {
function onSSTabRestored(aEvent) {
gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored, false);

Просмотреть файл

@ -106,20 +106,23 @@ nsGNOMEShellService::Init()
{
nsresult rv;
// GConf _must_ be available, or we do not allow
// GConf or GIO _must_ be available, or we do not allow
// CreateInstance to succeed.
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCOMPtr<nsIGIOService> giovfs =
do_GetService(NS_GIOSERVICE_CONTRACTID);
if (!gconf)
if (!gconf && !giovfs)
return NS_ERROR_NOT_AVAILABLE;
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
// the locale encoding. If it's not set, they use UTF-8.
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nsnull;
if (GetAppPathFromLauncher())
return NS_OK;
nsCOMPtr<nsIProperties> dirSvc
(do_GetService("@mozilla.org/file/directory_service;1"));
NS_ENSURE_TRUE(dirSvc, NS_ERROR_NOT_AVAILABLE);
@ -137,6 +140,34 @@ nsGNOMEShellService::Init()
NS_IMPL_ISUPPORTS1(nsGNOMEShellService, nsIShellService)
PRBool
nsGNOMEShellService::GetAppPathFromLauncher()
{
gchar *tmp;
const char *launcher = PR_GetEnv("MOZ_APP_LAUNCHER");
if (!launcher)
return PR_FALSE;
if (g_path_is_absolute(launcher)) {
mAppPath = launcher;
tmp = g_path_get_basename(launcher);
gchar *fullpath = g_find_program_in_path(tmp);
if (fullpath && mAppPath.Equals(fullpath))
mAppIsInPath = PR_TRUE;
g_free(fullpath);
} else {
tmp = g_find_program_in_path(launcher);
if (!tmp)
return PR_FALSE;
mAppPath = tmp;
mAppIsInPath = PR_TRUE;
}
g_free(tmp);
return PR_TRUE;
}
PRBool
nsGNOMEShellService::KeyMatchesAppName(const char *aKeyValue) const
{
@ -163,6 +194,27 @@ nsGNOMEShellService::KeyMatchesAppName(const char *aKeyValue) const
return matches;
}
PRBool
nsGNOMEShellService::CheckHandlerMatchesAppName(const nsACString &handler) const
{
gint argc;
gchar **argv;
nsCAutoString command(handler);
// The string will be something of the form: [/path/to/]browser "%s"
// We want to remove all of the parameters and get just the binary name.
if (g_shell_parse_argv(command.get(), &argc, &argv, NULL) && argc > 0) {
command.Assign(argv[0]);
g_strfreev(argv);
}
if (!KeyMatchesAppName(command.get()))
return PR_FALSE; // the handler is set to another app
return PR_TRUE;
}
NS_IMETHODIMP
nsGNOMEShellService::IsDefaultBrowser(PRBool aStartupCheck,
PRBool* aIsDefaultBrowser)
@ -172,31 +224,37 @@ nsGNOMEShellService::IsDefaultBrowser(PRBool aStartupCheck,
mCheckedThisSession = PR_TRUE;
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
PRBool enabled;
nsCAutoString handler;
nsCOMPtr<nsIGIOMimeApp> gioApp;
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
if (!appProtocols[i].essential)
continue;
handler.Truncate();
gconf->GetAppForProtocol(nsDependentCString(appProtocols[i].name),
&enabled, handler);
if (gconf) {
handler.Truncate();
gconf->GetAppForProtocol(nsDependentCString(appProtocols[i].name),
&enabled, handler);
// The string will be something of the form: [/path/to/]browser "%s"
// We want to remove all of the parameters and get just the binary name.
gint argc;
gchar **argv;
if (g_shell_parse_argv(handler.get(), &argc, &argv, NULL) && argc > 0) {
handler.Assign(argv[0]);
g_strfreev(argv);
if (!CheckHandlerMatchesAppName(handler) || !enabled)
return NS_OK; // the handler is disabled or set to another app
}
if (!KeyMatchesAppName(handler.get()) || !enabled)
return NS_OK; // the handler is disabled or set to another app
if (giovfs) {
handler.Truncate();
giovfs->GetAppForURIScheme(nsDependentCString(appProtocols[i].name),
getter_AddRefs(gioApp));
if (!gioApp)
return NS_OK;
gioApp->GetCommand(handler);
if (!CheckHandlerMatchesAppName(handler))
return NS_OK; // the handler is set to another app
}
}
*aIsDefaultBrowser = PR_TRUE;
@ -214,9 +272,20 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
#endif
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
if (gconf) {
nsCAutoString appKeyValue(mAppPath);
appKeyValue.Append(" \"%s\"");
nsCAutoString appKeyValue;
if (mAppIsInPath) {
// mAppPath is in the users path, so use only the basename as the launcher
gchar *tmp = g_path_get_basename(mAppPath.get());
appKeyValue = tmp;
g_free(tmp);
} else {
appKeyValue = mAppPath;
}
appKeyValue.AppendLiteral(" %s");
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
if (appProtocols[i].essential || aClaimAllTypes) {
gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
@ -225,13 +294,8 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
}
}
// set handler for .html and xhtml files and MIME types:
if (aClaimAllTypes) {
if (giovfs) {
nsresult rv;
nsCOMPtr<nsIGIOService> giovfs =
do_GetService(NS_GIOSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -254,10 +318,20 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
getter_AddRefs(appInfo));
NS_ENSURE_SUCCESS(rv, rv);
// Add mime types for html, xhtml extension and set app to just created appinfo.
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) {
appInfo->SetAsDefaultForMimeType(nsDependentCString(appTypes[i].mimeType));
appInfo->SetAsDefaultForFileExtensions(nsDependentCString(appTypes[i].extensions));
// set handler for the protocols
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
if (appProtocols[i].essential || aClaimAllTypes) {
appInfo->SetAsDefaultForURIScheme(nsDependentCString(appProtocols[i].name));
}
}
// set handler for .html and xhtml files and MIME types:
if (aClaimAllTypes) {
// Add mime types for html, xhtml extension and set app to just created appinfo.
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) {
appInfo->SetAsDefaultForMimeType(nsDependentCString(appTypes[i].mimeType));
appInfo->SetAsDefaultForFileExtensions(nsDependentCString(appTypes[i].extensions));
}
}
}
@ -367,24 +441,26 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
// if the file was written successfully, set it as the system wallpaper
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCAutoString options;
if (aPosition == BACKGROUND_TILE)
options.Assign("wallpaper");
else if (aPosition == BACKGROUND_STRETCH)
options.Assign("stretched");
else
options.Assign("centered");
if (gconf) {
nsCAutoString options;
if (aPosition == BACKGROUND_TILE)
options.Assign("wallpaper");
else if (aPosition == BACKGROUND_STRETCH)
options.Assign("stretched");
else
options.Assign("centered");
gconf->SetString(NS_LITERAL_CSTRING(kDesktopOptionsKey), options);
gconf->SetString(NS_LITERAL_CSTRING(kDesktopOptionsKey), options);
// Set the image to an empty string first to force a refresh
// (since we could be writing a new image on top of an existing
// Firefox_wallpaper.png and nautilus doesn't monitor the file for changes)
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey),
EmptyCString());
// Set the image to an empty string first to force a refresh
// (since we could be writing a new image on top of an existing
// Firefox_wallpaper.png and nautilus doesn't monitor the file for changes)
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey),
EmptyCString());
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey), filePath);
gconf->SetBool(NS_LITERAL_CSTRING(kDesktopDrawBGKey), PR_TRUE);
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey), filePath);
gconf->SetBool(NS_LITERAL_CSTRING(kDesktopDrawBGKey), PR_TRUE);
}
return rv;
}
@ -398,7 +474,9 @@ nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCAutoString background;
gconf->GetString(NS_LITERAL_CSTRING(kDesktopColorKey), background);
if (gconf) {
gconf->GetString(NS_LITERAL_CSTRING(kDesktopColorKey), background);
}
if (background.IsEmpty()) {
*aColor = 0;
@ -437,10 +515,12 @@ nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor)
NS_ASSERTION(aColor <= 0xffffff, "aColor has extra bits");
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCAutoString colorString;
ColorToCString(aColor, colorString);
if (gconf) {
nsCAutoString colorString;
ColorToCString(aColor, colorString);
gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
}
return NS_OK;
}
@ -456,7 +536,17 @@ nsGNOMEShellService::OpenApplication(PRInt32 aApplication)
else
return NS_ERROR_NOT_AVAILABLE;
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
if (giovfs) {
nsCOMPtr<nsIGIOMimeApp> gioApp;
giovfs->GetAppForURIScheme(scheme, getter_AddRefs(gioApp));
if (gioApp)
return gioApp->Launch(EmptyCString());
}
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
if (!gconf)
return NS_ERROR_FAILURE;
PRBool enabled;
nsCAutoString appCommand;

Просмотреть файл

@ -43,7 +43,7 @@
class nsGNOMEShellService : public nsIShellService
{
public:
nsGNOMEShellService() : mCheckedThisSession(PR_FALSE) { }
nsGNOMEShellService() : mCheckedThisSession(PR_FALSE), mAppIsInPath(PR_FALSE) { }
NS_DECL_ISUPPORTS
NS_DECL_NSISHELLSERVICE
@ -54,10 +54,13 @@ private:
~nsGNOMEShellService() {}
NS_HIDDEN_(PRBool) KeyMatchesAppName(const char *aKeyValue) const;
NS_HIDDEN_(PRBool) CheckHandlerMatchesAppName(const nsACString& handler) const;
NS_HIDDEN_(PRBool) GetAppPathFromLauncher();
PRPackedBool mCheckedThisSession;
PRPackedBool mUseLocaleFilenames;
nsCString mAppPath;
PRPackedBool mAppIsInPath;
};
#endif // nsgnomeshellservice_h____

Просмотреть файл

@ -82,11 +82,13 @@ struct SelectionState {
class RestoreSelectionState : public nsRunnable {
public:
RestoreSelectionState(nsTextControlFrame *aFrame, PRInt32 aStart, PRInt32 aEnd)
RestoreSelectionState(nsTextEditorState *aState, nsTextControlFrame *aFrame,
PRInt32 aStart, PRInt32 aEnd)
: mFrame(aFrame),
mWeakFrame(aFrame),
mStart(aStart),
mEnd(aEnd)
mEnd(aEnd),
mTextEditorState(aState)
{
}
@ -96,6 +98,7 @@ public:
// need to block script to avoid nested PrepareEditor calls (bug 642800).
nsAutoScriptBlocker scriptBlocker;
mFrame->SetSelectionRange(mStart, mEnd);
mTextEditorState->HideSelectionIfBlurred();
}
return NS_OK;
}
@ -105,6 +108,7 @@ private:
nsWeakFrame mWeakFrame;
PRInt32 mStart;
PRInt32 mEnd;
nsTextEditorState* mTextEditorState;
};
/*static*/
@ -1385,7 +1389,7 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
// Restore our selection after being bound to a new frame
if (mSelState) {
nsContentUtils::AddScriptRunner(new RestoreSelectionState(mBoundFrame, mSelState->mStart, mSelState->mEnd));
nsContentUtils::AddScriptRunner(new RestoreSelectionState(this, mBoundFrame, mSelState->mStart, mSelState->mEnd));
mSelState = nsnull;
}
@ -2011,6 +2015,16 @@ nsTextEditorState::SetPlaceholderClass(PRBool aVisible,
classValue, aNotify);
}
void
nsTextEditorState::HideSelectionIfBlurred()
{
NS_ABORT_IF_FALSE(mSelCon, "Should have a selection controller if we have a frame!");
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
if (!nsContentUtils::IsFocusedContent(content)) {
mSelCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN);
}
}
NS_IMPL_ISUPPORTS1(nsAnonDivObserver, nsIMutationObserver)
void

Просмотреть файл

@ -210,6 +210,8 @@ public:
void ClearValueCache() { mCachedValue.Truncate(); }
void HideSelectionIfBlurred();
private:
// not copy constructible
nsTextEditorState(const nsTextEditorState&);

Просмотреть файл

@ -10713,12 +10713,6 @@ nsNavigator::GetProductSub(nsAString& aProductSub)
return rv;
}
NS_IMETHODIMP
nsNavigator::GetSecurityPolicy(nsAString& aSecurityPolicy)
{
return NS_OK;
}
NS_IMETHODIMP
nsNavigator::GetMimeTypes(nsIDOMMimeTypeArray **aMimeTypes)
{

Просмотреть файл

@ -39,7 +39,7 @@
#include "domstubs.idl"
[scriptable, uuid(777bd8a1-38c1-4b12-ba8f-ff6c2eb8c56b)]
[scriptable, uuid(d7758ece-f088-4701-9ae4-1450192dca38)]
interface nsIDOMNavigator : nsISupports
{
readonly attribute DOMString appCodeName;
@ -54,7 +54,6 @@ interface nsIDOMNavigator : nsISupports
readonly attribute DOMString product;
readonly attribute DOMString productSub;
readonly attribute nsIDOMPluginArray plugins;
readonly attribute DOMString securityPolicy;
readonly attribute DOMString userAgent;
readonly attribute boolean cookieEnabled;
readonly attribute boolean onLine;

Просмотреть файл

@ -217,7 +217,7 @@ nsRect& nsRect::ExtendForScaling(float aXMult, float aYMult)
NS_ASSERTION((IsFloatInteger(aXMult) || IsFloatInteger(1/aXMult)) &&
(IsFloatInteger(aYMult) || IsFloatInteger(1/aYMult)),
"Multiplication factors must be integers or 1/integer");
// Scale rect by multiplier, snap outwards to integers and then unscale.
// We round the results to the nearest integer to prevent floating point errors.
if (aXMult < 1) {
@ -330,15 +330,14 @@ PRBool nsIntRect::UnionRect(const nsIntRect &aRect1, const nsIntRect &aRect2)
return result;
}
// scale the rect but round to smallest containing rect
nsIntRect& nsIntRect::ScaleRoundOut(float aXScale, float aYScale)
{
nscoord right = NSToCoordCeil(float(XMost()) * aXScale);
nscoord bottom = NSToCoordCeil(float(YMost()) * aYScale);
x = NSToCoordFloor(float(x) * aXScale);
y = NSToCoordFloor(float(y) * aYScale);
width = (right - x);
height = (bottom - y);
return *this;
// scale the rect but round to smallest containing rect
nsIntRect& nsIntRect::ScaleRoundOut(float aXScale, float aYScale)
{
nscoord right = NSToCoordCeil(float(XMost()) * aXScale);
nscoord bottom = NSToCoordCeil(float(YMost()) * aYScale);
x = NSToCoordFloor(float(x) * aXScale);
y = NSToCoordFloor(float(y) * aYScale);
width = (right - x);
height = (bottom - y);
return *this;
}

Просмотреть файл

@ -1983,6 +1983,8 @@ nsGfxScrollFrameInner::BuildDisplayList(nsDisplayListBuilder* aBuilder,
(XRE_GetProcessType() == GeckoProcessType_Content &&
(styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN ||
styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN) &&
(scrollRange.width > 0 ||
scrollRange.height > 0) &&
(!mIsRoot || !mOuter->PresContext()->IsRootContentDocument()));
if (ShouldBuildLayer()) {

Просмотреть файл

@ -276,6 +276,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
layer->SetContainer(container);
layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));
layer->SetContentFlags(Layer::CONTENT_OPAQUE);
// Set a transform on the layer to draw the video in the right place
gfxMatrix transform;
transform.Translate(r.pos);

Просмотреть файл

@ -3,7 +3,7 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="setTimeout(boom, 1000)"
onload="loaded()"
class="reftest-wait">
<hbox style="display: none">
@ -21,7 +21,10 @@
</content>
<implementation>
<constructor>
window.setTimeout(finish, 1000);
window.setTimeout(function() {
document.documentElement.clientHeight;
window.setTimeout(finish, 0);
}, 0);
</constructor>
</implementation>
</binding>
@ -29,6 +32,13 @@
</hbox>
<script>
function loaded()
{
setTimeout(function() {
document.documentElement.clientHeight;
setTimeout(boom, 0);
}, 0);
}
function boom()
{
document.documentElement.style.MozBinding = "url('#foo')";

Просмотреть файл

@ -60,3 +60,5 @@ fails-if(Android) != spellcheck-hyphen-multiple-invalid.html spellcheck-hyphen-m
== caret_on_presshell_reinit.html caret_on_presshell_reinit-ref.html
== caret_on_presshell_reinit-2.html caret_on_presshell_reinit-ref.html
== 642800.html 642800-ref.html
== selection_visibility_after_reframe.html selection_visibility_after_reframe-ref.html
!= selection_visibility_after_reframe-2.html selection_visibility_after_reframe-ref.html

Просмотреть файл

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<body>
<input value="foo">
<script>
var i = document.querySelector("input");
i.selectionStart = 1;
i.selectionEnd = 2;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<input value="foo">
</body>
</html>

Просмотреть файл

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<body>
<input value="foo">
<script>
var i = document.querySelector("input");
i.selectionStart = 1;
i.selectionEnd = 2;
i.style.display = "none";
document.body.clientHeight;
i.style.display = "";
</script>
</body>
</html>

Просмотреть файл

@ -414,13 +414,13 @@ nsMenuBarFrame::ChangeMenuItem(nsMenuFrame* aMenuItem,
}
nsMenuFrame*
nsMenuBarFrame::Enter()
nsMenuBarFrame::Enter(nsGUIEvent* aEvent)
{
if (!mCurrentMenu)
return nsnull;
if (mCurrentMenu->IsOpen())
return mCurrentMenu->Enter();
return mCurrentMenu->Enter(aEvent);
return mCurrentMenu;
}

Просмотреть файл

@ -112,7 +112,7 @@ public:
// Called when Enter is pressed while the menubar is focused. If the current
// menu is open, let the child handle the key.
nsMenuFrame* Enter();
nsMenuFrame* Enter(nsGUIEvent* aEvent);
// Used to handle ALT+key combos
nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent);

Просмотреть файл

@ -832,7 +832,7 @@ nsMenuFrame::SetDebug(nsBoxLayoutState& aState, nsIFrame* aList, PRBool aDebug)
// In either case, do nothing if the item is disabled.
//
nsMenuFrame*
nsMenuFrame::Enter()
nsMenuFrame::Enter(nsGUIEvent *aEvent)
{
if (IsDisabled()) {
#ifdef XP_WIN
@ -853,7 +853,7 @@ nsMenuFrame::Enter()
if (!IsOpen()) {
// The enter key press applies to us.
if (!IsMenu() && mMenuParent)
Execute(0); // Execute our event handler
Execute(aEvent); // Execute our event handler
else
return this;
}

Просмотреть файл

@ -174,7 +174,7 @@ public:
// one in its parent popup. This will carry out the command attached to
// the menuitem. If the menu should be opened, this frame will be returned,
// otherwise null will be returned.
nsMenuFrame* Enter();
nsMenuFrame* Enter(nsGUIEvent* aEvent);
virtual void SetParent(nsIFrame* aParent);

Просмотреть файл

@ -1235,52 +1235,50 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, PRBool aIsMove)
vFlip = FlipStyle_Outside;
}
// if a panel is being moved, don't flip it. But always do this for content
// shells, so that the popup doesn't extend outside the containing frame.
if (aIsMove && mPopupType == ePopupTypePanel && !mInContentShell) {
hFlip = vFlip = FlipStyle_None;
// If a panel is being moved, don't constrain or flip it. But always do this for
// content shells, so that the popup doesn't extend outside the containing frame.
if (mInContentShell || !aIsMove || mPopupType != ePopupTypePanel) {
nsRect screenRect = GetConstraintRect(anchorRect, rootScreenRect);
// ensure that anchorRect is on screen
if (!anchorRect.IntersectRect(anchorRect, screenRect)) {
anchorRect.width = anchorRect.height = 0;
// if the anchor isn't within the screen, move it to the edge of the screen.
if (anchorRect.x < screenRect.x)
anchorRect.x = screenRect.x;
if (anchorRect.XMost() > screenRect.XMost())
anchorRect.x = screenRect.XMost();
if (anchorRect.y < screenRect.y)
anchorRect.y = screenRect.y;
if (anchorRect.YMost() > screenRect.YMost())
anchorRect.y = screenRect.YMost();
}
// shrink the the popup down if it is larger than the screen size
if (mRect.width > screenRect.width)
mRect.width = screenRect.width;
if (mRect.height > screenRect.height)
mRect.height = screenRect.height;
// at this point the anchor (anchorRect) is within the available screen
// area (screenRect) and the popup is known to be no larger than the screen.
// Next, check if there is enough space to show the popup at full size when
// positioned at screenPoint. If not, flip the popups to the opposite side
// of their anchor point, or resize them as necessary.
mRect.width = FlipOrResize(screenPoint.x, mRect.width, screenRect.x,
screenRect.XMost(), anchorRect.x, anchorRect.XMost(),
margin.left, margin.right, offsetForContextMenu, hFlip, &mHFlip);
mRect.height = FlipOrResize(screenPoint.y, mRect.height, screenRect.y,
screenRect.YMost(), anchorRect.y, anchorRect.YMost(),
margin.top, margin.bottom, offsetForContextMenu, vFlip, &mVFlip);
NS_ASSERTION(screenPoint.x >= screenRect.x && screenPoint.y >= screenRect.y &&
screenPoint.x + mRect.width <= screenRect.XMost() &&
screenPoint.y + mRect.height <= screenRect.YMost(),
"Popup is offscreen");
}
nsRect screenRect = GetConstraintRect(anchorRect, rootScreenRect);
// ensure that anchorRect is on screen
if (!anchorRect.IntersectRect(anchorRect, screenRect)) {
anchorRect.width = anchorRect.height = 0;
// if the anchor isn't within the screen, move it to the edge of the screen.
if (anchorRect.x < screenRect.x)
anchorRect.x = screenRect.x;
if (anchorRect.XMost() > screenRect.XMost())
anchorRect.x = screenRect.XMost();
if (anchorRect.y < screenRect.y)
anchorRect.y = screenRect.y;
if (anchorRect.YMost() > screenRect.YMost())
anchorRect.y = screenRect.YMost();
}
// shrink the the popup down if it is larger than the screen size
if (mRect.width > screenRect.width)
mRect.width = screenRect.width;
if (mRect.height > screenRect.height)
mRect.height = screenRect.height;
// at this point the anchor (anchorRect) is within the available screen
// area (screenRect) and the popup is known to be no larger than the screen.
// Next, check if there is enough space to show the popup at full size when
// positioned at screenPoint. If not, flip the popups to the opposite side
// of their anchor point, or resize them as necessary.
mRect.width = FlipOrResize(screenPoint.x, mRect.width, screenRect.x,
screenRect.XMost(), anchorRect.x, anchorRect.XMost(),
margin.left, margin.right, offsetForContextMenu, hFlip, &mHFlip);
mRect.height = FlipOrResize(screenPoint.y, mRect.height, screenRect.y,
screenRect.YMost(), anchorRect.y, anchorRect.YMost(),
margin.top, margin.bottom, offsetForContextMenu, vFlip, &mVFlip);
NS_ASSERTION(screenPoint.x >= screenRect.x && screenPoint.y >= screenRect.y &&
screenPoint.x + mRect.width <= screenRect.XMost() &&
screenPoint.y + mRect.height <= screenRect.YMost(),
"Popup is offscreen");
// determine the x and y position of the view by subtracting the desired
// screen position from the screen position of the root frame.
nsPoint viewPoint = screenPoint - rootScreenRect.TopLeft();
@ -1539,13 +1537,13 @@ nsMenuPopupFrame::ChangeMenuItem(nsMenuFrame* aMenuItem,
}
nsMenuFrame*
nsMenuPopupFrame::Enter()
nsMenuPopupFrame::Enter(nsGUIEvent* aEvent)
{
mIncrementalString.Truncate();
// Give it to the child.
if (mCurrentMenu)
return mCurrentMenu->Enter();
return mCurrentMenu->Enter(aEvent);
return nsnull;
}

Просмотреть файл

@ -234,7 +234,7 @@ public:
// that menu, or null if no menu should be opened. Also, calling Enter will
// reset the current incremental search string, calculated in
// FindMenuWithShortcut.
nsMenuFrame* Enter();
nsMenuFrame* Enter(nsGUIEvent* aEvent);
nsPopupType PopupType() const { return mPopupType; }
PRBool IsMenu() { return mPopupType == ePopupTypeMenu; }

Просмотреть файл

@ -1731,6 +1731,13 @@ nsXULPopupManager::CancelMenuTimer(nsMenuParent* aMenuParent)
}
}
static nsGUIEvent* DOMKeyEventToGUIEvent(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aEvent));
nsEvent* evt = privateEvent ? privateEvent->GetInternalNSEvent() : nsnull;
return (evt->eventStructType == NS_KEY_EVENT) ? static_cast<nsGUIEvent *>(evt) : nsnull;
}
PRBool
nsXULPopupManager::HandleShortcutNavigation(nsIDOMKeyEvent* aKeyEvent,
nsMenuPopupFrame* aFrame)
@ -1745,7 +1752,8 @@ nsXULPopupManager::HandleShortcutNavigation(nsIDOMKeyEvent* aKeyEvent,
if (result) {
aFrame->ChangeMenuItem(result, PR_FALSE);
if (action) {
nsMenuFrame* menuToOpen = result->Enter();
nsGUIEvent* evt = DOMKeyEventToGUIEvent(aKeyEvent);
nsMenuFrame* menuToOpen = result->Enter(evt);
if (menuToOpen) {
nsCOMPtr<nsIContent> content = menuToOpen->GetContent();
ShowMenu(content, PR_TRUE, PR_FALSE);
@ -2178,10 +2186,11 @@ nsXULPopupManager::KeyPress(nsIDOMEvent* aKeyEvent)
// Enter method will return a menu if one needs to be opened as a result.
nsMenuFrame* menuToOpen = nsnull;
nsMenuChainItem* item = GetTopVisibleMenu();
nsGUIEvent* evt = DOMKeyEventToGUIEvent(aKeyEvent);
if (item)
menuToOpen = item->Frame()->Enter();
menuToOpen = item->Frame()->Enter(evt);
else if (mActiveMenuBar)
menuToOpen = mActiveMenuBar->Enter();
menuToOpen = mActiveMenuBar->Enter(evt);
if (menuToOpen) {
nsCOMPtr<nsIContent> content = menuToOpen->GetContent();
ShowMenu(content, PR_TRUE, PR_FALSE);

Просмотреть файл

@ -1479,7 +1479,7 @@ version 1.2.9beta5 [March 4, 2006]
Removed trailing blanks from source files.
Put version and date of latest change in each source file, and changed
copyright year accordingly.
More cleanup of configure.ac, Makefile.ac, and associated scripts.
More cleanup of configure.ac, Makefile.am, and associated scripts.
Restored scripts/makefile.elf which was inadvertently deleted.
version 1.2.9beta6 [March 6, 2006]
@ -2610,6 +2610,191 @@ version 1.4.3rc03 [June 23, 2010]
version 1.4.3 [June 26, 2010]
Updated some of the "last changed" dates.
version 1.4.4beta01 [July 12, 2010]
Removed extraneous new_push_process_row.c file.
Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5
Removed some newly-added TAB characters from pngpread.c.
Fixed some indentation in pngpread.c and pngrutil.c
Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans)
Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {')
Put "#ifndef PNG_EXTERN, #endif" around "#define PNG_EXTERN" in pngpriv.h
version 1.4.4beta02 [July 24, 2010]
Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2
Moved the definition of png_snprintf() outside of the enclosing
#ifdef blocks in pngconf.h
Added a special case typedef of png_longjmp_ptr for WATCOM.
version 1.4.4beta03 [July 24, 2010]
Removed reference to cbuilder5/* from Makefile.in and Makefile.am
Eliminated the new special case typedef of png_longjmp_ptr for WATCOM
and made a special case "#define PNGAPI" in pngconf.h instead.
version 1.4.4beta04 [July 31, 2010]
Updated the read macros and functions from 1.5.0beta38.
version 1.4.4beta05 [August 6, 2010]
Updated projects/visualc71 so it can find scripts/pnglibconf.h
Removed unused png_mem_* defines from pngconf.h.
Correct use of _WINDOWS_ in pngconf.h
version 1.4.4beta06 [August 11, 2010]
Don't try to use version-script with cygwin/mingw.
Revised contrib/gregbook to work under cygwin/mingw.
version 1.4.4beta07 [August 26, 2010]
Updated prebuilt aclocal.m4 and ltmain.sh
Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov)
Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for
installing libpng in /usr/lib64 (Funda Wang).
Revised CMakeLists.txt to put the man pages in share/man/man* not man/man*
Revised CMakeLists.txt to make symlinks instead of copies when installing.
Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman)
Moved "#include pngusr.h" ahead of PNG_USER_PRIVATEBUILD test in pngconf.h
Eliminated a deprecated reference to png_ptr->io_ptr in pngtest.c
Eliminated new unnecessary #if tests regarding the sCAL chunk from pngrutil.c
version 1.4.4beta08 [September 2, 2010]
Updated the xcode project to work with libpng-1.4.x and added iOS targets
for simulator and device (Philippe Hausler).
version 1.4.4rc01 [September 10, 2010]
No changes.
version 1.4.4rc02 [September 13, 2010]
Revised CMakeLists.txt (Philip Lowman).
version 1.4.4rc03 [September 14, 2010]
Removed an extraneous close-double-quote from CMakeLists.txt
Eliminated another deprecated reference to png_ptr->io_ptr in pngtest.c
version 1.4.4rc04 [September 16, 2010]
Fixed indentation and removed debugging message from CMakeLists.txt
Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER,
$AUTOPOINT, $ACLOCAL and $LIBTOOLIZE
version 1.4.4rc05 [September 20, 2010]
Rebuilt configure scripts with automake-1.11.1 instead of automake-1.11.
Removed unused mkinstalldirs file.
version 1.4.4 [September 23, 2010]
No changes.
version 1.4.5beta01 [September 25, 2010]
Fixed possible configure.ac bug introduced in version 1.4.4rc05.
Rebuilt configure scripts with autoconf-2.68 instead of autoconf-2.65
version 1.4.5beta02 [October 5, 2010]
Reverted configure scripts to autoconf-2.65
Fixed problem with symbols creation in Makefile.am which was assuming that
all versions of cpp write to standard output by default (Martin Banky). The
bug was introduced in libpng-1.2.9beta5.
version 1.4.5beta03 [October 8, 2010]
Wrapped long lines in CMakeLists.txt and introduced ${libpng_public_hdrs}
Undid Makefile.am revision of 1.4.5beta02.
version 1.4.5beta04 [November 8, 2010]
Check for out-of-range text compression mode in png_set_text().
version 1.4.5rc01 [November 19, 2010]
No changes.
version 1.4.5beta05 [November 20, 2010]
Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin)
Moved reading of file signature into png_read_sig (Cosmin)
Fixed atomicity of chunk header serialization (Cosmin)
Added test for io_state in pngtest.c (Cosmin)
Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
version 1.4.5beta06 [November 21, 2010]
Restored the parentheses in pngrutil.c; they are needed when the
png_get_*int_*() functions are compiled (i.e., when PNG_USE_READ_MACROS
is not defined).
Make the "png_get_uint_16" macro return a png_uint_32 in libpng-1.4 for API
compatibility.
Changes to remove gcc warnings (John Bowler)
Certain optional gcc warning flags resulted in warnings in libpng code.
With these changes only -Wconversion and -Wcast-qual cannot be turned on.
Changes are trivial rearrangements of code. -Wconversion is not possible
for pngrutil.c (because of the widespread use of += et al on variables
smaller than (int) or (unsigned int)) and -Wcast-qual is not possible
with pngwio.c and pngwutil.c because the 'write' callback and zlib
compression both fail to declare their input buffers with 'const'.
version 1.4.5beta07 [November 25, 2010]
Reverted png_get_uint_16 macro to beta05 and added comment about the
potential API incompatibility.
version 1.4.5rc02 [December 2, 2010]
No changes.
version 1.4.5rc03 [December 3, 2010]
Added missing vstudio/*/*.vcxproj files to the zip and 7z distributions.
version 1.4.5 [December 9, 2010]
Removed PNG_NO_WRITE_GAMMA from pngminim/encoder/pngusr.h
version 1.4.6beta01 [December 29, 2010]
Fixed bug in background transformation handling in pngrtran.c (it was
looking for the flag in png_ptr->transformations instead of in
png_ptr->flags) (David Raymond).
version 1.4.6beta02 [January 14, 2011]
Fixed misspelled macros in contrib/pngminim (Cosmin).
Updated CMakeLists.txt (Clifford Yapp).
version 1.4.6beta03 [January 14, 2011]
Fixed some typecasts in png_debug statements (Cosmin).
version 1.4.6beta04 [January 22, 2011]
Updated documentation of png_set|get_tRNS() (Thomas Klausner).
Added png_const_structp and png_const_infop types, and used them in
prototypes for most png_get_*() functions.
In the manual, describe the png_get_IHDR() arguments in the correct order.
Ported change in png_do_rgb_to_gray() from libpng-1.5.1, to make
it more robust against internal libpng coding errors.
version 1.4.6beta05 [January 23, 2011]
Updated the synopses in the manual to reflect recent changes.
Fixed a typo in the *.def files and deleted entries that are now
declared in pngpriv.h
version 1.4.6beta06 [March 19, 2011]
Updated contrib/pngsuite/README to add the word "modify".
Added the private PNG_UNUSED() macro definition in pngconf.h.
version 1.4.6beta07 [March 22, 2011]
ifdef out mask arrays in pngread.c when interlacing is not supported.
Added attribute definition (warnings) for MSC_VER >= 1300 in pngconf.h
Added -D_CRT_SECURE_NO_DEPRECATE to CFLAGS in makefile.vcwin32
Fixed mistake in the descriptions of user read_transform and write_transform
function prototypes in the manual. The row_info struct is png_row_infop.
Added a request in the manual that applications do not use "png_" or
"PNG_" to begin any of their own symbols.
Fixed incorrect examples of callback prototypes in the manual, that were
introduced in libpng-1.0.0.
Removed "strip" from contrib/pngminim/*/makefile.
Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail
to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill)
version 1.4.6rc01 [March 31, 2011]
No changes.
version 1.4.6rc02 [April 6, 2011]
Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
version 1.4.6 [April 8, 2011]
No changes.
version 1.4.7rc01 [April 9, 2011]
Relocated misplaced new declarations in pngwutil.c.
version 1.4.7 [April 10, 2011]
Disabled PNG_PEDANTIC_WARNINGS for all MSC versions as in libpng-1.4.5.
Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement).

Просмотреть файл

@ -10,8 +10,8 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.4.3, June 26, 2010, are
Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
libpng versions 1.2.6, August 15, 2004, through 1.4.7, April 10, 2011, are
Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
June 26, 2010
April 10, 2011

Просмотреть файл

@ -1,6 +1,8 @@
Changes made to pristine png source by mozilla.org developers.
2011/04/08 -- Synced with libpng-1.4.7 (bug #624133).
2010/06/30 -- Synced with libpng-1.4.3 (bug #564792).
2010/02/26 -- Synced with libpng-1.4.1 (bug #544747).

Просмотреть файл

@ -1,4 +1,4 @@
README for libpng version 1.4.3 - June 26, 2010 (shared library 14.0)
README for libpng version 1.4.7 - April 10, 2011 (shared library 14.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@ -185,9 +185,9 @@ Files in this distribution:
makefile.std => Generic UNIX makefile (cc, creates static
libpng.a)
makefile.elf => Linux/ELF makefile symbol versioning,
gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@ -209,12 +209,12 @@ Files in this distribution:
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.so9 => Solaris 9 makefile
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc

Просмотреть файл

@ -42,15 +42,23 @@
#define PNG_NO_GLOBAL_ARRAYS
#ifdef _MSC_VER
/* The PNG_PEDANTIC_WARNINGS (attributes) fail to build with some MSC
* compilers; we'll play it safe and disable them for all MSC compilers.
*/
#define PNG_NO_PEDANTIC_WARNINGS
#endif
#ifndef MOZ_PNG_READ
#define PNG_NO_READ_SUPPORTED
#endif
#define PNG_NO_READ_BGR
#define PNG_NO_SET_USER_LIMITS
#define PNG_NO_USER_LIMITS
#define PNG_NO_ASSEMBLER_CODE
#define PNG_NO_WARN_UNINITIALIZED_ROW
#define PNG_NO_READ_BACKGROUND
#define PNG_NO_READ_DITHER
#define PNG_NO_READ_QUANTIZE
#define PNG_NO_READ_INVERT
#define PNG_NO_READ_SHIFT
#define PNG_NO_READ_PACK
@ -61,8 +69,10 @@
#define PNG_NO_READ_INVERT_ALPHA
#define PNG_NO_READ_RGB_TO_GRAY
#define PNG_NO_READ_USER_TRANSFORM
#define PNG_NO_READ_bKGD
#define PNG_NO_READ_hIST
#define PNG_NO_READ_oFFs
#define PNG_NO_READ_pCAL
#define PNG_NO_READ_pHYs
#define PNG_NO_READ_sBIT
@ -75,7 +85,6 @@
#define PNG_NO_READ_EMPTY_PLTE
#define PNG_NO_READ_OPT_PLTE
#define PNG_NO_READ_STRIP_ALPHA
#define PNG_NO_READ_oFFs
#define PNG_NO_SEQUENTIAL_READ_SUPPORTED
#ifndef MOZ_PNG_WRITE
@ -118,6 +127,7 @@
#define PNG_NO_HANDLE_AS_UNKNOWN
#define PNG_NO_INFO_IMAGE
#define PNG_NO_IO_STATE
#define PNG_NO_USER_MEM
#define PNG_NO_FIXED_POINT_SUPPORTED
#define PNG_NO_MNG_FEATURES
@ -126,7 +136,7 @@
#define PNG_NO_ZALLOC_ZERO
#define PNG_NO_ERROR_NUMBERS
#define PNG_NO_EASY_ACCESS
#define PNG_NO_TIME_RFC1123
/* Mangle names of exported libpng functions so different libpng versions
can coexist. It is recommended that if you do this, you give your

Просмотреть файл

@ -1,8 +1,8 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -17,11 +17,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_4_3 Your_png_h_is_not_version_1_4_3;
/* Version information for C files. This had better match the version
* string defined in png.h.
*/
typedef version_1_4_7 Your_png_h_is_not_version_1_4_7;
/* 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
@ -543,21 +539,21 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
png_charp PNGAPI
png_get_copyright(png_structp png_ptr)
png_get_copyright(png_const_structp png_ptr)
{
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
#ifdef PNG_STRING_COPYRIGHT
return PNG_STRING_COPYRIGHT
#else
#ifdef __STDC__
return ((png_charp) PNG_STRING_NEWLINE \
"libpng version 1.4.3 - June 26, 2010" PNG_STRING_NEWLINE \
"libpng version 1.4.7 - April 10, 2011" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2010 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);
#else
return ((png_charp) "libpng version 1.4.3 - June 26, 2010\
return ((png_charp) "libpng version 1.4.7 - April 10, 2011\
Copyright (c) 1998-2010 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
@ -574,23 +570,23 @@ png_get_copyright(png_structp png_ptr)
* it is guaranteed that png.c uses the correct version of png.h.
*/
png_charp PNGAPI
png_get_libpng_ver(png_structp png_ptr)
png_get_libpng_ver(png_const_structp png_ptr)
{
/* Version of *.c files used when building libpng */
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
return ((png_charp) PNG_LIBPNG_VER_STRING);
}
png_charp PNGAPI
png_get_header_ver(png_structp png_ptr)
png_get_header_ver(png_const_structp png_ptr)
{
/* Version of *.h files used when building libpng */
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
return ((png_charp) PNG_LIBPNG_VER_STRING);
}
png_charp PNGAPI
png_get_header_version(png_structp png_ptr)
png_get_header_version(png_const_structp png_ptr)
{
/* Returns longer string containing both version and date */
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
@ -678,7 +674,7 @@ png_convert_size(size_t size)
*/
void /* PRIVATE */
png_64bit_product (long v1, long v2, unsigned long *hi_product,
png_64bit_product(long v1, long v2, unsigned long *hi_product,
unsigned long *lo_product)
{
int a, b, c, d;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.4.3 - June 26, 2010
* libpng version 1.4.7 - April 10, 2011
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Copyright (c) 1998-2011 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.)
*
@ -46,14 +46,14 @@
* includes the resource compiler for Windows DLL configurations.
*/
#ifdef PNG_USER_CONFIG
# include "pngusr.h"
# ifndef PNG_USER_PRIVATEBUILD
# define PNG_USER_PRIVATEBUILD
# endif
# include "pngusr.h"
#endif
/*
* If you create a private DLL you need to define in "pngusr.h" the followings:
* If you create a private DLL you should define in "pngusr.h" the following:
* #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
* the DLL was built>
* e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
@ -61,7 +61,7 @@
* distinguish your DLL from those of the official release. These
* correspond to the trailing letters that come after the version
* number and must match your private DLL name>
* e.g. // private DLL "libpng13gx.dll"
* e.g. // private DLL "libpng14gx.dll"
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
*
* The following macros are also at your disposal if you want to complete the
@ -86,6 +86,18 @@
/* End of material added to libpng-1.2.8 */
/* Added at libpng-1.4.6 */
#ifndef PNG_UNUSED
/* Unused formal parameter warnings are silenced using the following macro
* which is expected to have no bad effects on performance (optimizing
* compilers will probably remove it entirely). Note that if you replace
* it with something other than whitespace, you must include the terminating
* semicolon.
*/
# define PNG_UNUSED(param) (void)param;
#endif
/* End of material added to libpng-1.4.6 */
#ifndef PNG_VERSION_INFO_ONLY
/* This is the size of the compression buffer, and thus the size of
@ -271,11 +283,19 @@
* #define PNG_NO_STDIO
*/
#ifdef _WIN32_WCE
# define PNG_NO_CONSOLE_IO
# define PNG_NO_STDIO
# define PNG_NO_TIME_RFC1123
# ifdef PNG_DEBUG
# undef PNG_DEBUG
# endif
#endif
#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
# define PNG_STDIO_SUPPORTED
#endif
#ifdef PNG_BUILD_DLL
# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
# define PNG_NO_CONSOLE_IO
@ -441,7 +461,7 @@
/* The following uses const char * instead of char * for error
* and warning message functions, so some compilers won't complain.
* If you do not want to use const, define PNG_NO_CONST here.
* If you do not want to use const, define PNG_NO_CONST.
*/
#ifndef PNG_CONST
@ -456,8 +476,10 @@
* library that you will not be using. I wish I could figure out how to
* automate this, but I can't do that without making it seriously hard
* on the users. So if you are not using an ability, change the #define
* to and #undef, and that part of the library will not be compiled. If
* your linker can't find a function, you may want to make sure the
* to an #undef, or pass in PNG_NO_feature and that part of the library
* will not be compiled.
* If your linker can't find a function, you may want to make sure the
* ability is defined here. Some of these depend upon some others being
* defined. I haven't figured out all the interactions here, so you may
* have to experiment awhile to get everything to compile. If you are
@ -1129,7 +1151,7 @@ typedef unsigned char png_byte;
#else
typedef size_t png_size_t;
#endif
#define png_sizeof(x) sizeof(x)
#define png_sizeof(x) (sizeof (x))
/* The following is needed for medium model support. It cannot be in the
* pngpriv.h header. Needs modification for other compilers besides
@ -1251,6 +1273,13 @@ typedef char FAR * FAR * FAR * png_charppp;
# define PNG_DLL
#endif
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
* Don't ignore those warnings; you must also reset the default calling
* convention in your compiler to match your PNGAPI, and you must build
* zlib and your applications the same way you build libpng.
*/
#ifdef __CYGWIN__
# undef PNGAPI
# define PNGAPI __cdecl
@ -1258,14 +1287,11 @@ typedef char FAR * FAR * FAR * png_charppp;
# define PNG_IMPEXP
#endif
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
* Don't ignore those warnings; you must also reset the default calling
* convention in your compiler to match your PNGAPI, and you must build
* zlib and your applications the same way you build libpng.
*/
#ifdef __WATCOMC__
# ifndef PNGAPI
# define PNGAPI
# endif
#endif
#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
# ifndef PNG_NO_MODULEDEF
@ -1350,6 +1376,8 @@ typedef char FAR * FAR * FAR * png_charppp;
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
#endif
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
/* Support for compiler specific function attributes. These are used
* so that where compiler support is available incorrect use of API
* functions in png.h will generate compiler warnings.
@ -1378,15 +1406,15 @@ typedef char FAR * FAR * FAR * png_charppp;
# endif
# ifndef PNG_ALLOCATED
# define PNG_ALLOCATED __attribute__((__malloc__))
# endif
# ifndef PNG_DEPRECATED
# define PNG_DEPRECATED __attribute__((__deprecated__))
# endif
/* This specifically protects structure members that should only be
* accessed from within the library, therefore should be empty during
* a library build.
*/
# ifndef PNG_DEPRECATED
# define PNG_DEPRECATED __attribute__((__deprecated__))
# endif
# ifndef PNG_DEPSTRUCT
# define PNG_DEPSTRUCT __attribute__((__deprecated__))
# endif
@ -1427,7 +1455,7 @@ typedef char FAR * FAR * FAR * png_charppp;
/* memory model/platform independent fns */
#ifndef PNG_ABORT
# ifdef _WINDOWS_
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
# define PNG_ABORT() ExitProcess(0)
# else
# define PNG_ABORT() abort()
@ -1448,7 +1476,8 @@ typedef char FAR * FAR * FAR * png_charppp;
# define png_memset _fmemset
# define png_sprintf sprintf
#else
# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
# /* Favor Windows over C runtime fns */
# define CVT_PTR(ptr) (ptr)
# define CVT_PTR_NOCHECK(ptr) (ptr)
# define png_strcpy lstrcpyA
@ -1468,31 +1497,32 @@ typedef char FAR * FAR * FAR * png_charppp;
# define png_memcpy memcpy
# define png_memset memset
# define png_sprintf sprintf
# ifndef PNG_NO_SNPRINTF
# ifdef _MSC_VER
# define png_snprintf _snprintf /* Added to v 1.2.19 */
# define png_snprintf2 _snprintf
# define png_snprintf6 _snprintf
# else
# define png_snprintf snprintf /* Added to v 1.2.19 */
# define png_snprintf2 snprintf
# define png_snprintf6 snprintf
# endif
# else
/* You don't have or don't want to use snprintf(). Caution: Using
* sprintf instead of snprintf exposes your application to accidental
* or malevolent buffer overflows. If you don't have snprintf()
* as a general rule you should provide one (you can get one from
* Portable OpenSSH).
*/
# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
# endif
# endif
#endif
#ifndef PNG_NO_SNPRINTF
# ifdef _MSC_VER
# define png_snprintf _snprintf /* Added to v 1.2.19 */
# define png_snprintf2 _snprintf
# define png_snprintf6 _snprintf
# else
# define png_snprintf snprintf /* Added to v 1.2.19 */
# define png_snprintf2 snprintf
# define png_snprintf6 snprintf
# endif
#else
/* You don't have or don't want to use snprintf(). Caution: Using
* sprintf instead of snprintf exposes your application to accidental
* or malevolent buffer overflows. If you don't have snprintf()
* as a general rule you should provide one (you can get one from
* Portable OpenSSH).
*/
# define png_snprintf(s1,n,fmt,x1) png_sprintf(s1,fmt,x1)
# define png_snprintf2(s1,n,fmt,x1,x2) png_sprintf(s1,fmt,x1,x2)
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
#endif
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
* to png_alloc_size_t are not necessary; in fact, it is recommended
@ -1503,22 +1533,19 @@ typedef char FAR * FAR * FAR * png_charppp;
* to encounter practical situations that require such conversions.
*/
#if defined(__TURBOC__) && !defined(__FLAT__)
# define png_mem_alloc farmalloc
# define png_mem_free farfree
typedef unsigned long png_alloc_size_t;
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
# define png_mem_alloc(s) halloc(s, 1)
# define png_mem_free hfree
typedef unsigned long png_alloc_size_t;
# else
# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
typedef DWORD png_alloc_size_t;
/* This is an attempt to detect an old Windows system where (int) is
* actually 16 bits, in that case png_malloc must have an argument with a
* bigger size to accomodate the requirements of the library.
*/
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
typedef DWORD png_alloc_size_t;
# else
# define png_mem_alloc malloc
# define png_mem_free free
typedef png_size_t png_alloc_size_t;
# endif
# endif

Просмотреть файл

@ -1,8 +1,8 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.4.0 [January 3, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -306,7 +306,7 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
/* Here if not setjmp support or if png_ptr is null. */
PNG_ABORT();
#ifndef PNG_CONSOLE_IO_SUPPORTED
error_message = error_message; /* Make compiler happy */
PNG_UNUSED(error_message) /* Make compiler happy */
#endif
}
@ -352,9 +352,9 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
fprintf(stderr, PNG_STRING_NEWLINE);
}
#else
warning_message = warning_message; /* Make compiler happy */
PNG_UNUSED(warning_message) /* Make compiler happy */
#endif
png_ptr = png_ptr; /* Make compiler happy */
PNG_UNUSED(png_ptr) /* Make compiler happy */
}
#endif /* PNG_WARNINGS_SUPPORTED */
@ -380,7 +380,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
* pointer before png_write_destroy and png_read_destroy are called.
*/
png_voidp PNGAPI
png_get_error_ptr(png_structp png_ptr)
png_get_error_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return NULL;

Просмотреть файл

@ -1,8 +1,8 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [April 10, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -18,7 +18,8 @@
#include "pngpriv.h"
png_uint_32 PNGAPI
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 flag)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->valid & flag);
@ -28,7 +29,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
}
png_size_t PNGAPI
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->rowbytes);
@ -39,7 +40,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_INFO_IMAGE_SUPPORTED
png_bytepp PNGAPI
png_get_rows(png_structp png_ptr, png_infop info_ptr)
png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->row_pointers);
@ -52,7 +53,7 @@ png_get_rows(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_EASY_ACCESS_SUPPORTED
/* Easy access to info, added in libpng-0.99 */
png_uint_32 PNGAPI
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->width;
@ -61,7 +62,7 @@ png_get_image_width(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->height;
@ -70,7 +71,7 @@ png_get_image_height(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->bit_depth;
@ -79,7 +80,7 @@ png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->color_type;
@ -88,7 +89,7 @@ png_get_color_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->filter_type;
@ -97,7 +98,7 @@ png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->interlace_type;
@ -106,7 +107,7 @@ png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->compression_type;
@ -115,7 +116,7 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -136,7 +137,7 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -157,7 +158,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -180,7 +181,7 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -204,7 +205,7 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
#endif
png_int_32 PNGAPI
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_oFFs_SUPPORTED
@ -226,7 +227,7 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
@ -248,7 +249,7 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
@ -270,7 +271,7 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
@ -293,35 +294,35 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
png_uint_32 PNGAPI
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5));
}
png_uint_32 PNGAPI
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5));
}
png_uint_32 PNGAPI
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5));
}
float PNGAPI
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
*.00003937);
}
float PNGAPI
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
*.00003937);
@ -329,7 +330,7 @@ png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
@ -369,7 +370,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
#endif /* PNG_EASY_ACCESS_SUPPORTED */
png_byte PNGAPI
png_get_channels(png_structp png_ptr, png_infop info_ptr)
png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->channels);
@ -378,7 +379,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
}
png_bytep PNGAPI
png_get_signature(png_structp png_ptr, png_infop info_ptr)
png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->signature);
@ -388,7 +389,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_bKGD_SUPPORTED
png_uint_32 PNGAPI
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
png_color_16p *background)
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
@ -406,7 +407,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_cHRM_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y)
{
@ -437,7 +438,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
png_fixed_point *blue_x, png_fixed_point *blue_y)
@ -472,7 +473,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_gAMA_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr, double *file_gamma)
{
png_debug1(1, "in %s retrieval function", "gAMA");
@ -487,7 +488,7 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
png_fixed_point *int_file_gamma)
{
png_debug1(1, "in %s retrieval function", "gAMA");
@ -505,7 +506,8 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sRGB_SUPPORTED
png_uint_32 PNGAPI
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
int *file_srgb_intent)
{
png_debug1(1, "in %s retrieval function", "sRGB");
@ -521,7 +523,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
#ifdef PNG_iCCP_SUPPORTED
png_uint_32 PNGAPI
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
png_charpp name, int *compression_type,
png_charpp profile, png_uint_32 *proflen)
{
@ -545,7 +547,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sPLT_SUPPORTED
png_uint_32 PNGAPI
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
png_sPLT_tpp spalettes)
{
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
@ -559,7 +561,8 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_hIST_SUPPORTED
png_uint_32 PNGAPI
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_16p *hist)
{
png_debug1(1, "in %s retrieval function", "hIST");
@ -614,7 +617,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_oFFs_SUPPORTED
png_uint_32 PNGAPI
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
{
png_debug1(1, "in %s retrieval function", "oFFs");
@ -633,7 +636,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_pCAL_SUPPORTED
png_uint_32 PNGAPI
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
png_charp *units, png_charpp *params)
{
@ -659,7 +662,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sCAL_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, double *width, double *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
@ -675,7 +678,7 @@ png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, png_charpp width, png_charpp height)
{
if (png_ptr != NULL && info_ptr != NULL &&
@ -694,7 +697,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
@ -727,7 +730,8 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
#endif
png_uint_32 PNGAPI
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
png_colorp *palette,
int *num_palette)
{
png_debug1(1, "in %s retrieval function", "PLTE");
@ -745,7 +749,8 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
#ifdef PNG_sBIT_SUPPORTED
png_uint_32 PNGAPI
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
png_color_8p *sig_bit)
{
png_debug1(1, "in %s retrieval function", "sBIT");
@ -761,8 +766,8 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
#ifdef PNG_TEXT_SUPPORTED
png_uint_32 PNGAPI
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text)
png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
png_textp *text_ptr, int *num_text)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
@ -786,7 +791,8 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
#ifdef PNG_tIME_SUPPORTED
png_uint_32 PNGAPI
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
png_get_tIME(png_const_structp png_ptr, png_infop info_ptr,
png_timep *mod_time)
{
png_debug1(1, "in %s retrieval function", "tIME");
@ -802,7 +808,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
#ifdef PNG_tRNS_SUPPORTED
png_uint_32 PNGAPI
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{
png_uint_32 retval = 0;
@ -848,7 +854,7 @@ png_get_acTL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *num_frames, png_uint_32 *num_plays)
{
png_debug1(1, "in %s retrieval function", "acTL");
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_acTL) &&
num_frames != NULL && num_plays != NULL)
@ -857,7 +863,7 @@ png_get_acTL(png_structp png_ptr, png_infop info_ptr,
*num_plays = info_ptr->num_plays;
return (1);
}
return (0);
}
@ -865,7 +871,7 @@ png_uint_32 PNGAPI
png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_num_frames()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->num_frames);
return (0);
@ -875,7 +881,7 @@ png_uint_32 PNGAPI
png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_num_plays()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->num_plays);
return (0);
@ -889,11 +895,11 @@ png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
png_byte *dispose_op, png_byte *blend_op)
{
png_debug1(1, "in %s retrieval function", "fcTL");
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_fcTL) &&
width != NULL && height != NULL &&
x_offset != NULL && x_offset != NULL &&
width != NULL && height != NULL &&
x_offset != NULL && x_offset != NULL &&
delay_num != NULL && delay_den != NULL &&
dispose_op != NULL && blend_op != NULL)
{
@ -907,7 +913,7 @@ png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
*blend_op = info_ptr->next_frame_blend_op;
return (1);
}
return (0);
}
@ -915,7 +921,7 @@ png_uint_32 PNGAPI
png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_width()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_width);
return (0);
@ -925,7 +931,7 @@ png_uint_32 PNGAPI
png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_height()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_height);
return (0);
@ -935,7 +941,7 @@ png_uint_32 PNGAPI
png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_x_offset()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_x_offset);
return (0);
@ -945,7 +951,7 @@ png_uint_32 PNGAPI
png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_y_offset()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_y_offset);
return (0);
@ -955,7 +961,7 @@ png_uint_16 PNGAPI
png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_delay_num()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_delay_num);
return (0);
@ -965,7 +971,7 @@ png_uint_16 PNGAPI
png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_delay_den()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_delay_den);
return (0);
@ -975,7 +981,7 @@ png_byte PNGAPI
png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_dispose_op()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_dispose_op);
return (0);
@ -985,7 +991,7 @@ png_byte PNGAPI
png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_blend_op()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_blend_op);
return (0);
@ -995,16 +1001,17 @@ png_byte PNGAPI
png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_first_frame_is_hidden()");
if (png_ptr != NULL)
return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
return 0;
}
#endif /* PNG_APNG_SUPPORTED */
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
png_uint_32 PNGAPI
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
png_unknown_chunkpp unknowns)
{
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
@ -1018,7 +1025,7 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte PNGAPI
png_get_rgb_to_gray_status (png_structp png_ptr)
png_get_rgb_to_gray_status(png_const_structp png_ptr)
{
return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
}
@ -1026,14 +1033,14 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
#ifdef PNG_USER_CHUNKS_SUPPORTED
png_voidp PNGAPI
png_get_user_chunk_ptr(png_structp png_ptr)
png_get_user_chunk_ptr(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_chunk_ptr : NULL);
}
#endif
png_size_t PNGAPI
png_get_compression_buffer_size(png_structp png_ptr)
png_get_compression_buffer_size(png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->zbuf_size : 0L);
}
@ -1043,25 +1050,24 @@ png_get_compression_buffer_size(png_structp png_ptr)
/* These functions were added to libpng 1.2.6 and were enabled
* by default in libpng-1.4.0 */
png_uint_32 PNGAPI
png_get_user_width_max (png_structp png_ptr)
png_get_user_width_max(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_width_max : 0);
}
png_uint_32 PNGAPI
png_get_user_height_max (png_structp png_ptr)
png_get_user_height_max(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_height_max : 0);
}
/* This function was added to libpng 1.4.0 */
png_uint_32 PNGAPI
png_get_chunk_cache_max (png_structp png_ptr)
png_get_chunk_cache_max(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_chunk_cache_max : 0);
}
/* This function was added to libpng 1.4.1 */
png_alloc_size_t PNGAPI
png_get_chunk_malloc_max (png_structp png_ptr)
png_get_chunk_malloc_max(png_const_structp png_ptr)
{
return (png_ptr?
png_ptr->user_chunk_malloc_max : 0);
@ -1071,13 +1077,13 @@ png_get_chunk_malloc_max (png_structp png_ptr)
/* These functions were added to libpng 1.4.0 */
#ifdef PNG_IO_STATE_SUPPORTED
png_uint_32 PNGAPI
png_get_io_state (png_structp png_ptr)
png_get_io_state(png_const_structp png_ptr)
{
return png_ptr->io_state;
}
png_bytep PNGAPI
png_get_io_chunk_name (png_structp png_ptr)
png_get_io_chunk_name(png_structp png_ptr)
{
return png_ptr->chunk_name;
}

Просмотреть файл

@ -1,8 +1,8 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [April 10, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -601,7 +601,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
* pointer before png_write_destroy and png_read_destroy are called.
*/
png_voidp PNGAPI
png_get_mem_ptr(png_structp png_ptr)
png_get_mem_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);

Просмотреть файл

@ -1,8 +1,8 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.4.3 [June 26, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -234,9 +234,9 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
}
#ifdef PNG_READ_APNG_SUPPORTED
if (png_ptr->num_frames_read > 0 &&
if (png_ptr->num_frames_read > 0 &&
png_ptr->num_frames_read < info_ptr->num_frames)
{
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
@ -244,7 +244,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
/* Discard trailing IDATs for the first frame */
if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
png_error(png_ptr, "out of place IDAT");
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
@ -262,13 +262,13 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
return;
}
png_ensure_sequence_number(png_ptr, 4);
if (!(png_ptr->mode & PNG_HAVE_fcTL))
{
/* Discard trailing fdATs for frames other than the first */
if (png_ptr->num_frames_read < 2)
png_error(png_ptr, "out of place fdAT");
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
@ -284,7 +284,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_ptr->idat_size = png_ptr->push_length - 4;
png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->process_mode = PNG_READ_IDAT_MODE;
return;
}
}
@ -295,23 +295,23 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr);
return;
}
png_read_reset(png_ptr);
png_ptr->mode &= ~PNG_HAVE_fcTL;
png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
if (!(png_ptr->mode & PNG_HAVE_fcTL))
png_error(png_ptr, "missing required fcTL chunk");
png_read_reinit(png_ptr, info_ptr);
png_progressive_read_reset(png_ptr);
if (png_ptr->frame_info_fn != NULL)
(*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
return;
}
else
@ -327,11 +327,11 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
return;
}
return;
}
#endif /* PNG_READ_APNG_SUPPORTED */
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
if (png_ptr->mode & PNG_AFTER_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
@ -921,7 +921,7 @@ png_push_read_IDAT(png_structp png_ptr)
return;
}
}
else
else
#endif
#ifdef PNG_READ_APNG_SUPPORTED
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)
@ -942,7 +942,7 @@ png_push_read_IDAT(png_structp png_ptr)
}
png_ptr->idat_size = png_ptr->push_length;
#ifdef PNG_READ_APNG_SUPPORTED
if (png_ptr->num_frames_read > 0)
{
@ -1032,7 +1032,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
* or the stream marked as finished.
*/
while (png_ptr->zstream.avail_in > 0 &&
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
{
int ret;
@ -1061,49 +1061,49 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
/* Check for any failure before proceeding. */
if (ret != Z_OK && ret != Z_STREAM_END)
{
/* Terminate the decompression. */
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
/* Terminate the decompression. */
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
/* This may be a truncated stream (missing or
* damaged end code). Treat that as a warning.
*/
* damaged end code). Treat that as a warning.
*/
if (png_ptr->row_number >= png_ptr->num_rows ||
png_ptr->pass > 6)
png_warning(png_ptr, "Truncated compressed data in IDAT");
else
png_error(png_ptr, "Decompression error in IDAT");
png_ptr->pass > 6)
png_warning(png_ptr, "Truncated compressed data in IDAT");
else
png_error(png_ptr, "Decompression error in IDAT");
/* Skip the check on unprocessed input */
/* Skip the check on unprocessed input */
return;
}
/* Did inflate output any data? */
if (png_ptr->zstream.next_out != png_ptr->row_buf)
{
/* Is this unexpected data after the last row?
* If it is, artificially terminate the LZ output
* here.
*/
/* Is this unexpected data after the last row?
* If it is, artificially terminate the LZ output
* here.
*/
if (png_ptr->row_number >= png_ptr->num_rows ||
png_ptr->pass > 6)
png_ptr->pass > 6)
{
/* Extra data. */
png_warning(png_ptr, "Extra compressed data in IDAT");
/* Extra data. */
png_warning(png_ptr, "Extra compressed data in IDAT");
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
/* Do no more processing; skip the unprocessed
* input check below.
*/
/* Do no more processing; skip the unprocessed
* input check below.
*/
return;
}
}
/* Do we have a complete row? */
if (png_ptr->zstream.avail_out == 0)
png_push_process_row(png_ptr);
/* Do we have a complete row? */
if (png_ptr->zstream.avail_out == 0)
png_push_process_row(png_ptr);
}
/* And check for the end of the stream. */
if (ret == Z_STREAM_END)
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
}
/* All the data should have been processed, if anything
@ -1177,7 +1177,7 @@ png_push_process_row(png_structp png_ptr)
if (png_ptr->pass == 6 && png_ptr->height <= 4)
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
@ -1217,7 +1217,7 @@ png_push_process_row(png_structp png_ptr)
for (i = 0; i < 4 && png_ptr->pass == 2; i++)
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
@ -1267,13 +1267,13 @@ png_push_process_row(png_structp png_ptr)
for (i = 0; i < 2 && png_ptr->pass == 4; i++)
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
if (png_ptr->pass == 6) /* Pass 5 might be empty */
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
@ -1292,12 +1292,14 @@ png_push_process_row(png_structp png_ptr)
if (png_ptr->pass == 6) /* Skip top generated row */
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
break;
}
default:
case 6:
{
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
@ -1306,7 +1308,7 @@ png_push_process_row(png_structp png_ptr)
if (png_ptr->pass != 6)
break;
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
}
@ -1391,7 +1393,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
png_error(png_ptr, "Out of place tEXt");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1489,7 +1491,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
png_error(png_ptr, "Out of place zTXt");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1690,7 +1692,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
png_error(png_ptr, "Out of place iTXt");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1817,15 +1819,14 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
{
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS
PNG_HANDLE_CHUNK_ALWAYS
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
&& png_ptr->read_user_chunk_fn == NULL
&& png_ptr->read_user_chunk_fn == NULL
#endif
)
)
#endif
png_chunk_error(png_ptr, "unknown critical chunk");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
@ -1915,7 +1916,7 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
}
void PNGAPI
png_progressive_combine_row (png_structp png_ptr,
png_progressive_combine_row(png_structp png_ptr,
png_bytep old_row, png_bytep new_row)
{
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
@ -1955,7 +1956,7 @@ png_set_progressive_frame_fn(png_structp png_ptr,
#endif
png_voidp PNGAPI
png_get_progressive_ptr(png_structp png_ptr)
png_get_progressive_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);

Просмотреть файл

@ -1,9 +1,9 @@
/* pngpriv.h - private declarations for use inside libpng
*
* libpng version 1.4.3 - June 26, 2010
* libpng version 1.4.7 - April 10, 2011
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Copyright (c) 1998-2011 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.)
*
@ -28,14 +28,16 @@
#include <stdlib.h>
#ifndef PNG_EXTERN
/* The functions exported by PNG_EXTERN are internal functions, which
* aren't usually used outside the library (as far as I know), so it is
* debatable if they should be exported at all. In the future, when it
* is possible to have run-time registry of chunk-handling functions,
* some of these will be made available again.
#define PNG_EXTERN extern
# define PNG_EXTERN extern
*/
#define PNG_EXTERN
# define PNG_EXTERN
#endif
/* Other defines specific to compilers can go here. Try to keep
* them inside an appropriate ifdef/endif pair for portability.
@ -75,10 +77,6 @@
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
defined(_WIN32) || defined(__WIN32__)
# include <windows.h> /* defines _WINDOWS_ macro */
/* I have no idea why is this necessary... */
# ifdef _MSC_VER
# include <malloc.h>
# endif
#endif
/* Various modes of operation. Note that after an init, mode is set to
@ -301,6 +299,9 @@ PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
png_size_t length));
/* Read and check the PNG file signature */
PNG_EXTERN void png_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr));
/* Read the chunk header (length + type name) */
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
@ -481,9 +482,9 @@ PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
PNG_EXTERN void png_write_acTL PNGARG((png_structp png_ptr,
png_uint_32 num_frames, png_uint_32 num_plays));
PNG_EXTERN void png_write_fcTL PNGARG((png_structp png_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
PNG_EXTERN void png_write_fcTL PNGARG((png_structp png_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den,
png_byte dispose_op, png_byte blend_op));
#endif
@ -550,7 +551,7 @@ PNG_EXTERN void png_progressive_read_reset PNGARG((png_structp png_ptr));
#ifdef PNG_WRITE_APNG_SUPPORTED
/* Private, reset some things to become ready for writing next frame */
PNG_EXTERN void png_write_reset PNGARG((png_structp png_ptr));
PNG_EXTERN void png_write_reinit PNGARG((png_structp png_ptr,
PNG_EXTERN void png_write_reinit PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 width, png_uint_32 height));
#endif
@ -706,7 +707,7 @@ PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif /* PNG_READ_iCCP_SUPPORTED */
@ -741,7 +742,7 @@ PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif /* PNG_READ_sPLT_SUPPORTED */
@ -778,7 +779,7 @@ PNG_EXTERN void png_handle_fcTL PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_have_info PNGARG((png_structp png_ptr, png_infop info_ptr));
PNG_EXTERN void png_handle_fdAT PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
PNG_EXTERN void png_ensure_sequence_number PNGARG((png_structp png_ptr,
PNG_EXTERN void png_ensure_sequence_number PNGARG((png_structp png_ptr,
png_uint_32 length));
#endif
@ -874,14 +875,14 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
int filter_type));
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
png_infop end_info_ptr));
/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
extern void png_write_destroy PNGARG((png_structp png_ptr));
PNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr));
#ifdef USE_FAR_KEYWORD /* memory model conversion function */
extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
int check));
#endif /* USE_FAR_KEYWORD */

Просмотреть файл

@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -214,34 +214,12 @@ void PNGAPI
png_read_info(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_info");
if (png_ptr == NULL || info_ptr == NULL)
return;
/* If we haven't checked all of the PNG signature bytes, do so now. */
if (png_ptr->sig_bytes < 8)
{
png_size_t num_checked = png_ptr->sig_bytes,
num_to_check = 8 - num_checked;
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
#endif
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
png_ptr->sig_bytes = 8;
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
{
if (num_checked < 4 &&
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
}
if (num_checked < 3)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}
/* Read and check the PNG file signature. */
png_read_sig(png_ptr, info_ptr);
for (;;)
{
@ -442,22 +420,22 @@ void PNGAPI
png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
{
png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
png_debug(0, "Reading frame head");
if (!(png_ptr->mode & PNG_HAVE_acTL))
png_error(png_ptr, "attempt to png_read_frame_head() but "
"no acTL present");
/* do nothing for the main IDAT */
if (png_ptr->num_frames_read == 0)
return;
png_crc_finish(png_ptr, 0); /* CRC from last IDAT or fdAT chunk */
png_read_reset(png_ptr);
png_ptr->mode &= ~PNG_HAVE_fcTL;
have_chunk_after_DAT = 0;
for (;;)
{
@ -466,13 +444,13 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
PNG_fcTL;
png_byte chunk_length[4];
png_uint_32 length;
png_read_data(png_ptr, chunk_length, 4);
length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
/* discard trailing IDATs for the first frame */
@ -488,7 +466,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
{
png_ensure_sequence_number(png_ptr, length);
/* discard trailing fdATs for frames other than the first */
if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
png_crc_finish(png_ptr, length - 4);
@ -496,7 +474,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
{
png_ptr->idat_size = length - 4;
png_ptr->mode |= PNG_HAVE_IDAT;
break;
}
else
@ -517,7 +495,7 @@ void PNGAPI
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_update_info");
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
@ -539,7 +517,7 @@ void PNGAPI
png_start_read_image(png_structp png_ptr)
{
png_debug(1, "in png_start_read_image");
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
@ -556,14 +534,16 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
PNG_fdAT;
PNG_IEND;
#endif
#ifdef PNG_READ_INTERLACING_SUPPORTED
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
0xff};
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
int ret;
#endif
if (png_ptr == NULL)
return;
png_debug2(1, "in png_read_row (row %lu, pass %d)",
(unsigned long) png_ptr->row_number, png_ptr->pass);
@ -619,6 +599,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 1:
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
{
@ -629,6 +610,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 2:
if ((png_ptr->row_number & 0x07) != 4)
{
@ -639,6 +621,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 3:
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
{
@ -649,6 +632,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 4:
if ((png_ptr->row_number & 3) != 2)
{
@ -659,6 +643,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 5:
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
{
@ -669,6 +654,8 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
default:
case 6:
if (!(png_ptr->row_number & 1))
{
@ -822,7 +809,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
png_bytepp dp;
png_debug(1, "in png_read_rows");
if (png_ptr == NULL)
return;
rp = row;
@ -873,7 +860,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
png_bytepp rp;
png_debug(1, "in png_read_image");
if (png_ptr == NULL)
return;
@ -911,7 +898,7 @@ void PNGAPI
png_read_end(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_end");
if (png_ptr == NULL)
return;
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
@ -1096,7 +1083,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#endif
png_debug(1, "in png_destroy_read_struct");
if (png_ptr_ptr != NULL)
png_ptr = *png_ptr_ptr;
if (png_ptr == NULL)
@ -1172,7 +1159,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
#endif
png_debug(1, "in png_read_destroy");
if (info_ptr != NULL)
png_info_destroy(png_ptr, info_ptr);
@ -1455,8 +1442,8 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
transforms = transforms; /* Quiet compiler warnings */
params = params;
PNG_UNUSED(transforms) /* Quiet compiler warnings */
PNG_UNUSED(params)
}
#endif /* PNG_INFO_IMAGE_SUPPORTED */

Просмотреть файл

@ -1,8 +1,8 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [January 14, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -33,7 +33,7 @@ void /* PRIVATE */
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
png_debug1(4, "reading %d bytes", (int)length);
if (png_ptr->read_data_fn != NULL)
(*(png_ptr->read_data_fn))(png_ptr, data, length);
else

Просмотреть файл

@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [%RDATE%]
* Copyright (c) 1998-2011 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.)
*
@ -26,7 +26,7 @@ void PNGAPI
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
{
png_debug(1, "in png_set_crc_action");
if (png_ptr == NULL)
return;
@ -98,7 +98,7 @@ png_set_background(png_structp png_ptr,
int need_expand, double background_gamma)
{
png_debug(1, "in png_set_background");
if (png_ptr == NULL)
return;
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
@ -686,6 +686,11 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
break;
case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
break;
default:
png_error(png_ptr, "invalid error action in png_set_rgb_to_gray");
break;
}
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
#ifdef PNG_READ_EXPAND_SUPPORTED
@ -828,6 +833,8 @@ png_init_read_transformations(png_structp png_ptr)
}
break;
default:
case 8:
case 16:
@ -1001,7 +1008,7 @@ png_init_read_transformations(png_structp png_ptr)
*/
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations &= ~PNG_GAMMA;
png_ptr->transformations |= PNG_STRIP_ALPHA;
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
}
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
else
@ -1028,6 +1035,9 @@ png_init_read_transformations(png_structp png_ptr)
gs = 1.0 / (png_ptr->background_gamma *
png_ptr->screen_gamma);
break;
default:
png_error(png_ptr, "invalid background gamma type");
}
png_ptr->background_1.gray = (png_uint_16)(pow(
@ -1121,7 +1131,7 @@ png_init_read_transformations(png_structp png_ptr)
/* Handled alpha, still need to strip the channel. */
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations |= PNG_STRIP_ALPHA;
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
}
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
@ -1626,6 +1636,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
@ -1682,6 +1695,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
switch (row_info->bit_depth)
{
default:
break;
case 2:
{
png_bytep bp;
@ -2274,7 +2290,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_debug(1, "in png_do_rgb_to_gray");
if (
if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
@ -2798,6 +2814,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
break;
}
@ -3230,6 +3249,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
@ -3428,6 +3450,9 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
}
}
@ -3522,6 +3547,9 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = 8;
@ -3672,6 +3700,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;

Просмотреть файл

@ -1,8 +1,8 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.4.3 [June 26, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 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,50 +23,98 @@
png_uint_32 PNGAPI
png_get_uint_31(png_structp png_ptr, png_bytep buf)
{
png_uint_32 i = png_get_uint_32(buf);
if (i > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range");
return (i);
}
#ifndef PNG_USE_READ_MACROS
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 PNGAPI
png_get_uint_32(png_bytep buf)
{
png_uint_32 i = ((png_uint_32)(*buf) << 24) +
((png_uint_32)(*(buf + 1)) << 16) +
((png_uint_32)(*(buf + 2)) << 8) +
(png_uint_32)(*(buf + 3));
png_uint_32 val = png_get_uint_32(buf);
return (i);
if (val > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range");
return (val);
}
#ifndef PNG_USE_READ_MACROS
/* The parentheses around "PNGAPI function_name" in the following three
* functions are necessary because they allow the macros to co-exist with
* these (unused but exported) functions.
*/
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 (PNGAPI
png_get_uint_32)(png_bytep buf)
{
png_uint_32 uval = png_get_uint_32(buf);
if ((uval & 0x80000000L) == 0) /* non-negative */
return uval;
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)uval;
}
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
* data is stored in the PNG file in two's complement format, and it is
* assumed that the machine format for signed integers is the same.
* data is stored in the PNG file in two's complement format and there
* is no guarantee that a 'png_int_32' is exactly 32 bits, therefore
* the following code does a two's complement to native conversion.
*/
png_int_32 PNGAPI
png_get_int_32(png_bytep buf)
png_int_32 (PNGAPI
png_get_int_32)(png_bytep buf)
{
png_int_32 i = ((png_int_32)(*buf) << 24) +
((png_int_32)(*(buf + 1)) << 16) +
((png_int_32)(*(buf + 2)) << 8) +
(png_int_32)(*(buf + 3));
png_uint_32 uval = png_get_uint_32(buf);
if ((uval & 0x80000000L) == 0) /* non-negative */
return uval;
return (i);
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)uval;
}
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16 PNGAPI
png_get_uint_16(png_bytep buf)
png_uint_16 (PNGAPI
png_get_uint_16)(png_bytep buf)
{
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
(png_uint_16)(*(buf + 1)));
/* ANSI-C requires an int value to accomodate at least 16 bits so this
* works and allows the compiler not to worry about possible narrowing
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
* than 16 bits either.)
*/
unsigned int val =
((unsigned int)(*buf) << 8) +
((unsigned int)(*(buf + 1)));
return (i);
return (png_uint_16)val;
}
#endif /* PNG_USE_READ_MACROS */
/* Read and check the PNG file signature */
void /* PRIVATE */
png_read_sig(png_structp png_ptr, png_infop info_ptr)
{
png_size_t num_checked, num_to_check;
/* Exit if the user application does not expect a signature. */
if (png_ptr->sig_bytes >= 8)
return;
num_checked = png_ptr->sig_bytes;
num_to_check = 8 - num_checked;
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
#endif
/* The signature must be serialized in a single I/O call. */
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
png_ptr->sig_bytes = 8;
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
{
if (num_checked < 4 &&
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
}
if (num_checked < 3)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}
/* Read the chunk header (length + type name).
* Put the type name into png_ptr->chunk_name, and return the length.
*/
@ -77,32 +125,31 @@ png_read_chunk_header(png_structp png_ptr)
png_uint_32 length;
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that the chunk header is being read.
* PNG_IO_CHUNK_HDR requires a single I/O call.
*/
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
#endif
/* Read the length and the chunk name */
/* Read the length and the chunk name.
* This must be performed in a single I/O call.
*/
png_read_data(png_ptr, buf, 8);
length = png_get_uint_31(png_ptr, buf);
/* Put the chunk name into png_ptr->chunk_name */
/* Put the chunk name into png_ptr->chunk_name. */
png_memcpy(png_ptr->chunk_name, buf + 4, 4);
png_debug2(0, "Reading %s chunk, length = %lu",
png_ptr->chunk_name, length);
png_ptr->chunk_name, (unsigned long)length);
/* Reset the crc and run it over the chunk name */
/* Reset the crc and run it over the chunk name. */
png_reset_crc(png_ptr);
png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
/* Check to see if chunk name is valid */
/* Check to see if chunk name is valid. */
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that chunk data will (possibly) be read.
* PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
/* It is unspecified how many I/O calls will be performed
* during the serialization of the chunk data.
*/
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
#endif
@ -116,6 +163,7 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
{
if (png_ptr == NULL)
return;
png_read_data(png_ptr, buf, length);
png_calculate_crc(png_ptr, buf, length);
}
@ -135,6 +183,7 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
}
if (i)
{
png_crc_read(png_ptr, png_ptr->zbuf, i);
@ -149,11 +198,13 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{
png_chunk_warning(png_ptr, "CRC error");
}
else
{
png_chunk_benign_error(png_ptr, "CRC error");
return (0);
}
return (1);
}
@ -176,6 +227,7 @@ png_crc_error(png_structp png_ptr)
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
need_crc = 0;
}
else /* critical */
{
if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
@ -183,11 +235,10 @@ png_crc_error(png_structp png_ptr)
}
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that the chunk CRC is being read */
/* PNG_IO_CHUNK_CRC requires the I/O to be done at once */
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
#endif
/* The chunk CRC must be serialized in a single I/O call. */
png_read_data(png_ptr, crc_bytes, 4);
if (need_crc)
@ -195,6 +246,7 @@ png_crc_error(png_structp png_ptr)
crc = png_get_uint_32(crc_bytes);
return ((int)(crc != png_ptr->crc));
}
else
return (0);
}
@ -234,6 +286,7 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
if (avail < copy) copy = avail;
png_memcpy(output + count, png_ptr->zbuf, copy);
}
count += avail;
}
@ -267,9 +320,11 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
case Z_BUF_ERROR:
msg = "Buffer error in compressed datastream in %s chunk";
break;
case Z_DATA_ERROR:
msg = "Data error in compressed datastream in %s chunk";
break;
default:
msg = "Incomplete compressed datastream in %s chunk";
break;
@ -369,6 +424,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
png_warning(png_ptr, "png_inflate logic error");
png_free(png_ptr, text);
}
else
png_warning(png_ptr, "Not enough memory to decompress chunk");
}
@ -652,7 +708,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_finish(png_ptr, length);
info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
PNG_UNUSED(info_ptr) /* Quiet compiler warnings about unused info_ptr */
}
#ifdef PNG_READ_gAMA_SUPPORTED
@ -1165,9 +1221,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_bytep entry_start;
png_sPLT_t new_palette;
#ifdef PNG_POINTER_INDEXING_SUPPORTED
png_sPLT_entryp pp;
#endif
int data_length, entry_size, i;
png_uint_32 skip = 0;
png_size_t slength;
@ -1306,7 +1360,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
pp[i].blue = png_get_uint_16(entry_start); entry_start += 2;
pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
}
pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;
}
#endif
@ -1675,7 +1729,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)",
length + 1);
(unsigned long)(length + 1));
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
@ -1813,7 +1867,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)",
length + 1);
(unsigned long)(length + 1));
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
{
@ -1880,9 +1934,6 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr, "malformed height string in sCAL chunk");
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, swidth);
#endif
return;
}
#else
@ -1893,9 +1944,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, swidth);
#endif
return;
}
png_memcpy(sheight, ep, png_strlen(ep));
@ -2357,7 +2406,7 @@ png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_32 num_frames;
png_uint_32 num_plays;
png_uint_32 didSet;
png_debug(1, "in png_handle_acTL");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
@ -2382,13 +2431,13 @@ png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, length);
return;
}
png_crc_read(png_ptr, data, 8);
png_crc_finish(png_ptr, 0);
num_frames = png_get_uint_31(png_ptr, data);
num_plays = png_get_uint_31(png_ptr, data + 4);
/* the set function will do error checking on num_frames */
didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
if(didSet)
@ -2407,9 +2456,11 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_16 delay_den;
png_byte dispose_op;
png_byte blend_op;
png_debug(1, "in png_handle_fcTL");
png_ensure_sequence_number(png_ptr, length);
if (!(png_ptr->mode & PNG_HAVE_IHDR))
{
png_error(png_ptr, "Missing IHDR before fcTL");
@ -2420,13 +2471,13 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
* but correct. PNG_HAVE_IDAT is unset before the frame head is read
* i can't think of a better message */
png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
png_crc_finish(png_ptr, length);
png_crc_finish(png_ptr, length-4);
return;
}
else if (png_ptr->mode & PNG_HAVE_fcTL)
{
png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
png_crc_finish(png_ptr, length);
png_crc_finish(png_ptr, length-4);
return;
}
else if (length != 26)
@ -2435,12 +2486,10 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, length);
return;
}
png_ensure_sequence_number(png_ptr, length);
png_crc_read(png_ptr, data, 22);
png_crc_finish(png_ptr, 0);
width = png_get_uint_31(png_ptr, data);
height = png_get_uint_31(png_ptr, data + 4);
x_offset = png_get_uint_31(png_ptr, data + 8);
@ -2449,21 +2498,29 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
delay_den = png_get_uint_16(data + 18);
dispose_op = data[20];
blend_op = data[21];
if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
png_error(png_ptr, "fcTL for the first frame must have zero offset");
if (png_ptr->num_frames_read == 0 &&
if (png_ptr->num_frames_read == 0 &&
(width != info_ptr->width || height != info_ptr->height))
png_error(png_ptr, "size in first frame's fcTL must match "
"the size in IHDR");
/* the set function will do more error checking */
png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
x_offset, y_offset, delay_num, delay_den,
dispose_op, blend_op);
png_read_reinit(png_ptr, info_ptr);
if (info_ptr != NULL)
{
if (png_ptr->num_frames_read == 0 &&
(width != info_ptr->width || height != info_ptr->height))
png_error(png_ptr, "size in first frame's fcTL must match "
"the size in IHDR");
/* the set function will do more error checking */
png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
x_offset, y_offset, delay_num, delay_den,
dispose_op, blend_op);
png_read_reinit(png_ptr, info_ptr);
}
png_ptr->mode |= PNG_HAVE_fcTL;
}
@ -2481,8 +2538,8 @@ void /* PRIVATE */
png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_ensure_sequence_number(png_ptr, length);
/* This function is only called from png_read_end(), png_read_info(),
/* This function is only called from png_read_end(), png_read_info(),
* and png_push_read_chunk() which means that:
* - the user doesn't want to read this frame
* - or this is an out-of-place fdAT
@ -2496,17 +2553,17 @@ png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
{
png_byte data[4];
png_uint_32 sequence_number;
if (length < 4)
png_error(png_ptr, "invalid fcTL or fdAT chunk found");
png_crc_read(png_ptr, data, 4);
sequence_number = png_get_uint_31(png_ptr, data);
if (sequence_number != png_ptr->next_seq_num)
png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
"number found");
png_ptr->next_seq_num++;
}
#endif /* PNG_READ_APNG_SUPPORTED */
@ -2621,7 +2678,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, skip);
#ifndef PNG_READ_USER_CHUNKS_SUPPORTED
info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
PNG_UNUSED(info_ptr) /* Quiet compiler warnings about unused info_ptr */
#endif
}
@ -3077,7 +3134,7 @@ png_do_read_interlace(png_structp png_ptr)
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
}
#ifndef PNG_READ_PACKSWAP_SUPPORTED
transformations = transformations; /* Silence compiler warning */
PNG_UNUSED(transformations) /* Silence compiler warning */
#endif
}
#endif /* PNG_READ_INTERLACING_SUPPORTED */
@ -3087,7 +3144,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_bytep prev_row, int filter)
{
png_debug(1, "in png_read_filter_row");
png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter);
png_debug2(2, "row = %lu, filter = %d",
(unsigned long)png_ptr->row_number, filter);
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
@ -3278,17 +3336,10 @@ png_read_finish_row(png_structp png_ptr)
{
while (!png_ptr->idat_size)
{
png_byte chunk_length[4];
png_crc_finish(png_ptr, 0);
png_read_data(png_ptr, chunk_length, 4);
png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
png_ptr->idat_size = png_read_chunk_header(png_ptr);
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
png_error(png_ptr, "Not enough image data");
}
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_in = png_ptr->zbuf;
@ -3535,13 +3586,13 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_debug1(3, "width = %lu,", png_ptr->width);
png_debug1(3, "height = %lu,", png_ptr->height);
png_debug1(3, "iwidth = %lu,", png_ptr->iwidth);
png_debug1(3, "num_rows = %lu,", png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes);
png_debug1(3, "width = %lu,", (unsigned long)png_ptr->width);
png_debug1(3, "height = %lu,", (unsigned long)png_ptr->height);
png_debug1(3, "iwidth = %lu,", (unsigned long)png_ptr->iwidth);
png_debug1(3, "num_rows = %lu,", (unsigned long)png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
png_debug1(3, "irowbytes = %lu",
PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
(unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
png_ptr->flags |= PNG_FLAG_ROW_INIT;
}
@ -3585,7 +3636,7 @@ png_progressive_read_reset(png_structp png_ptr)
/* offset to next interlace block in the y direction */
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
if (png_ptr->interlaced)
{
if (!(png_ptr->transformations & PNG_INTERLACE))

Просмотреть файл

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [January 14, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -260,7 +260,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
info_ptr->rowbytes = 0;
else
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
#if defined(PNG_APNG_SUPPORTED)
/* for non-animated png. this may be overwritten from an acTL chunk later */
info_ptr->num_frames = 1;
@ -695,6 +695,13 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
if (text_ptr[i].key == NULL)
continue;
if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
{
png_warning(png_ptr, "text compression mode is out of range");
continue;
}
key_len = png_strlen(text_ptr[i].key);
if (text_ptr[i].compression <= 0)
@ -939,49 +946,49 @@ png_set_sPLT(png_structp png_ptr,
#if defined(PNG_APNG_SUPPORTED)
png_uint_32 PNGAPI
png_set_acTL(png_structp png_ptr, png_infop info_ptr,
png_set_acTL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 num_frames, png_uint_32 num_plays)
{
png_debug1(1, "in %s storage function", "acTL");
if (png_ptr == NULL || info_ptr == NULL)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Call to png_set_acTL() with NULL png_ptr "
"or info_ptr ignored");
return (0);
}
if (num_frames == 0)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Ignoring attempt to set acTL with num_frames zero");
return (0);
}
if (num_frames > PNG_UINT_31_MAX)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Ignoring attempt to set acTL with num_frames > 2^31-1");
return (0);
}
if (num_plays > PNG_UINT_31_MAX)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Ignoring attempt to set acTL with num_plays "
"> 2^31-1");
return (0);
}
info_ptr->num_frames = num_frames;
info_ptr->num_plays = num_plays;
info_ptr->valid |= PNG_INFO_acTL;
return (1);
}
/* delay_num and delay_den can hold any 16-bit values including zero */
png_uint_32 PNGAPI
png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den,
@ -991,15 +998,15 @@ png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Call to png_set_fcTL() with NULL png_ptr or info_ptr "
"ignored");
return (0);
}
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
delay_num, delay_den, dispose_op, blend_op);
/* For efficiency, ignore BLEND_OP_OVER when image is opaque.
* See bug #441971 and #455140
*/
@ -1023,20 +1030,20 @@ png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
info_ptr->next_frame_delay_den = delay_den;
info_ptr->next_frame_dispose_op = dispose_op;
info_ptr->next_frame_blend_op = blend_op;
info_ptr->valid |= PNG_INFO_fcTL;
return (1);
}
void /* PRIVATE */
png_ensure_fcTL_is_valid(png_structp png_ptr,
png_ensure_fcTL_is_valid(png_structp png_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den,
png_byte dispose_op, png_byte blend_op)
{
if (width + x_offset > png_ptr->first_frame_width ||
if (width + x_offset > png_ptr->first_frame_width ||
height + y_offset > png_ptr->first_frame_height)
png_error(png_ptr, "dimensions of a frame are greater than"
"the ones in IHDR");
@ -1064,15 +1071,15 @@ png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
png_byte is_hidden)
{
png_debug(1, "in png_first_frame_is_hidden()");
if (png_ptr == NULL)
return 0;
if(is_hidden)
png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
else
png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
return 1;
}
#endif /* PNG_APNG_SUPPORTED */
@ -1149,7 +1156,7 @@ png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_uint_32 PNGAPI
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
png_permit_mng_features(png_structp png_ptr, png_uint_32 mng_features)
{
png_debug(1, "in png_permit_mng_features");
@ -1263,7 +1270,7 @@ png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* This function was added to libpng 1.2.6 */
void PNGAPI
png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
png_set_user_limits(png_structp png_ptr, png_uint_32 user_width_max,
png_uint_32 user_height_max)
{
/* Images with dimensions larger than these limits will be
@ -1278,7 +1285,7 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
/* This function was added to libpng 1.4.0 */
void PNGAPI
png_set_chunk_cache_max (png_structp png_ptr,
png_set_chunk_cache_max(png_structp png_ptr,
png_uint_32 user_chunk_cache_max)
{
if (png_ptr)
@ -1287,7 +1294,7 @@ png_set_chunk_cache_max (png_structp png_ptr,
/* This function was added to libpng 1.4.1 */
void PNGAPI
png_set_chunk_malloc_max (png_structp png_ptr,
png_set_chunk_malloc_max(png_structp png_ptr,
png_alloc_size_t user_chunk_malloc_max)
{
if (png_ptr)

Просмотреть файл

@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.4.2 [April 29, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [April 10, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -662,7 +662,7 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
* are called.
*/
png_voidp PNGAPI
png_get_user_transform_ptr(png_structp png_ptr)
png_get_user_transform_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);
@ -673,5 +673,5 @@ png_get_user_transform_ptr(png_structp png_ptr)
#endif
}
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -1,8 +1,8 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.4.0 [January 3, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 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.)
*
@ -669,8 +669,8 @@ png_write_row(png_structp png_ptr, png_bytep row)
if (png_ptr == NULL)
return;
png_debug2(1, "in png_write_row (row %ld, pass %d)",
png_ptr->row_number, png_ptr->pass);
png_debug2(1, "in png_write_row (row %lu, pass %d)",
(unsigned long)png_ptr->row_number, png_ptr->pass);
/* Initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
@ -786,7 +786,8 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_ptr->row_info.width);
png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width);
png_debug1(3, "row_info->width = %lu",
(unsigned long)png_ptr->row_info.width);
png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
@ -1458,33 +1459,33 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
/* It is REQUIRED to call this to finish writing the rest of the file */
png_write_end(png_ptr, info_ptr);
transforms = transforms; /* Quiet compiler warnings */
params = params;
PNG_UNUSED(transforms) /* Quiet compiler warnings */
PNG_UNUSED(params)
}
#endif
#if defined(PNG_WRITE_APNG_SUPPORTED)
void PNGAPI
png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_byte blend_op)
{
png_debug(1, "in png_write_frame_head");
/* there is a chance this has been set after png_write_info was called,
* so it would be set but not written. is there a way to be sure? */
if (!(info_ptr->valid & PNG_INFO_acTL))
png_error(png_ptr, "png_write_frame_head(): acTL not set");
png_write_reset(png_ptr);
png_write_reinit(png_ptr, info_ptr, width, height);
if ( !(png_ptr->num_frames_written == 0 &&
if ( !(png_ptr->num_frames_written == 0 &&
(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
delay_num, delay_den, dispose_op, blend_op);
}
@ -1492,9 +1493,8 @@ void PNGAPI
png_write_frame_tail(png_structp png_ptr, png_infop png_info)
{
png_debug(1, "in png_write_frame_tail");
png_ptr->num_frames_written++;
}
#endif /* PNG_WRITE_APNG_SUPPORTED */
#endif /* PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -195,6 +195,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
*dp = (png_byte)v;
break;
}
default:
break;
}
row_info->bit_depth = (png_byte)bit_depth;
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);

Просмотреть файл

@ -246,10 +246,12 @@ png_text_compress(png_structp png_ptr,
*/
/* Set up the compression buffers */
/* TODO: the following cast hides a potential overflow problem. */
png_ptr->zstream.avail_in = (uInt)text_len;
/* NOTE: assume zlib doesn't overwrite the input */
png_ptr->zstream.next_in = (Bytef *)text;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
png_ptr->zstream.next_out = png_ptr->zbuf;
/* This is the same compression loop as in png_write_row() */
do
@ -688,11 +690,29 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
if (length >= 2 &&
png_ptr->height < 16384 && png_ptr->width < 16384)
{
unsigned int z_cinfo;
unsigned int half_z_window_size;
/* Compute the maximum possible length of the datastream */
/* Number of pixels, plus for each row a filter byte and possible
* and possibly a padding byte, so increase the maximum
* size to account for these.
*/
png_uint_32 uncompressed_idat_size = png_ptr->height *
((png_ptr->width *
png_ptr->channels * png_ptr->bit_depth + 15) >> 3);
unsigned int z_cinfo = z_cmf >> 4;
unsigned int half_z_window_size = 1 << (z_cinfo + 7);
/* If it's interlaced, each block of 8 rows is sent as up to
* 14 rows, i.e., 6 additional rows, each with a filter byte
* and possibly a padding byte
*/
if (png_ptr->interlaced)
uncompressed_idat_size += ((png_ptr->height + 7)/8) *
(png_ptr->bit_depth < 8 ? 12 : 6);
z_cinfo = z_cmf >> 4;
half_z_window_size = 1 << (z_cinfo + 7);
while (uncompressed_idat_size <= half_z_window_size &&
half_z_window_size >= 256)
{
@ -721,16 +741,16 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
else
{
png_byte buf[4];
png_write_chunk_start(png_ptr, (png_bytep)png_fdAT, 4 + length);
png_save_uint_32(buf, png_ptr->next_seq_num);
png_write_chunk_data(png_ptr, buf, 4);
png_write_chunk_data(png_ptr, data, length);
png_write_chunk_end(png_ptr);
png_ptr->next_seq_num++;
}
#endif
@ -1748,43 +1768,43 @@ png_write_acTL(png_structp png_ptr,
{
PNG_acTL;
png_byte data[16];
png_debug(1, "in png_write_acTL");
png_ptr->num_frames_to_write = num_frames;
if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
num_frames--;
png_save_uint_32(data, num_frames);
png_save_uint_32(data + 4, num_plays);
png_write_chunk(png_ptr, (png_bytep)png_acTL, data, (png_size_t)8);
}
void /* PRIVATE */
png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_byte blend_op)
{
PNG_fcTL;
png_byte data[26];
png_debug(1, "in png_write_fcTL");
if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
png_error(png_ptr, "x and/or y offset for the first frame aren't 0");
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
height != png_ptr->first_frame_height))
png_error(png_ptr, "width and/or height in the first frame's fcTL "
"don't match the ones in IHDR");
/* more error checking */
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
delay_num, delay_den, dispose_op, blend_op);
png_save_uint_32(data, png_ptr->next_seq_num);
png_save_uint_32(data + 4, width);
png_save_uint_32(data + 8, height);
@ -1794,9 +1814,9 @@ png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_save_uint_16(data + 22, delay_den);
data[24] = dispose_op;
data[25] = blend_op;
png_write_chunk(png_ptr, (png_bytep)png_fcTL, data, (png_size_t)26);
png_ptr->next_seq_num++;
}
#endif /* PNG_WRITE_APNG_SUPPORTED */
@ -2883,24 +2903,24 @@ png_write_reset(png_structp png_ptr)
}
void /* PRIVATE */
png_write_reinit(png_structp png_ptr, png_infop info_ptr,
png_write_reinit(png_structp png_ptr, png_infop info_ptr,
png_uint_32 width, png_uint_32 height)
{
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
height != png_ptr->first_frame_height))
png_error(png_ptr, "width and/or height in the first frame's fcTL "
"don't match the ones in IHDR");
if (width > png_ptr->first_frame_width ||
if (width > png_ptr->first_frame_width ||
height > png_ptr->first_frame_height)
png_error(png_ptr, "width and/or height for a frame greater than"
"the ones in IHDR");
png_set_IHDR(png_ptr, info_ptr, width, height,
info_ptr->bit_depth, info_ptr->color_type,
png_set_IHDR(png_ptr, info_ptr, width, height,
info_ptr->bit_depth, info_ptr->color_type,
info_ptr->interlace_type, info_ptr->compression_type,
info_ptr->filter_type);
png_ptr->width = width;
png_ptr->height = height;
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);

Просмотреть файл

@ -45,6 +45,8 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_STATIC_FILES = test_sample.xul \
test_synthesizeDragStart.xul \
test_synthesizeDrop.xul \
$(NULL)
libs:: $(_STATIC_FILES)

Просмотреть файл

@ -41,8 +41,6 @@
* Assure EventUtils can perform synthesizeDrop as specified
*/
_tests\testing\mochitest\chrome\testing\mochitest\tests\SimpleTest\tests\test_synthesizeDrop.xul
-->
<window title="Mozilla Bug 462172 extra tests for synthesizeDrop"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@ -70,8 +68,8 @@ var drag1 = [[
function doOnDrop(aEvent)
{
gData = aEvent.dataTransfer.getData(drag1[0][0].type);
aEvent.preventDefault; // cancels event and keeps dropEffect
// as was before event.
aEvent.preventDefault(); // cancels event and keeps dropEffect
// as was before event.
}
function doOnDragEnter(aEvent)

Просмотреть файл

@ -41,9 +41,6 @@ VPATH = @srcdir@
relativesrcdir = testing/mochitest/tests/SimpleTest
include $(DEPTH)/config/autoconf.mk
DIRS = tests \
$(NULL)
include $(topsrcdir)/config/rules.mk
_SIMPLETEST_FILES = MozillaFileLogger.js \
quit.js \

Просмотреть файл

@ -1,49 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = testing/mochitest/tests/SimpleTest/tests
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_CHROME_FILES = test_synthesizeDragStart.xul \
test_synthesizeDrop.xul \
$(NULL)
libs:: $(_CHROME_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)

Просмотреть файл

@ -264,7 +264,8 @@ function nextContextMenuTest(desiredHeight)
function testPopupMovement()
{
var button = document.getElementById("label");
var popup = document.getElementById((gTests[gTestIndex] == "panel movement") ? "panel" : "popup");
var isPanelTest = (gTests[gTestIndex] == "panel movement");
var popup = document.getElementById(isPanelTest ? "panel" : "popup");
var screenX, screenY, buttonScreenX, buttonScreenY;
var rect = popup.getBoundingClientRect();
@ -273,21 +274,36 @@ function testPopupMovement()
popup.moveTo(1, 1);
[screenX, screenY] = getScreenXY(popup);
var expectedx = overlapOSChrome ? 1 : (screen.availLeft < 1 ? 1 : screen.availLeft);
var expectedy = overlapOSChrome ? 1 : (screen.availTop < 1 ? 1 : screen.availTop);
var expectedx = 1, expectedy = 1;
if (!isPanelTest && !overlapOSChrome) {
if (screen.availLeft >= 1) expectedx = screen.availLeft;
if (screen.availTop >= 1) expectedy = screen.availTop;
}
is(screenX, expectedx, gTests[gTestIndex] + " (1, 1) x");
is(screenY, expectedy, gTests[gTestIndex] + " (1, 1) y");
popup.moveTo(100, 8000);
var expectedy = (overlapOSChrome ? screen.height + screen.top : screen.availHeight + screen.availTop) -
Math.round(rect.height) - 3;
if (isPanelTest) {
expectedy = 8000;
}
else {
expectedy = (overlapOSChrome ? screen.height + screen.top : screen.availHeight + screen.availTop) -
Math.round(rect.height) - 3;
}
[screenX, screenY] = getScreenXY(popup);
is(screenX, 100, gTests[gTestIndex] + " (100, 8000) x");
is(screenY, expectedy, gTests[gTestIndex] + " (100, 8000) y");
popup.moveTo(6000, 100);
expectedx = (overlapOSChrome ? screen.width + screen.left : screen.availWidth + screen.availLeft) -
Math.round(rect.width) - 3;
if (isPanelTest) {
expectedx = 6000;
}
else {
expectedx = (overlapOSChrome ? screen.width + screen.left : screen.availWidth + screen.availLeft) -
Math.round(rect.width) - 3;
}
[screenX, screenY] = getScreenXY(popup);
is(screenX, expectedx, gTests[gTestIndex] + " (6000, 100) x");

Просмотреть файл

@ -133,6 +133,22 @@ function testtag_datepicker(dp, type, testid)
setDateField("value", "2000-a-19", true, 2002, 6, 15);
setDateField("dateValue", "none", true, 2002, 6, 15);
// grid and popup types can display a different month than the current one
var isGridOrPopup = (type == "grid" || type == "popup");
dp.displayedMonth = 3;
testtag_comparedate(dp, testid + "set displayedMonth",
2002, isGridOrPopup ? 6 : 3, 15, 3);
dp.displayedYear = 2009;
testtag_comparedate(dp, testid + "set displayedYear",
isGridOrPopup ? 2002 : 2009, isGridOrPopup ? 6 : 3, 15, 3, 2009);
if (isGridOrPopup) {
dp.value = "2008-02-29";
dp.displayedYear = 2009;
is(dp.displayedMonth, 1, "set displayedYear during leap year");
}
is(dp.open, false, testid + "open false");
if (type != "popup") {
dp.open = true;
@ -241,7 +257,56 @@ function testtag_datepicker_UI_grid(dp, type, testid)
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up");
is(dp.value, "2003-02-15", testid + "key page up");
// check handling at the start and end of the month
dp.value = "2010-10-01";
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-01");
is(dp.displayedMonth, 8, testid + "key page up 2010-10-01 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear");
dp.value = "2010-10-01";
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-01");
is(dp.displayedMonth, 10, testid + "key page down 2010-10-01 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page down 2010-10-01 displayedYear");
dp.value = "2010-10-31";
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-31");
is(dp.displayedMonth, 8, testid + "key page up 2010-10-31 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear");
dp.value = "2010-10-31";
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-31");
is(dp.displayedMonth, 10, testid + "key page down 2010-10-31 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page up 2010-10-31 displayedYear");
// check handling at the end of february
dp.value = "2010-03-31";
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-03-31");
is(dp.displayedMonth, 1, testid + "key page up 2010-03-31 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page up 2010-03-31 displayedYear");
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-02-28");
is(dp.displayedMonth, 0, testid + "key page up 2010-02-28 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear");
dp.value = "2010-01-31";
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-01-31");
is(dp.displayedMonth, 1, testid + "key page down 2010-01-31 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page up 2010-01-31 displayedYear");
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-02-28");
is(dp.displayedMonth, 2, testid + "key page down 2010-02-28 displayedMonth");
is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear");
// check handling at the end of february during a leap year
dp.value = "2008-01-31";
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2008-01-31");
is(dp.displayedMonth, 1, testid + "key page down 2008-01-31 displayedMonth");
is(dp.displayedYear, 2008, testid + "key page up 2008-01-31 displayedYear");
dp.value = "2008-03-31";
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2008-03-31");
is(dp.displayedMonth, 1, testid + "key page up 2008-03-31 displayedMonth");
is(dp.displayedYear, 2008, testid + "key page up 2008-03-31 displayedYear");
// the value of a read only datepicker cannot be changed
dp.value = "2003-02-15";
dp.readOnly = true;
synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "!change", testid + "key left read only");
is(dp.value, "2003-02-15", testid + "key left read only");
@ -314,7 +379,7 @@ function testtag_getdatestring(year, month, date)
return year + "-" + month + "-" + date;
}
function testtag_comparedate(dp, testid, year, month, date)
function testtag_comparedate(dp, testid, year, month, date, displayedMonth, displayedYear)
{
is(dp.value, testtag_getdatestring(year, month, date), testid + " value");
if (testid.indexOf("initial") == -1)
@ -330,6 +395,8 @@ function testtag_comparedate(dp, testid, year, month, date)
is(dp.year, year, testid + " year");
is(dp.month, month, testid + " month");
is(dp.displayedMonth, displayedMonth ? displayedMonth : month, testid + " displayedMonth");
is(dp.displayedYear, displayedYear ? displayedYear : year, testid + " displayedYear");
is(dp.date, date, testid + " date");
}

Просмотреть файл

@ -27,6 +27,7 @@
SimpleTest.waitForExplicitFinish();
var gShowPopup = false;
var gModifiers = 0;
var iswin = (navigator.platform.indexOf("Win") == 0);
@ -112,7 +113,7 @@ function differentPressed()
list.open = false;
SimpleTest.finish();
checkEnter();
}
function keyCheck(list, key, index, testname)
@ -122,6 +123,50 @@ function keyCheck(list, key, index, testname)
is(list.selectedItem, item, testname + " selectedItem");
}
function checkModifiers(event)
{
var expectedModifiers = (gModifiers == 1);
is(event.shiftKey, expectedModifiers, "shift key pressed");
is(event.ctrlKey, expectedModifiers, "ctrl key pressed");
is(event.altKey, expectedModifiers, "alt key pressed");
is(event.metaKey, expectedModifiers, "meta key pressed");
gModifiers++;
}
function checkEnter()
{
var list = $("list");
list.addEventListener("popuphidden", checkEnterWithModifiers, false);
list.addEventListener("command", checkModifiers, false);
list.open = true;
synthesizeKey("VK_ENTER", { });
}
function checkEnterWithModifiers()
{
is(gModifiers, 1, "modifiers checked when not set");
var list = $("list");
ok(!list.open, "list closed on enter press");
list.removeEventListener("popuphidden", checkEnterWithModifiers, false);
list.addEventListener("popuphidden", done, false);
list.open = true;
synthesizeKey("VK_ENTER", { shiftKey: true, ctrlKey: true, altKey: true, metaKey: true });
}
function done()
{
is(gModifiers, 2, "modifiers checked when set");
var list = $("list");
ok(!list.open, "list closed on enter press with modifiers");
list.removeEventListener("popuphidden", done, false);
SimpleTest.finish();
}
SimpleTest.waitForFocus(runTests);
]]>

Просмотреть файл

@ -20,7 +20,7 @@
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Neil Deakin <enndeakin@sympatico.ca> (Original Author)
- Neil Deakin <enndeakin@gmail.com> (Original Author)
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
@ -645,6 +645,11 @@
</property>
<property name="open" onget="return false;" onset="return val;"/>
<property name="displayedMonth" onget="return this.month;"
onset="this.month = val; return val;"/>
<property name="displayedYear" onget="return this.year;"
onset="this.year = val; return val;"/>
<method name="_setValueNoSync">
<parameter name="aValue"/>
<body>
@ -989,6 +994,25 @@
</setter>
</property>
<property name="displayedMonth">
<getter>
return this._displayedDate.getMonth();
</getter>
<setter>
this._updateUI(this.monthField, val, true);
return val;
</setter>
</property>
<property name="displayedYear">
<getter>
return this._displayedDate.getFullYear();
</getter>
<setter>
this._updateUI(this.yearField, val, true);
return val;
</setter>
</property>
<method name="_init">
<body>
<![CDATA[
@ -1030,15 +1054,30 @@
<method name="_updateUI">
<parameter name="aField"/>
<parameter name="aValue"/>
<parameter name="aIncDecMonth"/>
<parameter name="aCheckMonth"/>
<body>
<![CDATA[
var date;
var currentMonth;
if (aIncDecMonth) {
if (aCheckMonth) {
if (!this._displayedDate)
this._displayedDate = this.dateValue;
this._displayedDate.setMonth(aValue);
var expectedMonth = aValue;
if (aField == this.monthField) {
this._displayedDate.setMonth(aValue);
}
else {
expectedMonth = this._displayedDate.getMonth();
this._displayedDate.setFullYear(aValue);
}
if (expectedMonth != -1 && expectedMonth != 12 &&
expectedMonth != this._displayedDate.getMonth()) {
// If the month isn't what was expected, then the month overflowed.
// Setting the date to 0 will go back to the last day of the right month.
this._displayedDate.setDate(0);
}
date = new Date(this._displayedDate);
currentMonth = this._displayedDate.getMonth();
@ -1251,6 +1290,24 @@
]]>
</setter>
</property>
<property name="displayedMonth">
<getter>
return document.getAnonymousElementByAttribute(this, "anonid", "grid").displayedMonth;
</getter>
<setter>
document.getAnonymousElementByAttribute(this, "anonid", "grid").displayedMonth = val;
return val;
</setter>
</property>
<property name="displayedYear">
<getter>
return document.getAnonymousElementByAttribute(this, "anonid", "grid").displayedYear;
</getter>
<setter>
document.getAnonymousElementByAttribute(this, "anonid", "grid").displayedYear = val;
return val;
</setter>
</property>
</implementation>
</binding>

Просмотреть файл

@ -253,6 +253,11 @@ ifdef MOZ_ENABLE_LIBXUL
include $(srcdir)/libxul-rules.mk
endif
ifeq ($(OS_ARCH),OpenBSD)
# Needed by nsAuthGSSAPI
EXTRA_DSO_LDOPTS += -lkrb5 -lcrypto
endif
ifdef MOZ_JAVAXPCOM
dlldeps-javaxpcom.cpp: $(topsrcdir)/extensions/java/xpcom/src/dlldeps-javaxpcom.cpp
$(INSTALL) $^ .

Просмотреть файл

@ -1,5 +1,3 @@
# LOCALIZATION NOTE: Do not translate <html:br/>
restartTitle=Close %S
restartMessageNoUnlocker=%S is already running, but is not responding. To open a new window, you must first close the existing %S process, or restart your system.
restartMessageUnlocker=%S is already running, but is not responding. The old %S process must be closed to open a new window.

Просмотреть файл

@ -106,15 +106,15 @@ nsGIOMimeApp::GetCommand(nsACString& aCommand)
{
get_commandline_t g_app_info_get_commandline_ptr;
void *libHandle = dlopen("libgio-2.0.so", RTLD_LAZY);
void *libHandle = dlopen("libgio-2.0.so.0", RTLD_LAZY);
if (!libHandle) {
return NS_ERROR_FAILURE;
}
dlerror(); /* clear any existing error */
g_app_info_get_commandline_ptr =
(get_commandline_t) dlsym(libHandle, "g_app_info_get_commandline");
if (dlerror() != NULL) {
const char cmd = *g_app_info_get_commandline_ptr(mApp);
if (dlerror() == NULL) {
const char *cmd = g_app_info_get_commandline_ptr(mApp);
if (!cmd) {
dlclose(libHandle);
return NS_ERROR_FAILURE;
@ -282,6 +282,33 @@ nsGIOMimeApp::SetAsDefaultForFileExtensions(nsACString const& fileExts)
return NS_OK;
}
/**
* Set default application for URI's of a particular scheme
* @param aURIScheme string containing the URI scheme
* @return NS_OK when application was set as default for URI scheme,
* NS_ERROR_FAILURE otherwise
*/
NS_IMETHODIMP
nsGIOMimeApp::SetAsDefaultForURIScheme(nsACString const& aURIScheme)
{
GError *error = NULL;
nsCAutoString contentType("x-scheme-handler/");
contentType.Append(aURIScheme);
g_app_info_set_as_default_for_type(mApp,
contentType.get(),
&error);
if (error) {
g_warning("Cannot set application as default for URI scheme (%s): %s",
PromiseFlatCString(aURIScheme).get(),
error->message);
g_error_free(error);
return NS_ERROR_FAILURE;
}
return NS_OK;
}
nsresult
nsGIOService::Init()
{
@ -321,6 +348,23 @@ nsGIOService::GetMimeTypeFromExtension(const nsACString& aExtension,
}
// used in nsGNOMERegistry
// -----------------------------------------------------------------------------
NS_IMETHODIMP
nsGIOService::GetAppForURIScheme(const nsACString& aURIScheme,
nsIGIOMimeApp** aApp)
{
*aApp = nsnull;
GAppInfo *app_info = g_app_info_get_default_for_uri_scheme(
PromiseFlatCString(aURIScheme).get());
if (app_info) {
nsGIOMimeApp *mozApp = new nsGIOMimeApp(app_info);
NS_ADDREF(*aApp = mozApp);
} else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
nsGIOService::GetAppForMimeType(const nsACString& aMimeType,
nsIGIOMimeApp** aApp)
@ -419,50 +463,23 @@ nsGIOService::CreateAppFromCommand(nsACString const& cmd,
GAppInfo *app_info = NULL, *app_info_from_list = NULL;
GList *apps = g_app_info_get_all();
GList *apps_p = apps;
get_commandline_t g_app_info_get_commandline_ptr;
void *libHandle = dlopen("libgio-2.0.so", RTLD_LAZY);
if (!libHandle) {
return NS_ERROR_FAILURE;
}
dlerror(); /* clear any existing error */
g_app_info_get_commandline_ptr =
(get_commandline_t) dlsym(libHandle, "g_app_info_get_commandline");
if (dlerror() != NULL) {
g_app_info_get_commandline_ptr = NULL;
}
// Try to find relevant and existing GAppInfo in all installed application
// We do this by comparing each GAppInfo's executable with out own
while (apps_p) {
app_info_from_list = (GAppInfo*) apps_p->data;
/* This is a silly test. It just compares app names but not
* commands. This is due to old version of Glib/Gio. The required
* function which allows to do a regular check of existence of desktop file
* is possible by using function g_app_info_get_commandline. This function
* has been introduced in Glib 2.20. */
if (app_info_from_list && strcmp(g_app_info_get_name(app_info_from_list),
PromiseFlatCString(appName).get()) == 0 )
{
if (g_app_info_get_commandline_ptr)
{
/* Following test is only possible with Glib >= 2.20.
* Compare path only by using strncmp */
if (strncmp(g_app_info_get_commandline_ptr(app_info_from_list),
PromiseFlatCString(cmd).get(),
strlen(PromiseFlatCString(cmd).get())) == 0)
{
app_info = app_info_from_list;
break;
} else {
g_object_unref(app_info_from_list);
}
} else {
if (!app_info) {
// If the executable is not absolute, get it's full path
char *executable = g_find_program_in_path(g_app_info_get_executable(app_info_from_list));
if (executable && strcmp(executable, PromiseFlatCString(cmd).get()) == 0) {
g_object_ref (app_info_from_list);
app_info = app_info_from_list;
break;
}
} else {
g_object_unref(app_info_from_list);
g_free(executable);
}
g_object_unref(app_info_from_list);
apps_p = apps_p->next;
}
g_list_free(apps);
@ -477,12 +494,10 @@ nsGIOService::CreateAppFromCommand(nsACString const& cmd,
if (!app_info) {
g_warning("Cannot create application info from command: %s", error->message);
g_error_free(error);
dlclose(libHandle);
return NS_ERROR_FAILURE;
}
nsGIOMimeApp *mozApp = new nsGIOMimeApp(app_info);
NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*appInfo = mozApp);
dlclose(libHandle);
return NS_OK;
}

Просмотреть файл

@ -46,7 +46,7 @@ interface nsIURI;
with nsIGIOService::GetAppForMimeType. */
// 66009894-9877-405b-9321-bf30420e34e6 prev uuid
[scriptable, uuid(e77021b4-4012-407d-b686-7a1f18050109)]
[scriptable, uuid(ca6bad0c-8a48-48ac-82c7-27bb8f510fbe)]
interface nsIGIOMimeApp : nsISupports
{
const long EXPECTS_URIS = 0;
@ -62,6 +62,7 @@ interface nsIGIOMimeApp : nsISupports
void launch(in AUTF8String uri);
void setAsDefaultForMimeType(in AUTF8String mimeType);
void setAsDefaultForFileExtensions(in AUTF8String extensions);
void setAsDefaultForURIScheme(in AUTF8String uriScheme);
};
/*
@ -77,7 +78,7 @@ interface nsIGIOMimeApp : nsISupports
*/
// prev id dea20bf0-4e4d-48c5-b932-dc3e116dc64b
[scriptable, uuid(47e372c2-78bb-4899-8114-56aa7d9cdac5)]
[scriptable, uuid(eda22a30-84e1-4e16-9ca0-cd1553c2b34a)]
interface nsIGIOService : nsISupports
{
@ -87,6 +88,9 @@ interface nsIGIOService : nsISupports
should not include a leading dot. */
AUTF8String getMimeTypeFromExtension(in AUTF8String extension);
/* Obtain the preferred application for opening a given URI scheme */
nsIGIOMimeApp getAppForURIScheme(in AUTF8String aURIScheme);
/* Obtain the preferred application for opening a given MIME type */
nsIGIOMimeApp getAppForMimeType(in AUTF8String mimeType);