From d6f586015d8801bedf790170609517c11d234859 Mon Sep 17 00:00:00 2001 From: "dwitte%stanford.edu" Date: Tue, 24 Jun 2003 04:44:55 +0000 Subject: [PATCH] removing bitmap/png, screen capturing, and boxmodel colorpicking functionality from DOM Inspector. b=211096, r=caillon, sr=jst. --- extensions/inspector/base/public/Makefile.in | 5 - .../inspector/base/public/inIBitmap.idl | 59 --- .../inspector/base/public/inIBitmapDepot.idl | 54 --- .../inspector/base/public/inIBitmapURI.idl | 27 -- .../inspector/base/public/inIPNGEncoder.idl | 51 --- .../base/public/inIScreenCapturer.idl | 52 --- extensions/inspector/base/src/Makefile.in | 16 - extensions/inspector/base/src/inBitmap.cpp | 145 -------- extensions/inspector/base/src/inBitmap.h | 59 --- .../inspector/base/src/inBitmapChannel.cpp | 286 -------------- .../inspector/base/src/inBitmapChannel.h | 60 --- .../inspector/base/src/inBitmapDecoder.cpp | 141 ------- .../inspector/base/src/inBitmapDecoder.h | 50 --- .../inspector/base/src/inBitmapDepot.cpp | 95 ----- extensions/inspector/base/src/inBitmapDepot.h | 58 --- .../base/src/inBitmapProtocolHandler.cpp | 107 ------ .../base/src/inBitmapProtocolHandler.h | 56 --- extensions/inspector/base/src/inBitmapURI.cpp | 267 -------------- extensions/inspector/base/src/inBitmapURI.h | 44 --- .../inspector/base/src/inPNGEncoder.cpp | 131 ------- extensions/inspector/base/src/inPNGEncoder.h | 63 ---- extensions/inspector/base/src/win/Makefile.in | 49 --- .../base/src/win/inScreenCapturer.cpp | 189 ---------- .../inspector/base/src/win/inScreenCapturer.h | 65 ---- extensions/inspector/build/src/Makefile.in | 15 - .../inspector/build/src/nsInspectorModule.cpp | 79 +--- extensions/inspector/jar.mn | 1 - .../content/viewers/boxModel/boxModel.js | 348 +----------------- .../content/viewers/boxModel/boxModel.xul | 50 --- .../content/viewers/boxModel/colorPicker.xul | 69 ---- .../locale/en-US/viewers/boxModel.dtd | 21 -- .../classic/viewers/boxModel/boxModel.css | 65 ---- .../skin/modern/viewers/boxModel/boxModel.css | 65 ---- 33 files changed, 7 insertions(+), 2835 deletions(-) delete mode 100644 extensions/inspector/base/public/inIBitmap.idl delete mode 100644 extensions/inspector/base/public/inIBitmapDepot.idl delete mode 100644 extensions/inspector/base/public/inIBitmapURI.idl delete mode 100644 extensions/inspector/base/public/inIPNGEncoder.idl delete mode 100644 extensions/inspector/base/public/inIScreenCapturer.idl delete mode 100644 extensions/inspector/base/src/inBitmap.cpp delete mode 100644 extensions/inspector/base/src/inBitmap.h delete mode 100644 extensions/inspector/base/src/inBitmapChannel.cpp delete mode 100644 extensions/inspector/base/src/inBitmapChannel.h delete mode 100644 extensions/inspector/base/src/inBitmapDecoder.cpp delete mode 100644 extensions/inspector/base/src/inBitmapDecoder.h delete mode 100644 extensions/inspector/base/src/inBitmapDepot.cpp delete mode 100644 extensions/inspector/base/src/inBitmapDepot.h delete mode 100644 extensions/inspector/base/src/inBitmapProtocolHandler.cpp delete mode 100644 extensions/inspector/base/src/inBitmapProtocolHandler.h delete mode 100644 extensions/inspector/base/src/inBitmapURI.cpp delete mode 100644 extensions/inspector/base/src/inBitmapURI.h delete mode 100644 extensions/inspector/base/src/inPNGEncoder.cpp delete mode 100644 extensions/inspector/base/src/inPNGEncoder.h delete mode 100644 extensions/inspector/base/src/win/Makefile.in delete mode 100644 extensions/inspector/base/src/win/inScreenCapturer.cpp delete mode 100644 extensions/inspector/base/src/win/inScreenCapturer.h delete mode 100644 extensions/inspector/resources/content/viewers/boxModel/colorPicker.xul diff --git a/extensions/inspector/base/public/Makefile.in b/extensions/inspector/base/public/Makefile.in index 813e994362f5..1623401333a7 100644 --- a/extensions/inspector/base/public/Makefile.in +++ b/extensions/inspector/base/public/Makefile.in @@ -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 diff --git a/extensions/inspector/base/public/inIBitmap.idl b/extensions/inspector/base/public/inIBitmap.idl deleted file mode 100644 index 764ad6e43fa7..000000000000 --- a/extensions/inspector/base/public/inIBitmap.idl +++ /dev/null @@ -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 (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); -}; - diff --git a/extensions/inspector/base/public/inIBitmapDepot.idl b/extensions/inspector/base/public/inIBitmapDepot.idl deleted file mode 100644 index f10e20658bac..000000000000 --- a/extensions/inspector/base/public/inIBitmapDepot.idl +++ /dev/null @@ -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 (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); -}; - diff --git a/extensions/inspector/base/public/inIBitmapURI.idl b/extensions/inspector/base/public/inIBitmapURI.idl deleted file mode 100644 index f96cfaeba805..000000000000 --- a/extensions/inspector/base/public/inIBitmapURI.idl +++ /dev/null @@ -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 - */ - -#include "nsIURI.idl" - -[scriptable, uuid(5F0D8F70-15A9-4c4d-B952-086005A8133C)] -interface inIBitmapURI : nsIURI -{ - readonly attribute wstring bitmapName; -}; diff --git a/extensions/inspector/base/public/inIPNGEncoder.idl b/extensions/inspector/base/public/inIPNGEncoder.idl deleted file mode 100644 index 8c735e8cac44..000000000000 --- a/extensions/inspector/base/public/inIPNGEncoder.idl +++ /dev/null @@ -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); -}; diff --git a/extensions/inspector/base/public/inIScreenCapturer.idl b/extensions/inspector/base/public/inIScreenCapturer.idl deleted file mode 100644 index 39714534c696..000000000000 --- a/extensions/inspector/base/public/inIScreenCapturer.idl +++ /dev/null @@ -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); -}; - - diff --git a/extensions/inspector/base/src/Makefile.in b/extensions/inspector/base/src/Makefile.in index a40c849755e4..075c94eeef37 100644 --- a/extensions/inspector/base/src/Makefile.in +++ b/extensions/inspector/base/src/Makefile.in @@ -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 diff --git a/extensions/inspector/base/src/inBitmap.cpp b/extensions/inspector/base/src/inBitmap.cpp deleted file mode 100644 index 2c5c0bb49c4a..000000000000 --- a/extensions/inspector/base/src/inBitmap.cpp +++ /dev/null @@ -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 (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; -} - diff --git a/extensions/inspector/base/src/inBitmap.h b/extensions/inspector/base/src/inBitmap.h deleted file mode 100644 index 8b106ae16958..000000000000 --- a/extensions/inspector/base/src/inBitmap.h +++ /dev/null @@ -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 (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__ diff --git a/extensions/inspector/base/src/inBitmapChannel.cpp b/extensions/inspector/base/src/inBitmapChannel.cpp deleted file mode 100644 index bcd3325fcf7d..000000000000 --- a/extensions/inspector/base/src/inBitmapChannel.cpp +++ /dev/null @@ -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 - */ - -#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 depot(do_GetService("@mozilla.org/inspector/bitmap-depot;1")); - if (!depot) - return NS_ERROR_FAILURE; - nsCOMPtr uri(do_QueryInterface(mUrl)); - nsXPIDLString durl; - uri->GetBitmapName(getter_Copies(durl)); - nsCOMPtr 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 streamSupports; - NS_NewByteInputStream(getter_AddRefs(streamSupports), (const char*)bufStart, length); - nsCOMPtr 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; -} - diff --git a/extensions/inspector/base/src/inBitmapChannel.h b/extensions/inspector/base/src/inBitmapChannel.h deleted file mode 100644 index 4874415275f0..000000000000 --- a/extensions/inspector/base/src/inBitmapChannel.h +++ /dev/null @@ -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 - */ - -#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 mUrl; - nsCOMPtr mOriginalURI; - PRUint32 mLoadAttributes; - PRInt32 mContentLength; - nsCOMPtr mLoadGroup; - nsCOMPtr mCallbacks; - nsCOMPtr mOwner; - nsresult mStatus; - -}; - -#endif // __inBitmapChannel_h___ diff --git a/extensions/inspector/base/src/inBitmapDecoder.cpp b/extensions/inspector/base/src/inBitmapDecoder.cpp deleted file mode 100644 index 916f970c7282..000000000000 --- a/extensions/inspector/base/src/inBitmapDecoder.cpp +++ /dev/null @@ -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 - * - */ - -#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; -} diff --git a/extensions/inspector/base/src/inBitmapDecoder.h b/extensions/inspector/base/src/inBitmapDecoder.h deleted file mode 100644 index 28a5720954a8..000000000000 --- a/extensions/inspector/base/src/inBitmapDecoder.h +++ /dev/null @@ -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 - */ - -#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 mImage; - nsCOMPtr mFrame; - nsCOMPtr mObserver; // this is just qi'd from mRequest for speed -}; - -#endif // __inBitmapDecoder_h__ diff --git a/extensions/inspector/base/src/inBitmapDepot.cpp b/extensions/inspector/base/src/inBitmapDepot.cpp deleted file mode 100644 index 3095cad635d8..000000000000 --- a/extensions/inspector/base/src/inBitmapDepot.cpp +++ /dev/null @@ -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 (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 bitmap(aBitmap); - nsCOMPtr supports = do_QueryInterface(bitmap); - mHash.Put(&key, supports); - - return NS_OK; -} - -NS_IMETHODIMP -inBitmapDepot::Get(const nsAString& aName, inIBitmap** _retval) -{ - nsStringKey key(aName); - nsCOMPtr supports = mHash.Get(&key); - nsCOMPtr 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 supports; - mHash.Remove(&key, getter_AddRefs(supports)); - nsCOMPtr bitmap = do_QueryInterface(supports); - *_retval = bitmap; - NS_IF_ADDREF(*_retval); - - return NS_OK; -} - diff --git a/extensions/inspector/base/src/inBitmapDepot.h b/extensions/inspector/base/src/inBitmapDepot.h deleted file mode 100644 index 2b4c7b2ef6d4..000000000000 --- a/extensions/inspector/base/src/inBitmapDepot.h +++ /dev/null @@ -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 (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__ diff --git a/extensions/inspector/base/src/inBitmapProtocolHandler.cpp b/extensions/inspector/base/src/inBitmapProtocolHandler.cpp deleted file mode 100644 index c126064aa805..000000000000 --- a/extensions/inspector/base/src/inBitmapProtocolHandler.cpp +++ /dev/null @@ -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 - */ - -#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 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 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; -} diff --git a/extensions/inspector/base/src/inBitmapProtocolHandler.h b/extensions/inspector/base/src/inBitmapProtocolHandler.h deleted file mode 100644 index 073caf02e856..000000000000 --- a/extensions/inspector/base/src/inBitmapProtocolHandler.h +++ /dev/null @@ -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 - * - * - * 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___ diff --git a/extensions/inspector/base/src/inBitmapURI.cpp b/extensions/inspector/base/src/inBitmapURI.cpp deleted file mode 100644 index 5c54641884a3..000000000000 --- a/extensions/inspector/base/src/inBitmapURI.cpp +++ /dev/null @@ -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 - */ - -#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 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; -} - diff --git a/extensions/inspector/base/src/inBitmapURI.h b/extensions/inspector/base/src/inBitmapURI.h deleted file mode 100644 index f00466f2c066..000000000000 --- a/extensions/inspector/base/src/inBitmapURI.h +++ /dev/null @@ -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 - */ - -#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__ diff --git a/extensions/inspector/base/src/inPNGEncoder.cpp b/extensions/inspector/base/src/inPNGEncoder.cpp deleted file mode 100644 index af283ebe8292..000000000000 --- a/extensions/inspector/base/src/inPNGEncoder.cpp +++ /dev/null @@ -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"); -} diff --git a/extensions/inspector/base/src/inPNGEncoder.h b/extensions/inspector/base/src/inPNGEncoder.h deleted file mode 100644 index 739f81b59dd4..000000000000 --- a/extensions/inspector/base/src/inPNGEncoder.h +++ /dev/null @@ -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__ diff --git a/extensions/inspector/base/src/win/Makefile.in b/extensions/inspector/base/src/win/Makefile.in deleted file mode 100644 index 199a06d4fb08..000000000000 --- a/extensions/inspector/base/src/win/Makefile.in +++ /dev/null @@ -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 diff --git a/extensions/inspector/base/src/win/inScreenCapturer.cpp b/extensions/inspector/base/src/win/inScreenCapturer.cpp deleted file mode 100644 index f880a529ab6d..000000000000 --- a/extensions/inspector/base/src/win/inScreenCapturer.cpp +++ /dev/null @@ -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 window = inLayoutUtils::GetWindowFor(aElement); - if (!window) return NS_ERROR_FAILURE; - nsCOMPtr 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 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 dc; - - // determine pixel bit depth - PRUint32 depth = ::GetDeviceCaps(hdc, COLORRES); - - nsresult rv; - nsCOMPtr 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; -} diff --git a/extensions/inspector/base/src/win/inScreenCapturer.h b/extensions/inspector/base/src/win/inScreenCapturer.h deleted file mode 100644 index 3936772a342f..000000000000 --- a/extensions/inspector/base/src/win/inScreenCapturer.h +++ /dev/null @@ -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 - -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 mCSSUtils; - -}; - -#endif // __inScreenCapturer_h__ diff --git a/extensions/inspector/build/src/Makefile.in b/extensions/inspector/build/src/Makefile.in index c1b9f7322096..43fcaf0b51dd 100644 --- a/extensions/inspector/build/src/Makefile.in +++ b/extensions/inspector/build/src/Makefile.in @@ -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 - - diff --git a/extensions/inspector/build/src/nsInspectorModule.cpp b/extensions/inspector/build/src/nsInspectorModule.cpp index 56efa32718b7..99094a31d11c 100644 --- a/extensions/inspector/build/src/nsInspectorModule.cpp +++ b/extensions/inspector/build/src/nsInspectorModule.cpp @@ -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) diff --git a/extensions/inspector/jar.mn b/extensions/inspector/jar.mn index f8506e041fb7..492911ccd66d 100644 --- a/extensions/inspector/jar.mn +++ b/extensions/inspector/jar.mn @@ -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) diff --git a/extensions/inspector/resources/content/viewers/boxModel/boxModel.js b/extensions/inspector/resources/content/viewers/boxModel/boxModel.js index eb2505c76f1c..a63a2feaefe1 100644 --- a/extensions/inspector/resources/content/viewers/boxModel/boxModel.js +++ b/extensions/inspector/resources/content/viewers/boxModel/boxModel.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); -} diff --git a/extensions/inspector/resources/content/viewers/boxModel/boxModel.xul b/extensions/inspector/resources/content/viewers/boxModel/boxModel.xul index 24bfaf826766..9b1be35fd50a 100644 --- a/extensions/inspector/resources/content/viewers/boxModel/boxModel.xul +++ b/extensions/inspector/resources/content/viewers/boxModel/boxModel.xul @@ -18,17 +18,7 @@ - - - - - - - -