(NOT PART OF BUILD) Document Inspector

This commit is contained in:
hewitt%netscape.com 2001-02-15 09:07:37 +00:00
parent dc930d8dd9
commit 505ba4a366
62 changed files with 7853 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS=public src
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,27 @@
#!nmake
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
include <$(DEPTH)/config/config.mak>
DIRS = public src
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,45 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE=inspector
XPIDL_MODULE=inspector
XPIDLSRCS = nsIDOMDSResource.idl \
nsIInsDOMDataSource.idl \
nsICSSRuleDataSource.idl \
nsICSSDecDataSource.idl \
nsICSSDecIntHolder.idl \
inIFlasher.idl \
inISearchProcess.idl \
inISearchObserver.idl \
inICSSValueSearch.idl \
inIFileSearch.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,47 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inISearchProcess.idl"
interface nsIDOMDocument;
[scriptable, uuid(e0d39e48-1dd1-11b2-81bd-9a0c117f0736)]
interface inICSSValueSearch : inISearchProcess {
attribute nsIDOMDocument document;
// the base url for all returned URL results, if returnRelativeURLs is true
attribute wstring baseURL;
// strip off the baseURL for all URL results if true
attribute boolean returnRelativeURLs;
// correct the paths on a chrome url, such as turning global/skin/blah into global/blah
attribute boolean normalizeChromeURLs;
// add a css property to search for
void addPropertyCriteria(in wstring aPropName);
// set the text value to search for in the properties specified (optional)
attribute wstring textCriteria;
};

View File

@ -0,0 +1,50 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inISearchProcess.idl"
interface nsIFile;
interface nsISupportsArray;
[scriptable, uuid(EFA53257-526D-4350-9088-343A510346B8)]
interface inIFileSearch : inISearchProcess {
// the base url for all returned URL results, if returnRelativePaths is true
attribute wstring basePath;
// strip off the basePath for all results through getStringResultAt if true
attribute boolean returnRelativePaths;
unsigned long getDirectoryDepth(in nsIFile aDir);
nsISupportsArray getSubDirectories(in nsIFile aDir);
// criteria
attribute wstring filenameCriteria;
attribute wstring textCriteria;
attribute nsIFile searchPath;
attribute boolean searchRecursive;
// results
readonly attribute unsigned long directoriesSearched;
readonly attribute nsIFile currentDirectory;
nsIFile getFileResultAt(in long aIndex);
};

View File

@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsIDOMElement;
interface nsIDOMWindowInternal;
[scriptable, uuid(7B4A099F-6F6E-4565-977B-FB622ADBFF49)]
interface inIFlasher : nsISupports
{
void drawElementOutline(in nsIDOMElement aElement, in nsIDOMWindowInternal aWindow, in wstring aColor, in long aThickness);
void repaintElement(in nsIDOMElement aElement, in nsIDOMWindowInternal aWindow);
};

View File

@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface inISearchProcess;
[scriptable, uuid(46226D9B-E398-4106-8D9B-225D4D0589F5)]
interface inISearchObserver : nsISupports
{
// result codes which are sent to onSearchEnd
const short SUCCESS = 1; // search completed successfully
const short INTERRUPTED = 2; // search stopped due to user interruption
const short ERROR = 3; // search stopped due to an error
void onSearchStart(in inISearchProcess aModule);
void onSearchResult(in inISearchProcess aModule);
void onSearchEnd(in inISearchProcess aModule, in short aResult);
void onSearchError(in inISearchProcess aModule, in wstring aMessage);
};

View File

@ -0,0 +1,34 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
[scriptable, uuid(A7FC849B-A705-4da2-AF6C-989417548E6A)]
interface inISearchOrphanImages : nsISupports {
attribute wstring searchPath;
attribute wstring remotePath;
attribute boolean isSkin;
attribute nsIDOMDocument document;
};

View File

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface inISearchObserver;
interface nsISupportsArray;
[scriptable, uuid(D5FA765B-2448-4686-B7C1-5FF13ACB0FC9)]
interface inISearchProcess : nsISupports
{
// indicates if an asynchronous search is in progress
readonly attribute boolean isActive;
// the number of results returned
readonly attribute long resultCount;
// for optimization when doing an async search, this will optionally
// destroy old results, assuming they will be fetched as soon as
// the observer is notified of their presence. If true, then indices
// pass to the get*ResultAt methods will return null for any index
// other than the most recent one, and getResults will return null always.
attribute boolean holdResults;
// start a synchronous search
void searchSync();
// start an asynchronous search
void searchAsync(in inISearchObserver aObserver);
// command an async process to stop immediately
void searchStop();
// performs a step in the asynchronous search loop
// return indicates true if loop is done, false if it should continue
// This is there only for the benefit of asynchronous search controllers,
// and is not for use by those who just wish to call searchAsync
boolean searchStep();
// methods for getting results of specific types
wstring getStringResultAt(in long aIndex);
long getIntResultAt(in long aIndex);
unsigned long getUIntResultAt(in long aIndex);
};

View File

@ -0,0 +1,39 @@
#!nmake
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
XPIDLSRCS = .\nsIDOMDSResource.idl \
.\nsIInsDOMDataSource.idl \
.\nsICSSRuleDataSource.idl \
.\nsICSSDecDataSource.idl \
.\nsICSSDecIntHolder.idl \
.\inIFlasher.idl \
.\inISearchProcess.idl \
.\inISearchObserver.idl \
.\inICSSValueSearch.idl \
.\inIFileSearch.idl \
$(NULL)
MODULE=inspector
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,43 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIRDFResource;
[scriptable, uuid(3777C69B-0605-454f-851C-760F4A05888A)]
interface nsICSSDecDataSource : nsISupports
{
attribute nsIRDFResource refResource;
void setCSSProperty(in wstring aName, in wstring aValue, in wstring aPriority);
void removeCSSProperty(in wstring aName);
};
%{C++
/* {B10FB023-72C7-489f-BE65-BCA9B38F856D} */
#define NS_CSSDEC_DATASOURCE_CID \
{ 0xb10fb023, 0x72c7, 0x489f, { 0xbe, 0x65, 0xbc, 0xa9, 0xb3, 0x8f, 0x85, 0x6d } }
%}

View File

@ -0,0 +1,40 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
[scriptable, uuid(AC2EEEC0-8C36-4792-9020-3A81D9AA3110)]
interface nsICSSDecIntHolder : nsISupports
{
};
%{C++
/* {32E9DAA2-6D24-46bc-B2A6-E97839650EDA} */
#define NS_CSSDECINTHOLDER_CID \
{ 0x32e9daa2, 0x6d24, 0x46bc, { 0xb2, 0xa6, 0xe9, 0x78, 0x39, 0x65, 0xe, 0xda } }
#define NS_CSSDECINTHOLDER_CONTRACTID \
"@mozilla.org/inspector/cssdecIntHolder;1"
%}

View File

@ -0,0 +1,40 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
[scriptable, uuid(88B8B7CB-A1A0-4056-A2E1-04F4831C4C91)]
interface nsICSSRuleDataSource : nsISupports
{
attribute nsIDOMElement element;
};
%{C++
/* {71BCEACF-D73A-43f3-8F37-09BF916D7854} */
#define NS_CSSRULE_DATASOURCE_CID \
{ 0x71bceacf, 0xd73a, 0x43f3, { 0x8f, 0x37, 0x9, 0xbf, 0x91, 0x6d, 0x78, 0x54 } }
%}

View File

@ -0,0 +1,41 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "domstubs.idl"
%{C++
#include "nsIDOMNode.h"
%}
[scriptable, uuid(F092D67C-0DBE-472e-82EA-BF70C9649A8A)]
interface nsIDOMDSResource : nsISupports {
attribute nsISupports object;
};
%{C++
/* {76C9161F-4C4C-4c1b-8F96-64587315C79E} */
#define NS_DOMDSRESOURCE_CID \
{ 0x76c9161f, 0x4c4c, 0x4c1b, { 0x8f, 0x96, 0x64, 0x58, 0x73, 0x15, 0xc7, 0x9e } }
%}

View File

@ -0,0 +1,47 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsIRDFResource;
[scriptable, uuid(A029F6DD-9945-4607-850F-C8476387A52A)]
interface nsIInsDOMDataSource : nsISupports
{
attribute nsIDOMDocument document;
attribute boolean showAnonymousContent;
void addFilterByType(in unsigned short aType, in boolean aExclusive);
void removeFilterByType(in unsigned short aType);
boolean isFiltered(in unsigned short aType);
nsIRDFResource getResourceForObject(in nsISupports aObject);
};
%{C++
/* {3AD0C13B-195E-48e7-AF29-F024E2D759EA} */
#define NS_INSDOMDATASOURCE_CID \
{ 0x3ad0c13b, 0x195e, 0x48e7, { 0xaf, 0x29, 0xf0, 0x24, 0xe2, 0xd7, 0x59, 0xea } }
%}

View File

@ -0,0 +1,48 @@
#
# 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 Netscape are
# Copyright (C) 1998 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=inspector_s
SHORT_LIBNAME=inspector_s
CPPSRCS= \
nsDOMDSResource.cpp \
nsDOMDataSource.cpp \
nsCSSRuleDataSource.cpp \
nsCSSDecDataSource.cpp \
nsCSSDecIntHolder.cpp \
inFlasher.cpp \
inSearchLoop.cpp \
inCSSValueSearch.cpp \
inFileSearch.cpp \
$(NULL)
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,38 @@
/* -*- 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.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 Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*/
#include "nsRDFCID.h"
#include "nsHashtable.h"
#define INS_NAMESPACE_URI "http://www.mozilla.org/inspector#"
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
static NS_DEFINE_CID(kISupportsIID, NS_ISUPPORTS_IID);
// This might not be thread safe as a global variable, but it needs to be global
// because multiple instances of nsDOMDataSource need to use the same
// resource objects for the same nodes so they can pass resource id's
// back and forth. Need to make sure this is thread-safe in the future, though.
static nsSupportsHashtable gDOMObjectTable;

View File

@ -0,0 +1,360 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inCSSValueSearch.h"
#include "nsIComponentManager.h"
#include "nsVoidArray.h"
///////////////////////////////////////////////////////////////////////////////
inCSSValueSearch::inCSSValueSearch()
{
NS_INIT_ISUPPORTS();
mHoldResults = PR_TRUE;
mReturnRelativeURLs = PR_FALSE;
mNormalizeChromeURLs = PR_FALSE;
mResultCount = 0;
mProperties = new nsCSSProperty[100];
mPropertyCount = 0;
nsCSSProps::AddRefTable();
}
inCSSValueSearch::~inCSSValueSearch()
{
nsCSSProps::ReleaseTable();
delete mProperties;
delete mResults;
}
NS_IMPL_ISUPPORTS2(inCSSValueSearch, inISearchProcess, inICSSValueSearch);
///////////////////////////////////////////////////////////////////////////////
// inISearchProcess
NS_IMETHODIMP
inCSSValueSearch::GetIsActive(PRBool *aIsActive)
{
*aIsActive = mIsActive;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetResultCount(PRInt32 *aResultCount)
{
*aResultCount = mResultCount;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetHoldResults(PRBool *aHoldResults)
{
*aHoldResults = mHoldResults;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetHoldResults(PRBool aHoldResults)
{
mHoldResults = aHoldResults;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SearchSync()
{
InitSearch();
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
if (doc) {
PRInt32 count = doc->GetNumberOfStyleSheets();
for (PRInt32 i = 0; i < count; i++) {
nsIStyleSheet* sheet = doc->GetStyleSheetAt(i);
SearchStyleSheet(sheet);
}
}
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SearchAsync(inISearchObserver *aObserver)
{
InitSearch();
mObserver = aObserver;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SearchStop()
{
KillSearch(inISearchObserver::INTERRUPTED);
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SearchStep(PRBool* _retval)
{
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetStringResultAt(PRInt32 aIndex, PRUnichar **_retval)
{
if (mHoldResults) {
nsAutoString* result = (nsAutoString*)mResults->ElementAt(aIndex);
*_retval = result->ToNewUnicode();
} else if (aIndex == mResultCount-1) {
*_retval = mLastResult->ToNewUnicode();
} else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetIntResultAt(PRInt32 aIndex, PRInt32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inCSSValueSearch::GetUIntResultAt(PRInt32 aIndex, PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////
// inICSSValueSearch
NS_IMETHODIMP
inCSSValueSearch::GetDocument(nsIDOMDocument** aDocument)
{
*aDocument = mDocument;
NS_IF_ADDREF(*aDocument);
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetDocument(nsIDOMDocument* aDocument)
{
mDocument = aDocument;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetBaseURL(PRUnichar** aBaseURL)
{
*aBaseURL = mBaseURL->ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetBaseURL(const PRUnichar* aBaseURL)
{
nsAutoString url;
mBaseURL = &url;
url.Assign(aBaseURL);
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetReturnRelativeURLs(PRBool* aReturnRelativeURLs)
{
*aReturnRelativeURLs = mReturnRelativeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetReturnRelativeURLs(PRBool aReturnRelativeURLs)
{
mReturnRelativeURLs = aReturnRelativeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetNormalizeChromeURLs(PRBool *aNormalizeChromeURLs)
{
*aNormalizeChromeURLs = mNormalizeChromeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetNormalizeChromeURLs(PRBool aNormalizeChromeURLs)
{
mNormalizeChromeURLs = aNormalizeChromeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::AddPropertyCriteria(const PRUnichar *aPropName)
{
nsAutoString propName;
propName.Assign(aPropName);
nsCSSProperty prop = nsCSSProps::LookupProperty(propName);
mProperties[mPropertyCount] = prop;
mPropertyCount++;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetTextCriteria(PRUnichar** aTextCriteria)
{
*aTextCriteria = mTextCriteria->ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetTextCriteria(const PRUnichar* aTextCriteria)
{
if (!mTextCriteria) mTextCriteria = new nsAutoString();
mTextCriteria->Assign(aTextCriteria);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// inCSSValueSearch
nsresult
inCSSValueSearch::InitSearch()
{
if (mHoldResults) {
mResults = new nsVoidArray();
}
mResultCount = 0;
return NS_OK;
}
nsresult
inCSSValueSearch::KillSearch(PRInt16 aResult)
{
mIsActive = PR_TRUE;
mObserver->OnSearchEnd(this, aResult);
return NS_OK;
}
nsresult
inCSSValueSearch::SearchStyleSheet(nsIStyleSheet* aStyleSheet)
{
NS_IF_ADDREF(aStyleSheet);
nsCOMPtr<nsICSSStyleSheet> cssSheet = do_QueryInterface(aStyleSheet);
if (cssSheet) {
// recurse downward through the stylesheet tree
PRInt32 count;
cssSheet->StyleSheetCount(count);
for (PRInt32 i = 0; i < count; i++) {
nsICSSStyleSheet* child;
cssSheet->GetStyleSheetAt(i, child);
SearchStyleSheet(child);
}
cssSheet->StyleRuleCount(count);
for (i = 0; i < count; i++) {
nsICSSRule* rule;
cssSheet->GetStyleRuleAt(i, rule);
SearchStyleRule(rule);
}
}
NS_IF_RELEASE(aStyleSheet);
return NS_OK;
}
nsresult
inCSSValueSearch::SearchStyleRule(nsIStyleRule* aStyleRule)
{
NS_IF_ADDREF(aStyleRule);
nsCOMPtr<nsICSSStyleRule> cssRule = do_QueryInterface(aStyleRule);
if (cssRule) {
nsCOMPtr<nsICSSDeclaration> aDec = cssRule->GetDeclaration();
for (PRUint32 i = 0; i < mPropertyCount; i++) {
nsCSSProperty prop = mProperties[i];
SearchStyleValue(aDec, prop);
}
}
NS_IF_RELEASE(aStyleRule);
return NS_OK;
}
nsresult
inCSSValueSearch::SearchStyleValue(nsICSSDeclaration* aDec, nsCSSProperty aProp)
{
nsCString cstring = nsCSSProps::GetStringValue(aProp);
nsCSSValue value;
aDec->GetValue(aProp, value);
if (value.GetUnit() == eCSSUnit_URL) {
nsAutoString* result = new nsAutoString();
value.GetStringValue(*result);
if (mReturnRelativeURLs)
EqualizeURL(result);
mResults->AppendElement((void*)result);
mResultCount++;
}
return NS_OK;
}
nsresult
inCSSValueSearch::EqualizeURL(nsAutoString* aURL)
{
if (mNormalizeChromeURLs) {
if (aURL->Find("chrome://", false, 0, 1) >= 0) {
PRUint32 len = aURL->Length();
char* result = new char[len-8];
char* buffer = aURL->ToNewCString();
PRUint32 i = 9;
PRUint32 milestone = 0;
PRUint32 s = 0;
while (i < len) {
if (buffer[i] == '/') {
milestone += 1;
}
if (milestone == 0 || milestone > 1) {
result[i-9-s] = (buffer[i] == '/') ? '/' : buffer[i];
} else {
s++;
}
i++;
}
result[i-9-s] = 0;
aURL->AssignWithConversion(result);
}
} else {
}
return NS_OK;
}

View File

@ -0,0 +1,85 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __inCSSValueSearch_h__
#define __inCSSValueSearch_h__
#include "inICSSValueSearch.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "inISearchObserver.h"
#include "nsVoidArray.h"
#include "nsICSSStyleSheet.h"
#include "nsICSSStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsCSSValue.h"
class inCSSValueSearch : public inICSSValueSearch
{
public:
inCSSValueSearch();
~inCSSValueSearch();
protected:
PRBool mIsActive;
PRInt32 mResultCount;
PRBool mHoldResults;
nsVoidArray* mResults;
nsAutoString* mLastResult;
nsCOMPtr<inISearchObserver> mObserver;
nsCOMPtr<nsIDOMDocument> mDocument;
nsAutoString* mBaseURL;
PRBool mReturnRelativeURLs;
PRBool mNormalizeChromeURLs;
nsAutoString* mTextCriteria;
nsCSSProperty* mProperties;
PRUint32 mPropertyCount;
nsresult InitSearch();
nsresult KillSearch(PRInt16 aResult);
nsresult SearchStyleSheet(nsIStyleSheet* aStyleSheet);
nsresult SearchStyleRule(nsIStyleRule* aStyleRule);
nsresult SearchStyleValue(nsICSSDeclaration* aDec, nsCSSProperty aProp);
nsresult EqualizeURL(nsAutoString* aURL);
public:
NS_DECL_ISUPPORTS
NS_DECL_INISEARCHPROCESS
NS_DECL_INICSSVALUESEARCH
};
//////////////////////////////////////////////////////////////
// {4D977F60-FBE7-4583-8CB7-F5ED882293EF}
#define IN_CSSVALUESEARCH_CID \
{ 0x4d977f60, 0xfbe7, 0x4583, { 0x8c, 0xb7, 0xf5, 0xed, 0x88, 0x22, 0x93, 0xef } }
#define IN_CSSVALUESEARCH_CONTRACTID \
"@mozilla.org/inspector/search;1?type=cssvalue"
#endif

View File

@ -0,0 +1,638 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inFileSearch.h"
#include "nsCOMPtr.h"
#include "nsString.h"
///////////////////////////////////////////////////////////////////////////////
inFileSearch::inFileSearch()
{
NS_INIT_ISUPPORTS();
mSearchLoop = 0;
}
inFileSearch::~inFileSearch()
{
}
NS_IMPL_ISUPPORTS2(inFileSearch, inISearchProcess, inIFileSearch);
///////////////////////////////////////////////////////////////////////////////
// inISearchProcess
NS_IMETHODIMP
inFileSearch::GetIsActive(PRBool *aIsActive)
{
*aIsActive = mIsActive;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetResultCount(PRInt32 *aResultCount)
{
*aResultCount = mResultCount;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetHoldResults(PRBool *aHoldResults)
{
*aHoldResults = mHoldResults;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SetHoldResults(PRBool aHoldResults)
{
mHoldResults = aHoldResults;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SearchSync()
{
/* if (mSearchPath)
SearchDirectory(mSearchPath, PR_TRUE);
else {
return NS_ERROR_FAILURE;
}
*/
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inFileSearch::SearchAsync(inISearchObserver *aObserver)
{
mObserver = aObserver;
mObserver->OnSearchStart(this);
InitSearch();
InitSubDirectoryStack();
InitSearchLoop();
if (mSearchPath) {
// start off by searching the first directory
SearchDirectory(mSearchPath, PR_FALSE);
if (mSearchRecursive) {
// start the loop to continue searching
mIsActive = PR_TRUE;
mSearchLoop->Start();
} else {
KillSearch(inISearchObserver::SUCCESS);
}
} else {
nsAutoString msg;
msg.AssignWithConversion("No search path has been provided");
mObserver->OnSearchError(this, msg.ToNewUnicode());
KillSearch(inISearchObserver::ERROR);
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SearchStop()
{
KillSearch(inISearchObserver::INTERRUPTED);
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SearchStep(PRBool* _retval)
{
nsIFile* nextDir;
PRBool more = GetNextSubDirectory(&nextDir);
if (more) {
SearchDirectory(nextDir, PR_FALSE);
} else {
KillSearch(inISearchObserver::SUCCESS);
*_retval = PR_TRUE;
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetStringResultAt(PRInt32 aIndex, PRUnichar **_retval)
{
nsCOMPtr<nsIFile> file;
if (mHoldResults) {
nsCOMPtr<nsISupports> supports;
mResults->GetElementAt(aIndex, getter_AddRefs(supports));
file = do_QueryInterface(supports);
} else if (aIndex == mResultCount-1 && mLastResult) {
// get the path of the last result as an nsAutoString
file = mLastResult;
}
if (file) {
char* temp;
mLastResult->GetPath(&temp);
nsAutoString path;
path.AssignWithConversion(temp);
if (mReturnRelativePaths)
MakePathRelative(&path);
*_retval = path.ToNewUnicode();
} else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetIntResultAt(PRInt32 aIndex, PRInt32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inFileSearch::GetUIntResultAt(PRInt32 aIndex, PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////
// inIFileSearch
NS_IMETHODIMP
inFileSearch::GetBasePath(PRUnichar** aBasePath)
{
if (mBasePath) {
*aBasePath = mBasePath->ToNewUnicode();
} else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SetBasePath(const PRUnichar* aBasePath)
{
mBasePath = new nsAutoString();
mBasePath->Assign(aBasePath);
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetReturnRelativePaths(PRBool* aReturnRelativePaths)
{
*aReturnRelativePaths = mReturnRelativePaths;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SetReturnRelativePaths(PRBool aReturnRelativePaths)
{
mReturnRelativePaths = aReturnRelativePaths;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetFilenameCriteria(PRUnichar** aFilenameCriteria)
{
// TODO: reconstruct parsed filename criteria into string
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SetFilenameCriteria(const PRUnichar* aFilenameCriteria)
{
// first pass: scan for commas so we know how long to make array
PRUint32 idx = 0;
PRUint32 commas = 0;
const PRUnichar* c = aFilenameCriteria;
while (*c) {
if (*c == ',')
++commas;
++c;
}
mFilenameCriteria = new PRUnichar*[commas+1];
mFilenameCriteriaCount = 0;
// second pass: split up at commas and insert into array
idx = 0;
PRUint32 lastComma = -1;
PRUnichar* buf = new PRUnichar[257];
c = aFilenameCriteria;
PRBool going = PR_TRUE;
while (going) {
if (*c == ',' || !*c) {
buf[idx-lastComma-1] = 0;
lastComma = idx;
mFilenameCriteria[mFilenameCriteriaCount] = buf;
++mFilenameCriteriaCount;
buf = new PRUnichar[257];
if (!*c) going = PR_FALSE;
} else {
buf[idx-lastComma-1] = *c;
}
++c;
++idx;
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetTextCriteria(PRUnichar** aTextCriteria)
{
*aTextCriteria = mTextCriteria->ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SetTextCriteria(const PRUnichar* aTextCriteria)
{
mTextCriteria = new nsAutoString();
mTextCriteria->Assign(aTextCriteria);
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetSearchPath(nsIFile** aSearchPath)
{
*aSearchPath = mSearchPath;
NS_IF_ADDREF(*aSearchPath);
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SetSearchPath(nsIFile* aSearchPath)
{
mSearchPath = aSearchPath;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetSearchRecursive(PRBool* aSearchRecursive)
{
*aSearchRecursive = mSearchRecursive;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SetSearchRecursive(PRBool aSearchRecursive)
{
mSearchRecursive = aSearchRecursive;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetDirectoriesSearched(PRUint32* aDirectoriesSearched)
{
*aDirectoriesSearched = mDirsSearched;
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetCurrentDirectory(nsIFile** aCurrentDirectory)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inFileSearch::GetFileResultAt(PRInt32 aIndex, nsIFile** _retval)
{
if (mHoldResults && mResults) {
nsCOMPtr<nsISupports> supports;
mResults->GetElementAt(aIndex, getter_AddRefs(supports));
nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
*_retval = file;
} else if (aIndex == mResultCount-1 && mLastResult) {
*_retval = mLastResult;
NS_IF_ADDREF(*_retval);
} else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetDirectoryDepth(nsIFile* aDir, PRUint32* _retval)
{
*_retval = 0;
return CountDirectoryDepth(aDir, _retval);
}
NS_IMETHODIMP
inFileSearch::GetSubDirectories(nsIFile* aDir, nsISupportsArray** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////
// inFileSearch
nsresult
inFileSearch::InitSearch()
{
if (mHoldResults) {
mResults = do_CreateInstance("@mozilla.org/supports-array;1");
} else {
mResults = nsnull;
}
mLastResult = nsnull;
mResultCount = 0;
mDirsSearched = 0;
return NS_OK;
}
nsresult
inFileSearch::KillSearch(PRInt16 aResult)
{
mIsActive = PR_TRUE;
mObserver->OnSearchEnd(this, aResult);
return NS_OK;
}
nsresult
inFileSearch::SearchDirectory(nsIFile* aDir, PRBool aIsSync)
{
++mDirsSearched;
// recurse through subdirectories
nsISimpleEnumerator* entries;
aDir->GetDirectoryEntries(&entries);
if (!aIsSync) {
// store this directory for next step in async search
PushSubDirectoryOnStack(aDir);
}
PRBool hasMoreElements;
PRBool isDirectory;
nsCOMPtr<nsIFile> entry;
entries->HasMoreElements(&hasMoreElements);
while (hasMoreElements) {
entries->GetNext(getter_AddRefs(entry));
entries->HasMoreElements(&hasMoreElements);
entry->IsDirectory(&isDirectory);
if (isDirectory && aIsSync) {
// this is a directory, so search it now (only if synchronous)
if (aIsSync)
SearchDirectory(entry, aIsSync);
} else {
// this is a file, so see if it matches
if (MatchFile(entry)) {
PrepareResult(entry, aIsSync);
}
}
}
return NS_OK;
}
nsresult
inFileSearch::PrepareResult(nsIFile* aFile, PRBool aIsSync)
{
if (aIsSync || mHoldResults) {
mResults->AppendElement(aFile);
}
if (!aIsSync) {
++mResultCount;
mLastResult = aFile;
mObserver->OnSearchResult(this);
}
return NS_OK;
}
nsresult
inFileSearch::InitSearchLoop()
{
if (!mSearchLoop) {
nsCOMPtr<inISearchProcess> process = do_QueryInterface(this);
mSearchLoop = new inSearchLoop(process);
}
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// Subdirectory stack (for asynchronous searches)
nsresult
inFileSearch::InitSubDirectoryStack()
{
mDirStack = do_CreateInstance("@mozilla.org/supports-array;1");
return NS_OK;
}
PRBool
inFileSearch::GetNextSubDirectory(nsIFile** aDir)
{
// get the enumerator on top of the stack
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsISimpleEnumerator> nextDirs;
PRUint32 count;
while (true) {
mDirStack->Count(&count);
// the stack is empty, so our search must be complete
if (count == 0) return PR_FALSE;
// get the next directory enumerator on the stack
mDirStack->GetElementAt(count-1, getter_AddRefs(supports));
nextDirs = do_QueryInterface(supports);
// get the next directory from the enumerator
nsIFile* dir = GetNextDirectory(nextDirs);
if (dir) {
// this enumerator is ready to rock, so let's move on
*aDir = dir;
return PR_TRUE;
} else {
// enumerator is done, so pop it off the stack
mDirStack->RemoveElement(supports);
}
}
return PR_TRUE;
}
nsresult
inFileSearch::PushSubDirectoryOnStack(nsIFile* aDir)
{
nsISimpleEnumerator* entries;
aDir->GetDirectoryEntries(&entries);
mDirStack->AppendElement(entries);
return NS_OK;
}
nsIFile*
inFileSearch::GetNextDirectory(nsISimpleEnumerator* aEnum)
{
nsCOMPtr<nsIFile> file;
nsCOMPtr<nsISupports> supports;
PRBool isDir;
PRBool hasMoreElements;
while (true) {
aEnum->HasMoreElements(&hasMoreElements);
if (!hasMoreElements)
break;
aEnum->GetNext(getter_AddRefs(supports));
file = do_QueryInterface(supports);
file->IsDirectory(&isDir);
if (isDir)
break;
}
nsIFile* f = file.get();
NS_IF_ADDREF(f);
return isDir ? f : nsnull;
}
///////////////////////////////////////////////////////////////////////////////
// Pattern Matching
PRBool
inFileSearch::MatchFile(nsIFile* aFile)
{
char* fileName;
aFile->GetLeafName(&fileName);
nsAutoString temp;
temp.AssignWithConversion(fileName);
PRUnichar* fileNameUnicode = temp.ToNewUnicode();
PRBool match;
for (PRUint32 i = 0; i < mFilenameCriteriaCount; ++i) {
match = MatchPattern(mFilenameCriteria[i], fileNameUnicode);
if (match) return PR_TRUE;
}
return PR_FALSE;
}
PRBool
inFileSearch::MatchPattern(PRUnichar* aPattern, PRUnichar* aString)
{
PRInt32 index = 0;
PRBool matching = true;
char wildcard = '*';
PRUnichar* patternPtr = aPattern;
PRUnichar* stringPtr = aString;
while (matching && *patternPtr && *stringPtr) {
if (*patternPtr == wildcard) {
matching = AdvanceWildcard(&stringPtr, patternPtr+1);
} else {
matching = *patternPtr == *stringPtr;
++stringPtr;
}
if (!matching) return false;
++patternPtr;
++index;
}
return matching;
}
PRBool
inFileSearch::AdvanceWildcard(PRUnichar** aString, PRUnichar* aNextChar)
{
PRUnichar* stringPtr = *aString;
while (1) {
if (*stringPtr == *aNextChar) {
// we have found the next char after the wildcard, so return with success
*aString = stringPtr;
return true;
} else if (*stringPtr == 0)
return false;
++stringPtr;
}
}
///////////////////////////////////////////////////////////////////////////////
// URL fixing
nsresult
inFileSearch::MakePathRelative(nsAutoString* aPath)
{
nsAutoString result;
// get an nsAutoString version of the search path
char* temp;
mSearchPath->GetPath(&temp);
nsAutoString searchPath;
searchPath.AssignWithConversion(temp);
PRInt32 found = aPath->Find(searchPath, false, 0, 1);
if (found == 0) {
PRUint32 len = searchPath.Length();
aPath->Mid(result, len+1, aPath->Length()-len);
result.ReplaceChar('\\', '/');
}
aPath->Assign(result);
return NS_OK;
}
nsresult
inFileSearch::CountDirectoryDepth(nsIFile* aDir, PRUint32* aDepth)
{
++(*aDepth);
nsISimpleEnumerator* entries;
aDir->GetDirectoryEntries(&entries);
PRBool hasMoreElements;
PRBool isDirectory;
nsCOMPtr<nsIFile> entry;
entries->HasMoreElements(&hasMoreElements);
while (hasMoreElements) {
entries->GetNext(getter_AddRefs(entry));
entries->HasMoreElements(&hasMoreElements);
entry->IsDirectory(&isDirectory);
if (isDirectory) {
CountDirectoryDepth(entry, aDepth);
}
}
return NS_OK;
}

View File

@ -0,0 +1,103 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __inFileSearch_h__
#define __inFileSearch_h__
#include "inIFileSearch.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsISupportsArray.h"
#include "inISearchObserver.h"
#include "nsIFile.h"
#include "inSearchLoop.h"
class inFileSearch : public inIFileSearch
{
public:
inFileSearch();
~inFileSearch();
protected:
// inISearchProcess related
PRBool mIsActive;
PRInt32 mResultCount;
nsIFile* mLastResult;
nsCOMPtr<nsISupportsArray> mResults;
PRBool mHoldResults;
nsAutoString* mBasePath;
PRBool mReturnRelativePaths;
nsCOMPtr<inISearchObserver> mObserver;
// inIFileSearch related
nsCOMPtr<nsIFile> mSearchPath;
nsAutoString* mTextCriteria;
PRUnichar** mFilenameCriteria;
PRUint32 mFilenameCriteriaCount;
PRBool mSearchRecursive;
PRUint32 mDirsSearched;
// asynchronous search related
nsCOMPtr<nsISupportsArray> mDirStack;
inSearchLoop* mSearchLoop;
// life cycle of search
nsresult InitSearch();
nsresult KillSearch(PRInt16 aResult);
nsresult SearchDirectory(nsIFile* aDir, PRBool aIsSync);
nsresult PrepareResult(nsIFile* aFile, PRBool aIsSync);
// asynchronous search helpers
nsresult InitSearchLoop();
nsresult InitSubDirectoryStack();
PRBool GetNextSubDirectory(nsIFile** aDir);
nsresult PushSubDirectoryOnStack(nsIFile* aDir);
nsIFile* GetNextDirectory(nsISimpleEnumerator* aEnum);
// pattern matching
PRBool MatchFile(nsIFile* aFile);
static PRBool MatchPattern(PRUnichar* aPattern, PRUnichar* aString);
static PRBool AdvanceWildcard(PRUnichar** aString, PRUnichar* aNextChar);
// misc
nsresult MakePathRelative(nsAutoString* aPath);
nsresult CountDirectoryDepth(nsIFile* aDir, PRUint32* aDepth);
public:
NS_DECL_ISUPPORTS
NS_DECL_INISEARCHPROCESS
NS_DECL_INIFILESEARCH
};
//////////////////////////////////////////////////////////////
// {D5636476-9F94-47f2-9CE9-69CDD9D7BBCD}
#define IN_FILESEARCH_CID \
{ 0xd5636476, 0x9f94, 0x47f2, { 0x9c, 0xe9, 0x69, 0xcd, 0xd9, 0xd7, 0xbb, 0xcd } }
#define IN_FILESEARCH_CONTRACTID \
"@mozilla.org/inspector/search;1?type=file"
#endif

View File

@ -0,0 +1,182 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inFlasher.h"
#include "dsinfo.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIServiceManager.h"
#include "nsIFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIDocument.h"
#include "nsIDocShell.h"
#include "nsIPresShell.h"
#include "nsIRenderingContext.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMElement.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsIScriptGlobalObject.h"
///////////////////////////////////////////////////////////////////////////////
inFlasher::inFlasher()
{
NS_INIT_REFCNT();
}
inFlasher::~inFlasher()
{
}
NS_IMPL_ISUPPORTS1(inFlasher, inIFlasher);
///////////////////////////////////////////////////////////////////////////////
// inIFlasher
NS_IMETHODIMP
inFlasher::RepaintElement(nsIDOMElement* aElement, nsIDOMWindowInternal* aWindow)
{
nsIPresShell* presShell = GetPresShellFor(aWindow);
nsIFrame* frame = GetFrameFor(aElement, presShell);
if (!frame) return NS_OK;
nsCOMPtr<nsIPresContext> pcontext;
presShell->GetPresContext(getter_AddRefs(pcontext));
nsIFrame* parentWithView;
frame->GetParentWithView(pcontext, &parentWithView);
if (parentWithView) {
nsIView* view;
parentWithView->GetView(pcontext, &view);
if (view) {
nsIViewManager* viewManager;
view->GetViewManager(viewManager);
nsRect rect;
parentWithView->GetRect(rect);
viewManager->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC);
}
}
return NS_OK;
}
NS_IMETHODIMP
inFlasher::DrawElementOutline(nsIDOMElement* aElement, nsIDOMWindowInternal* aWindow, const PRUnichar* aColor, PRInt32 aThickness)
{
nsIPresShell* presShell = GetPresShellFor(aWindow);
nsIFrame* frame = GetFrameFor(aElement, presShell);
if (!frame) return NS_OK;
nsCOMPtr<nsIPresContext> pcontext;
presShell->GetPresContext(getter_AddRefs(pcontext));
nsCOMPtr<nsIRenderingContext> rcontext;
presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext));
nsAutoString colorStr;
colorStr.Assign(aColor);
nscolor color;
PRBool rv = NS_HexToRGB(colorStr, &color);
nsRect rect;
frame->GetRect(rect);
nsPoint origin(0,0);
GetClientOrigin(frame, origin);
float p2t;
pcontext->GetPixelsToTwips(&p2t);
DrawOutline(origin.x, origin.y, rect.width, rect.height, color, aThickness, p2t, rcontext);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// inFlasher
NS_IMETHODIMP
inFlasher::DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, nscolor aColor,
PRUint32 aThickness, float aP2T, nsIRenderingContext* aRenderContext)
{
aRenderContext->SetColor(aColor);
DrawLine(aX, aY, aWidth, aThickness, DIR_HORIZONTAL, BOUND_OUTER, aP2T, aRenderContext);
DrawLine(aX, aY, aHeight, aThickness, DIR_VERTICAL, BOUND_OUTER, aP2T, aRenderContext);
DrawLine(aX, aY+aHeight, aWidth, aThickness, DIR_HORIZONTAL, BOUND_INNER, aP2T, aRenderContext);
DrawLine(aX+aWidth, aY, aHeight, aThickness, DIR_VERTICAL, BOUND_INNER, aP2T, aRenderContext);
return NS_OK;
}
NS_IMETHODIMP
inFlasher::DrawLine(nscoord aX, nscoord aY, nscoord aLength, PRUint32 aThickness,
PRBool aDir, PRBool aBounds, float aP2T, nsIRenderingContext* aRenderContext)
{
nscoord thickTwips = NSIntPixelsToTwips(aThickness, aP2T);
if (aDir) { // horizontal
aRenderContext->FillRect(aX, aY+(aBounds?0:-thickTwips), aLength, thickTwips);
} else { // vertical
aRenderContext->FillRect(aX+(aBounds?0:-thickTwips), aY, thickTwips, aLength);
}
return NS_OK;
}
NS_IMETHODIMP
inFlasher::GetClientOrigin(nsIFrame* aFrame, nsPoint& aPoint)
{
nsIFrame* parent = aFrame;
while (parent) {
nsPoint origin;
parent->GetOrigin(origin);
aPoint.x += origin.x;
aPoint.y += origin.y;
parent->GetParent(&parent);
}
return NS_OK;
}
nsIFrame*
inFlasher::GetFrameFor(nsIDOMElement* aElement, nsIPresShell* aShell)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
nsIFrame* frame;
aShell->GetPrimaryFrameFor(content, &frame);
return frame;
}
nsIPresShell*
inFlasher::GetPresShellFor(nsISupports* aThing)
{
nsCOMPtr<nsIScriptGlobalObject> so = do_QueryInterface(aThing);
nsCOMPtr<nsIDocShell> docShell;
so->GetDocShell(getter_AddRefs(docShell));
nsIPresShell* presShell;
docShell->GetPresShell(&presShell);
return presShell;
}

View File

@ -0,0 +1,70 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __inFlasher_h__
#define __inFlasher_h__
#include "inIFlasher.h"
#include "nsIDOMElement.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsIRenderingContext.h"
#define BOUND_INNER 0
#define BOUND_OUTER 1
#define DIR_VERTICAL 0
#define DIR_HORIZONTAL 1
class inFlasher : public inIFlasher
{
public:
inFlasher();
~inFlasher();
protected:
nsIFrame* GetFrameFor(nsIDOMElement* aElement, nsIPresShell* aShell);
nsIPresShell* GetPresShellFor(nsISupports* aThing);
NS_IMETHOD DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, nscolor aColor,
PRUint32 aThickness, float aP2T, nsIRenderingContext* aRenderContext);
NS_IMETHOD DrawLine(nscoord aX, nscoord aY, nscoord aLength, PRUint32 aThickness,
PRBool aDir, PRBool aBounds, float aP2T, nsIRenderingContext* aRenderContext);
NS_IMETHOD GetClientOrigin(nsIFrame* aFrame, nsPoint& aPoint);
public:
NS_DECL_ISUPPORTS
NS_DECL_INIFLASHER
};
//////////////////////////////////////////////////////////////
// {9286E71A-621A-4b91-851E-9984C1A2E81A}
#define IN_FLASHER_CID \
{ 0x9286e71a, 0x621a, 0x4b91, { 0x85, 0x1e, 0x99, 0x84, 0xc1, 0xa2, 0xe8, 0x1a } }
#define IN_FLASHER_CONTRACTID \
"@mozilla.org/inspector/flasher;1"
#endif

View File

@ -0,0 +1,83 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inSearchItemImage.h"
///////////////////////////////////////////////////////////////////////////////
inSearchItemImage::inSearchItemImage(nsAutoString* aURL)
{
NS_INIT_ISUPPORTS();
mURL = *aURL;
}
inSearchItemImage::~inSearchItemImage()
{
}
NS_IMPL_ISUPPORTS1(inSearchItemImage, inISearchItem);
///////////////////////////////////////////////////////////////////////////////
// inISearchItem
NS_IMETHODIMP
inSearchItemImage::GetDescription(PRUnichar** aDescription)
{
*aDescription = mURL.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inSearchItemImage::GetIconURL(PRUnichar** aURL)
{
nsAutoString url;
url.AssignWithConversion("chrome://inspector/content/search/ImageSearchItem.gif");
*aURL = url.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inSearchItemImage::IsViewable(PRBool* _retval)
{
*_retval = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
inSearchItemImage::IsEditable(PRBool *_retval)
{
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
inSearchItemImage::ViewItem(nsIDOMElement **_retval)
{
return NS_OK;
}
NS_IMETHODIMP
inSearchItemImage::EditItem()
{
return NS_OK;
}

View File

@ -0,0 +1,55 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __searchItemImage_h__
#define __searchItemImage_h__
#include "inISearchItem.h"
#include "nsCOMPtr.h"
#include "nsString.h"
class inSearchItemImage : public inISearchItem
{
public:
inSearchItemImage(nsAutoString* aURL);
~inSearchItemImage();
protected:
nsAutoString mURL;
public:
NS_DECL_ISUPPORTS
NS_DECL_INISEARCHITEM
};
////////////////////////////////////////////////////////////////////
// {AA526D81-7523-4fc6-9B6A-22D74CC55AB7}
#define IN_SEARCHITEMIMAGE_CID \
{ 0xaa526d81, 0x7523, 0x4fc6, { 0x9b, 0x6a, 0x22, 0xd7, 0x4c, 0xc5, 0x5a, 0xb7 } }
#define IN_SEARCHITEMIMAGE_CONTRACTID \
"@mozilla.org/inspector/searchitem;1?type=image"
#endif

View File

@ -0,0 +1,76 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inSearchLoop.h"
#include "nsITimer.h"
///////////////////////////////////////////////////////////////////////////////
inSearchLoop::inSearchLoop(inISearchProcess* aSearchProcess)
{
mSearchProcess = aSearchProcess;
nsresult rv;
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
}
inSearchLoop::~inSearchLoop()
{
}
///////////////////////////////////////////////////////////////////////////////
// inSearchLoop
nsresult
inSearchLoop::Start()
{
mTimer->Init(inSearchLoop::TimerCallback, (void*)this, 0, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
return NS_OK;
}
nsresult
inSearchLoop::Step()
{
PRBool done = PR_FALSE;
mSearchProcess->SearchStep(&done);
if (done)
Stop();
return NS_OK;
}
nsresult
inSearchLoop::Stop()
{
mTimer->Cancel();
return NS_OK;
}
void
inSearchLoop::TimerCallback(nsITimer *aTimer, void *aClosure)
{
inSearchLoop* loop = (inSearchLoop*) aClosure;
loop->Step();
}

View File

@ -0,0 +1,46 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __inSearchLoop_h__
#define __inSearchLoop_h__
#include "nsITimer.h"
#include "inISearchProcess.h"
class inSearchLoop
{
public:
inSearchLoop(inISearchProcess* aSearchProcess);
~inSearchLoop();
protected:
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<inISearchProcess> mSearchProcess;
public:
nsresult Start();
nsresult Step();
nsresult Stop();
static void TimerCallback(nsITimer *aTimer, void *aClosure);
};
#endif

View File

@ -0,0 +1,569 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "inSearchOrphanImages.h"
#include "dsinfo.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsString.h"
#include "nsILocalFile.h"
#include "nsIURI.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsICSSStyleSheet.h"
#include "nsICSSStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsCSSValue.h"
#include "nsITimer.h"
#include "nsIRDFService.h"
#include "nsIRDFResource.h"
///////////////////////////////////////////////////////////////////////////////
#define INS_RDF_SEARCH_ROOT "inspector:searchResults"
#define INS_RDF_RESULTS INS_NAMESPACE_URI "results"
#define INS_RDF_URL INS_NAMESPACE_URI "url"
nsIRDFResource* kINS_SearchRoot;
nsIRDFResource* kINS_results;
nsIRDFResource* kINS_url;
///////////////////////////////////////////////////////////////////////////////
inSearchOrphanImages::inSearchOrphanImages()
{
NS_INIT_ISUPPORTS();
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService), (nsISupports**) &mRDF);
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to get RDF service");
rv = nsServiceManager::GetService(kRDFContainerUtilsCID, NS_GET_IID(nsIRDFContainerUtils), (nsISupports**) &mRDFCU);
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to get RDF container utils");
mRDF->GetResource(INS_RDF_SEARCH_ROOT, &kINS_SearchRoot);
mRDF->GetResource(INS_RDF_RESULTS, &kINS_results);
mRDF->GetResource(INS_RDF_URL, &kINS_url);
}
inSearchOrphanImages::~inSearchOrphanImages()
{
}
NS_IMPL_ISUPPORTS2(inSearchOrphanImages, inISearchOrphanImages, inISearchProcess);
///////////////////////////////////////////////////////////////////////////////
// inISearchOrphanImages
NS_IMETHODIMP
inSearchOrphanImages::GetSearchPath(PRUnichar** aSearchPath)
{
*aSearchPath = mSearchPath.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::SetSearchPath(const PRUnichar* aSearchPath)
{
mSearchPath.Assign(aSearchPath);
mSearchPath.Trim("\\/", PR_FALSE, PR_TRUE, PR_FALSE);
mSearchPath.AppendWithConversion("\\");
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::GetRemotePath(PRUnichar** aRemotePath)
{
*aRemotePath = mRemotePath.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::SetRemotePath(const PRUnichar* aRemotePath)
{
mRemotePath.Assign(aRemotePath);
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::GetIsSkin(PRBool* aIsSkin)
{
*aIsSkin = mIsSkin;
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::SetIsSkin(PRBool aIsSkin)
{
mIsSkin = aIsSkin;
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::GetDocument(nsIDOMDocument** aDocument)
{
*aDocument = mDocument;
NS_IF_ADDREF(*aDocument);
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::SetDocument(nsIDOMDocument* aDocument)
{
mDocument = aDocument;
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// inISearchProcess
nsresult
inSearchOrphanImages::GetUid(PRUnichar** aUid)
{
nsAutoString uid;
uid.AssignWithConversion("findOrphanImages");
*aUid = uid.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::GetDataSource(nsIRDFDataSource** aDataSource)
{
*aDataSource = mDataSource;
NS_IF_ADDREF(*aDataSource);
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::GetProgressPercent(PRInt16* aProgressPercent)
{
PRUint32 count;
mDirectories->Count(&count);
*aProgressPercent = (100 * (mCurrentStep+1)) / count;
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::GetResultCount(PRUint32* aResultCount)
{
*aResultCount = mResultCount;
return NS_OK;
}
NS_IMETHODIMP
inSearchOrphanImages::GetProgressText(PRUnichar** aProgressText)
{
// XX return current directory being searched
nsAutoString text;
text.AssignWithConversion("searching");
*aProgressText = text.ToNewUnicode();
return NS_OK;
}
nsresult
inSearchOrphanImages::Start(inISearchObserver* aObserver)
{
nsresult rv;
mObserver = aObserver;
mCurrentStep = 0;
mResultCount = 0;
rv = InitDataSource();
if (NS_FAILED(rv)) {
ReportError("Unable to create results datasource.");
return NS_OK;
}
mObserver->OnSearchStart(this);
rv = CacheAllDirectories();
if (!NS_FAILED(rv))
StartSearchTimer();
PRUint32 count;
mDirectories->Count(&count);
return rv;
}
NS_IMETHODIMP
inSearchOrphanImages::Stop()
{
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// inSearchOrphanImages
nsresult
inSearchOrphanImages::SearchStep(PRBool* aDone)
{
PRUint32 count;
mDirectories->Count(&count);
if (mCurrentStep == 0) {
BuildRemoteURLHash();
} else if (mCurrentStep == count) {
*aDone = PR_TRUE;
mObserver->OnSearchEnd(this);
} else {
nsCOMPtr<nsIFile> file;
mDirectories->GetElementAt(mCurrentStep-1, getter_AddRefs(file));
SearchDirectory(file);
}
mCurrentStep++;
return NS_OK;
}
nsresult
inSearchOrphanImages::CacheAllDirectories()
{
if (mSearchPath.Length() < 1) return NS_ERROR_FAILURE;
mDirectories = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
nsCOMPtr<nsILocalFile> file;
NS_NewLocalFile(mSearchPath.ToNewCString(), false, getter_AddRefs(file));
CacheDirectory(file);
return NS_OK;
}
nsresult
inSearchOrphanImages::CacheDirectory(nsIFile* aDir)
{
// store this direcotyr
mDirectories->AppendElement(aDir);
// recurse through subdirectories
nsISimpleEnumerator* entries;
aDir->GetDirectoryEntries(&entries);
PRBool* hasMoreElements = new PRBool();
PRBool* isDirectory = new PRBool();
nsCOMPtr<nsIFile> entry;
entries->HasMoreElements(hasMoreElements);
while (*hasMoreElements) {
entries->GetNext(getter_AddRefs(entry));
entries->HasMoreElements(hasMoreElements);
entry->IsDirectory(isDirectory);
if (*isDirectory) {
CacheDirectory(entry);
}
}
return NS_OK;
}
nsresult
inSearchOrphanImages::SearchDirectory(nsIFile* aDir)
{
nsISimpleEnumerator* entries;
aDir->GetDirectoryEntries(&entries);
PRBool* hasMoreElements = new PRBool();
PRBool* isFile = new PRBool();
nsCOMPtr<nsIFile> entry;
entries->HasMoreElements(hasMoreElements);
while (*hasMoreElements) {
entries->GetNext(getter_AddRefs(entry));
entries->HasMoreElements(hasMoreElements);
entry->IsFile(isFile);
if (*isFile) {
nsAutoString ext = GetFileExtension(entry);
if (ext.EqualsIgnoreCase("gif", -1) ||
ext.EqualsIgnoreCase("png", -1) ||
ext.EqualsIgnoreCase("jpg", -1)) {
char* path;
entry->GetPath(&path);
nsAutoString localPath;
localPath.AssignWithConversion(path);
nsAutoString equalized = EqualizeLocalURL(&localPath);
nsStringKey key(equalized);
PRUint32 result = (PRUint32) mFileHash->Get(&key);
if (!result) {
//printf("ORPHAN: '%s'\n", url);
nsCOMPtr<nsIRDFResource> res;
CreateResourceFromFile(entry, getter_AddRefs(res));
mResultCount++;
mObserver->OnSearchResult(this);
}
}
}
}
return NS_OK;
}
nsAutoString
inSearchOrphanImages::GetFileExtension(nsIFile* aFile)
{
nsAutoString result;
char* fileName;
aFile->GetLeafName(&fileName);
nsAutoString name;
name.AssignWithConversion(fileName);
name.Right(result, 3);
result.ToLowerCase();
return result;
}
nsresult
inSearchOrphanImages::BuildRemoteURLHash()
{
// XXX dunno if I have to addref here and release the old one.. Scripting habits be damned!
mFileHash = new nsHashtable(3000, true);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
if (doc) {
PRInt32 count = doc->GetNumberOfStyleSheets();
for (PRInt32 i = 0; i < count; i++) {
nsIStyleSheet* sheet = doc->GetStyleSheetAt(i);
HashStyleSheet(sheet);
}
}
return NS_OK;
}
nsresult
inSearchOrphanImages::HashStyleSheet(nsIStyleSheet* aStyleSheet)
{
NS_IF_ADDREF(aStyleSheet);
nsCOMPtr<nsICSSStyleSheet> cssSheet = do_QueryInterface(aStyleSheet);
if (cssSheet) {
// recurse downward through the stylesheet tree
PRInt32 count;
cssSheet->StyleSheetCount(count);
for (PRInt32 i = 0; i < count; i++) {
nsICSSStyleSheet* child;
cssSheet->GetStyleSheetAt(i, child);
HashStyleSheet(child);
}
cssSheet->StyleRuleCount(count);
for (i = 0; i < count; i++) {
nsICSSRule* rule;
cssSheet->GetStyleRuleAt(i, rule);
HashStyleRule(rule);
}
}
NS_IF_RELEASE(aStyleSheet);
return NS_OK;
}
nsresult
inSearchOrphanImages::HashStyleRule(nsIStyleRule* aStyleRule)
{
NS_IF_ADDREF(aStyleRule);
nsCOMPtr<nsICSSStyleRule> cssRule = do_QueryInterface(aStyleRule);
if (cssRule) {
nsCOMPtr<nsICSSDeclaration> aDec = cssRule->GetDeclaration();
HashStyleValue(aDec, eCSSProperty_background_image);
HashStyleValue(aDec, eCSSProperty_list_style_image);
}
NS_IF_RELEASE(aStyleRule);
return NS_OK;
}
nsresult
inSearchOrphanImages::HashStyleValue(nsICSSDeclaration* aDec, nsCSSProperty aProp)
{
nsCSSValue value;
aDec->GetValue(aProp, value);
if (value.GetUnit() == eCSSUnit_URL) {
nsAutoString result;
result = value.GetStringValue(result);
EqualizeRemoteURL(&result);
nsStringKey key (result);
mFileHash->Put(&key, (void*)1);
}
return NS_OK;
}
nsresult
inSearchOrphanImages::EqualizeRemoteURL(nsAutoString* aURL)
{
if (mIsSkin) {
if (aURL->Find("chrome://", false, 0, 1) >= 0) {
PRUint32 len = aURL->Length();
char* result = new char[len-8];
char* buffer = aURL->ToNewCString();
PRUint32 i = 9;
PRUint32 milestone = 0;
PRUint32 s = 0;
while (i < len) {
if (buffer[i] == '/') {
milestone += 1;
}
if (milestone == 0 || milestone > 1) {
result[i-9-s] = (buffer[i] == '/') ? '/' : buffer[i];
} else {
s++;
}
i++;
}
result[i-9-s] = 0;
aURL->AssignWithConversion(result);
//printf("hash: '%s'\n", result);
}
} else {
}
return NS_OK;
}
nsAutoString
inSearchOrphanImages::EqualizeLocalURL(nsAutoString* aURL)
{
nsAutoString result;
PRInt32 found = aURL->Find(mSearchPath, false, 0, 1);
if (found == 0) {
PRUint32 len = mSearchPath.Length();
aURL->Mid(result, len, aURL->Length()-len);
result.ReplaceChar('\\', '/');
//printf("file: '%s'\n", result.ToNewCString());
}
return result;
}
nsresult
inSearchOrphanImages::ReportError(char* aMsg)
{
nsAutoString msg;
msg.AssignWithConversion(aMsg);
mObserver->OnSearchError(this, msg.ToNewUnicode());
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// timer stuff
nsresult
inSearchOrphanImages::StartSearchTimer()
{
nsresult rv;
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
mTimer->Init(inSearchOrphanImages::SearchTimerCallback, (void*)this, 0, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
return NS_OK;
}
nsresult
inSearchOrphanImages::StopSearchTimer()
{
mTimer->Cancel();
mTimer = nsnull;
return NS_OK;
}
void
inSearchOrphanImages::SearchTimerCallback(nsITimer *aTimer, void *aClosure)
{
inSearchOrphanImages* search = (inSearchOrphanImages*) aClosure;
PRBool done = PR_FALSE;
search->SearchStep(&done);
if (done) {
search->StopSearchTimer();
}
}
///////////////////////////////////////////////////////////////////////////////
// RDF stuff
nsresult
inSearchOrphanImages::InitDataSource()
{
nsresult rv;
mDataSource = do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource", &rv);
nsCOMPtr<nsIRDFResource> res;
mRDF->GetAnonymousResource(getter_AddRefs(res));
mDataSource->Assert(kINS_SearchRoot, kINS_results, res, true);
mRDFCU->MakeSeq(mDataSource, res, getter_AddRefs(mResultSeq));
return rv;
}
nsresult
inSearchOrphanImages::CreateResourceFromFile(nsIFile* aFile, nsIRDFResource** aRes)
{
nsCOMPtr<nsIRDFResource> res;
mRDF->GetAnonymousResource(getter_AddRefs(res));
char* url;
aFile->GetURL(&url);
nsAutoString theURL;
theURL.AssignWithConversion(url);
nsCOMPtr<nsIRDFLiteral> literal;
mRDF->GetLiteral(theURL.ToNewUnicode(), getter_AddRefs(literal));
mDataSource->Assert(res, kINS_url, literal, true);
mResultSeq->AppendElement(res);
return NS_OK;
}

View File

@ -0,0 +1,111 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __searchOrphanImages_h__
#define __searchOrphanImages_h__
#include "inISearchOrphanImages.h"
#include "inISearchProcess.h"
#include "inISearchObserver.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsSupportsArray.h"
#include "nsHashtable.h"
#include "nsIDOMDocument.h"
#include "nsIStyleSheet.h"
#include "nsIStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsCSSProps.h"
#include "nsIFile.h"
#include "nsITimer.h"
#include "nsIRDFService.h"
#include "nsIRDFLiteral.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFContainer.h"
class inSearchOrphanImages : public inISearchOrphanImages,
public inISearchProcess
{
public:
inSearchOrphanImages();
~inSearchOrphanImages();
nsresult SearchStep(PRBool* aDone);
nsresult StopSearchTimer();
protected:
nsIRDFService* mRDF;
nsIRDFContainerUtils* mRDFCU;
nsCOMPtr<nsITimer> mTimer;
nsHashtable* mFileHash;
nsCOMPtr<nsISupportsArray> mDirectories;
PRUint32 mCurrentStep;
PRUint32 mResultCount;
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsCOMPtr<nsIRDFContainer> mResultSeq;
nsCOMPtr<inISearchObserver> mObserver;
nsAutoString mRemotePath;
nsAutoString mSearchPath;
PRBool mIsSkin;
nsCOMPtr<nsIDOMDocument> mDocument;
nsresult BuildRemoteURLHash();
nsresult HashStyleSheet(nsIStyleSheet* aStyleSheet);
nsresult HashStyleRule(nsIStyleRule* aStyleRule);
nsresult HashStyleValue(nsICSSDeclaration* aDec, nsCSSProperty aProp);
nsresult EqualizeRemoteURL(nsAutoString* aURL);
nsAutoString EqualizeLocalURL(nsAutoString* aURL);
nsresult SearchDirectory(nsIFile* aDir);
nsAutoString GetFileExtension(nsIFile* aFile);
nsresult StartSearchTimer();
nsresult CacheAllDirectories();
nsresult CacheDirectory(nsIFile* aDir);
nsresult InitDataSource();
nsresult CreateResourceFromFile(nsIFile* aFile, nsIRDFResource** aRes);
nsresult ReportError(char* aMsg);
static void SearchTimerCallback(nsITimer *aTimer, void *aClosure);
public:
NS_DECL_ISUPPORTS
NS_DECL_INISEARCHORPHANIMAGES
NS_DECL_INISEARCHPROCESS
};
////////////////////////////////////////////////////////////////////
// {865761A8-7A39-426c-8114-396FA2B03768}
#define IN_SEARCHORPHANIMAGES_CID \
{ 0x865761a8, 0x7a39, 0x426c, { 0x81, 0x14, 0x39, 0x6f, 0xa2, 0xb0, 0x37, 0x68 } }
#define IN_SEARCHORPHANIMAGES_CONTRACTID \
"@mozilla.org/inspector/search;1?name=findOrphanImages"
#endif

View File

@ -0,0 +1,72 @@
#!nmake
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
LIBRARY_NAME=inspector_s
MODULE=inspector
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
CPPSRCS= \
.\nsDOMDataSource.cpp \
.\nsCSSRuleDataSource.cpp \
.\nsCSSDecDataSource.cpp \
.\nsDOMDSResource.cpp \
.\nsCSSDecIntHolder.cpp \
.\inFlasher.cpp \
.\inSearchLoop.cpp \
.\inFileSearch.cpp \
.\inCSSValueSearch.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsDOMDataSource.obj \
.\$(OBJDIR)\nsCSSRuleDataSource.obj \
.\$(OBJDIR)\nsCSSDecDataSource.obj \
.\$(OBJDIR)\nsDOMDSResource.obj \
.\$(OBJDIR)\nsCSSDecIntHolder.obj \
.\$(OBJDIR)\inFlasher.obj \
.\$(OBJDIR)\inSearchLoop.obj \
.\$(OBJDIR)\inFileSearch.obj \
.\$(OBJDIR)\inCSSValueSearch.obj \
$(NULL)
EXPORTS = $(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
-I$(PUBLIC)\dom -I$(PUBLIC)\uconv
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

View File

@ -0,0 +1,438 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-file-style: "stroustrup" -*-
*
* 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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
#include "nsCSSDecDataSource.h"
#include "dsinfo.h"
////////////////////////////////////////////////////////////////////////
// globals and constants
#define INS_RDF_DECROOT "inspector:DecRoot"
#define INS_RDF_PROPERTY INS_NAMESPACE_URI "Property"
#define INS_RDF_PROPERTYNAME INS_NAMESPACE_URI "PropertyName"
#define INS_RDF_PROPERTYVALUE INS_NAMESPACE_URI "PropertyValue"
#define INS_RDF_PROPERTYPRIORITY INS_NAMESPACE_URI "PropertyPriority"
static PRInt32 gCurrentId = 0;
nsIRDFResource *kINS_DecRoot;
nsIRDFResource *kINS_Property;
nsIRDFResource *kINS_PropertyName;
nsIRDFResource *kINS_PropertyValue;
nsIRDFResource *kINS_PropertyPriority;
////////////////////////////////////////////////////////////////////////
nsCSSDecDataSource::nsCSSDecDataSource()
{
NS_INIT_REFCNT();
}
nsCSSDecDataSource::~nsCSSDecDataSource()
{
if (mRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
mRDFService = nsnull;
}
/* NS_IF_RELEASE(kINS_DecRoot);
NS_IF_RELEASE(kINS_Property);
NS_IF_RELEASE(kINS_PropertyName);
NS_IF_RELEASE(kINS_PropertyValue);
NS_IF_RELEASE(kINS_PropertyPriority);
*/
}
nsresult
nsCSSDecDataSource::Init()
{
nsresult rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService), (nsISupports**) &mRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv;
mRDFService->GetResource(INS_RDF_DECROOT, &kINS_DecRoot);
mRDFService->GetResource(INS_RDF_PROPERTY, &kINS_Property);
mRDFService->GetResource(INS_RDF_PROPERTYNAME, &kINS_PropertyName);
mRDFService->GetResource(INS_RDF_PROPERTYVALUE, &kINS_PropertyValue);
mRDFService->GetResource(INS_RDF_PROPERTYPRIORITY, &kINS_PropertyPriority);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS2(nsCSSDecDataSource,
nsICSSDecDataSource,
nsIRDFDataSource);
////////////////////////////////////////////////////////////////////////
// nsICSSRuleDataSource
NS_IMETHODIMP
nsCSSDecDataSource::GetRefResource(nsIRDFResource** aRefResource)
{
*aRefResource = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsCSSDecDataSource::SetRefResource(nsIRDFResource* aRefResource)
{
nsresult rv;
nsCOMPtr<nsIDOMDSResource> domRes = do_QueryInterface(aRefResource);
nsCOMPtr<nsISupports> supports;
rv = domRes->GetObject(getter_AddRefs(supports));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMCSSStyleRule> rule = do_QueryInterface(supports, &rv);
if (NS_FAILED(rv)) return rv;
mStyleRule = rule;
return NS_OK;
}
NS_IMETHODIMP nsCSSDecDataSource::SetCSSProperty(const PRUnichar* aName, const PRUnichar* aValue, const PRUnichar* aPriority)
{
nsresult rv;
// get the declaration
nsCOMPtr<nsIDOMCSSStyleDeclaration> dec;
rv = mStyleRule->GetStyle(getter_AddRefs(dec));
nsAutoString name; name.Assign(aName);
nsAutoString value; value.Assign(aValue);
nsAutoString priority; priority.Assign(aPriority);
return dec->SetProperty(name, value, priority);
}
NS_IMETHODIMP nsCSSDecDataSource::RemoveCSSProperty(const PRUnichar* aName)
{
nsresult rv;
// get the declaration
nsCOMPtr<nsIDOMCSSStyleDeclaration> dec;
rv = mStyleRule->GetStyle(getter_AddRefs(dec));
nsAutoString ret;
nsAutoString name; name.Assign(aName);
return dec->RemoveProperty(name, ret);
}
////////////////////////////////////////////////////////////////////////
// nsIRDFDataSource
NS_IMETHODIMP
nsCSSDecDataSource::GetURI(char* *aURI)
{
NS_PRECONDITION(aURI != nsnull, "null ptr");
if (! aURI) return NS_ERROR_NULL_POINTER;
*aURI = nsXPIDLCString::Copy("rdf:" NS_CSSDECDATASOURCE_ID);
if (! *aURI) return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsCSSDecDataSource::GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsIRDFResource **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFNode **_retval)
{
*_retval = nsnull;
nsresult rv;
if (aSource == kINS_DecRoot) {
// It's the root, so we ignore it
return NS_OK;
} else {
// It's not the root, so we proceed to find the target node
nsCOMPtr<nsIDOMDSResource> domRes = do_QueryInterface(aSource);
if (domRes) {
nsCOMPtr<nsISupports> supports;
domRes->GetObject(getter_AddRefs(supports));
nsCOMPtr<nsCSSDecIntHolder> rule = do_QueryInterface(supports, &rv);
if (NS_SUCCEEDED(rv))
return CreatePropertyTarget(rule->mInt, aProperty, _retval);
}
}
return rv;
}
NS_IMETHODIMP
nsCSSDecDataSource::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsISimpleEnumerator **_retval)
{
nsresult rv;
nsCOMPtr<nsISupportsArray> arcs;
rv = NS_NewISupportsArray(getter_AddRefs(arcs));
nsArrayEnumerator* cursor = new nsArrayEnumerator(arcs);
if (!cursor) return NS_ERROR_OUT_OF_MEMORY;
*_retval = cursor;
NS_ADDREF(*_retval);
if (!mStyleRule) return NS_OK;
// The only node with targets is the root, since this this data source
// is just a flat list of properties
if (aSource == kINS_DecRoot && aProperty == kINS_Property) {
rv = GetTargetsForStyleRule(mStyleRule, aProperty, arcs);
}
return NS_OK;
}
NS_IMETHODIMP
nsCSSDecDataSource::Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::Change(nsIRDFResource *, nsIRDFResource *,
nsIRDFNode *, nsIRDFNode*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCSSDecDataSource::Move(nsIRDFResource *, nsIRDFResource *,
nsIRDFResource *, nsIRDFNode*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCSSDecDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval)
{
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsCSSDecDataSource::AddObserver(nsIRDFObserver *aObserver)
{
return NS_OK;
}
NS_IMETHODIMP
nsCSSDecDataSource::RemoveObserver(nsIRDFObserver *aObserver)
{
return NS_OK;
}
NS_IMETHODIMP
nsCSSDecDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval)
{
return NS_OK;
}
NS_IMETHODIMP
nsCSSDecDataSource::GetAllResources(nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::IsCommandEnabled(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments, PRBool *_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::DoCommand(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::GetAllCmds(nsIRDFResource *aSource, nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSDecDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCSSDecDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsCSSDecDataSource
nsIRDFService*
nsCSSDecDataSource::GetRDFService()
{
if (!mRDFService) {
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService), (nsISupports**) &mRDFService);
if (NS_FAILED(rv)) return nsnull;
}
return mRDFService;
}
nsresult
nsCSSDecDataSource::GetTargetsForStyleRule(nsIDOMCSSStyleRule* aRule, nsIRDFResource* aProperty, nsISupportsArray* aArcs)
{
nsresult rv;
// get the declaration
nsCOMPtr<nsIDOMCSSStyleDeclaration> dec;
rv = aRule->GetStyle(getter_AddRefs(dec));
// loop through the properties
PRUint32 count;
dec->GetLength(&count);
nsCSSDecIntHolder* holder;
for (PRUint32 i = 0; i < count; i++) {
holder = new nsCSSDecIntHolder(i);
nsCOMPtr<nsIRDFResource> resource;
rv = GetResourceForObject(holder, getter_AddRefs(resource));
rv = aArcs->AppendElement(resource);
}
return NS_OK;
}
nsresult
nsCSSDecDataSource::GetResourceForObject(nsISupports* aObject, nsIRDFResource** _retval)
{
nsresult rv;
nsISupportsKey* objKey = new nsISupportsKey(aObject);
nsCOMPtr<nsISupports> supports = (nsISupports*) mObjectTable.Get(objKey);
if (supports) {
nsCOMPtr<nsIRDFResource> res = do_QueryInterface(supports, &rv);
*_retval = res;
} else {
// it's not in the hash table, so add it.
char *uri = PR_smprintf(NS_DOMDSRESOURCE_ID "://CSSPROP%8.8X", gCurrentId++);
// have the resource created by the resource factory
rv = GetRDFService()->GetResource(uri, _retval);
if (NS_FAILED(rv)) return rv;
// add it to the hash table
mObjectTable.Put(objKey, *_retval);
// now fill in the resource stuff
nsCOMPtr<nsIDOMDSResource> nodeContainer = do_QueryInterface(*_retval, &rv);
if (NS_FAILED(rv)) return rv;
nodeContainer->SetObject(aObject);
}
return NS_OK;
}
nsresult
nsCSSDecDataSource::CreatePropertyTarget(PRUint32 aIndex, nsIRDFResource* aProperty, nsIRDFNode **aResult)
{
nsCOMPtr<nsIDOMCSSStyleDeclaration> dec;
nsresult rv = mStyleRule->GetStyle(getter_AddRefs(dec));
nsAutoString name;
dec->Item(aIndex, name);
nsAutoString str;
if (aProperty == kINS_PropertyName) {
str = name;
} else if (aProperty == kINS_PropertyValue) {
dec->GetPropertyValue(name, str);
} else if (aProperty == kINS_PropertyPriority) {
dec->GetPropertyPriority(name, str);
}
return CreateLiteral(str, aResult);
}
nsresult
nsCSSDecDataSource::CreateLiteral(nsString& str, nsIRDFNode **aResult)
{
nsresult rv;
nsCOMPtr<nsIRDFLiteral> literal;
PRUnichar* uniStr = str.ToNewUnicode();
rv = GetRDFService()->GetLiteral(uniStr, getter_AddRefs(literal));
nsMemory::Free(uniStr);
*aResult = literal;
NS_IF_ADDREF(*aResult);
return NS_OK;
}

View File

@ -0,0 +1,109 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef cssdecdatasource___h___
#define cssdecdatasource___h___
#define NS_CSSDECDATASOURCE_ID "Inspector_CSSDec"
#include "nsICSSDecDataSource.h"
#include "nsDOMDSResource.h"
#include "nsCSSDecIntHolder.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsIDOMElement.h"
#include "nsIDOMCSSStyleRule.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsIDocument.h"
#include "nsIStyleSheet.h"
#include "nsIURI.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsIStyleSet.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIStyleContext.h"
#include "nsIStyleRule.h"
#include "nsICSSStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsIRDFService.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFRemoteDataSource.h"
#include "nsIRDFObserver.h"
#include "nsIRDFNode.h"
#include "nsRDFCID.h"
#include "rdf.h"
#include "nsIComponentManager.h"
#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIServiceManager.h"
#include "nsSpecialSystemDirectory.h"
#include "nsVoidArray.h"
#include "nsXPIDLString.h"
#include "nsEnumeratorUtils.h"
#include "nsEscape.h"
#include "nsIAtom.h"
#include "prprf.h"
class nsCSSDecDataSource : public nsICSSDecDataSource,
public nsIRDFDataSource
{
// nsCSSDecDataSource
public:
nsCSSDecDataSource();
virtual ~nsCSSDecDataSource();
nsresult Init();
private:
nsIRDFService* mRDFService;
nsIDOMCSSStyleRule* mStyleRule;
nsSupportsHashtable mObjectTable;
nsIRDFService* GetRDFService();
nsresult GetTargetsForStyleRule(nsIDOMCSSStyleRule* aRule, nsIRDFResource* aProperty, nsISupportsArray* aArcs);
nsresult GetResourceForObject(nsISupports* aObject, nsIRDFResource** _retval);
nsresult CreatePropertyTarget(PRUint32 aIndex, nsIRDFResource* aProperty, nsIRDFNode **aResult);
nsresult CreateLiteral(nsString& str, nsIRDFNode **aResult);
public:
// nsISupports
NS_DECL_ISUPPORTS
// nsICSSDecDataSource
NS_DECL_NSICSSDECDATASOURCE
// nsIRDFDataSource
NS_DECL_NSIRDFDATASOURCE
};
#endif // cssdecdatasource___h___

View File

@ -0,0 +1,19 @@
#include "nsCSSDecIntHolder.h"
////////////////////////////////////////////////////
// Quick and dirty definition of holder object
nsCSSDecIntHolder::nsCSSDecIntHolder() { }
nsCSSDecIntHolder::nsCSSDecIntHolder(PRUint32 aInt)
{
mInt = aInt;
NS_INIT_REFCNT();
}
nsCSSDecIntHolder::~nsCSSDecIntHolder()
{
}
NS_IMPL_ISUPPORTS1(nsCSSDecIntHolder, nsICSSDecIntHolder);

View File

@ -0,0 +1,26 @@
#ifndef nscssdecintholder___h___
#define nscssdecintholder___h___
#include "nsICSSDecIntHolder.h"
////////////////////////////////////////////////////
// Quick and dirty declaration of holder object
class nsCSSDecIntHolder : public nsICSSDecIntHolder {
public:
nsCSSDecIntHolder();
nsCSSDecIntHolder(PRUint32 aInt);
virtual ~nsCSSDecIntHolder();
PRUint32 mInt;
// nsISupports
NS_DECL_ISUPPORTS
// nsICSSDecIntHolder
NS_DECL_NSICSSDECINTHOLDER
};
#endif

View File

@ -0,0 +1,435 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-file-style: "stroustrup" -*-
*
* 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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
#include "nsCSSRuleDataSource.h"
#include "dsinfo.h"
////////////////////////////////////////////////////////////////////////
// globals and constants
#define INS_RDF_RULEROOT "inspector:RuleRoot"
#define INS_RDF_RULE INS_NAMESPACE_URI "Rule"
#define INS_RDF_SELECTOR INS_NAMESPACE_URI "Selector"
#define INS_RDF_WEIGHT INS_NAMESPACE_URI "Weight"
#define INS_RDF_FILEURL INS_NAMESPACE_URI "FileURL"
#define INS_RDF_LINENUM INS_NAMESPACE_URI "LineNum"
static PRInt32 gCurrentId = 0;
nsIRDFResource *kINS_RuleRoot;
nsIRDFResource *kINS_Rule;
nsIRDFResource *kINS_Selector;
nsIRDFResource *kINS_Weight;
nsIRDFResource *kINS_FileURL;
nsIRDFResource *kINS_LineNum;
////////////////////////////////////////////////////////////////////////
nsCSSRuleDataSource::nsCSSRuleDataSource()
{
NS_INIT_REFCNT();
}
nsCSSRuleDataSource::~nsCSSRuleDataSource()
{
if (mRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
mRDFService = nsnull;
}
/* NS_IF_RELEASE(kINS_RuleRoot);
NS_IF_RELEASE(kINS_Rule);
NS_IF_RELEASE(kINS_Selector);
NS_IF_RELEASE(kINS_Weight);
NS_IF_RELEASE(kINS_FileURL);
NS_IF_RELEASE(kINS_LineNum);
*/
}
nsresult
nsCSSRuleDataSource::Init()
{
nsresult rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService), (nsISupports**) &mRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv;
mRDFService->GetResource(INS_RDF_RULEROOT, &kINS_RuleRoot);
mRDFService->GetResource(INS_RDF_RULE, &kINS_Rule);
mRDFService->GetResource(INS_RDF_SELECTOR, &kINS_Selector);
mRDFService->GetResource(INS_RDF_WEIGHT, &kINS_Weight);
mRDFService->GetResource(INS_RDF_FILEURL, &kINS_FileURL);
mRDFService->GetResource(INS_RDF_LINENUM, &kINS_LineNum);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS2(nsCSSRuleDataSource,
nsICSSRuleDataSource,
nsIRDFDataSource);
////////////////////////////////////////////////////////////////////////
// nsICSSRuleDataSource
NS_IMETHODIMP
nsCSSRuleDataSource::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
return NS_OK;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetElement(nsIDOMElement** aElement)
{
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsIRDFDataSource
NS_IMETHODIMP
nsCSSRuleDataSource::GetURI(char* *aURI)
{
NS_PRECONDITION(aURI != nsnull, "null ptr");
if (! aURI) return NS_ERROR_NULL_POINTER;
*aURI = nsXPIDLCString::Copy("rdf:" NS_CSSRULEDATASOURCE_ID);
if (! *aURI) return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsIRDFResource **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFNode **_retval)
{
*_retval = nsnull;
nsresult rv;
if (aSource == kINS_RuleRoot) {
// It's the root, so we ignore it
return NS_OK;
} else {
// It's not the root, so we proceed to find the target node
nsCOMPtr<nsIDOMDSResource> domRes = do_QueryInterface(aSource);
if (domRes) {
nsCOMPtr<nsISupports> supports;
domRes->GetObject(getter_AddRefs(supports));
nsCOMPtr<nsICSSStyleRule> rule = do_QueryInterface(supports, &rv);
if (NS_SUCCEEDED(rv))
return CreateStyleRuleTarget(rule, aProperty, _retval);
}
}
return rv;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsISimpleEnumerator **_retval)
{
nsresult rv;
nsCOMPtr<nsISupportsArray> arcs;
rv = NS_NewISupportsArray(getter_AddRefs(arcs));
nsArrayEnumerator* cursor = new nsArrayEnumerator(arcs);
if (!cursor) return NS_ERROR_OUT_OF_MEMORY;
*_retval = cursor;
NS_ADDREF(*_retval);
if (!mElement) return NS_OK;
// The only node with targets is the root, since this this data source
// is just a flat list of rules
if (aSource == kINS_RuleRoot) {
rv = GetTargetsForElement(mElement, aProperty, arcs);
}
return NS_OK;
}
NS_IMETHODIMP
nsCSSRuleDataSource::Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::Change(nsIRDFResource *, nsIRDFResource *,
nsIRDFNode *, nsIRDFNode*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCSSRuleDataSource::Move(nsIRDFResource *, nsIRDFResource *,
nsIRDFResource *, nsIRDFNode*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCSSRuleDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval)
{
return NS_OK;
}
NS_IMETHODIMP
nsCSSRuleDataSource::AddObserver(nsIRDFObserver *aObserver)
{
return NS_OK;
}
NS_IMETHODIMP
nsCSSRuleDataSource::RemoveObserver(nsIRDFObserver *aObserver)
{
return NS_OK;
}
NS_IMETHODIMP
nsCSSRuleDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval)
{
return NS_OK;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetAllResources(nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::IsCommandEnabled(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments, PRBool *_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::DoCommand(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::GetAllCmds(nsIRDFResource *aSource, nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
nsCSSRuleDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCSSRuleDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsCSSRuleDataSource
nsIRDFService*
nsCSSRuleDataSource::GetRDFService()
{
if (!mRDFService) {
nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService), (nsISupports**) &mRDFService);
if (NS_FAILED(rv)) return nsnull;
}
return mRDFService;
}
nsresult
nsCSSRuleDataSource::GetTargetsForElement(nsIDOMElement* aElement, nsIRDFResource* aProperty, nsISupportsArray* aArcs)
{
// query to a content node
nsCOMPtr<nsIContent> content;
content = do_QueryInterface(aElement);
// get the document
nsCOMPtr<nsIDOMDocument> doc1;
aElement->GetOwnerDocument(getter_AddRefs(doc1));
nsCOMPtr<nsIDocument> doc;
doc = do_QueryInterface(doc1);
// loop through the PresShells
nsresult rv;
PRInt32 num = doc->GetNumberOfShells();
nsCOMPtr<nsIPresShell> shell;
nsIFrame* frame;
nsCOMPtr<nsIStyleContext> styleContext;
for (PRInt32 i = 0; i < num; i++) {
// get the style context
shell = doc->GetShellAt(i);
rv = shell->GetPrimaryFrameFor(content, &frame);
if (NS_FAILED(rv) || !frame) return rv;
shell->GetStyleContextFor(frame, getter_AddRefs(styleContext));
if (NS_FAILED(rv) || !styleContext) return rv;
// display all the pretty information
PRInt32 count = styleContext->GetStyleRuleCount();
nsCOMPtr<nsISupportsArray> rules(dont_AddRef(styleContext->GetStyleRules()));
nsCOMPtr<nsICSSStyleRule> rule;
for (PRInt32 k = 0; k < count; k++) {
rule = do_QueryInterface(rules->ElementAt(k));
nsCOMPtr<nsIRDFResource> resource;
rv = GetResourceForObject(rule, getter_AddRefs(resource));
rv = aArcs->AppendElement(resource);
}
}
return NS_OK;
}
nsresult
nsCSSRuleDataSource::GetResourceForObject(nsISupports* aObject, nsIRDFResource** _retval)
{
nsresult rv;
nsISupportsKey* objKey = new nsISupportsKey(aObject);
nsCOMPtr<nsISupports> supports = (nsISupports*) mObjectTable.Get(objKey);
if (supports) {
nsCOMPtr<nsIRDFResource> res = do_QueryInterface(supports, &rv);
*_retval = res;
} else {
// it's not in the hash table, so add it.
char *uri = PR_smprintf(NS_DOMDSRESOURCE_ID "://CSSRULE%8.8X", gCurrentId++);
// have the resource created by the resource factory
rv = GetRDFService()->GetResource(uri, _retval);
if (NS_FAILED(rv)) return rv;
// add it to the hash table
mObjectTable.Put(objKey, *_retval);
// now fill in the resource stuff
nsCOMPtr<nsIDOMDSResource> nodeContainer = do_QueryInterface(*_retval, &rv);
if (NS_FAILED(rv)) return rv;
nodeContainer->SetObject(aObject);
}
return NS_OK;
}
nsresult
nsCSSRuleDataSource::CreateStyleRuleTarget(nsICSSStyleRule* aRule, nsIRDFResource* aProperty, nsIRDFNode **aResult)
{
nsresult rv;
nsAutoString str;
if (aProperty == kINS_Selector) {
aRule->GetSourceSelectorText(str);
} else if (aProperty == kINS_Weight) {
PRUint32 weight = aRule->GetWeight();
char* ln = PR_smprintf("%d", weight);
str.AssignWithConversion(ln);
} else if (aProperty == kINS_FileURL) {
nsCOMPtr<nsIStyleSheet> sheet;
nsCOMPtr<nsIURI> uri;
char* spec;
rv = aRule->GetStyleSheet(*getter_AddRefs(sheet));
if (NS_FAILED(rv) || !sheet) return rv;
rv = sheet->GetURL(*getter_AddRefs(uri));
if (NS_FAILED(rv) || !uri) return rv;
uri->GetSpec(&spec);
str.AssignWithConversion(spec);
} else if (aProperty == kINS_LineNum) {
PRUint32 linenum = aRule->GetLineNumber();
char* ln = PR_smprintf("%d", linenum);
str.AssignWithConversion(ln);
}
return CreateLiteral(str, aResult);
}
nsresult
nsCSSRuleDataSource::CreateLiteral(nsString& str, nsIRDFNode **aResult)
{
nsresult rv;
nsCOMPtr<nsIRDFLiteral> literal;
PRUnichar* uniStr = str.ToNewUnicode();
rv = GetRDFService()->GetLiteral(uniStr, getter_AddRefs(literal));
nsMemory::Free(uniStr);
*aResult = literal;
NS_IF_ADDREF(*aResult);
return NS_OK;
}

View File

@ -0,0 +1,108 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef cssruledatasource___h___
#define cssruledatasource___h___
#define NS_CSSRULEDATASOURCE_ID "Inspector_CSSRules"
#include "nsICSSRuleDataSource.h"
#include "nsDOMDSResource.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIStyleSheet.h"
#include "nsIURI.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsIStyleSet.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIStyleContext.h"
#include "nsIStyleRule.h"
#include "nsICSSStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsIRDFService.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFRemoteDataSource.h"
#include "nsIRDFObserver.h"
#include "nsIRDFNode.h"
#include "nsRDFCID.h"
#include "rdf.h"
#include "nsIComponentManager.h"
#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIServiceManager.h"
#include "nsSpecialSystemDirectory.h"
#include "nsVoidArray.h"
#include "nsXPIDLString.h"
#include "nsEnumeratorUtils.h"
#include "nsEscape.h"
#include "nsIAtom.h"
#include "prprf.h"
class nsCSSRuleDataSource : public nsICSSRuleDataSource,
public nsIRDFDataSource
{
// nsCSSRuleDataSource
public:
nsCSSRuleDataSource();
virtual ~nsCSSRuleDataSource();
nsresult Init();
private:
nsIRDFService* GetRDFService();
nsresult GetTargetsForElement(nsIDOMElement* aElement, nsIRDFResource* aProperty, nsISupportsArray* aArcs);
nsresult GetResourceForObject(nsISupports* aObject, nsIRDFResource** _retval);
nsresult CreateStyleRuleTarget(nsICSSStyleRule* aRule, nsIRDFResource* aProperty, nsIRDFNode **aResult);
nsresult CreateLiteral(nsString& str, nsIRDFNode **aResult);
nsIRDFService* mRDFService;
nsIRDFService* mService;
nsIDOMElement* mElement;
nsSupportsHashtable mObjectTable;
// nsISupports
NS_DECL_ISUPPORTS
// nsICSSRuleDataSource
NS_DECL_NSICSSRULEDATASOURCE
// nsIRDFDataSource
NS_DECL_NSIRDFDATASOURCE
};
#endif // cssruledatasource___h___

View File

@ -0,0 +1,61 @@
/* -*- 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.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 Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*/
#include "nsDOMDSResource.h"
nsDOMDSResource::nsDOMDSResource()
{
}
nsDOMDSResource::~nsDOMDSResource()
{
}
NS_IMPL_ISUPPORTS_INHERITED(nsDOMDSResource, nsRDFResource, nsIDOMDSResource)
NS_IMETHODIMP
nsDOMDSResource::SetObject(nsISupports* object)
{
mObject = do_QueryInterface(object);
return NS_OK;
}
NS_IMETHODIMP
nsDOMDSResource::GetObject(nsISupports** object)
{
if (!object) return NS_ERROR_NULL_POINTER;
*object = mObject;
NS_IF_ADDREF(*object);
return NS_OK;
}
NS_METHOD
nsDOMDSResource::Create(nsISupports* aOuter, const nsIID& iid, void **result)
{
nsDOMDSResource* ve = new nsDOMDSResource();
if (!ve) return NS_ERROR_NULL_POINTER;
NS_ADDREF(ve);
nsresult rv = ve->QueryInterface(iid, result);
NS_RELEASE(ve);
return rv;
}

View File

@ -0,0 +1,70 @@
/* -*- 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.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 Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*/
#ifndef __nsdomdsresource_h
#define __nsdomdsresource_h
#define NS_DOMDSRESOURCE_ID "InspectorDOMResource"
#include "nsIDOMDSResource.h"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
#include "rdf.h"
#include "nsIRDFService.h"
#include "nsRDFResource.h"
/////////////////////////////////////////////////////////////////////
// This object is registered with the datasource factory to
// be instantiated for all resources created with a uri that begins
// with InspectorDOMResource://
//
// This is a multi-purpose object that is used by datasources as
// a temporary transport object for data. When ::GetTargets is called,
// a list of these objects is created by the datasource. Each object
// holds a reference back to the real object it represents. This
// object is then sent back to GetTarget, where we get the real
// object and query it for info.
/////////////////////////////////////////////////////////////////////
class nsDOMDSResource : public nsRDFResource,
public nsIDOMDSResource
{
// nsDOMDSResource
public:
nsDOMDSResource();
virtual ~nsDOMDSResource();
static NS_METHOD Create(nsISupports* aOuter, const nsIID& iid, void **result);
private:
nsCOMPtr<nsISupports> mObject;
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMDSResource
NS_DECL_NSIDOMDSRESOURCE
};
#endif // __nsdomdsresource_h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,204 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef domdatasource___h___
#define domdatasource___h___
#define NS_DOMDSDATASOURCE_ID "Inspector_DOM"
#include "nsIInsDOMDataSource.h"
#include "nsDOMDSResource.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsHashtable.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsIDOMAttr.h"
#include "nsIDOMElement.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMNodeList.h"
#include "nsIDocumentObserver.h"
#include "nsIDocument.h"
#include "nsIBindingManager.h"
#include "nsIXBLBinding.h"
#include "rdf.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFContainer.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFRemoteDataSource.h"
#include "nsIRDFLiteral.h"
#include "nsIRDFResource.h"
#include "nsIRDFNode.h"
#include "nsIRDFObserver.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "nsIComponentManager.h"
#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIServiceManager.h"
#include "nsVoidArray.h"
#include "nsXPIDLString.h"
#include "nsEnumeratorUtils.h"
#include "nsIAtom.h"
#include "prprf.h"
class nsDOMDataSource : public nsIInsDOMDataSource,
public nsIRDFDataSource,
public nsIDocumentObserver
{
// nsDOMDataSource
public:
nsDOMDataSource();
virtual ~nsDOMDataSource();
nsresult Init();
private:
nsCOMPtr<nsIDOMDocument> mDocument;
nsIBindingManager *mBindingManager;
PRBool *mShowAnonymousContent;
PRUint16 *mFilters;
nsIRDFService *mRDFService;
nsVoidArray *mObservers;
nsIRDFService* GetRDFService();
// Filters
PRUint16 GetNodeTypeKey(PRUint16 aType);
// Datasource Construction
nsresult GetTargetsForKnownObject(nsISupports *object, nsIRDFResource *aProperty, PRBool aShowAnon, nsISupportsArray *arcs);
nsresult CreateDOMNodeArcs(nsIDOMNode *node, PRBool aShowAnon, nsISupportsArray* arcs);
nsresult CreateChildNodeArcs(nsIDOMNode *aNode, nsISupportsArray *aArcs);
nsresult CreateDOMNodeListArcs(nsIDOMNodeList *nodelist, nsISupportsArray *arcs);
nsresult CreateDOMNamedNodeMapArcs(nsIDOMNamedNodeMap *aNodeMap, nsISupportsArray *aArcs);
nsresult CreateDOMNodeTarget(nsIDOMNode *node, nsIRDFResource *aProperty, nsIRDFNode **aResult);
nsresult CreateRootTarget(nsIRDFResource* aSource, nsIRDFResource* aProperty, nsIRDFNode **aResult);
nsresult CreateLiteral(nsString& str, nsIRDFNode **aResult);
nsresult GetFieldNameFromRes(nsIRDFResource* aProperty, nsAutoString* aResult);
// Observer Notification
static PRBool ChangeEnumFunc(void *aElement, void *aData);
static PRBool AssertEnumFunc(void *aElement, void *aData);
static PRBool UnassertEnumFunc(void *aElement, void *aData);
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property, nsIRDFNode *object, PRUint32 aType);
// Misc
PRBool IsObjectInCache(nsISupports* aObject);
nsresult RemoveResourceForObject(nsISupports* aObject);
PRBool HasChildren(nsIDOMNode* aContainer);
static nsresult FindAttrRes(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, nsIRDFResource** aAttrRes);
static PRBool FindAttrResEnumFunc(nsHashKey *aKey, void *aData, void* closure);
static PRBool HasChild(nsIDOMNode* aContainer, nsIDOMNode* aChild);
static PRBool HasAttribute(nsIDOMNode* aContainer, nsIDOMNode* aAttr);
static void DumpResourceValue(nsIRDFResource* aRes);
public:
// nsISupports
NS_DECL_ISUPPORTS
// nsIInsDOMDataSource
NS_DECL_NSIINSDOMDATASOURCE
// nsIRDFDataSource
NS_DECL_NSIRDFDATASOURCE
// nsIDocumentObserver
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) { return NS_OK; }
NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) { return NS_OK; }
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
nsIContent* aContent,
nsISupports* aSubContent) { return NS_OK; }
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2) { return NS_OK; }
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet) { return NS_OK; }
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet) { return NS_OK; }
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
PRBool aDisabled) { return NS_OK; }
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint) { return NS_OK; }
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule) { return NS_OK; }
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule) { return NS_OK; }
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
};
//////////
typedef struct _nsDOMDSNotification {
nsIRDFDataSource *datasource;
nsIRDFResource *subject;
nsIRDFResource *property;
nsIRDFNode *object;
} nsDOMDSNotification;
typedef struct _nsDOMDSFindAttrInfo {
nsIContent *mCrap;
nsIContent *mContent;
PRInt32 mNameSpaceID;
nsIAtom *mAttribute;
nsIRDFResource **mAttrRes;
} nsDOMDSFindAttrInfo;
#endif // domdatasource___h___

View File

@ -0,0 +1,32 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS=src
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,22 @@
var gVersion = "0.5";
var err = initInstall("Document Inspector", "inspector", gVersion);
logComment("initInstall: " + err);
var fProgram = getFolder("Program");
logComment("fProgram: " + fProgram);
err = addDirectory("", gVersion, "bin", fProgram, "", true);
logComment("addDirectory: " + err);
registerChrome(CONTENT | DELAYED_CHROME, getFolder("Chrome","inspector.jar"), "content/inspector/");
registerChrome(LOCALE | DELAYED_CHROME, getFolder("Chrome","inspector.jar"), "locale/en-US/inspector/");
registerChrome(SKIN | DELAYED_CHROME, getFolder("Chrome","inspector.jar"), "skin/modern/inspector/");
registerChrome(SKIN | DELAYED_CHROME, getFolder("Chrome","inspector.jar"), "skin/classic/inspector/");
if (getLastError() == SUCCESS) {
err = performInstall();
logComment("performInstall: " + err);
} else {
cancelInstall(err);
}

View File

@ -0,0 +1,27 @@
#!nmake
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
include <$(DEPTH)/config/config.mak>
DIRS = src
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,54 @@
#
# 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 Netscape are
# Copyright (C) 1998 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 = inspector
SHORT_LIBNAME = inspector
IS_COMPONENT = 1
CPPSRCS = \
nsInspectorModule.cpp \
$(NULL)
LOCAL_INCLUDES += -I$(srcdir)/../../base/src
EXTRA_DSO_LIBS = rdfutil_s
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/libinspector_s \
$(NULL)
EXTRA_DSO_LDOPTS += \
-L$(DIST)/bin \
-L$(DIST)/lib \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,49 @@
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
MODULE=inspector
LIBNAME = .\$(OBJDIR)\inspector
DLL = $(LIBNAME).dll
################################################################################
## library
LINCS=-I..\..\base\src
CPP_OBJS= \
.\$(OBJDIR)\nsInspectorModule.obj \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\rdfutil_s.lib \
$(DIST)\lib\inspector_s.lib \
$(DIST)\lib\gkgfxwin.lib \
$(DIST)\lib\raptorhtmlstyle_s.lib \
$(LIBNSPR) \
$(NULL)
include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin\components
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib

View File

@ -0,0 +1,56 @@
/* -*- 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.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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsIGenericFactory.h"
#include "nsDOMDSResource.h"
#include "nsDOMDataSource.h"
#include "nsCSSRuleDataSource.h"
#include "nsCSSDecDataSource.h"
#include "nsCSSDecIntHolder.h"
#include "inFlasher.h"
#include "inCSSValueSearch.h"
#include "inFileSearch.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDOMDataSource, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCSSRuleDataSource, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCSSDecDataSource, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMDSResource)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCSSDecIntHolder)
NS_GENERIC_FACTORY_CONSTRUCTOR(inFlasher)
NS_GENERIC_FACTORY_CONSTRUCTOR(inCSSValueSearch)
NS_GENERIC_FACTORY_CONSTRUCTOR(inFileSearch)
static nsModuleComponentInfo components[] =
{
{ "DOM DS Resource", NS_DOMDSRESOURCE_CID, NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX NS_DOMDSRESOURCE_ID, nsDOMDSResourceConstructor },
{ "DOM Datasource", NS_INSDOMDATASOURCE_CID, NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_DOMDSDATASOURCE_ID, nsDOMDataSourceConstructor },
{ "CSS Rule Datasource", NS_CSSRULE_DATASOURCE_CID, NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_CSSRULEDATASOURCE_ID, nsCSSRuleDataSourceConstructor },
{ "CSS Dec Datasource", NS_CSSDEC_DATASOURCE_CID, NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_CSSDECDATASOURCE_ID, nsCSSDecDataSourceConstructor },
{ "Flasher", IN_FLASHER_CID, IN_FLASHER_CONTRACTID, inFlasherConstructor },
{ "Data Holder", NS_CSSDECINTHOLDER_CID, NS_CSSDECINTHOLDER_CONTRACTID, nsCSSDecIntHolderConstructor },
{ "CSS Value Search", IN_CSSVALUESEARCH_CID, IN_CSSVALUESEARCH_CONTRACTID, inCSSValueSearchConstructor },
{ "File Search", IN_FILESEARCH_CID, IN_FILESEARCH_CONTRACTID, inFileSearchConstructor }
};
NS_IMPL_NSGETMODULE("nsInspectorModule", components)

View File

@ -0,0 +1,37 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS=content skin locale
include $(topsrcdir)/config/rules.mk
chrome::
$(REGCHROME) content inspector inspector.jar
$(REGCHROME) locale en-US/inspector inspector.jar
$(REGCHROME) skin modern/inspector inspector.jar
$(REGCHROME) skin classic/inspector inspector.jar

View File

@ -0,0 +1,127 @@
/***************************************************************
* Flasher ---------------------------------------------------
* Object for controlling a timed flashing animation which
* paints a border around an element.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
var gFlasherRegistry = [];
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class Flasher
function Flasher(aShell, aColor, aThickness, aDuration, aSpeed)
{
this.mShell = aShell;
this.color = aColor;
this.mThickness = aThickness;
this.duration = aDuration;
this.mSpeed = aSpeed;
this.register();
}
Flasher.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mFlashTimeout: null,
mElement:null,
mWindow:null,
mRegistryId: null,
mFlashes: 0,
mStartTime: 0,
mColor: null,
mThickness: 0,
mDuration: 0,
mSpeed: 0,
////////////////////////////////////////////////////////////////////////////
//// Properties
get flashing() { return this.mFlashTimeout; },
get element() { return this.mElement; },
set element(val)
{
if (val && val.nodeType == 1)
this.mElement = val;
else
throw "Invalid node type.";
},
get window() { return this.mWindow; },
set window(aVal) { this.mWindow = aVal; },
get color() { return this.mColor; },
set color(aVal) { if (aVal.charAt(0) == '#') aVal = aVal.substr(1); this.mColor = aVal; },
get thickness() { return this.mThickness; },
set thickness(aVal) { this.mThickness = aVal; },
get duration() { return this.mDuration; },
set duration(aVal) { this.mDuration = aVal*1000; /*seconds->milliseconds*/ },
get speed() { return this.mSpeed; },
set speed(aVal) { this.mSpeed = aVal; },
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// :::::::::::::::::::: Methods ::::::::::::::::::::::::::::
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
register: function()
{
var length = gFlasherRegistry.length;
gFlasherRegistry[length] = this;
this.mRegistryId = length;
},
start: function()
{
this.mFlashes = 0;
this.mStartTime = new Date();
this.doFlash();
},
doFlash: function()
{
if (this.mFlashes%2) {
this.paintOn();
} else {
this.paintOff();
}
this.mFlashes++;
if (new Date() - this.mStartTime < this.mDuration) {
this.mFlashTimeout = window.setTimeout("gFlasherRegistry["+this.mRegistryId+"].doFlash()", this.mSpeed);
} else {
this.stop();
}
},
stop: function()
{
window.clearTimeout(this.mFlashTimeout);
this.mFlashTimeout = null;
this.paintOff();
},
paintOn: function()
{
this.mShell.drawElementOutline(this.mElement, this.mWindow, this.mColor, this.mThickness);
},
paintOff: function()
{
this.mShell.repaintElement(this.mElement, this.mWindow);
}
};

View File

@ -0,0 +1,730 @@
/***************************************************************
* InspectorApp -------------------------------------------------
* The primary object that controls the Inspector application.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/ViewerRegistry.js
* chrome://inspector/content/Flasher.js
* chrome://inspector/content/search/inSearchService.js
* chrome://inspector/content/search/inSearchModule.js
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFArray.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
* chrome://inspector/content/jsutil/xul/FrameExchange.js
* chrome://inspector/content/jsutil/system/ClipboardUtils.js
* chrome://inspector/content/jsutil/system/file.js
****************************************************************/
//////////// global variables /////////////////////
var inspector;
var kHistoryURL = "chrome/inspector/inspector-history.rdf";
var kViewerRegURL = "chrome/inspector/viewer-registry.rdf";
var kSearchRegURL = "chrome/inspector/search-registry.rdf";
//////////// global constants ////////////////////
const kInstallDirId = "CurProcD";
const kFlasherCID = "@mozilla.org/inspector/flasher;1"
const kWindowMediatorIID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
const kObserverServiceIID = "@mozilla.org/observer-service;1";
const kDirServiceCID = "@mozilla.org/file/directory_service;1"
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
//////////////////////////////////////////////////
window.addEventListener("load", InspectorApp_initialize, false);
function InspectorApp_initialize()
{
inspector = new InspectorApp();
inspector.initialize();
}
////////////////////////////////////////////////////////////////////////////
//// class InspectorApp
function InspectorApp() // implements inIViewerPaneContainer
{
this.mInstallURL = this.getSpecialDirectory(kInstallDirId).URL;
kHistoryURL = this.prependBaseURL(kHistoryURL);
kViewerRegURL = this.prependBaseURL(kViewerRegURL);
kSearchRegURL = this.prependBaseURL(kSearchRegURL);
this.mUFlasher = XPCU.createInstance(kFlasherCID, "inIFlasher");
}
InspectorApp.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mShell: null,
mHistory: null,
mViewerReg: null,
mSearchService: null,
mPaneCount: 2,
mCurrentViewer: null,
mCurrentWindow: null,
mShowBrowser: false,
mInstallURL: null,
mFlashSelected: null,
mFlashes: 0,
mInitialized: false,
mFlasher: null,
mIsViewingContent: false,
get document() { return this.mDocViewerPane.viewer.viewee },
get searchRegistry() { return this.mSearchService },
initialize: function()
{
this.initPrefs();
this.loadViewerRegistry();
this.loadHistory();
this.initSearch();
var el = document.getElementById("bxBrowser");
el.addEventListener("load", BrowserLoadListener, true);
this.toggleBrowser(true, false);
this.toggleSearch(true, false);
this.setFlashSelected(PrefUtils.getPref("inspector.blink.on"));
},
initViewerPanes: function()
{
var elPane = document.getElementById("bxDocPane");
this.mDocViewerPane = new ViewerPane();
this.mDocViewerPane.initialize("Document", this, elPane, this.mViewerReg);
elPane = document.getElementById("bxObjectPane");
this.mObjViewerPane = new ViewerPane();
this.mObjViewerPane.initialize("Object", this, elPane, this.mViewerReg);
this.setAllViewerCmdAttributes("disabled", "true");
},
////////////////////////////////////////////////////////////////////////////
//// interface inIViewerPaneContainer
get viewerPaneCount() { return this.mPaneCount; },
onViewerChanged: function(aPane, aOldViewer, aOldEntry, aNewViewer, aNewEntry)
{
var ids, el, i;
if (!this.mInitialized) {
this.mIsViewingContent = true;
var bx = document.getElementById("bxInspectorPanes");
bx.setAttribute("hide", "false");
} else {
this.mInitialized = true;
}
this.mViewerReg.cacheViewer(aNewViewer, aNewEntry);
// disable all commands for for the old viewer
if (aOldViewer)
this.setViewerCmdAttribute(aOldEntry, "disabled", "true");
// enable all commands for for the new viewer
if (aNewViewer)
this.setViewerCmdAttribute(aNewEntry, "disabled", "false");
},
onVieweeChanged: function(aPane, aNewObject)
{
if (aPane == this.mDocViewerPane) {
this.mObjViewerPane.viewee = aNewObject;
if (this.mFlashSelected)
this.flashElement(aNewObject, this.mCurrentWindow);
}
},
getViewerPaneAt: function(aIndex)
{
if (aIndex == 0) {
return this.mDocViewerPane;
} else if (aIndex == 1) {
return this.mObjViewerPane;
} else {
return null;
}
},
setCommandAttribute: function(aCmdId, aAttribute, aValue)
{
var cmd = document.getElementById(aCmdId);
if (cmd)
cmd.setAttribute(aAttribute, aValue);
},
getCommandAttribute: function(aCmdId, aAttribute)
{
var cmd = document.getElementById(aCmdId);
return cmd ? cmd.getAttribute(aAttribute) : null;
},
////////////////////////////////////////////////////////////////////////////
//// UI Commands
gotoTypedURL: function()
{
var url = document.getElementById("tfURLBar").value;
this.gotoURL(url);
},
goToWindow: function(aMenuitem)
{
this.setTargetWindowById(aMenuitem.id);
},
goToHistoryItem: function(aMenuitem)
{
var url = aMenuitem.getAttribute("value");
this.gotoURL(url, true);
},
showOpenURLDialog: function()
{
var defaultURL = "chrome://inspector/content/tests/allskin.xul"; // for testing
var url = prompt("Enter a URL:", defaultURL);
if (url) {
this.gotoURL(url);
}
},
showPrefsDialog: function()
{
goPreferences("inspector.xul", "chrome://inspector/content/prefs/pref-inspector.xul", "inspector");
},
runSearch: function()
{
var path = null; // TODO: should persist last path chosen in a pref
var file = FilePickerUtils.pickFile("Find Search File", path, ["filterXML"], "Open");
if (file) {
var url = file.URL;
// XX temporary until 56354 is fixed
url = url.replace("file://", "file:///");
this.startSearchModule(url);
}
},
toggleBrowser: function(aExplicit, aValue, aSetOnly)
{
var val = aExplicit ? aValue : !this.mShowBrowser;
this.mShowBrowser = val;
if (!aSetOnly)
this.openSplitter("Browser", val);
var cmd = document.getElementById("cmdToggleBrowser");
cmd.setAttribute("checked", val);
},
toggleSearch: function(aExplicit, aValue, aSetOnly)
{
var val = aExplicit ? aValue : !this.mShowSearch;
this.mShowSearch = val;
if (!aSetOnly)
this.openSplitter("Search", val);
var cmd = document.getElementById("cmdToggleSearch");
cmd.setAttribute("checked", val);
},
openSplitter: function(aName, aTruth)
{
var splitter = document.getElementById("spl" + aName);
if (aTruth)
splitter.open();
else
splitter.close();
},
toggleFlashSelected: function(aExplicit, aValue)
{
var val = aExplicit ? aValue : !this.mFlashSelected;
PrefUtils.setPref("inspector.blink.on", val);
this.setFlashSelected(val);
},
setFlashSelected: function(aValue)
{
this.mFlashSelected = aValue;
var cmd = document.getElementById("cmdFlashSelected");
cmd.setAttribute("checked", aValue);
},
/*
viewSearchItem: function()
{
if (this.mCurrentSearch.canViewItems)
window.openDialog("chrome://inspector/content/utilWindow.xul", "viewItem", "chrome,resizable");
},
doViewSearchItem: function(aWindow)
{
var idx = this.getSelectedSearchIndex();
var el = this.mCurrentSearch.viewItemAt(idx);
aWindow.title = this.mCurrentSearch.getItemDescription(idx);
aWindow.document.getElementById("bxCenter").appendChild(el);
},
editSearchItem: function()
{
},
onSearchTreeClick: function(aEvent)
{
if (aEvent.detail == 2) { // double click
this.viewSearchItem();
}
},
*/
copySearchItemLine: function()
{
var mod = this.mSearchService.currentModule;
var idx = this.mSearchService.getSelectedIndex(0);
var text = mod.getItemText(idx);
ClipboardUtils.writeString(text);
},
copySearchItemAll: function()
{
var text = this.getAllSearchItemText();
ClipboardUtils.writeString(text);
},
saveSearchItemText: function()
{
var target = FilePickerUtils.pickFile("Save Results As", null, ["filterAll", "filterText"], "Save");
var text = this.getAllSearchItemText();
var file = new File(target.path);
file.open('w');
file.write(text);
file.close();
},
getAllSearchItemText: function()
{
var mod = this.mSearchService.currentModule;
var len = mod.resultCount;
var text = "";
for (var i = 0; i < len; i++) {
text += mod.getItemText(i) + "\r";
}
return text;
},
showNotes: function()
{
window.open("http://www.joehewitt.com/inspector/releasenotes.html");
},
showAbout: function()
{
alert("Document Inspector - a debugging tool that's fun for the whole family!");
},
exit: function()
{
window.close();
// Todo: remove observer service here
},
////////////////////////////////////////////////////////////////////////////
//// Navigation
gotoURL: function(aURL, aNoSaveHistory)
{
this.mPendingURL = aURL;
this.mPendingNoSave = aNoSaveHistory;
this.browseToURL(aURL);
this.toggleBrowser(true, true);
},
browseToURL: function(aURL)
{
this.webNavigation.loadURI(aURL, nsIWebNavigation.LOAD_FLAGS_NONE);
},
setTargetWindowById: function(aResId)
{
var windowManager = XPCU.getService(kWindowMediatorIID, "nsIWindowMediator");
var win = windowManager.getWindowForResource(aResId);
if (win) {
this.setTargetWindow(win);
this.setURLText("window: " + aResId);
this.toggleBrowser(true, false);
} else
alert("Unable to switch to window.");
},
setTargetWindow: function(aWindow)
{
this.mCurrentWindow = aWindow;
this.setTargetDocument(aWindow.document);
},
setTargetDocument: function(aDoc)
{
this.mDocViewerPane.viewee = aDoc;
var doc = this.mDocViewerPane.viewee;
},
// turn these into getters and setters
setURLText: function(aText)
{
document.getElementById("tfURLBar").value = aText;
},
setStatus: function(aText)
{
document.getElementById("txStatus").setAttribute("value", aText);
},
getStatus: function(aText)
{
return document.getElementById("txStatus").getAttribute("value");
},
setProgress: function(aPercent)
{
document.getElementById("pmStatus").setAttribute("value", aPercent);
},
setSearchTitle: function(aTitle)
{
var splitter = document.getElementById("splSearch");
splitter.setAttribute("value", "Search" + (aTitle ? " - " + aTitle : ""));
},
get webNavigation()
{
var browser = document.getElementById("ifBrowser");
return browser.webNavigation;
},
////////////////////////////////////////////////////////////////////////////
//// Document Loading
documentLoaded: function()
{
this.setTargetWindow(_content);
// add url to the history, unless explicity told not to
if (!this.mPendingNoSave)
this.addToHistory(this.mPendingURL);
// put the url into the urlbar
this.setURLText(this.mPendingURL);
this.mPendingURL = null;
this.mPendingNoSave = null;
},
////////////////////////////////////////////////////////////////////////////
//// Search
initSearch: function()
{
var ss = new inSearchService();
this.mSearchService = ss;
ss.addSearchObserver(this);
ss.resultsTree = document.getElementById("trSearch");
ss.contextMenu = document.getElementById("ppSearchResults");
ss.contextMenuInsertPt = document.getElementById("ppSearchResults-insertion");
ss.contextMenuInsert = inSearchService.INSERT_BEFORE;
},
startSearchModule: function(aModuleURL)
{
this.mSearchService.startModule(aModuleURL);
},
clearSearchResults: function()
{
this.setSearchTitle(null);
this.setStatus("");
this.setProgress(0);
this.mSearchService.clearSearch();
},
////////////////////////////////////////////////////////////////////////////
//// interface inISearchObserver
onSearchStart: function(aModule)
{
this.setSearchTitle(aModule.title);
this.toggleSearch(true, true);
},
onSearchResult: function(aModule)
{
if (aModule.isPastMilestone) {
this.setStatus("Searching - " + aModule.resultCount + " results found.");
this.setProgress(aModule.progressPercent);
}
},
onSearchEnd: function(aModule, aResult)
{
var diff = Math.round(aModule.elapsed / 100) / 10;
this.setProgress(100);
this.setStatus("Search complete - " + aModule.resultCount + " results found ("+diff+"s)");
},
onSearchError: function(aModule, aMessage)
{
alert("Unable to complete this search due to the following error:\n" + aMessage);
},
////////////////////////////////////////////////////////////////////////////
//// Viewer Registry Interaction
loadViewerRegistry: function()
{
this.mViewerReg = new ViewerRegistry();
this.mViewerReg.load(kViewerRegURL, this);
},
onViewerRegistryLoad: function()
{
this.initViewerPanes();
},
onViewerRegistryLoadError: function(aStatus, aErrorMsg)
{
// fatal error
alert("Unable to load viewer registry.");
this.exit();
},
getViewer: function(aUID)
{
return this.mViewerReg.getViewerByUID(aUID);
},
////////////////////////////////////////////////////////////////////////////
//// History
loadHistory: function()
{
RDFU.loadDataSource(kHistoryURL, HistoryLoadListener);
},
prepareHistory: function(aDS)
{
this.mHistory = RDFArray.fromContainer(aDS, "inspector:history", kInspectorNSURI);
var mppHistory = document.getElementById("mppHistory");
mppHistory.database.AddDataSource(aDS);
mppHistory.builder.rebuild();
},
addToHistory: function(aURL)
{
this.mHistory.add({ URL: aURL});
this.mHistory.save();
},
////////////////////////////////////////////////////////////////////////////
//// Preferences
initPrefs: function()
{
PrefUtils.addObserver("inspector", PrefChangeObserver);
},
onPrefChanged: function(aName)
{
if (aName == "inspector.blink.on")
this.setFlashSelected(PrefUtils.getPref("inspector.blink.on"));
if (this.mFlasher) {
if (aName == "inspector.blink.border-color") {
this.mFlasher.color = PrefUtils.getPref("inspector.blink.border-color");
} else if (aName == "inspector.blink.border-width") {
this.mFlasher.thickness = PrefUtils.getPref("inspector.blink.border-width");
} else if (aName == "inspector.blink.duration") {
this.mFlasher.duration = PrefUtils.getPref("inspector.blink.duration");
} else if (aName == "inspector.blink.speed") {
this.mFlasher.speed = PrefUtils.getPref("inspector.blink.speed");
}
}
},
////////////////////////////////////////////////////////////////////////////
//// Uncategorized
get isViewingContent() { return this.mIsViewingContent },
getSpecialDirectory: function(aName)
{
var dirService = XPCU.getService(kDirServiceCID, "nsIProperties");
return dirService.get(aName, Components.interfaces.nsIFile);
},
fillInTooltip: function(tipElement)
{
var retVal = false;
var textNode = document.getElementById("txTooltip");
if (textNode) {
try {
var tipText = tipElement.getAttribute("tooltiptext");
if (tipText != "") {
textNode.setAttribute("value", tipText);
retVal = true;
}
}
catch (e) { }
}
return retVal;
},
initPopup: function(aPopup)
{
var items = aPopup.getElementsByTagName("menuitem");
var js, fn, item;
for (var i = 0; i < items.length; i++) {
item = items[i];
fn = item.isDisabled;
if (!fn) {
js = item.getAttribute("isDisabled");
if (js) {
fn = new Function(js);
item.isDisabled = fn;
} else {
item.isDisabled = null; // to prevent annoying "strict" warning messages
}
}
if (fn) {
item.setAttribute("disabled", item.isDisabled());
}
fn = null;
}
},
onTreeItemSelected: function()
{
var tree = this.mDOMTree;
var items = tree.selectedItems;
if (items.length > 0) {
var node = this.getNodeFromTreeItem(items[0]);
this.startViewingNode(node, items[0].id);
}
},
///////////////////////////////////////////////////////////////////////////
// The string we get back from shell.getInstallationURL starts with
// "file://" and so we need to add an extra slash, or the load fails.
//
// @param wstring aURL - the url to repair
///////////////////////////////////////////////////////////////////////////
prependBaseURL: function(aURL)
{
return "file:///" + this.mInstallURL.substr(7) + aURL;
},
flashElement: function(aElement, aWindow)
{
// make sure we only try to flash element nodes
if (aElement.nodeType == 1) {
if (!this.mFlasher)
this.mFlasher = new Flasher(this.mUFlasher,
PrefUtils.getPref("inspector.blink.border-color"),
PrefUtils.getPref("inspector.blink.border-width"),
PrefUtils.getPref("inspector.blink.duration"),
PrefUtils.getPref("inspector.blink.speed"));
if (this.mFlasher.flashing)
this.mFlasher.stop();
try {
this.mFlasher.element = aElement;
this.mFlasher.window = aWindow;
this.mFlasher.start();
} catch (ex) {
}
}
},
setViewerCmdAttribute: function(aEntry, aAttr, aValue)
{
var uid = this.mViewerReg.getEntryProperty(aEntry, "uid");
var cmds = document.getElementById("brsGlobalCommands");
var els = cmds.getElementsByAttribute("viewer", uid);
for (var i = 0; i < els.length; i++) {
if (els[i].getAttribute("exclusive") != "false")
els[i].setAttribute(aAttr, aValue);
}
},
setAllViewerCmdAttributes: function(aAttr, aValue)
{
var count = this.mViewerReg.getEntryCount();
for (var i = 0; i < count; i++) {
this.setViewerCmdAttribute(i, aAttr, aValue);
}
},
emptyChildren: function(aNode)
{
while (aNode.childNodes.length > 0) {
aNode.removeChild(aNode.lastChild);
}
},
onSplitterOpen: function(aSplitter)
{
if (aSplitter.id == "splBrowser") {
this.toggleBrowser(true, aSplitter.isOpened, true);
} else if (aSplitter.id == "splSearch") {
this.toggleSearch(true, aSplitter.isOpened, true);
}
}
};
////////////////////////////////////////////////////////////////////////////
//// event listeners
var HistoryLoadListener = {
onDataSourceReady: function(aDS)
{
inspector.prepareHistory(aDS);
},
onError: function()
{
}
};
var PrefChangeObserver = {
Observe: function(aSubject, aTopic, aData)
{
inspector.onPrefChanged(aData);
}
};
function BrowserLoadListener(aEvent)
{
inspector.documentLoaded();
}
function UtilWindowOpenListener(aWindow)
{
inspector.doViewSearchItem(aWindow);
}

View File

@ -0,0 +1,37 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
install::
$(INSTALL) $(srcdir)/inspector-history.rdf $(DIST)/bin/chrome/inspector
$(INSTALL) $(srcdir)/inspector-prefs.rdf $(DIST)/bin/chrome/inspector
$(INSTALL) $(srcdir)/viewer-registry.rdf $(DIST)/bin/chrome/inspector
$(INSTALL) $(srcdir)/search-registry.rdf $(DIST)/bin/chrome/inspector
$(INSTALL) $(srcdir)/prefs/inspector.js $(DIST)/bin/defaults/pref
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,266 @@
/***************************************************************
* ViewerPane ---------------------------------------------------
* Interface for a pane accepts a node and displays all eligible
* viewers in a list and activates the selected viewer.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class ViewerPane
function ViewerPane() // implements inIViewerPane
{
}
ViewerPane.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mContextMenu: null,
mCurrentEntry: null,
mCurrentViewer: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewerPane
//// attributes
get viewee() { return this.mViewee; },
set viewee(aVal) { this.startViewingObject(aVal) },
get container() { return this.mContainer; },
get viewer() { return this.mCurrentViewer; },
get title() { return this.mTitle; },
get uiElement() { return this.mUIElement; },
get viewerReg() { return this.mViewerReg; },
//// methods
initialize: function (aTitle, aContainer, aUIElement, aRegistry)
{
this.mTitle = aTitle;
this.mUIElement = aUIElement;
this.mContainer = aContainer;
this.mViewerReg = aRegistry;
this.mListEl = aUIElement.getElementsByAttribute("ins-role", "viewer-list")[0];
this.mTitleEl = aUIElement.getElementsByAttribute("ins-role", "viewer-title")[0];
this.mMenuEl = aUIElement.getElementsByAttribute("ins-role", "viewer-menu")[0];
this.mIFrameEl = aUIElement.getElementsByAttribute("ins-role", "viewer-iframe")[0];
this.fillViewerList();
},
onViewerConstructed: function(aViewer)
{
var old = this.mCurrentViewer;
this.mCurrentViewer = aViewer;
var oldEntry = this.mCurrentEntry;
this.mCurrentEntry = this.mPendingEntry;
this.rebuildViewerContextMenu();
var title = this.mViewerReg.getEntryProperty(this.mCurrentEntry, "description");
this.setTitle(title);
this.mContainer.onViewerChanged(this, old, oldEntry, this.mCurrentViewer, this.mCurrentEntry);
aViewer.viewee = this.mViewee;
},
onVieweeChanged: function(aObject)
{
this.mContainer.onVieweeChanged(this, aObject);
},
setCommandAttribute: function(aCmdId, aAttribute, aValue)
{
this.mContainer.setCommandAttribute(aCmdId, aAttribute, aValue);
},
getCommandAttribute: function(aCmdId, aAttribute)
{
return this.mContainer.getCommandAttribute(aCmdId, aAttribute);
},
////////////////////////////////////////////////////////////////////////////
//// UI Commands
///////////////////////////////////////////////////////////////////////////
// Sets the new view to the item just selected from the "viewer list"
///////////////////////////////////////////////////////////////////////////
onViewerListCommand: function(aItem)
{
this.switchViewer(aItem.entry);
},
///////////////////////////////////////////////////////////////////////////
// Prepares the list of viewers for a node, rebuilds the menulist to display
// them, and load the default viewer for the node.
//
// @param Object aObject - the object to begin viewing
///////////////////////////////////////////////////////////////////////////
startViewingObject: function(aObject)
{
this.mViewee = aObject;
// get the list of viewers which match the node
var entries = this.mViewerReg.findViewersForObject(aObject);
this.rebuildViewerList(entries);
if (entries.length > 0 && !this.entryInList(this.mCurrentEntry, entries)) {
this.switchViewer(entries[0]);
} else {
this.mCurrentViewer.viewee = aObject;
}
},
///////////////////////////////////////////////////////////////////////////
// Clear out and rebuild the menulist full of the available views
// for the currently selected node.
//
// @param Array aEntries - an array of entries from the viewer registry
///////////////////////////////////////////////////////////////////////////
rebuildViewerList: function(aEntries)
{
var mpp = this.mListElPopup;
this.mListEl.setAttribute("disabled", aEntries.length <= 0);
// empty the list
while (mpp.childNodes.length)
mpp.removeChild(mpp.childNodes[0]);
for (var i = 0; i < aEntries.length; i++) {
var entry = aEntries[i];
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("value", this.mViewerReg.getEntryProperty(entry, "description"));
menuitem.entry = entry;
mpp.appendChild(menuitem);
}
},
///////////////////////////////////////////////////////////////////////////
// Loads the viewer described by an entry in the viewer registry.
//
// @param nsIRDFNode aEntry - entry in the viewer registry
///////////////////////////////////////////////////////////////////////////
switchViewer: function(aEntry)
{
var url = this.mViewerReg.getEntryURL(aEntry);
var loadNew = true;
if (this.mCurrentViewer) {
var oldURL = this.mViewerReg.getEntryURL(this.mCurrentEntry);
if (oldURL == url) {
loadNew = false;
}
}
if (loadNew) {
this.mPendingEntry = aEntry;
this.loadViewerURL(url);
}
},
///////////////////////////////////////////////////////////////////////////
// Begin loading a new viewer from a given url.
//
// @param String aURL - the url of the viewer document
///////////////////////////////////////////////////////////////////////////
loadViewerURL: function(aURL)
{
if (this.mCurrentViewer) {
// tell the old viewer it's about to go away
this.mCurrentViewer.destroy();
}
// load the new document
FrameExchange.loadURL(this.mIFrameEl, aURL, this);
},
///////////////////////////////////////////////////////////////////////////
// Rebuild the viewer context menu
///////////////////////////////////////////////////////////////////////////
rebuildViewerContextMenu: function()
{
// remove old context menu
if (this.mContextMenu) {
this.mMenuEl.removeChild(this.mContextMenu);
this.mFormerContextParent.appendChild(this.mContextMenu);
}
var uid = this.mViewerReg.getEntryProperty(this.mCurrentEntry, "uid");
var ppId = "ppViewerContext-" + uid;
var pp = document.getElementById(ppId);
if (pp) {
this.mMenuEl.setAttribute("disabled", "false");
var parent = pp.parentNode;
parent.removeChild(pp);
this.mMenuEl.appendChild(pp);
this.mFormerContextParent = parent;
this.mContextMenu = pp;
} else {
this.mMenuEl.setAttribute("disabled", "true");
}
},
///////////////////////////////////////////////////////////////////////////
// Check to see if an entry exists in an arry of entries
//
// @param nsIRDFResource aEntry - the entry being searched for
// @param Array aList - array of entries
///////////////////////////////////////////////////////////////////////////
entryInList: function(aEntry, aList)
{
for (var i in aList) {
if (aList[i] == aEntry) return true;
}
return false;
},
///////////////////////////////////////////////////////////////////////////
// Set the text in the viewer title bar
//
// @param String title - the text to use
///////////////////////////////////////////////////////////////////////////
setTitle: function(aTitle)
{
this.mTitleEl.setAttribute("value", (this.mTitle ? this.mTitle + " - " : "") + aTitle);
},
///////////////////////////////////////////////////////////////////////////
// Fill out the content of the "viewer list" menu
///////////////////////////////////////////////////////////////////////////
fillViewerList: function()
{
this.mListEl.pViewer = this;
this.mListEl.setAttribute("oncommand", "this.pViewer.onViewerListCommand(event.target)");
var mpp = document.createElement("menupopup");
this.mListEl.appendChild(mpp);
this.mListElPopup = mpp;
}
};

View File

@ -0,0 +1,212 @@
/***************************************************************
* ViewerRegistry -----------------------------------------------
* The centry registry where information about all installed
* viewers is kept.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
var kViewerURLPrefix = "chrome://inspector/content/viewers/";
////////////////////////////////////////////////////////////////////////////
//// class ViewerRegistry
function ViewerRegistry() // implements inIViewerRegistry
{
this.mViewerHash = {};
}
ViewerRegistry.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// interface inIViewerRegistry
// not yet formalized...
////////////////////////////////////////////////////////////////////////////
//// Initialization
mDS: null,
mObserver: null,
mViewerDS: null,
mViewerHash: null,
mFilters: null,
get url() { return this.mURL; },
//// Loading Methods
load: function(aURL, aObserver)
{
this.mURL = aURL;
this.mObserver = aObserver;
RDFU.loadDataSource(aURL, new ViewerRegistryLoadObserver(this));
},
onError: function(aErrorMsg)
{
this.mObserver.onViewerRegistryLoadError(aStatus, aErrorMsg);
},
onLoad: function(aDS)
{
this.mDS = aDS;
this.prepareRegistry();
this.mObserver.onViewerRegistryLoad();
},
prepareRegistry: function()
{
this.mViewerDS = RDFArray.fromContainer(this.mDS, "inspector:viewers", kInspectorNSURI);
// create and cache the filter functions
var js, fn;
this.mFilters = [];
for (var i = 0; i < this.mViewerDS.length; ++i) {
js = this.getEntryProperty(i, "filter");
try {
fn = new Function("object", js);
} catch (ex) {
fn = new Function("return false");
debug("### ERROR - Syntax error in filter for viewer \"" + this.getEntryProperty(i, "description") + "\"\n");
}
this.mFilters.push(fn);
}
},
///////////////////////////////////////////////////////////////////////////
// Returns the absolute url where the xul file for a viewer can be found.
//
// @param long aIndex - the index of the entry representing the viewer
// @return wstring - the fully cannonized url
///////////////////////////////////////////////////////////////////////////
getEntryURL: function(aIndex)
{
var uid = this.getEntryProperty(aIndex, "uid");
return kViewerURLPrefix + uid + "/" + uid + ".xul";
},
//// Lookup Methods
///////////////////////////////////////////////////////////////////////////
// Searches the viewer registry for all viewers that can view a particular
// object.
//
// @param Object aObject - the object being searched against
// @return nsIRDFResource[] - array of entries in the viewer registry
///////////////////////////////////////////////////////////////////////////
findViewersForObject: function(aObject)
{
// check each entry in the registry
var len = this.mViewerDS.length;
var entry;
var urls = [];
for (var i = 0; i < len; ++i) {
if (this.objectMatchesEntry(aObject, i)) {
if (this.getEntryProperty(i, "important")) {
urls.unshift(i);
} else {
urls.push(i);
}
}
}
return urls;
},
///////////////////////////////////////////////////////////////////////////
// Determines if an object is eligible to be viewed by a particular viewer.
//
// @param Object aObject - the object being checked for eligibility
// @param long aIndex - the index of the entry
// @return boolean - true if object can be viewed
///////////////////////////////////////////////////////////////////////////
objectMatchesEntry: function(aObject, aIndex)
{
return this.mFilters[aIndex](aObject);
},
///////////////////////////////////////////////////////////////////////////
// Notifies the registry that a viewer has been instantiated, and that
// it corresponds to a particular entry in the viewer registry.
//
// @param
///////////////////////////////////////////////////////////////////////////
cacheViewer: function(aViewer, aIndex)
{
var uid = this.getEntryProperty(aIndex, "uid");
this.mViewerHash[uid] = { viewer: aViewer, entry: aIndex };
},
// for previously loaded viewers only
getViewerByUID: function(aUID)
{
return this.mViewerHash[aUID].viewer;
},
// for previously loaded viewers only
getEntryForViewer: function(aViewer)
{
return this.mViewerHash[aViewer.uid].entry;
},
// for previously loaded viewers only
getEntryByUID: function(aUID)
{
return this.mViewerHash[aUID].aIndex;
},
getEntryProperty: function(aIndex, aProp)
{
return this.mViewerDS.get(aIndex, aProp);
},
getEntryCount: function()
{
return this.mViewerDS.length;
},
////////////////////////////////////////////////////////////////////////////
//// Viewer Registration
addNewEntry: function(aUID, aDescription, aFilter)
{
},
removeEntry: function(aIndex)
{
},
saveRegistry: function()
{
}
};
////////////////////////////////////////////////////////////////////////////
//// Listener Objects
function ViewerRegistryLoadObserver(aTarget)
{
this.mTarget = aTarget;
}
ViewerRegistryLoadObserver.prototype = {
mTarget: null,
onError: function(aErrorMsg)
{
this.mTarget.onLoadError(aErrorMsg);
},
onDataSourceReady: function(aDS)
{
this.mTarget.onLoad(aDS);
}
};

View File

@ -0,0 +1,63 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<overlay id="ovCommandsMain"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<broadcasterset id="brsGlobalCommands" datasources="rdf:null" ref="commands:global">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<member container="?uri" child="?cmd"/>
</conditions>
<bindings>
<binding subject="?cmd" predicate="&INS-rdf;oncommand" object="?oncommand"/>
<binding subject="?cmd" predicate="&INS-rdf;onkeypress" object="?onkeypress"/>
</bindings>
<action>
<broadcaster uri="?cmd" onkeypress="?onkeypress" oncommand="?oncommand" disabled="true"/>
</action>
</rule>
</template>
<broadcaster
id="cmdGotoURL"
onkeypress="if(event.keyCode == 13) inspector.gotoTypedURL();"
oncommand="inspector.gotoTypedURL()"/>
<broadcaster id="cmdShowOpenURLDialog" oncommand="inspector.showOpenURLDialog()"/>
<broadcaster id="cmdExit" oncommand="inspector.exit();"/>
<broadcaster id="cmdUndo" disabled="true" oncommand=""/>
<broadcaster id="cmdRedo" disabled="true" oncommand=""/>
<broadcaster id="cmdCut" disabled="true" oncommand=""/>
<broadcaster id="cmdCopy" disabled="true" oncommand=""/>
<broadcaster id="cmdPaste" disabled="true" oncommand=""/>
<broadcaster id="cmdDelete" disabled="true" oncommand=""/>
<broadcaster id="cmdShowPrefsDialog" oncommand="inspector.showPrefsDialog()"/>
<broadcaster id="cmdRunSearch" oncommand="inspector.runSearch()"/>
<broadcaster id="cmdToggleBrowser" oncommand="inspector.toggleBrowser()"/>
<broadcaster id="cmdToggleSearch" oncommand="inspector.toggleSearch()"/>
<broadcaster id="cmdFlashSelected" oncommand="inspector.toggleFlashSelected()"/>
<broadcaster id="cmdShowNotes" oncommand="inspector.showNotes()"/>
<broadcaster id="cmdShowAbout" oncommand="inspector.showAbout()"/>
<broadcaster id="cmdViewSearchItem" oncommand="inspector.viewSearchItem()"/>
<broadcaster id="cmdEditSearchItem" oncommand="inspector.editSearchItem()"/>
<broadcaster id="cmdCopySearchItemLine" oncommand="inspector.copySearchItemLine()"/>
<broadcaster id="cmdCopySearchItemAll" oncommand="inspector.copySearchItemAll()"/>
<broadcaster id="cmdSaveSearchItemText" oncommand="inspector.saveSearchItemText()"/>
<broadcaster id="cmdClearSearch" oncommand="inspector.clearSearchResults()"/>
</broadcasterset>
</overlay>

View File

@ -0,0 +1,52 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the packages being supplied by this jar -->
<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:inspector"/>
</RDF:Seq>
<!-- package information -->
<RDF:Description about="urn:mozilla:package:inspector"
chrome:displayName="Document Inspector"
chrome:author="Joe Hewitt"
chrome:name="inspector">
</RDF:Description>
<!-- overlay information -->
<RDF:Seq about="urn:mozilla:overlays">
<RDF:li resource="chrome://communicator/content/tasksOverlay.xul"/>
<RDF:li resource="chrome://inspector/content/commandOverlay.xul"/>
<RDF:li resource="chrome://inspector/content/keysetOverlay.xul"/>
<RDF:li resource="chrome://inspector/content/popupOverlay.xul"/>
<RDF:li resource="chrome://communicator/content/pref/preftree.xul"/>
</RDF:Seq>
<!-- Communicator Overlays -->
<RDF:Seq about="chrome://communicator/content/tasksOverlay.xul">
<RDF:li>chrome://inspector/content/tasksOverlay.xul</RDF:li>
</RDF:Seq>
<RDF:Seq about="chrome://communicator/content/pref/preftree.xul">
<RDF:li>chrome://inspector/content/prefs/prefsOverlay.xul</RDF:li>
</RDF:Seq>
<!-- Inspector Overlays -->
<RDF:Seq about="chrome://inspector/content/commandOverlay.xul">
<RDF:li>chrome://inspector/content/viewers/dom/commandOverlay.xul</RDF:li>
<RDF:li>chrome://inspector/content/search/modules/commandOverlay.xul</RDF:li>
</RDF:Seq>
<RDF:Seq about="chrome://inspector/content/keysetOverlay.xul">
<RDF:li>chrome://inspector/content/viewers/dom/keysetOverlay.xul</RDF:li>
</RDF:Seq>
<RDF:Seq about="chrome://inspector/content/popupOverlay.xul">
<RDF:li>chrome://inspector/content/viewers/dom/popupOverlay.xul</RDF:li>
<RDF:li>chrome://inspector/content/search/modules/popupOverlay.xul</RDF:li>
</RDF:Seq>
</RDF:RDF>

View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ins="http://www.mozilla.org/inspector#">
<rdf:Seq about="inspector:history">
<rdf:li><rdf:Description
ins:Name="Foopy Doc"
ins:URL="http://www.mozilla.org"/></rdf:li>
</rdf:Seq>
</rdf:RDF>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ins="http://www.mozilla.org/inspector#">
<rdf:Description about="inspector:prefs">
<ins:general><rdf:Description
ins:stuff="blah"
/></ins:general>
</rdf:Description>
</rdf:RDF>

View File

@ -0,0 +1,10 @@
@namespace ins url("http://www.mozilla.org/inspector#");
*[hide="true"] {
visibility: hidden;
}
row {
vertical-align: middle;
}

View File

@ -0,0 +1,43 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xul-overlay href="chrome://inspector/content/inspectorOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/toolboxOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/commandOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/keysetOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/statusbarOverlay.xul"?>
<?xml-stylesheet href="chrome://inspector/skin/inspectorWindow.css"?>
<window id="winInspectorMain" class="color-dialog"
title="Document Inspector"
width="1024" height="768" orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="Javascript" src="chrome://communicator/content/utilityOverlay.js"/>
<popupset id="psTooltipSet">
<popup id="ppTooltip" class="tooltip" oncreate="return inspector.fillInTooltip(document.tooltipNode);">
<text id="txTooltip"/>
</popup>
</popupset>
<popupset id="ppsGlobalPopupset"/>
<keyset id="ksGlobalKeyset"/>
<broadcasterset id="brsGlobalCommands"/>
<toolbox id="tbxInsToolbox">
<menubar id="mbrInspectorMain"/>
<toolbar id="tbInspectorPrimary"/>
</toolbox>
<box id="bxInspectorMain" flex="1"/>
<box id="bxStatus"/>
</window>

View File

@ -0,0 +1,80 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<overlay id="ovInspector"
xmlns:ins="&INS-rdf;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/InspectorApp.js"/>
<script language="javascript" src="chrome://inspector/content/ViewerRegistry.js"/>
<script language="javascript" src="chrome://inspector/content/ViewerPane.js"/>
<script language="javascript" src="chrome://inspector/content/utils.js"/>
<script language="javascript" src="chrome://inspector/content/Flasher.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFArray.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/FrameExchange.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/system/ClipboardUtils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/system/PrefUtils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/system/FilePickerUtils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/system/file.js"/>
<script language="javascript" src="chrome://inspector/content/search/inSearchService.js"/>
<script language="javascript" src="chrome://inspector/content/search/inSearchModule.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/inFormManager.js"/>
<script language="javascript" src="chrome://inspector/content/search/inSearchUtils.js"/>
<script language="javascript" src="chrome://inspector/content/search/inSearchTreeBuilder.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/inTreeTableBuilder.js"/>
<box id="bxInspectorMain" orient="vertical">
<box id="bxInspectorPanes" orient="horizontal" flex="1" hide="true">
<box id="bxDocPane" class="viewer-pane" flex="1" orient="vertical">
<box id="bxDocHeader" class="viewer-pane-header" autostretch="never">
<menubutton class="viewer-list" ins-role="viewer-list" disabled="true"/>
<text class="viewer-title" ins-role="viewer-title" flex="1"/>
<menubutton class="viewer-menu" ins-role="viewer-menu" disabled="true"/>
</box>
<iframe id="ifDocViewer" class="viewer-iframe" flex="1" ins-role="viewer-iframe"/>
</box>
<splitter orient="vertical" collapse="before">
<grippy/>
</splitter>
<box id="bxObjectPane" class="viewer-pane" flex="1" orient="vertical">
<box id="bxObjHeader" class="viewer-pane-header" autostretch="never">
<menubutton class="viewer-list" ins-role="viewer-list" disabled="true"/>
<text class="viewer-title" ins-role="viewer-title" flex="1"/>
<menubutton class="viewer-menu" ins-role="viewer-menu" disabled="true"/>
</box>
<iframe id="ifObjViewer" class="viewer-iframe" flex="1" ins-role="viewer-iframe"/>
</box>
</box>
<splitter id="splBrowser" class="titled-splitter"
onopen="inspector.onSplitterOpen(this)"
value="Browser" closebutton="true" collapse="after"/>
<box id="bxBrowser" flex="1">
<browser id="ifBrowser" type="content-primary" flex="1" src="about:blank"/>
</box>
<splitter id="splSearch" class="titled-splitter"
onopen="inspector.onSplitterOpen(this)"
value="Search Results" closebutton="true" collapse="after"/>
<box id="bxSearch" orient="vertical">
<tree id="trSearch" flex="1" context="ppSearchResults" datasources="rdf:null">
<template/>
</tree>
<!-- TEMPORARY UNTIL FIX FOR 54237 -->
<browser id="inSearchServiceLoader" height="1"/>
</box>
</box>
</overlay>

View File

@ -0,0 +1,85 @@
inspector.jar:
content/inspector/contents.rdf
content/inspector/inspector.xul
content/inspector/inspectorOverlay.xul
content/inspector/toolboxOverlay.xul
content/inspector/statusbarOverlay.xul
content/inspector/commandOverlay.xul
content/inspector/keysetOverlay.xul
content/inspector/popupOverlay.xul
content/inspector/tasksOverlay.xul
content/inspector/utilWindow.xul
content/inspector/inspector.css
content/inspector/util.dtd
content/inspector/InspectorApp.js
content/inspector/ViewerRegistry.js
content/inspector/ViewerPane.js
content/inspector/Flasher.js
content/inspector/utils.js
content/inspector/extensions/treeEditable.xml (extensions/treeEditable.xml)
content/inspector/extensions/treeEditable.css (extensions/treeEditable.css)
content/inspector/extensions/titledSplitter.xml (extensions/titledSplitter.xml)
content/inspector/extensions/titledSplitter.css (extensions/titledSplitter.css)
content/inspector/extensions/wsm-colorpicker.js (extensions/wsm-colorpicker.js)
content/inspector/jsutil/rdf/RDFU.js (jsutil/rdf/RDFU.js)
content/inspector/jsutil/rdf/RDFArray.js (jsutil/rdf/RDFArray.js)
content/inspector/jsutil/system/ClipboardUtils.js (jsutil/system/ClipboardUtils.js)
content/inspector/jsutil/system/PrefUtils.js (jsutil/system/PrefUtils.js)
content/inspector/jsutil/system/FilePickerUtils.js (jsutil/system/FilePickerUtils.js)
content/inspector/jsutil/system/DiskSearch.js (jsutil/system/DiskSearch.js)
content/inspector/jsutil/system/file.js (jsutil/system/file.js)
content/inspector/jsutil/xpcom/XPCU.js (jsutil/xpcom/XPCU.js)
content/inspector/jsutil/xul/FrameExchange.js (jsutil/xul/FrameExchange.js)
content/inspector/jsutil/xul/inFormManager.js (jsutil/xul/inFormManager.js)
content/inspector/jsutil/xul/inTreeTableBuilder.js (jsutil/xul/inTreeTableBuilder.js)
content/inspector/jsutil/xul/DNDUtils.js (jsutil/xul/DNDUtils.js)
content/inspector/prefs/prefs.xul (prefs/prefs.xul)
content/inspector/prefs/prefsOverlay.xul (prefs/prefsOverlay.xul)
content/inspector/prefs/pref-inspector.xul (prefs/pref-inspector.xul)
content/inspector/prefs/pref-sidebar.xul (prefs/pref-sidebar.xul)
content/inspector/prefs/pref-sidebar.js (prefs/pref-sidebar.js)
content/inspector/search/inSearchService.js (search/inSearchService.js)
content/inspector/search/inSearchModule.js (search/inSearchModule.js)
content/inspector/search/inSearchTreeBuilder.js (search/inSearchTreeBuilder.js)
content/inspector/search/inSearchUtils.js (search/inSearchUtils.js)
content/inspector/search/modules/popupOverlay.xul (search/modules/popupOverlay.xul)
content/inspector/search/modules/commandOverlay.xul (search/modules/commandOverlay.xul)
content/inspector/search/modules/findFiles/findFiles.xml (search/modules/findFiles/findFiles.xml)
content/inspector/search/modules/findFiles/dialog.xul (search/modules/findFiles/dialog.xul)
content/inspector/search/modules/findFiles/dialog.js (search/modules/findFiles/dialog.js)
content/inspector/search/modules/junkImgs/junkImgs.xml (search/modules/junkImgs/junkImgs.xml)
content/inspector/search/modules/junkImgs/dialog.xul (search/modules/junkImgs/dialog.xul)
content/inspector/search/modules/junkImgs/dialog.js (search/modules/junkImgs/dialog.js)
content/inspector/sidebar/sidebar.xul (sidebar/sidebar.xul)
content/inspector/sidebar/InspectorSidebar.js (sidebar/InspectorSidebar.js)
content/inspector/tests/test1.html (tests/test1.html)
content/inspector/tests/test2.xul (tests/test2.xul)
content/inspector/tests/selectors.xul (tests/selectors.xul)
content/inspector/tests/selectors.css (tests/selectors.css)
content/inspector/tests/allskin.xul (tests/allskin.xul)
content/inspector/tests/allskin-ns.xul (tests/allskin-ns.xul)
content/inspector/viewers/computedStyle/computedStyle.xul (viewers/computedStyle/computedStyle.xul)
content/inspector/viewers/computedStyle/computedStyle.js (viewers/computedStyle/computedStyle.js)
content/inspector/viewers/dom/dom.xul (viewers/dom/dom.xul)
content/inspector/viewers/dom/dom.js (viewers/dom/dom.js)
content/inspector/viewers/dom/commandOverlay.xul (viewers/dom/commandOverlay.xul)
content/inspector/viewers/dom/keysetOverlay.xul (viewers/dom/keysetOverlay.xul)
content/inspector/viewers/dom/popupOverlay.xul (viewers/dom/popupOverlay.xul)
content/inspector/viewers/dom/findDialog.xul (viewers/dom/findDialog.xul)
content/inspector/viewers/dom/FindDialog.js (viewers/dom/FindDialog.js)
content/inspector/viewers/dom/columnsDialog.xul (viewers/dom/columnsDialog.xul)
content/inspector/viewers/dom/columnsDialog.js (viewers/dom/columnsDialog.js)
content/inspector/viewers/jsObject/jsObject.xul (viewers/jsObject/jsObject.xul)
content/inspector/viewers/jsObject/jsObject.js (viewers/jsObject/jsObject.js)
content/inspector/viewers/nodeElement/nodeElement.xul (viewers/nodeElement/nodeElement.xul)
content/inspector/viewers/nodeElement/nodeElement.js (viewers/nodeElement/nodeElement.js)
content/inspector/viewers/nodeText/nodeText.xul (viewers/nodeText/nodeText.xul)
content/inspector/viewers/nodeText/nodeText.js (viewers/nodeText/nodeText.js)
content/inspector/viewers/styleRules/styleRules.xul (viewers/styleRules/styleRules.xul)
content/inspector/viewers/styleRules/styleRules.js (viewers/styleRules/styleRules.js)
content/inspector/viewers/styleRules/commandOverlay.xul (viewers/styleRules/commandOverlay.xul)
content/inspector/viewers/styleRules/popupOverlay.xul (viewers/styleRules/popupOverlay.xul)
content/inspector/viewers/stylesheets/stylesheets.xul (viewers/stylesheets/stylesheets.xul)
content/inspector/viewers/stylesheets/stylesheets.js (viewers/stylesheets/stylesheets.js)
content/inspector/viewers/xblBindings/xblBindings.xul (viewers/xblBindings/xblBindings.xul)
content/inspector/viewers/xblBindings/xblBindings.js (viewers/xblBindings/xblBindings.js)

View File

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<overlay id="ovKeyset"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<keyset id="ksGlobalKeyset" xulkey="ctrl" datasources="rdf:null" ref="keys:global">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<member container="?uri" child="?key"/>
</conditions>
<bindings>
<binding subject="?key" predicate="&INS-rdf;xulkey" object="?xulkey"/>
<binding subject="?key" predicate="&INS-rdf;key" object="?tkey"/>
<binding subject="?key" predicate="&INS-rdf;keycode" object="?keycode"/>
<binding subject="?key" predicate="&INS-rdf;modifiers" object="?modifiers"/>
<binding subject="?key" predicate="&INS-rdf;observes" object="?observes"/>
<binding subject="?key" predicate="&INS-rdf;oncommand" object="?oncommand"/>
</bindings>
<action>
<key uri="?key"
xulkey="?xulkey" key="?tkey" keycode="?keycode" modifiers="?modifiers"
observes="?observes" oncommand="?oncommand"/>
</action>
</rule>
</template>
</keyset>
</overlay>

View File

@ -0,0 +1,33 @@
#!nmake
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
include <$(DEPTH)/config/config.mak>
DIRS = content skin locale
include <$(DEPTH)\config\rules.mak>
chrome::
$(REGCHROME) content inspector inspector.jar
$(REGCHROME) locale en-US/inspector inspector.jar
$(REGCHROME) skin modern/inspector inspector.jar
$(REGCHROME) skin classic/inspector inspector.jar