зеркало из https://github.com/mozilla/gecko-dev.git
removing bitmap/png, screen capturing, and boxmodel colorpicking functionality from DOM Inspector.
b=211096, r=caillon, sr=jst.
This commit is contained in:
Родитель
2cabcc78b9
Коммит
d6f586015d
|
@ -38,11 +38,6 @@ XPIDLSRCS = inIDOMView.idl \
|
|||
inICSSValueSearch.idl \
|
||||
inIFileSearch.idl \
|
||||
inIDOMUtils.idl \
|
||||
inIScreenCapturer.idl \
|
||||
inIBitmap.idl \
|
||||
inIBitmapDepot.idl \
|
||||
inIBitmapURI.idl \
|
||||
inIPNGEncoder.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[ptr] native nativePRUint8(PRUint8);
|
||||
|
||||
[scriptable, uuid(BACF8FB9-1FE0-40f0-852C-193442B75C0F)]
|
||||
interface inIBitmap : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long width;
|
||||
readonly attribute unsigned long height;
|
||||
|
||||
void init(in unsigned long aWidth, in unsigned long aHeight, in octet aBytesPerPixel);
|
||||
|
||||
wstring getPixelHex(in unsigned long aX, in unsigned long aY);
|
||||
|
||||
wstring putPixel(in unsigned long aX, in unsigned long aY, in octet aR, in octet aG, in octet aB);
|
||||
|
||||
wstring putPixelHex(in unsigned long aX, in unsigned long aY, in wstring aColor);
|
||||
|
||||
[noscript] void GetBits(out nativePRUint8 aBits);
|
||||
};
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsString.h"
|
||||
%}
|
||||
|
||||
interface inIBitmap;
|
||||
|
||||
[scriptable, uuid(9BAA65C2-2C9E-465e-9FE6-29F6C385DD38)]
|
||||
interface inIBitmapDepot : nsISupports
|
||||
{
|
||||
void put(in inIBitmap aBitmap, in AString aName);
|
||||
inIBitmap get(in AString aName);
|
||||
inIBitmap remove(in AString aName);
|
||||
};
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIURI.idl"
|
||||
|
||||
[scriptable, uuid(5F0D8F70-15A9-4c4d-B952-086005A8133C)]
|
||||
interface inIBitmapURI : nsIURI
|
||||
{
|
||||
readonly attribute wstring bitmapName;
|
||||
};
|
|
@ -1,51 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface inIBitmap;
|
||||
interface nsILocalFile;
|
||||
|
||||
[scriptable, uuid(EC4CE7FC-4268-4f6b-868A-6C0FE3863212)]
|
||||
interface inIPNGEncoder : nsISupports
|
||||
{
|
||||
const short BIT8 = 0;
|
||||
const short BIT24 = 1;
|
||||
|
||||
void writePNG(in inIBitmap aBitmap, in nsILocalFile aFile, in short aType);
|
||||
};
|
|
@ -1,52 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindowInternal;
|
||||
interface nsIDOMElement;
|
||||
interface inIBitmap;
|
||||
|
||||
[scriptable, uuid(18EE2F91-99F8-49c6-8638-6474D1E64F2D)]
|
||||
interface inIScreenCapturer : nsISupports
|
||||
{
|
||||
inIBitmap captureElement(in nsIDOMElement aElement);
|
||||
inIBitmap captureRegion(in nsIDOMWindowInternal aWindow, in long aX, in long aY, in long aWidth, in long aHeight);
|
||||
};
|
||||
|
||||
|
|
@ -39,11 +39,6 @@ REQUIRES = xpcom \
|
|||
necko \
|
||||
docshell \
|
||||
view \
|
||||
imglib2 \
|
||||
mimetype \
|
||||
exthandler \
|
||||
$(PNG_REQUIRES) \
|
||||
$(ZLIB_REQUIRES) \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS= \
|
||||
|
@ -55,19 +50,8 @@ CPPSRCS= \
|
|||
inFileSearch.cpp \
|
||||
inDOMUtils.cpp \
|
||||
inLayoutUtils.cpp \
|
||||
inBitmap.cpp \
|
||||
inBitmapDepot.cpp \
|
||||
inBitmapDecoder.cpp \
|
||||
inBitmapProtocolHandler.cpp \
|
||||
inBitmapChannel.cpp \
|
||||
inBitmapURI.cpp \
|
||||
inPNGEncoder.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += win
|
||||
endif
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
# This library is used by other shared libs in a static build
|
||||
FORCE_USE_PIC = 1
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "inBitmap.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inBitmap::inBitmap()
|
||||
: mBits(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
inBitmap::~inBitmap()
|
||||
{
|
||||
delete mBits;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(inBitmap, inIBitmap);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inIBitmap
|
||||
|
||||
// XXX this api currently takes bits per pixel
|
||||
NS_IMETHODIMP
|
||||
inBitmap::Init(PRUint32 aWidth, PRUint32 aHeight, PRUint8 aBytesPerPixel)
|
||||
{
|
||||
mWidth = aWidth;
|
||||
mHeight = aHeight;
|
||||
|
||||
if (aBytesPerPixel == 8) {
|
||||
mBits = new PRUint8[aWidth*aHeight];
|
||||
} else if (aBytesPerPixel == 16) {
|
||||
mBits = new PRUint8[aWidth*aHeight*2];
|
||||
} else if (aBytesPerPixel == 32 || aBytesPerPixel == 24) {
|
||||
mBits = new PRUint8[aWidth*aHeight*3];
|
||||
} else {
|
||||
NS_ERROR("Expected 8, 16, 24 or 32 bits per pixel");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!mBits) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmap::GetWidth(PRUint32* aWidth)
|
||||
{
|
||||
*aWidth = mWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmap::GetHeight(PRUint32* aHeight)
|
||||
{
|
||||
*aHeight = mHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmap::GetBits(PRUint8** aBits)
|
||||
{
|
||||
*aBits = mBits;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmap::GetPixelHex(PRUint32 aX, PRUint32 aY, PRUnichar **_retval)
|
||||
{
|
||||
if (aX < 0 || aX >= mWidth || aY < 0 || aY >= mHeight)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint8* c = mBits + ((aX+(mWidth*aY))*3);
|
||||
PRUint8 b = c[0];
|
||||
PRUint8 g = c[1];
|
||||
PRUint8 r = c[2];
|
||||
|
||||
|
||||
// smprintf won't 0-pad my hex values, so I have to space-pad it
|
||||
// and then replace space characters with zero characters
|
||||
PRUnichar *out = nsTextFormatter::smprintf(NS_LITERAL_STRING("#%2X%2X%2X").get(), r, g, b);
|
||||
if (!out)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for (PRUintn i = 1; i <= 6; ++i)
|
||||
if (out[i] == ' ')
|
||||
out[i] = '0';
|
||||
|
||||
*_retval = out;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmap::PutPixel(PRUint32 aX, PRUint32 aY, PRUint8 aR, PRUint8 aG, PRUint8 aB, PRUnichar **_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmap::PutPixelHex(PRUint32 aX, PRUint32 aY, const PRUnichar *aColor, PRUnichar **_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __inBitmap_h__
|
||||
#define __inBitmap_h__
|
||||
|
||||
#include "inIBitmap.h"
|
||||
|
||||
class inBitmap : public inIBitmap
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INIBITMAP
|
||||
|
||||
inBitmap();
|
||||
virtual ~inBitmap();
|
||||
|
||||
protected:
|
||||
PRUint32 mWidth;
|
||||
PRUint32 mHeight;
|
||||
PRUint8* mBits;
|
||||
};
|
||||
|
||||
#endif // __inBitmap_h__
|
|
@ -1,286 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "inBitmapChannel.h"
|
||||
#include "inIBitmapURI.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "inIBitmap.h"
|
||||
#include "inIBitmapDepot.h"
|
||||
|
||||
inBitmapChannel::inBitmapChannel()
|
||||
{
|
||||
mStatus = NS_OK;
|
||||
}
|
||||
|
||||
inBitmapChannel::~inBitmapChannel()
|
||||
{}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(inBitmapChannel,
|
||||
nsIChannel,
|
||||
nsIRequest)
|
||||
|
||||
nsresult
|
||||
inBitmapChannel::Init(nsIURI* uri)
|
||||
{
|
||||
NS_ASSERTION(uri, "no uri");
|
||||
mUrl = uri;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetName(nsACString &result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::IsPending(PRBool *result)
|
||||
{
|
||||
NS_NOTREACHED("inBitmapChannel::IsPending");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetStatus(nsresult *status)
|
||||
{
|
||||
*status = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::Cancel(nsresult status)
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mStatus = status;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::Suspend(void)
|
||||
{
|
||||
NS_NOTREACHED("inBitmapChannel::Suspend");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::Resume(void)
|
||||
{
|
||||
NS_NOTREACHED("inBitmapChannel::Resume");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChannel methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetOriginalURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mOriginalURI ? mOriginalURI : mUrl;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::SetOriginalURI(nsIURI* aURI)
|
||||
{
|
||||
mOriginalURI = aURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mUrl;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::Open(nsIInputStream **_retval)
|
||||
{
|
||||
printf("A OPENING BITMAP STREAM\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
{
|
||||
nsCOMPtr<inIBitmapDepot> depot(do_GetService("@mozilla.org/inspector/bitmap-depot;1"));
|
||||
if (!depot)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<inIBitmapURI> uri(do_QueryInterface(mUrl));
|
||||
nsXPIDLString durl;
|
||||
uri->GetBitmapName(getter_Copies(durl));
|
||||
nsCOMPtr<inIBitmap> bitmap;
|
||||
depot->Get(durl, getter_AddRefs(bitmap));
|
||||
|
||||
if (!bitmap)
|
||||
return NS_ERROR_FAILURE;
|
||||
PRUint32 w, h;
|
||||
bitmap->GetWidth(&w);
|
||||
bitmap->GetHeight(&h);
|
||||
PRUint8* bitmapBuf;
|
||||
bitmap->GetBits(&bitmapBuf);
|
||||
|
||||
aListener->OnStartRequest(this, ctxt);
|
||||
|
||||
PRUint32 length = (w*h*3) + (sizeof(PRUint32)*2);
|
||||
PRUint8* buffer = new PRUint8[length];
|
||||
PRUint8* bufStart = buffer;
|
||||
PRUint32* wbuf = (PRUint32*) buffer;
|
||||
wbuf[0] = w;
|
||||
wbuf[1] = h;
|
||||
buffer = (PRUint8*)(wbuf+2);
|
||||
|
||||
for (PRUint32 i = 0; i < w*h; ++i) {
|
||||
buffer[0] = bitmapBuf[0];
|
||||
buffer[1] = bitmapBuf[1];
|
||||
buffer[2] = bitmapBuf[2];
|
||||
buffer += 3;
|
||||
bitmapBuf += 3;
|
||||
}
|
||||
|
||||
// turn our string into a stream...and make the appropriate calls on our consumer
|
||||
nsCOMPtr<nsISupports> streamSupports;
|
||||
NS_NewByteInputStream(getter_AddRefs(streamSupports), (const char*)bufStart, length);
|
||||
nsCOMPtr<nsIInputStream> inputStr (do_QueryInterface(streamSupports));
|
||||
aListener->OnDataAvailable(this, ctxt, inputStr, 0, length);
|
||||
aListener->OnStopRequest(this, ctxt, NS_OK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::GetLoadFlags(PRUint32 *aLoadAttributes)
|
||||
{
|
||||
*aLoadAttributes = mLoadAttributes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::SetLoadFlags(PRUint32 aLoadAttributes)
|
||||
{
|
||||
mLoadAttributes = aLoadAttributes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::GetContentType(nsACString &aContentType)
|
||||
{
|
||||
aContentType = NS_LITERAL_CSTRING("image/inspector-bitmap");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::SetContentType(const nsACString &aContentType)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::GetContentCharset(nsACString &aContentCharset)
|
||||
{
|
||||
aContentCharset.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::SetContentCharset(const nsACString &aContentCharset)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
NS_NOTREACHED("inBitmapChannel::SetContentLength");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
||||
{
|
||||
*aSecurityInfo = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef __inBitmapChannel_h___
|
||||
#define __inBitmapChannel_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
class nsIFile;
|
||||
|
||||
class inBitmapChannel : public nsIChannel
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
|
||||
inBitmapChannel();
|
||||
virtual ~inBitmapChannel();
|
||||
|
||||
nsresult Init(nsIURI* uri);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mUrl;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
PRUint32 mLoadAttributes;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsresult mStatus;
|
||||
|
||||
};
|
||||
|
||||
#endif // __inBitmapChannel_h___
|
|
@ -1,141 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "inBitmapDecoder.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIContainerObserver.h"
|
||||
#include "nspr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(inBitmapDecoder);
|
||||
NS_IMPL_THREADSAFE_RELEASE(inBitmapDecoder);
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(inBitmapDecoder)
|
||||
NS_INTERFACE_MAP_ENTRY(imgIDecoder)
|
||||
NS_INTERFACE_MAP_END_THREADSAFE
|
||||
|
||||
inBitmapDecoder::inBitmapDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
inBitmapDecoder::~inBitmapDecoder()
|
||||
{ }
|
||||
|
||||
|
||||
/** imgIDecoder methods **/
|
||||
|
||||
NS_IMETHODIMP inBitmapDecoder::Init(imgILoad *aLoad)
|
||||
{
|
||||
mObserver = do_QueryInterface(aLoad);
|
||||
|
||||
mImage = do_CreateInstance("@mozilla.org/image/container;1");
|
||||
if (!mImage) return NS_ERROR_FAILURE;
|
||||
aLoad->SetImage(mImage);
|
||||
|
||||
mFrame = do_CreateInstance("@mozilla.org/gfx/image/frame;2");
|
||||
if (!mFrame) return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/** nsIOutputStream methods **/
|
||||
|
||||
NS_IMETHODIMP inBitmapDecoder::Close()
|
||||
{
|
||||
if (mObserver)
|
||||
{
|
||||
mObserver->OnStopFrame(nsnull, mFrame);
|
||||
mObserver->OnStopContainer(nsnull, mImage);
|
||||
mObserver->OnStopDecode(nsnull, NS_OK, nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapDecoder::Flush()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapDecoder::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
char *buf = (char *)PR_Malloc(count);
|
||||
if (!buf) return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
|
||||
// read the data from the input stram...
|
||||
PRUint32 readLen;
|
||||
rv = inStr->Read(buf, count, &readLen);
|
||||
|
||||
char *data = buf;
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mObserver->OnStartDecode(nsnull);
|
||||
|
||||
PRUint32* wbuf = (PRUint32*) data;
|
||||
PRInt32 w, h;
|
||||
w = wbuf[0];
|
||||
h = wbuf[1];
|
||||
|
||||
data = (char*) (wbuf+2);
|
||||
|
||||
mImage->Init(w, h, mObserver);
|
||||
if (mObserver)
|
||||
mObserver->OnStartContainer(nsnull, mImage);
|
||||
|
||||
mFrame->Init(0, 0, w, h, gfxIFormats::RGB, 24);
|
||||
mImage->AppendFrame(mFrame);
|
||||
if (mObserver)
|
||||
mObserver->OnStartFrame(nsnull, mFrame);
|
||||
|
||||
PRUint32 bpr;
|
||||
nscoord width, height;
|
||||
mFrame->GetImageBytesPerRow(&bpr);
|
||||
mFrame->GetWidth(&width);
|
||||
mFrame->GetHeight(&height);
|
||||
|
||||
PRUint32 realBpr = width*3;
|
||||
|
||||
PRUint32 i = 0;
|
||||
PRInt32 rownum = 0;
|
||||
do
|
||||
{
|
||||
PRUint8 *line = (PRUint8*)data + i*realBpr;
|
||||
mFrame->SetImageData(line, realBpr, (rownum++)*bpr);
|
||||
|
||||
nsRect r(0, rownum, width, 1);
|
||||
mObserver->OnDataAvailable(nsnull, mFrame, &r);
|
||||
++i;
|
||||
} while(rownum < height);
|
||||
|
||||
|
||||
PR_FREEIF(buf);
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef __inBitmapDecoder_h__
|
||||
#define __inBitmapDecoder_h__
|
||||
|
||||
#include "imgIDecoder.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIDecoderObserver.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "imgILoad.h"
|
||||
|
||||
class inBitmapDecoder : public imgIDecoder
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIDECODER
|
||||
|
||||
inBitmapDecoder();
|
||||
virtual ~inBitmapDecoder();
|
||||
|
||||
private:
|
||||
nsCOMPtr<imgIContainer> mImage;
|
||||
nsCOMPtr<gfxIImageFrame> mFrame;
|
||||
nsCOMPtr<imgIDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
};
|
||||
|
||||
#endif // __inBitmapDecoder_h__
|
|
@ -1,95 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "inBitmapDepot.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "inIBitmap.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inBitmapDepot::inBitmapDepot()
|
||||
{
|
||||
}
|
||||
|
||||
inBitmapDepot::~inBitmapDepot()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(inBitmapDepot, inIBitmapDepot);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inIBitmapDepot
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapDepot::Put(inIBitmap* aBitmap, const nsAString& aName)
|
||||
{
|
||||
nsStringKey key(aName);
|
||||
nsCOMPtr<inIBitmap> bitmap(aBitmap);
|
||||
nsCOMPtr<nsISupports> supports = do_QueryInterface(bitmap);
|
||||
mHash.Put(&key, supports);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapDepot::Get(const nsAString& aName, inIBitmap** _retval)
|
||||
{
|
||||
nsStringKey key(aName);
|
||||
nsCOMPtr<nsISupports> supports = mHash.Get(&key);
|
||||
nsCOMPtr<inIBitmap> bitmap = do_QueryInterface(supports);
|
||||
*_retval = bitmap;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapDepot::Remove(const nsAString& aName, inIBitmap** _retval)
|
||||
{
|
||||
nsStringKey key(aName);
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
mHash.Remove(&key, getter_AddRefs(supports));
|
||||
nsCOMPtr<inIBitmap> bitmap = do_QueryInterface(supports);
|
||||
*_retval = bitmap;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __inBitmapDepot_h__
|
||||
#define __inBitmapDepot_h__
|
||||
|
||||
#include "inIBitmapDepot.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
class inBitmapDepot : public inIBitmapDepot
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INIBITMAPDEPOT
|
||||
|
||||
inBitmapDepot();
|
||||
virtual ~inBitmapDepot();
|
||||
|
||||
protected:
|
||||
nsSupportsHashtable mHash;
|
||||
};
|
||||
|
||||
#endif // __inBitmapDepot_h__
|
|
@ -1,107 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "inBitmapChannel.h"
|
||||
#include "inBitmapURI.h"
|
||||
#include "inBitmapProtocolHandler.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inBitmapProtocolHandler::inBitmapProtocolHandler()
|
||||
{
|
||||
}
|
||||
|
||||
inBitmapProtocolHandler::~inBitmapProtocolHandler()
|
||||
{}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(inBitmapProtocolHandler, nsIProtocolHandler, nsISupportsWeakReference)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler
|
||||
|
||||
NS_IMETHODIMP inBitmapProtocolHandler::GetScheme(nsACString &result)
|
||||
{
|
||||
result = "moz-bitmap";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapProtocolHandler::GetDefaultPort(PRInt32 *result)
|
||||
{
|
||||
*result = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapProtocolHandler::GetProtocolFlags(PRUint32 *result)
|
||||
{
|
||||
*result = URI_NORELATIVE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
|
||||
{
|
||||
// don't override anything.
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapProtocolHandler::NewURI(const nsACString &aSpec,
|
||||
const char *aOriginCharset, // ignored
|
||||
nsIURI *aBaseURI,
|
||||
nsIURI **result)
|
||||
{
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NEWXPCOM(uri, inBitmapURI);
|
||||
if (!uri) return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = uri->SetSpec(aSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
*result = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = uri;
|
||||
NS_ADDREF(*result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP inBitmapProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
NS_NEWXPCOM(channel, inBitmapChannel);
|
||||
|
||||
if (channel)
|
||||
NS_STATIC_CAST(inBitmapChannel*,NS_STATIC_CAST(nsIChannel*, channel))->Init(url);
|
||||
|
||||
*result = channel;
|
||||
NS_IF_ADDREF(*result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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):
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __inBitmapProtocolHandler_h___
|
||||
#define __inBitmapProtocolHandler_h___
|
||||
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
class inBitmapProtocolHandler : public nsIProtocolHandler,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
inBitmapProtocolHandler();
|
||||
virtual ~inBitmapProtocolHandler();
|
||||
};
|
||||
|
||||
#endif // __inBitmapProtocolHandler_h___
|
|
@ -1,267 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "inBitmapURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#define DEFAULT_IMAGE_SIZE 16
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(inBitmapURI, inIBitmapURI, nsIURI)
|
||||
|
||||
#define NS_BITMAP_SCHEME "moz-bitmap:"
|
||||
#define NS_BITMAP_DELIMITER '?'
|
||||
|
||||
inBitmapURI::inBitmapURI()
|
||||
{
|
||||
}
|
||||
|
||||
inBitmapURI::~inBitmapURI()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// inIBitmapURI
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetBitmapName(PRUnichar** aBitmapName)
|
||||
{
|
||||
*aBitmapName = ToNewUnicode(mBitmapName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
inBitmapURI::FormatSpec(nsACString &result)
|
||||
{
|
||||
result = NS_LITERAL_CSTRING(NS_BITMAP_SCHEME "//") + mBitmapName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIURI
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetSpec(nsACString &aSpec)
|
||||
{
|
||||
return FormatSpec(aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetSpec(const nsACString &aSpec)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ioService (do_GetService(kIOServiceCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString scheme;
|
||||
rv = ioService->ExtractScheme(aSpec, scheme);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (strcmp("moz-bitmap", scheme.get()) != 0)
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
nsACString::const_iterator end, colon, delim;
|
||||
aSpec.BeginReading(colon);
|
||||
aSpec.EndReading(end);
|
||||
|
||||
if (!FindCharInReadable(':', colon, end))
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
delim = ++colon;
|
||||
if (!FindCharInReadable(NS_BITMAP_DELIMITER, delim, end))
|
||||
delim = end;
|
||||
|
||||
mBitmapName = Substring(colon, delim);
|
||||
// TODO: parse out other parameters
|
||||
|
||||
if (mBitmapName.IsEmpty())
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetPrePath(nsACString &prePath)
|
||||
{
|
||||
prePath = NS_BITMAP_SCHEME;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetScheme(nsACString &aScheme)
|
||||
{
|
||||
aScheme = "moz-bitmap";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetScheme(const nsACString &aScheme)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetUsername(nsACString &aUsername)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetUsername(const nsACString &aUsername)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetPassword(nsACString &aPassword)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetPassword(const nsACString &aPassword)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetUserPass(nsACString &aUserPass)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetUserPass(const nsACString &aUserPass)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetHostPort(nsACString &aHostPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetHostPort(const nsACString &aHostPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetHost(nsACString &aHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetHost(const nsACString &aHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetPort(PRInt32 *aPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetPort(PRInt32 aPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetPath(nsACString &aPath)
|
||||
{
|
||||
aPath.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SetPath(const nsACString &aPath)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetAsciiSpec(nsACString &aSpec)
|
||||
{
|
||||
return GetSpec(aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetAsciiHost(nsACString &aHost)
|
||||
{
|
||||
return GetHost(aHost);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::GetOriginCharset(nsACString &result)
|
||||
{
|
||||
result.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::Equals(nsIURI *other, PRBool *result)
|
||||
{
|
||||
nsCAutoString spec1;
|
||||
nsCAutoString spec2;
|
||||
|
||||
other->GetSpec(spec2);
|
||||
GetSpec(spec1);
|
||||
|
||||
*result = !nsCRT::strcasecmp(spec1.get(), spec2.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(o_Equals);
|
||||
if (!i_Scheme) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*o_Equals = PL_strcasecmp("moz-bitmap", i_Scheme) ? PR_FALSE : PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::Clone(nsIURI **result)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inBitmapURI::Resolve(const nsACString &relativePath, nsACString &result)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef __inBitmapURI_h__
|
||||
#define __inBitmapURI_h__
|
||||
|
||||
#include "inIBitmapURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class inBitmapURI : public inIBitmapURI
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURI
|
||||
NS_DECL_INIBITMAPURI
|
||||
|
||||
inBitmapURI();
|
||||
virtual ~inBitmapURI();
|
||||
|
||||
protected:
|
||||
nsCString mBitmapName;
|
||||
|
||||
nsresult FormatSpec(nsACString &result);
|
||||
};
|
||||
|
||||
#endif // __inBitmapURI_h__
|
|
@ -1,131 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "inPNGEncoder.h"
|
||||
#include "inIBitmap.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "png.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inPNGEncoder::inPNGEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
inPNGEncoder::~inPNGEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(inPNGEncoder, inIPNGEncoder)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void PNGAPI gPNGErrorHandler(png_structp aPNGStruct, png_const_charp aMsg);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// inIPNGEncoder
|
||||
|
||||
NS_IMETHODIMP
|
||||
inPNGEncoder::WritePNG(inIBitmap *aBitmap, nsILocalFile *aFile, PRInt16 aType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFile);
|
||||
|
||||
FILE *file;
|
||||
nsresult rv = aFile->OpenANSIFileDesc("wb", &file);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRUint8 *bits;
|
||||
aBitmap->GetBits(&bits);
|
||||
PRUint32 width;
|
||||
aBitmap->GetWidth(&width);
|
||||
PRUint32 height;
|
||||
aBitmap->GetHeight(&height);
|
||||
|
||||
png_structp pngStruct;
|
||||
png_infop infoStruct;
|
||||
|
||||
pngStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, gPNGErrorHandler, NULL);
|
||||
infoStruct = png_create_info_struct(pngStruct);
|
||||
png_init_io(pngStruct, file);
|
||||
png_set_compression_level(pngStruct, Z_BEST_COMPRESSION);
|
||||
|
||||
png_set_IHDR(pngStruct, infoStruct, width, height,
|
||||
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
png_write_info(pngStruct, infoStruct);
|
||||
|
||||
ReverseRGB(width, height, bits);
|
||||
PRUint8 *rowPtr = bits;
|
||||
for (PRUint32 row = 0; row < height; ++row) {
|
||||
png_write_row(pngStruct, rowPtr);
|
||||
rowPtr += width * 3;
|
||||
}
|
||||
ReverseRGB(width, height, bits);
|
||||
|
||||
png_write_end(pngStruct, NULL);
|
||||
|
||||
png_destroy_write_struct(&pngStruct, &infoStruct);
|
||||
|
||||
fclose(file);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
inPNGEncoder::ReverseRGB(PRUint32 aWidth, PRUint32 aHeight, PRUint8 *aBits)
|
||||
{
|
||||
PRUint8 temp;
|
||||
PRUint32 row, col;
|
||||
for (row = 0; row < aHeight; ++row) {
|
||||
for (col = 0; col < aWidth; ++col) {
|
||||
temp = aBits[0];
|
||||
aBits[0] = aBits[2];
|
||||
aBits[2] = temp;
|
||||
aBits += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gPNGErrorHandler(png_structp aPNGStruct, png_const_charp aMsg)
|
||||
{
|
||||
printf("ERROR ENCODING PNG IMAGE\n");
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __inPNGEncoder_h__
|
||||
#define __inPNGEncoder_h__
|
||||
|
||||
#include "inIPNGEncoder.h"
|
||||
|
||||
class inPNGEncoder : public inIPNGEncoder
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INIPNGENCODER
|
||||
|
||||
inPNGEncoder();
|
||||
virtual ~inPNGEncoder();
|
||||
|
||||
protected:
|
||||
|
||||
/*
|
||||
* Since inIBitmap stores pixel bytes in BGR order, and the png encoder
|
||||
* needs them in RGB format, this will reverse them prior to encoding.
|
||||
*/
|
||||
|
||||
static void ReverseRGB(PRUint32 aWidth, PRUint32 aHeight, PRUint8* aBits);
|
||||
};
|
||||
|
||||
#endif // __inPNGEncoder_h__
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH=../../../../..
|
||||
topsrcdir=@top_srcdir@
|
||||
srcdir=@srcdir@
|
||||
VPATH=@srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE=inspector
|
||||
LIBRARY_NAME=inscreencap_s
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
gfx \
|
||||
layout \
|
||||
widget \
|
||||
content \
|
||||
locale \
|
||||
dom \
|
||||
necko \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = inScreenCapturer.cpp
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/..
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,189 +0,0 @@
|
|||
/* */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "inScreenCapturer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
#include "inIBitmap.h"
|
||||
#include "inLayoutUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kInspectorCSSUtilsCID, NS_INSPECTORCSSUTILS_CID);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inScreenCapturer::inScreenCapturer()
|
||||
{
|
||||
}
|
||||
|
||||
inScreenCapturer::~inScreenCapturer()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(inScreenCapturer, inIScreenCapturer);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inIScreenCapturer
|
||||
|
||||
NS_IMETHODIMP
|
||||
inScreenCapturer::CaptureElement(nsIDOMElement *aElement, inIBitmap **_retval)
|
||||
{
|
||||
if (!aElement) return NS_ERROR_FAILURE;
|
||||
|
||||
if (!mCSSUtils) {
|
||||
nsresult rv;
|
||||
mCSSUtils = do_GetService(kInspectorCSSUtilsCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> window = inLayoutUtils::GetWindowFor(aElement);
|
||||
if (!window) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
// get the dimensions of the element, which is the region we will be copying
|
||||
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell);
|
||||
if (!frame) return NS_ERROR_FAILURE;
|
||||
nsRect rect;
|
||||
frame->GetRect(rect);
|
||||
nsRect screenpos = inLayoutUtils::GetScreenOrigin(aElement);
|
||||
rect.x = screenpos.x;
|
||||
rect.y = screenpos.y;
|
||||
|
||||
// adjust rect for margins
|
||||
mCSSUtils->AdjustRectForMargins(frame, rect);
|
||||
|
||||
// get scale for converting frame dimensions to pixels
|
||||
nsCOMPtr<nsIPresContext> pcontext;
|
||||
presShell->GetPresContext(getter_AddRefs(pcontext));
|
||||
float t2p;
|
||||
pcontext->GetTwipsToPixels(&t2p);
|
||||
|
||||
// convert twip values to pixels
|
||||
PRInt32 x = NSTwipsToIntPixels(rect.x, t2p);
|
||||
PRInt32 y = NSTwipsToIntPixels(rect.y, t2p);
|
||||
PRInt32 w = NSTwipsToIntPixels(rect.width, t2p);
|
||||
PRInt32 h = NSTwipsToIntPixels(rect.height, t2p);
|
||||
|
||||
// capture that sucker!
|
||||
CaptureRegion(window, x, y, w, h, _retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inScreenCapturer::CaptureRegion(nsIDOMWindowInternal *aWindow,
|
||||
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
|
||||
inIBitmap **_retval)
|
||||
{
|
||||
// get the native device context
|
||||
HDC hdc = ::GetDC(nsnull);
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
|
||||
// determine pixel bit depth
|
||||
PRUint32 depth = ::GetDeviceCaps(hdc, COLORRES);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<inIBitmap> bitmap(do_CreateInstance("@mozilla.org/inspector/bitmap;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = bitmap->Init(aWidth, aHeight, depth);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint8* bits;
|
||||
rv = bitmap->GetBits(&bits);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (depth == 8) {
|
||||
rv = DoCopy8(bits, hdc, aX, aY, aWidth, aHeight);
|
||||
} else if (depth == 16) {
|
||||
rv = DoCopy16(bits, hdc, aX, aY, aWidth, aHeight);
|
||||
} else if (depth == 32 || depth == 24) {
|
||||
rv = DoCopy32(bits, hdc, aX, aY, aWidth, aHeight);
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*_retval = bitmap;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inScreenCapturer
|
||||
|
||||
NS_IMETHODIMP
|
||||
inScreenCapturer::DoCopy32(PRUint8* aBits, HDC aHDC, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
PRUint8* bits = aBits;
|
||||
for (PRInt32 y = 0; y < aHeight; y++) {
|
||||
for (PRInt32 x = 0; x < aWidth; x++) {
|
||||
PRUint32 pixel = ::GetPixel(aHDC, aX+x,aY+y);
|
||||
*bits = NS_GET_B(pixel);
|
||||
*(bits+1) = NS_GET_G(pixel);
|
||||
*(bits+2) = NS_GET_R(pixel);
|
||||
bits += 3;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inScreenCapturer::DoCopy8(PRUint8* aBits, HDC aHDC, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inScreenCapturer::DoCopy16(PRUint8* aBits, HDC aHDC, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __inScreenCapturer_h__
|
||||
#define __inScreenCapturer_h__
|
||||
|
||||
#include "inIScreenCapturer.h"
|
||||
#include "nsIInspectorCSSUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include <windows.h>
|
||||
|
||||
class inScreenCapturer : public inIScreenCapturer
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INISCREENCAPTURER
|
||||
|
||||
inScreenCapturer();
|
||||
~inScreenCapturer();
|
||||
|
||||
protected:
|
||||
static NS_IMETHODIMP DoCopy8(PRUint8* aBits, HDC aHDC, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
static NS_IMETHODIMP DoCopy16(PRUint8* aBits, HDC aHDC, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
static NS_IMETHODIMP DoCopy32(PRUint8* aBits, HDC aHDC, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
nsCOMPtr<nsIInspectorCSSUtils> mCSSUtils;
|
||||
|
||||
};
|
||||
|
||||
#endif // __inScreenCapturer_h__
|
|
@ -43,7 +43,6 @@ REQUIRES = xpcom \
|
|||
widget \
|
||||
locale \
|
||||
necko \
|
||||
imglib2 \
|
||||
$(NULL)
|
||||
IS_COMPONENT = 1
|
||||
|
||||
|
@ -59,25 +58,11 @@ SHARED_LIBRARY_LIBS = \
|
|||
$(DIST)/lib/$(LIB_PREFIX)inspector_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../../base/src/win
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
$(DIST)/lib/$(LIB_PREFIX)inscreencap_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
ifdef GNU_CC
|
||||
OS_LIBS += -lgdi32
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(LIBS_DIR) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(PNG_LIBS) \
|
||||
$(ZLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
|
|
@ -44,15 +44,6 @@
|
|||
#include "inCSSValueSearch.h"
|
||||
#include "inFileSearch.h"
|
||||
#include "inDOMUtils.h"
|
||||
#include "inBitmap.h"
|
||||
#include "inBitmapDepot.h"
|
||||
#include "inBitmapDecoder.h"
|
||||
#include "inBitmapProtocolHandler.h"
|
||||
#include "inPNGEncoder.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "inScreenCapturer.h"
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMView)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inDeepTreeWalker)
|
||||
|
@ -60,15 +51,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(inFlasher)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(inCSSValueSearch)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inFileSearch)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMUtils)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inBitmap)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inBitmapDepot)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inBitmapDecoder)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inBitmapProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inPNGEncoder)
|
||||
|
||||
#ifdef WIN32
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(inScreenCapturer)
|
||||
#endif
|
||||
|
||||
// {FB5C1775-1BBD-4b9c-ABB0-AE7ACD29E87E}
|
||||
#define IN_DOMVIEW_CID \
|
||||
|
@ -94,32 +76,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(inPNGEncoder)
|
|||
#define IN_DOMUTILS_CID \
|
||||
{ 0x40b22006, 0x5dd5, 0x42f2, { 0xbf, 0xe7, 0x7d, 0xbf, 0x7, 0x57, 0xab, 0x8b } }
|
||||
|
||||
// {C4E47704-4C71-43f7-A37C-EF9FCD9ABBC2}
|
||||
#define IN_BITMAP_CID \
|
||||
{ 0xc4e47704, 0x4c71, 0x43f7, { 0xa3, 0x7c, 0xef, 0x9f, 0xcd, 0x9a, 0xbb, 0xc2 } }
|
||||
|
||||
// {99B8BA1F-B6B2-40ed-8BA4-F5EBC9BC1F10}
|
||||
#define IN_BITMAPDEPOT_CID \
|
||||
{ 0x99b8ba1f, 0xb6b2, 0x40ed, { 0x8b, 0xa4, 0xf5, 0xeb, 0xc9, 0xbc, 0x1f, 0x10 } }
|
||||
|
||||
// {9ED21085-3122-45bf-A275-61228EC5B8F2}
|
||||
#define IN_BITMAPDECODER_CID \
|
||||
{ 0x9ed21085, 0x3122, 0x45bf, { 0xa2, 0x75, 0x61, 0x22, 0x8e, 0xc5, 0xb8, 0xf2 } }
|
||||
|
||||
// {D08C5593-6C55-4d69-A0E9-4848D88CDCDA}
|
||||
#define IN_BITMAPPROTOCOLHANDLER_CID \
|
||||
{ 0xd08c5593, 0x6c55, 0x4d69, { 0xa0, 0xe9, 0x48, 0x48, 0xd8, 0x8c, 0xdc, 0xda } }
|
||||
|
||||
// {243533EA-446E-4a7e-A27A-C27890417DEE}
|
||||
#define IN_PNGENCODER_CID \
|
||||
{ 0x243533ea, 0x446e, 0x4a7e, { 0xa2, 0x7a, 0xc2, 0x78, 0x90, 0x41, 0x7d, 0xee } }
|
||||
|
||||
#ifdef WIN32
|
||||
// {ECE14DF2-FC83-469f-83AC-684D5F06B6CE}
|
||||
#define IN_SCREENCAPTURER_CID \
|
||||
{ 0xece14df2, 0xfc83, 0x469f, { 0x83, 0xac, 0x68, 0x4d, 0x5f, 0x6, 0xb6, 0xce } }
|
||||
#endif
|
||||
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "DOM View",
|
||||
|
@ -150,40 +106,7 @@ static const nsModuleComponentInfo components[] =
|
|||
{ "DOM Utils",
|
||||
IN_DOMUTILS_CID,
|
||||
"@mozilla.org/inspector/dom-utils;1",
|
||||
inDOMUtilsConstructor },
|
||||
|
||||
#ifdef WIN32
|
||||
{ "Screen Capturer",
|
||||
IN_SCREENCAPTURER_CID,
|
||||
"@mozilla.org/inspector/screen-capturer;1",
|
||||
inScreenCapturerConstructor },
|
||||
#endif
|
||||
|
||||
{ "Bitmap",
|
||||
IN_BITMAP_CID,
|
||||
"@mozilla.org/inspector/bitmap;1",
|
||||
inBitmapConstructor },
|
||||
|
||||
{ "Bitmap Depot",
|
||||
IN_BITMAPDEPOT_CID,
|
||||
"@mozilla.org/inspector/bitmap-depot;1",
|
||||
inBitmapDepotConstructor },
|
||||
|
||||
{ "Bitmap Channel",
|
||||
IN_BITMAPDECODER_CID,
|
||||
"@mozilla.org/image/decoder;2?type=image/inspector-bitmap",
|
||||
inBitmapDecoderConstructor },
|
||||
|
||||
{ "Bitmap Protocol Handler",
|
||||
IN_BITMAPPROTOCOLHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-bitmap",
|
||||
inBitmapProtocolHandlerConstructor },
|
||||
|
||||
{ "PNG Encoder",
|
||||
IN_PNGENCODER_CID,
|
||||
"@mozilla.org/inspector/png-encoder;1",
|
||||
inPNGEncoderConstructor }
|
||||
inDOMUtilsConstructor }
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsInspectorModule, components)
|
||||
|
|
|
@ -73,7 +73,6 @@ inspector.jar:
|
|||
content/inspector/viewers/dom/pseudoClassDialog.xul (resources/content/viewers/dom/pseudoClassDialog.xul)
|
||||
content/inspector/viewers/boxModel/boxModel.js (resources/content/viewers/boxModel/boxModel.js)
|
||||
content/inspector/viewers/boxModel/boxModel.xul (resources/content/viewers/boxModel/boxModel.xul)
|
||||
content/inspector/viewers/boxModel/colorPicker.xul (resources/content/viewers/boxModel/colorPicker.xul)
|
||||
content/inspector/viewers/jsObject/jsObject.js (resources/content/viewers/jsObject/jsObject.js)
|
||||
content/inspector/viewers/jsObject/jsObject.xul (resources/content/viewers/jsObject/jsObject.xul)
|
||||
content/inspector/viewers/jsObject/evalExprDialog.js (resources/content/viewers/jsObject/evalExprDialog.js)
|
||||
|
|
|
@ -78,13 +78,6 @@ BoxModelViewer.prototype =
|
|||
|
||||
mSubject: null,
|
||||
mPane: null,
|
||||
mBitmap: null,
|
||||
mLastBitmapId: null,
|
||||
mColorPicker: null,
|
||||
mOutlinesReady: false,
|
||||
mOutlines: false,
|
||||
mFills: false,
|
||||
mZoomScale: 1,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// interface inIViewer
|
||||
|
@ -96,39 +89,13 @@ BoxModelViewer.prototype =
|
|||
set subject(aObject)
|
||||
{
|
||||
this.mSubject = aObject;
|
||||
|
||||
if (this.mBitmap) {
|
||||
this.mBitmapDepot.remove(this.mLastBitmapId);
|
||||
this.mBitmap = null;
|
||||
}
|
||||
|
||||
document.getElementById("bxZoomStack").setAttribute("hidden", "true");
|
||||
|
||||
this.updateStatGroup();
|
||||
|
||||
this.updateCommand("cmdZoom", "disabled", true);
|
||||
this.updateCommand("cmdToggleFill", "disabled", true);
|
||||
this.updateCommand("cmdToggleOutlines", "disabled", true);
|
||||
this.updateCommand("cmdOpenColorPicker", "disabled", true);
|
||||
this.updateCommand("cmdSaveImage", "disabled", true);
|
||||
|
||||
this.mObsMan.dispatchEvent("subjectChange", { subject: aObject });
|
||||
},
|
||||
|
||||
initialize: function(aPane)
|
||||
{
|
||||
this.mPane = aPane;
|
||||
|
||||
this.mImgZoom = document.getElementById("imgZoom");
|
||||
|
||||
this.mScreenCap = XPCU.getService("@mozilla.org/inspector/screen-capturer;1", "inIScreenCapturer");
|
||||
if (this.mScreenCap)
|
||||
this.mBitmapDepot = XPCU.getService("@mozilla.org/inspector/bitmap-depot;1", "inIBitmapDepot");
|
||||
else {
|
||||
// screen capturer may not be implemented on all platforms, so hide the fancy stuff
|
||||
document.getElementById("bxCaptureStuff").setAttribute("hidden", "true");
|
||||
}
|
||||
|
||||
aPane.notifyViewerReady(this);
|
||||
},
|
||||
|
||||
|
@ -151,148 +118,6 @@ BoxModelViewer.prototype =
|
|||
|
||||
addObserver: function(aEvent, aObserver) { this.mObsMan.addObserver(aEvent, aObserver); },
|
||||
removeObserver: function(aEvent, aObserver) { this.mObsMan.removeObserver(aEvent, aObserver); },
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// image capture
|
||||
|
||||
capture: function()
|
||||
{
|
||||
// perform screen capture, cache image, and display image
|
||||
if (this.mScreenCap) {
|
||||
try {
|
||||
var bitmap = this.mScreenCap.captureElement(this.mSubject);
|
||||
} catch (ex) {
|
||||
// failed to do screen capture - die silently
|
||||
return;
|
||||
}
|
||||
|
||||
if (bitmap) {
|
||||
// create unique id for the bitmap and store it in bitmap depot
|
||||
var bitmapId = "inspector-box-object" + (new Date()).getTime();
|
||||
this.mBitmap = bitmap;
|
||||
this.mLastBitmapId = bitmapId;
|
||||
this.mBitmapDepot.put(bitmap, bitmapId);
|
||||
|
||||
// display bitmap in document
|
||||
document.getElementById("bxZoomStack").removeAttribute("hidden");
|
||||
this.mImgZoom.setAttribute("src", "moz-bitmap:"+bitmapId);
|
||||
|
||||
// zoom in to current zoom setting
|
||||
this.zoom(document.getElementById("mlZoom").value);
|
||||
|
||||
// enable all commands sensitive to presence of bitmap
|
||||
this.updateCommand("cmdZoom", "disabled", null);
|
||||
this.updateCommand("cmdToggleFill", "disabled", null);
|
||||
this.updateCommand("cmdToggleOutlines", "disabled", null);
|
||||
this.updateCommand("cmdOpenColorPicker", "disabled", null);
|
||||
this.updateCommand("cmdSaveImage", "disabled", null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
zoomMenulist: function()
|
||||
{
|
||||
var ml = document.getElementById("mlZoom");
|
||||
this.zoom(ml.value);
|
||||
},
|
||||
|
||||
zoom: function(aScale)
|
||||
{
|
||||
var s = parseInt(aScale);
|
||||
this.mZoomScale = s;
|
||||
var w = this.mBitmap.width * s;
|
||||
var h = this.mBitmap.height * s;
|
||||
this.mImgZoom.setAttribute("width", w);
|
||||
this.mImgZoom.setAttribute("height", h);
|
||||
|
||||
this.mOutlinesReady = false;
|
||||
if (this.showOutlines || this.fillOutlines)
|
||||
this.calculateOutlines();
|
||||
},
|
||||
|
||||
get showOutlines()
|
||||
{
|
||||
return document.getElementById("cbxShowOutlines").getAttribute("checked") == "true";
|
||||
},
|
||||
|
||||
get fillOutlines()
|
||||
{
|
||||
return document.getElementById("cbxFillOutlines").getAttribute("checked") == "true";
|
||||
},
|
||||
|
||||
getSubjectComputedStyle: function()
|
||||
{
|
||||
var view = this.mSubject.ownerDocument.defaultView;
|
||||
return view.getComputedStyle(this.mSubject, "");
|
||||
},
|
||||
|
||||
calculateOutlines: function()
|
||||
{
|
||||
var computed = this.getSubjectComputedStyle();
|
||||
var s = this.mZoomScale;
|
||||
|
||||
// fill out the margin outline
|
||||
var mt = parseInt(computed.getPropertyCSSValue("margin-top").cssText) * s;
|
||||
var mr = parseInt(computed.getPropertyCSSValue("margin-right").cssText) * s;
|
||||
var mb = parseInt(computed.getPropertyCSSValue("margin-bottom").cssText) * s;
|
||||
var ml = parseInt(computed.getPropertyCSSValue("margin-left").cssText) * s;
|
||||
var bx = document.getElementById("bxMargin");
|
||||
bx.setAttribute("style", (mt ? ("padding-top: " + mt + "px;") : "") +
|
||||
(mr ? ("padding-right: " + mr + "px;") : "") +
|
||||
(mb ? ("padding-bottom: " + mb + "px;") : "") +
|
||||
(ml ? ("padding-left: " + ml + "px;") : ""));
|
||||
|
||||
// fill out the border outline
|
||||
var bt = parseInt(computed.getPropertyCSSValue("border-top-width").cssText) * s;
|
||||
var br = parseInt(computed.getPropertyCSSValue("border-right-width").cssText) * s;
|
||||
var bb = parseInt(computed.getPropertyCSSValue("border-bottom-width").cssText) * s;
|
||||
var bl = parseInt(computed.getPropertyCSSValue("border-left-width").cssText) * s;
|
||||
bx = document.getElementById("bxBorder");
|
||||
bx.setAttribute("style", (bt ? ("padding-top: " + (bt-1) + "px;") : "") +
|
||||
(br ? ("padding-right: " + (br-1) + "px;") : "") +
|
||||
(bb ? ("padding-bottom: " + (bb-1) + "px;") : "") +
|
||||
(bl ? ("padding-left: " + (bl-1) + "px;") : ""));
|
||||
|
||||
// fill out the padding outline
|
||||
var pt = parseInt(computed.getPropertyCSSValue("padding-top").cssText) * s;
|
||||
var pr = parseInt(computed.getPropertyCSSValue("padding-right").cssText) * s;
|
||||
var pb = parseInt(computed.getPropertyCSSValue("padding-bottom").cssText) * s;
|
||||
var pl = parseInt(computed.getPropertyCSSValue("padding-left").cssText) * s;
|
||||
bx = document.getElementById("bxPadding");
|
||||
bx.setAttribute("style", (pt ? ("padding-top: " + (pt-2) + "px;") : "") +
|
||||
(pr ? ("padding-right: " + (pr-2) + "px;") : "") +
|
||||
(pb ? ("padding-bottom: " + (pb-2) + "px;") : "") +
|
||||
(pl ? ("padding-left: " + (pl-2) + "px;") : ""));
|
||||
|
||||
this.mOutlinesReady = true;
|
||||
},
|
||||
|
||||
toggleOutlines: function()
|
||||
{
|
||||
this.mOutlines = !this.mOutlines;
|
||||
document.getElementById("bxMargin").setAttribute("outline", this.mOutlines);
|
||||
document.getElementById("bxBorder").setAttribute("outline", this.mOutlines);
|
||||
document.getElementById("bxPadding").setAttribute("outline", this.mOutlines);
|
||||
document.getElementById("bxContent").setAttribute("outline", this.mOutlines);
|
||||
|
||||
if (!this.mOutlinesReady)
|
||||
this.calculateOutlines();
|
||||
},
|
||||
|
||||
toggleFill: function()
|
||||
{
|
||||
this.mFills = !this.mFills;
|
||||
document.getElementById("bxMargin").setAttribute("fill", this.mFills);
|
||||
document.getElementById("bxBorder").setAttribute("fill", this.mFills);
|
||||
document.getElementById("bxPadding").setAttribute("fill", this.mFills);
|
||||
document.getElementById("bxContent").setAttribute("fill", this.mFills);
|
||||
|
||||
if (!this.mOutlinesReady)
|
||||
this.calculateOutlines();
|
||||
},
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// statistical updates
|
||||
|
@ -303,13 +128,6 @@ BoxModelViewer.prototype =
|
|||
this.showStatGroup(ml.value);
|
||||
},
|
||||
|
||||
switchStatGroup: function(aGroup)
|
||||
{
|
||||
var ml = document.getElementById("mlStats");
|
||||
ml.value = aGroup;
|
||||
this.showStatGroup(aGroup);
|
||||
},
|
||||
|
||||
showStatGroup: function(aGroup)
|
||||
{
|
||||
if (aGroup == "position") {
|
||||
|
@ -369,6 +187,12 @@ BoxModelViewer.prototype =
|
|||
}
|
||||
},
|
||||
|
||||
getSubjectComputedStyle: function()
|
||||
{
|
||||
var view = this.mSubject.ownerDocument.defaultView;
|
||||
return view.getComputedStyle(this.mSubject, "");
|
||||
},
|
||||
|
||||
showMarginStats: function()
|
||||
{
|
||||
var style = this.getSubjectComputedStyle();
|
||||
|
@ -393,19 +217,6 @@ BoxModelViewer.prototype =
|
|||
this.showSideStats("padding", data);
|
||||
},
|
||||
|
||||
onRegionOver: function(aEvent)
|
||||
{
|
||||
if (aEvent.target == document.getElementById("bxMargin")) { // margin area
|
||||
this.switchStatGroup("margin");
|
||||
} else if (aEvent.target == document.getElementById("bxBorder")) { // border area
|
||||
this.switchStatGroup("border");
|
||||
} else if (aEvent.target == document.getElementById("bxPadding")) { // padding area
|
||||
this.switchStatGroup("padding");
|
||||
} else if (aEvent.target == document.getElementById("bxContent")) { // content area
|
||||
this.switchStatGroup("dimension");
|
||||
}
|
||||
},
|
||||
|
||||
showSideStats: function(aName, aData)
|
||||
{
|
||||
this.showStatistic(1, 1, aName+"-top", aData[0]);
|
||||
|
@ -416,11 +227,6 @@ BoxModelViewer.prototype =
|
|||
this.showStatistic(3, 2, "", "");
|
||||
},
|
||||
|
||||
onRegionOut: function(aEvent)
|
||||
{
|
||||
this.switchStatGroup("position");
|
||||
},
|
||||
|
||||
readMarginStyle: function(aStyle, aSide)
|
||||
{
|
||||
return aStyle.getPropertyCSSValue("margin-"+aSide).cssText;
|
||||
|
@ -441,147 +247,5 @@ BoxModelViewer.prototype =
|
|||
style + " " +
|
||||
aStyle.getPropertyCSSValue("border-"+aSide+"-color").cssText;
|
||||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// color picking
|
||||
|
||||
openColorPicker: function()
|
||||
{
|
||||
if (this.mColorPicker) return;
|
||||
|
||||
this.mColorPicker =
|
||||
window.openDialog("chrome://inspector/content/viewers/boxModel/colorPicker.xul",
|
||||
"_blank", "chrome,dependent");
|
||||
|
||||
var cmd = document.getElementById("cmdOpenColorPicker");
|
||||
cmd.setAttribute("disabled", "true");
|
||||
},
|
||||
|
||||
onColorPickerClosed: function()
|
||||
{
|
||||
this.mColorPicker = null;
|
||||
|
||||
var cmd = document.getElementById("cmdOpenColorPicker");
|
||||
cmd.removeAttribute("disabled");
|
||||
},
|
||||
|
||||
startPickColor: function(aDialogWin)
|
||||
{
|
||||
this.mColorDialogWin = aDialogWin;
|
||||
this.mColorPicking = true;
|
||||
|
||||
var box = document.getElementById("bxZoomStack");
|
||||
box.addEventListener("mousemove", ColorPickMouseMove, false);
|
||||
box.addEventListener("mousedown", ColorPickMouseDown, false);
|
||||
},
|
||||
|
||||
stopPickColor: function()
|
||||
{
|
||||
if (!this.mColorPicking) return;
|
||||
this.mColorPicking = false;
|
||||
|
||||
var box = document.getElementById("bxZoomStack");
|
||||
box.removeEventListener("mousemove", ColorPickMouseMove, false);
|
||||
box.removeEventListener("mousedown", ColorPickMouseDown, false);
|
||||
|
||||
this.mColorDialogWin.onStopPicking();
|
||||
},
|
||||
|
||||
captureColor: function(aEvent)
|
||||
{
|
||||
var bx = document.getElementById("bxMargin").boxObject;
|
||||
var x = aEvent.clientX - bx.x;
|
||||
var y = aEvent.clientY - bx.y;
|
||||
|
||||
var c = this.mBitmap.getPixelHex(Math.floor(x/this.mZoomScale), Math.floor(y/this.mZoomScale));
|
||||
this.showColor(c);
|
||||
},
|
||||
|
||||
showColor: function(aColor)
|
||||
{
|
||||
var doc = this.mColorDialogWin.document;
|
||||
var tx = doc.getElementById("txColor");
|
||||
tx.setAttribute("value", aColor);
|
||||
tx = doc.getElementById("bxColorSwatch");
|
||||
tx.setAttribute("style", "background-color: " + aColor);
|
||||
},
|
||||
|
||||
saveImage: function()
|
||||
{
|
||||
var encoder = XPCU.createInstance("@mozilla.org/inspector/png-encoder;1", "inIPNGEncoder");
|
||||
var path = FilePickerUtils.pickFile("Save Image as PNG", "", ["filterAll"], "Save");
|
||||
if (path)
|
||||
encoder.writePNG(this.mBitmap, path, 24);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// miscellaneous
|
||||
|
||||
updateCommand: function(aCmd, aAttr, aValue)
|
||||
{
|
||||
if (aValue == null)
|
||||
document.getElementById(aCmd).removeAttribute(aAttr);
|
||||
else
|
||||
document.getElementById(aCmd).setAttribute(aAttr, aValue);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// image scrolling
|
||||
/*
|
||||
startScroll: function(aEvent)
|
||||
{
|
||||
var zoomBx = document.getElementById("sbxZoom");
|
||||
zoomBx.addEventListener("mousemove", ImageScrollMouseMove, false);
|
||||
zoomBx.addEventListener("mouseup", ImageScrollMouseUp, false);
|
||||
|
||||
this.mScrollBaseX = aEvent.clientX;
|
||||
this.mScrollBaseY = aEvent.clientY;
|
||||
},
|
||||
|
||||
stopScroll: function(aEvent)
|
||||
{
|
||||
var zoomBx = document.getElementById("sbxZoom");
|
||||
zoomBx.removeEventListener("mousemove", ImageScrollMouseMove, false);
|
||||
zoomBx.removeEventListener("mouseup", ImageScrollMouseUp, false);
|
||||
},
|
||||
|
||||
doScroll: function(aEvent)
|
||||
{
|
||||
var zoomBx = document.getElementById("sbxZoom");
|
||||
var bx = zoomBx.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxModel);
|
||||
|
||||
var xd = aEvent.clientX - this.mScrollBaseX;
|
||||
var yd = aEvent.clientY - this.mScrollBaseY;
|
||||
this.mScrollBaseX += xd;
|
||||
this.mScrollBaseY += yd;
|
||||
|
||||
var xdata = {};
|
||||
var ydata = {};
|
||||
bx.getPosition(xdata, ydata);
|
||||
|
||||
// scrollBy is not implemented yet :(
|
||||
bx.scrollTo(xdata.value-(8*xd), ydata.value-(8*yd));
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
function ColorPickMouseMove(aEvent)
|
||||
{
|
||||
viewer.captureColor(aEvent);
|
||||
}
|
||||
|
||||
function ColorPickMouseDown()
|
||||
{
|
||||
viewer.stopPickColor();
|
||||
}
|
||||
|
||||
function ImageScrollMouseMove(aEvent)
|
||||
{
|
||||
viewer.doScroll(aEvent);
|
||||
}
|
||||
|
||||
function ImageScrollMouseUp(aEvent)
|
||||
{
|
||||
viewer.stopScroll(aEvent);
|
||||
}
|
||||
|
|
|
@ -18,17 +18,7 @@
|
|||
<script type="application/x-javascript" src="chrome://inspector/content/utils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/events/ObserverManager.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/system/FilePickerUtils.js"/>
|
||||
|
||||
<commandset id="cmdsBoxModel">
|
||||
<command id="cmdCapture" oncommand="viewer.capture()"/>
|
||||
<command id="cmdSaveImage" oncommand="viewer.saveImage()"/>
|
||||
<command id="cmdOpenColorPicker" oncommand="viewer.openColorPicker()"/>
|
||||
<command id="cmdToggleOutlines" oncommand="viewer.toggleOutlines()"/>
|
||||
<command id="cmdToggleFill" oncommand="viewer.toggleFill()"/>
|
||||
<command id="cmdZoom" oncommand="viewer.zoomMenulist()"/>
|
||||
</commandset>
|
||||
|
||||
<groupbox>
|
||||
<caption>
|
||||
<menulist id="mlStats" value="position" oncommand="viewer.showStatGroup(this.value)">
|
||||
|
@ -70,45 +60,5 @@
|
|||
</rows>
|
||||
</grid>
|
||||
</groupbox>
|
||||
|
||||
<vbox id="bxCaptureStuff" flex="1">
|
||||
<groupbox id="tbxImage">
|
||||
<caption label="&boxImage.label;"/>
|
||||
<hbox align="center" flex="1">
|
||||
<button label="&boxImageCapture.label;" command="cmdCapture"/>
|
||||
<button label="&boxColorPicker.label;" command="cmdOpenColorPicker"/>
|
||||
<button label="&boxSaveImage.label;" command="cmdSaveImage"/>
|
||||
<spacer flex="1"/>
|
||||
|
||||
<checkbox id="cbxShowOutlines" label="&boxShowOutlines.label;" command="cmdToggleOutlines"/>
|
||||
<checkbox id="cbxFillOutlines" label="&boxFillOutlines.label;" command="cmdToggleFill"/>
|
||||
<menulist id="mlZoom" value="1" command="cmdZoom">
|
||||
<menupopup>
|
||||
<menuitem value="1" label="&zoom1x.label;"/>
|
||||
<menuitem value="2" label="&zoom2x.label;"/>
|
||||
<menuitem value="4" label="&zoom4x.label;"/>
|
||||
<menuitem value="8" label="&zoom8x.label;"/>
|
||||
<menuitem value="16" label="&zoom16x.label;"/>
|
||||
<menuitem value="32" label="&zoom32x.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
<hbox id="bxZoom" align="start" flex="1">
|
||||
<stack id="bxZoomStack">
|
||||
<html:img id="imgZoom"/>
|
||||
<hbox id="bxMargin" flex="1"
|
||||
onmouseover="viewer.onRegionOver(event)"
|
||||
onmouseout="viewer.onRegionOut(event)">
|
||||
<hbox id="bxBorder" flex="1">
|
||||
<hbox id="bxPadding" flex="1">
|
||||
<hbox id="bxContent" flex="1"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</stack>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
</page>
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
|
||||
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
|
||||
<!ENTITY % dtd3 SYSTEM "chrome://inspector/locale/viewers/boxModel.dtd"> %dtd3;
|
||||
]>
|
||||
|
||||
<?xml-stylesheet href="chrome://inspector/skin/viewers/boxModel/boxModel.css"?>
|
||||
|
||||
<window id="winColorPicker" title="&boxColorPicker.title;" class="color-dialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript"><![CDATA[
|
||||
var viewer = window.opener.viewer;
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
startPicking();
|
||||
}
|
||||
|
||||
window.onunload = function()
|
||||
{
|
||||
stopPicking();
|
||||
viewer.onColorPickerClosed();
|
||||
}
|
||||
|
||||
function onStopPicking()
|
||||
{
|
||||
var stk = document.getElementById("dkStartStop");
|
||||
stk.setAttribute("selectedIndex", 0);
|
||||
}
|
||||
|
||||
function startPicking()
|
||||
{
|
||||
var stk = document.getElementById("dkStartStop");
|
||||
stk.setAttribute("selectedIndex", 1);
|
||||
|
||||
viewer.startPickColor(window);
|
||||
}
|
||||
|
||||
function stopPicking()
|
||||
{
|
||||
var stk = document.getElementById("dkStartStop");
|
||||
stk.setAttribute("selectedIndex", 0);
|
||||
|
||||
viewer.stopPickColor();
|
||||
}
|
||||
|
||||
function exit()
|
||||
{
|
||||
window.close();
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<vbox>
|
||||
<spacer id="bxColorSwatch" width="50" height="50" style="background-color: #FFFFFF"/>
|
||||
<textbox id="txColor" readonly="true"/>
|
||||
</vbox>
|
||||
<vbox flex="1">
|
||||
<deck id="dkStartStop">
|
||||
<button id="btnStart" label="&boxStartPicking.label;" oncommand="startPicking()"/>
|
||||
<button id="btnStop" label="&boxStopPicking.label;" oncommand="stopPicking()"/>
|
||||
</deck>
|
||||
<button id="btnClose" label="&boxClosePicker.label;" oncommand="exit()"/>
|
||||
</vbox>
|
||||
|
||||
</window>
|
|
@ -39,24 +39,3 @@
|
|||
<!ENTITY boxMargin.label "Margin">
|
||||
<!ENTITY boxBorder.label "Border">
|
||||
<!ENTITY boxPadding.label "Padding">
|
||||
|
||||
<!ENTITY boxImage.label "Image">
|
||||
<!ENTITY boxImageCapture.label "Capture">
|
||||
<!ENTITY boxSaveImage.label "Save As...">
|
||||
|
||||
<!ENTITY boxShowOutlines.label "Show Boxes">
|
||||
<!ENTITY boxFillOutlines.label "Fill Boxes">
|
||||
|
||||
<!ENTITY boxColorPicker.label "Pick Color...">
|
||||
<!ENTITY boxColorPicker.title "Color Picker">
|
||||
<!ENTITY boxStartPicking.label "Start">
|
||||
<!ENTITY boxStopPicking.label "Stop">
|
||||
<!ENTITY boxClosePicker.label "Close">
|
||||
|
||||
<!ENTITY zoom.label "Zoom">
|
||||
<!ENTITY zoom1x.label "&zoom.label; 1x">
|
||||
<!ENTITY zoom2x.label "&zoom.label; 2x">
|
||||
<!ENTITY zoom4x.label "&zoom.label; 4x">
|
||||
<!ENTITY zoom8x.label "&zoom.label; 8x">
|
||||
<!ENTITY zoom16x.label "&zoom.label; 16x">
|
||||
<!ENTITY zoom32x.label "&zoom.label; 32x">
|
||||
|
|
|
@ -43,68 +43,3 @@
|
|||
.value-column {
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
/* ::::: image capture area ::::: */
|
||||
|
||||
#bxZoom {
|
||||
overflow: auto;
|
||||
margin: 5px;
|
||||
border: 2px groove ThreeDFace;
|
||||
padding: 10px;
|
||||
background-color: #b9b9b9;
|
||||
}
|
||||
|
||||
/* ::::: box model outlines ::::: */
|
||||
|
||||
#imgZoom {
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
#imgZoom[hidden="true"] {
|
||||
visibility: collapse;
|
||||
}
|
||||
|
||||
#bxMargin[outline="true"] {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#bxBorder[outline="true"] {
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
#bxPadding[outline="true"] {
|
||||
border: 1px solid yellow;
|
||||
}
|
||||
|
||||
#bxContent[outline="true"] {
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
#bxMargin[fill="true"] {
|
||||
border: none;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#bxBorder[fill="true"] {
|
||||
border: none;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
#bxPadding[fill="true"] {
|
||||
border: none;
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
#bxContent[fill="true"] {
|
||||
border: none;
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
/* ::::: color picker dialog ::::: */
|
||||
|
||||
#bxColorSwatch {
|
||||
margin: 2px 4px;
|
||||
border: 1px solid #000000;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,68 +43,3 @@
|
|||
.value-column {
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
/* ::::: image capture area ::::: */
|
||||
|
||||
#bxZoom {
|
||||
overflow: auto;
|
||||
margin: 5px;
|
||||
border: 2px groove #C7D0D9;
|
||||
padding: 10px;
|
||||
background-color: #b9b9b9;
|
||||
}
|
||||
|
||||
/* ::::: box model outlines ::::: */
|
||||
|
||||
#imgZoom {
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
#imgZoom[hidden="true"] {
|
||||
visibility: collapse;
|
||||
}
|
||||
|
||||
#bxMargin[outline="true"] {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#bxBorder[outline="true"] {
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
#bxPadding[outline="true"] {
|
||||
border: 1px solid yellow;
|
||||
}
|
||||
|
||||
#bxContent[outline="true"] {
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
#bxMargin[fill="true"] {
|
||||
border: none;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#bxBorder[fill="true"] {
|
||||
border: none;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
#bxPadding[fill="true"] {
|
||||
border: none;
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
#bxContent[fill="true"] {
|
||||
border: none;
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
/* ::::: color picker dialog ::::: */
|
||||
|
||||
#bxColorSwatch {
|
||||
margin: 2px 4px;
|
||||
border: 1px solid #000000;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче