From bug 325100, the files in extensions/inspector/base/public|src were cvs-copied to layout/inspector. The old locations are no longer used.

This commit is contained in:
benjamin%smedbergs.us 2006-05-19 19:07:04 +00:00
Родитель 0a82d563d9
Коммит 646df4da70
26 изменённых файлов: 0 добавлений и 4831 удалений

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

@ -1,65 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Joe Hewitt <hewitt@netscape.com> (original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH=../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE=inspector
XPIDL_MODULE=inspector
ifdef MOZ_XUL_APP
XPI_NAME = inspector
endif
XPIDLSRCS = inIDOMView.idl \
inIDeepTreeWalker.idl \
inIFlasher.idl \
inISearchProcess.idl \
inISearchObserver.idl \
inICSSValueSearch.idl \
inIFileSearch.idl \
inIDOMUtils.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -1,62 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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;
};

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

@ -1,70 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
* Christopher A. Aillon <christopher@aillon.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIArray;
interface nsISupportsArray;
interface nsIDOMCharacterData;
interface nsIDOMElement;
interface nsIDOMDocument;
interface nsIDOMCSSStyleRule;
interface nsIDOMNode;
[scriptable, uuid(78fd16c2-bdfb-4b1d-8738-d536d0a8f430)]
interface inIDOMUtils : nsISupports
{
// CSS utilities
nsISupportsArray getCSSStyleRules(in nsIDOMElement aElement);
unsigned long getRuleLine(in nsIDOMCSSStyleRule aRule);
// DOM Node utilities
boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode);
// Returns the "parent" of a node. The parent of a document node is the
// frame/iframe containing that document. aShowingAnonymousContent says
// whether we are showing anonymous content.
nsIDOMNode getParentForNode(in nsIDOMNode aNode,
in boolean aShowingAnonymousContent);
// XBL utilities
nsIArray getBindingURLs(in nsIDOMElement aElement);
// content state utilities
long getContentState(in nsIDOMElement aElement);
void setContentState(in nsIDOMElement aElement, in long aState);
};

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

@ -1,56 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMNode;
[scriptable, uuid(3EB4C760-DFFD-4983-94A8-18BCB99100E4)]
interface inIDOMView : nsISupports
{
attribute nsIDOMNode rootNode;
attribute boolean showAnonymousContent;
attribute boolean showSubDocuments;
attribute boolean showWhitespaceNodes;
attribute unsigned long whatToShow;
nsIDOMNode getNodeFromRowIndex(in long rowIndex);
long getRowIndexFromNode(in nsIDOMNode node);
void rebuild();
};

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

@ -1,51 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIDOMTreeWalker.idl"
interface nsIDOMNode;
[scriptable, uuid(91FCA0E9-99D6-406b-9D78-4C96F11E9EE4)]
interface inIDeepTreeWalker : nsIDOMTreeWalker
{
attribute boolean showAnonymousContent;
attribute boolean showSubDocuments;
void init(in nsIDOMNode aRoot, in unsigned long aWhatToShow);
};

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

@ -1,65 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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);
};

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

@ -1,56 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
* Christopher A. Aillon <christopher@aillon.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsIDOMElement;
interface nsIDOMWindowInternal;
[scriptable, uuid(7B4A099F-6F6E-4565-977B-FB622ADBFF49)]
interface inIFlasher : nsISupports
{
attribute DOMString color;
attribute boolean invert;
attribute unsigned short thickness;
void drawElementOutline(in nsIDOMElement aElement);
void repaintElement(in nsIDOMElement aElement);
void scrollElementIntoView(in nsIDOMElement aElement);
};

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

@ -1,54 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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 AString aMessage);
};

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

@ -1,83 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsAString;
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
AString getStringResultAt(in long aIndex);
long getIntResultAt(in long aIndex);
unsigned long getUIntResultAt(in long aIndex);
};

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

@ -1,83 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH=../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE=inspector
LIBRARY_NAME=inspector_s
MOZILLA_INTERNAL_API = 1
ifdef MOZ_XUL_APP
XPI_NAME = inspector
endif
REQUIRES = xpcom \
string \
dom \
gfx \
layout \
content \
xul \
widget \
locale \
necko \
docshell \
view \
webshell \
$(NULL)
CPPSRCS= \
inDOMView.cpp \
inDeepTreeWalker.cpp \
inFlasher.cpp \
inSearchLoop.cpp \
inCSSValueSearch.cpp \
inFileSearch.cpp \
inDOMUtils.cpp \
inLayoutUtils.cpp \
$(NULL)
FORCE_STATIC_LIB = 1
# This library is used by other shared libs in a static build
FORCE_USE_PIC = 1
include $(topsrcdir)/config/rules.mk

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

@ -1,436 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "inCSSValueSearch.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsVoidArray.h"
#include "nsReadableUtils.h"
#include "nsIDOMDocumentStyle.h"
#include "nsIDOM3Node.h"
#include "nsIDOMStyleSheetList.h"
#include "nsIDOMCSSStyleSheet.h"
#include "nsIDOMCSSRuleList.h"
#include "nsIDOMCSSStyleRule.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMCSSImportRule.h"
#include "nsIDOMCSSMediaRule.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
static NS_DEFINE_CID(kInspectorCSSUtilsCID, NS_INSPECTORCSSUTILS_CID);
///////////////////////////////////////////////////////////////////////////////
inCSSValueSearch::inCSSValueSearch()
: mResults(nsnull),
mProperties(nsnull),
mResultCount(0),
mPropertyCount(0),
mIsActive(PR_FALSE),
mHoldResults(PR_TRUE),
mReturnRelativeURLs(PR_TRUE),
mNormalizeChromeURLs(PR_FALSE)
{
mProperties = new nsCSSProperty[100];
mCSSUtils = do_GetService(kInspectorCSSUtilsCID);
}
inCSSValueSearch::~inCSSValueSearch()
{
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<nsIURI> baseURL;
nsCOMPtr<nsIDOM3Node> dom3Node = do_QueryInterface(mDocument);
if (dom3Node) {
nsAutoString uri;
dom3Node->GetBaseURI(uri);
NS_NewURI(getter_AddRefs(baseURL), uri);
}
nsCOMPtr<nsIDOMDocumentStyle> doc = do_QueryInterface(mDocument);
if (doc) {
nsCOMPtr<nsIDOMStyleSheetList> sheets;
nsresult rv = doc->GetStyleSheets(getter_AddRefs(sheets));
NS_ENSURE_SUCCESS(rv, NS_OK);
PRUint32 length;
sheets->GetLength(&length);
for (PRUint32 i = 0; i < length; ++i) {
nsCOMPtr<nsIDOMStyleSheet> sheet;
sheets->Item(i, getter_AddRefs(sheet));
nsCOMPtr<nsIDOMCSSStyleSheet> cssSheet = do_QueryInterface(sheet);
if (cssSheet)
SearchStyleSheet(cssSheet, baseURL);
}
}
// XXX would be nice to search inline style as well.
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, nsAString& _retval)
{
if (mHoldResults) {
nsAutoString* result = (nsAutoString*)mResults->ElementAt(aIndex);
_retval = *result;
} else if (aIndex == mResultCount-1) {
_retval = mLastResult;
} 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)
{
if (!(*aBaseURL = ToNewUnicode(mBaseURL)))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetBaseURL(const PRUnichar* aBaseURL)
{
mBaseURL.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)
{
nsCSSProperty prop;
mCSSUtils->LookupCSSProperty(nsDependentString(aPropName), &prop);
mProperties[mPropertyCount] = prop;
mPropertyCount++;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetTextCriteria(PRUnichar** aTextCriteria)
{
if (!(*aTextCriteria = ToNewUnicode(mTextCriteria)))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetTextCriteria(const PRUnichar* aTextCriteria)
{
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(nsIDOMCSSStyleSheet* aStyleSheet, nsIURI* aBaseURL)
{
nsCOMPtr<nsIURI> baseURL;
nsAutoString href;
aStyleSheet->GetHref(href);
if (href.IsEmpty())
baseURL = aBaseURL;
else
NS_NewURI(getter_AddRefs(baseURL), href, nsnull, aBaseURL);
nsCOMPtr<nsIDOMCSSRuleList> rules;
nsresult rv = aStyleSheet->GetCssRules(getter_AddRefs(rules));
NS_ENSURE_SUCCESS(rv, rv);
return SearchRuleList(rules, baseURL);
}
nsresult
inCSSValueSearch::SearchRuleList(nsIDOMCSSRuleList* aRuleList, nsIURI* aBaseURL)
{
PRUint32 length;
aRuleList->GetLength(&length);
for (PRUint32 i = 0; i < length; ++i) {
nsCOMPtr<nsIDOMCSSRule> rule;
aRuleList->Item(i, getter_AddRefs(rule));
PRUint16 type;
rule->GetType(&type);
switch (type) {
case nsIDOMCSSRule::STYLE_RULE: {
nsCOMPtr<nsIDOMCSSStyleRule> styleRule = do_QueryInterface(rule);
SearchStyleRule(styleRule, aBaseURL);
} break;
case nsIDOMCSSRule::IMPORT_RULE: {
nsCOMPtr<nsIDOMCSSImportRule> importRule = do_QueryInterface(rule);
nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
importRule->GetStyleSheet(getter_AddRefs(childSheet));
if (childSheet)
SearchStyleSheet(childSheet, aBaseURL);
} break;
case nsIDOMCSSRule::MEDIA_RULE: {
nsCOMPtr<nsIDOMCSSMediaRule> mediaRule = do_QueryInterface(rule);
nsCOMPtr<nsIDOMCSSRuleList> childRules;
mediaRule->GetCssRules(getter_AddRefs(childRules));
SearchRuleList(childRules, aBaseURL);
} break;
default:
// XXX handle nsIDOMCSSRule::PAGE_RULE if we ever support it
break;
}
}
return NS_OK;
}
nsresult
inCSSValueSearch::SearchStyleRule(nsIDOMCSSStyleRule* aStyleRule, nsIURI* aBaseURL)
{
nsCOMPtr<nsIDOMCSSStyleDeclaration> decl;
nsresult rv = aStyleRule->GetStyle(getter_AddRefs(decl));
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 length;
decl->GetLength(&length);
nsAutoString property, value;
for (PRUint32 i = 0; i < length; ++i) {
decl->Item(i, property);
// XXX This probably ought to use GetPropertyCSSValue if it were
// implemented.
decl->GetPropertyValue(property, value);
SearchStyleValue(value, aBaseURL);
}
return NS_OK;
}
nsresult
inCSSValueSearch::SearchStyleValue(const nsAFlatString& aValue, nsIURI* aBaseURL)
{
if (StringBeginsWith(aValue, NS_LITERAL_STRING("url(")) &&
StringEndsWith(aValue, NS_LITERAL_STRING(")"))) {
const nsASingleFragmentString &url =
Substring(aValue, 4, aValue.Length() - 5);
// XXXldb Need to do more with |mReturnRelativeURLs|, perhaps?
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), url, nsnull, aBaseURL);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString spec;
uri->GetSpec(spec);
nsAutoString *result = new NS_ConvertUTF8toUTF16(spec);
if (mReturnRelativeURLs)
EqualizeURL(result);
mResults->AppendElement(result);
++mResultCount;
}
return NS_OK;
}
nsresult
inCSSValueSearch::EqualizeURL(nsAutoString* aURL)
{
if (mNormalizeChromeURLs) {
if (aURL->Find("chrome://", PR_FALSE, 0, 1) >= 0) {
PRUint32 len = aURL->Length();
char* result = new char[len-8];
const PRUnichar* src = aURL->get();
PRUint32 i = 9;
PRUint32 milestone = 0;
PRUint32 s = 0;
while (i < len) {
if (src[i] == '/') {
milestone += 1;
}
if (milestone != 1) {
result[i-9-s] = src[i];
} else {
s++;
}
i++;
}
result[i-9-s] = 0;
aURL->AssignWithConversion(result);
delete [] result;
}
} else {
}
return NS_OK;
}

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

@ -1,90 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inCSSValueSearch_h__
#define __inCSSValueSearch_h__
#include "inICSSValueSearch.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "inISearchObserver.h"
#include "nsVoidArray.h"
#include "nsIInspectorCSSUtils.h"
class nsIDOMCSSStyleSheet;
class nsIDOMCSSRuleList;
class nsIDOMCSSStyleRule;
class nsIURI;
class inCSSValueSearch : public inICSSValueSearch
{
public:
NS_DECL_ISUPPORTS
NS_DECL_INISEARCHPROCESS
NS_DECL_INICSSVALUESEARCH
inCSSValueSearch();
virtual ~inCSSValueSearch();
protected:
nsCOMPtr<inISearchObserver> mObserver;
nsCOMPtr<nsIInspectorCSSUtils> mCSSUtils;
nsCOMPtr<nsIDOMDocument> mDocument;
nsVoidArray* mResults;
nsCSSProperty* mProperties;
nsString mLastResult;
nsString mBaseURL;
nsString mTextCriteria;
PRInt32 mResultCount;
PRUint32 mPropertyCount;
PRBool mIsActive;
PRBool mHoldResults;
PRBool mReturnRelativeURLs;
PRBool mNormalizeChromeURLs;
nsresult InitSearch();
nsresult KillSearch(PRInt16 aResult);
nsresult SearchStyleSheet(nsIDOMCSSStyleSheet* aStyleSheet, nsIURI* aBaseURI);
nsresult SearchRuleList(nsIDOMCSSRuleList* aRuleList, nsIURI* aBaseURI);
nsresult SearchStyleRule(nsIDOMCSSStyleRule* aStyleRule, nsIURI* aBaseURI);
nsresult SearchStyleValue(const nsAFlatString& aValue, nsIURI* aBaseURI);
nsresult EqualizeURL(nsAutoString* aURL);
};
#endif // __inCSSValueSearch_h__

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

@ -1,249 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
* Christopher A. Aillon <christopher@aillon.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "inDOMUtils.h"
#include "inLayoutUtils.h"
#include "nsIServiceManager.h"
#include "nsString.h"
#include "nsIDOMElement.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMCharacterData.h"
#include "nsITextContent.h"
#include "nsRuleNode.h"
#include "nsIStyleRule.h"
#include "nsICSSStyleRule.h"
#include "nsICSSStyleRuleDOMWrapper.h"
#include "nsIDOMWindowInternal.h"
static NS_DEFINE_CID(kInspectorCSSUtilsCID, NS_INSPECTORCSSUTILS_CID);
///////////////////////////////////////////////////////////////////////////////
inDOMUtils::inDOMUtils()
{
mCSSUtils = do_GetService(kInspectorCSSUtilsCID);
}
inDOMUtils::~inDOMUtils()
{
}
NS_IMPL_ISUPPORTS1(inDOMUtils, inIDOMUtils)
///////////////////////////////////////////////////////////////////////////////
// inIDOMUtils
NS_IMETHODIMP
inDOMUtils::IsIgnorableWhitespace(nsIDOMCharacterData *aDataNode,
PRBool *aReturn)
{
NS_PRECONDITION(aDataNode, "Must have a character data node");
NS_PRECONDITION(aReturn, "Must have an out parameter");
*aReturn = PR_FALSE;
nsCOMPtr<nsITextContent> textContent = do_QueryInterface(aDataNode);
NS_ASSERTION(textContent, "Does not implement nsITextContent!");
if (!textContent->IsOnlyWhitespace()) {
return NS_OK;
}
// Okay. We have only white space. Let's check the white-space
// property now and make sure that this isn't preformatted text...
nsCOMPtr<nsIDOMWindowInternal> win = inLayoutUtils::GetWindowFor(aDataNode);
if (!win) {
// Hmm. Things are screwy if we have no window...
NS_ERROR("No window!");
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(win);
if (!presShell) {
// Display:none iframe or something... Bail out
return NS_OK;
}
nsCOMPtr<nsIContent> content = do_QueryInterface(aDataNode);
nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
if (frame) {
const nsStyleText* text = frame->GetStyleText();
*aReturn = text->mWhiteSpace != NS_STYLE_WHITESPACE_PRE &&
text->mWhiteSpace != NS_STYLE_WHITESPACE_MOZ_PRE_WRAP;
}
else {
// empty inter-tag text node without frame, e.g., in between <table>\n<tr>
*aReturn = PR_TRUE;
}
return NS_OK;
}
NS_IMETHODIMP
inDOMUtils::GetParentForNode(nsIDOMNode* aNode,
PRBool aShowingAnonymousContent,
nsIDOMNode** aParent)
{
// First do the special cases -- document nodes and anonymous content
nsCOMPtr<nsIDOMDocument> doc(do_QueryInterface(aNode));
nsCOMPtr<nsIDOMNode> parent;
if (doc) {
parent = inLayoutUtils::GetContainerFor(doc);
} else if (aShowingAnonymousContent) {
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
nsCOMPtr<nsIContent> bparent;
nsCOMPtr<nsIBindingManager> bindingManager = inLayoutUtils::GetBindingManagerFor(aNode);
if (bindingManager) {
bindingManager->GetInsertionParent(content, getter_AddRefs(bparent));
}
parent = do_QueryInterface(bparent);
}
if (!parent) {
// Ok, just get the normal DOM parent node
aNode->GetParentNode(getter_AddRefs(parent));
}
NS_IF_ADDREF(*aParent = parent);
return NS_OK;
}
NS_IMETHODIMP
inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
nsISupportsArray **_retval)
{
if (!aElement) return NS_ERROR_NULL_POINTER;
*_retval = nsnull;
nsRuleNode* ruleNode = nsnull;
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
mCSSUtils->GetRuleNodeForContent(content, &ruleNode);
if (!ruleNode) {
// This can fail for content nodes that are not in the document or
// if the document they're in doesn't have a presshell. Bail out.
return NS_OK;
}
nsCOMPtr<nsISupportsArray> rules;
NS_NewISupportsArray(getter_AddRefs(rules));
if (!rules) return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIStyleRule> srule;
nsCOMPtr<nsICSSStyleRule> cssRule;
nsCOMPtr<nsIDOMCSSRule> domRule;
for (PRBool isRoot;
mCSSUtils->IsRuleNodeRoot(ruleNode, &isRoot), !isRoot;
mCSSUtils->GetRuleNodeParent(ruleNode, &ruleNode))
{
mCSSUtils->GetRuleNodeRule(ruleNode, getter_AddRefs(srule));
cssRule = do_QueryInterface(srule);
if (cssRule) {
cssRule->GetDOMRule(getter_AddRefs(domRule));
if (domRule)
rules->InsertElementAt(domRule, 0);
}
}
*_retval = rules;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
inDOMUtils::GetRuleLine(nsIDOMCSSStyleRule *aRule, PRUint32 *_retval)
{
*_retval = 0;
if (!aRule)
return NS_OK;
nsCOMPtr<nsICSSStyleRuleDOMWrapper> rule = do_QueryInterface(aRule);
nsCOMPtr<nsICSSStyleRule> cssrule;
rule->GetCSSStyleRule(getter_AddRefs(cssrule));
if (cssrule)
*_retval = cssrule->GetLineNumber();
return NS_OK;
}
NS_IMETHODIMP
inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval)
{
return mCSSUtils->GetBindingURLs(aElement, _retval);
}
NS_IMETHODIMP
inDOMUtils::SetContentState(nsIDOMElement *aElement, PRInt32 aState)
{
if (!aElement)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
if (esm) {
nsCOMPtr<nsIContent> content;
content = do_QueryInterface(aElement);
return esm->SetContentState(content, aState);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
inDOMUtils::GetContentState(nsIDOMElement *aElement, PRInt32* aState)
{
*aState = 0;
if (!aElement)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
if (esm) {
nsCOMPtr<nsIContent> content;
content = do_QueryInterface(aElement);
return esm->GetContentState(content, *aState);
}
return NS_ERROR_FAILURE;
}

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

@ -1,61 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inDOMUtils_h__
#define __inDOMUtils_h__
#include "inIDOMUtils.h"
#include "nsIEventStateManager.h"
#include "nsISupportsArray.h"
#include "nsIInspectorCSSUtils.h"
class inDOMUtils : public inIDOMUtils
{
public:
NS_DECL_ISUPPORTS
NS_DECL_INIDOMUTILS
inDOMUtils();
virtual ~inDOMUtils();
protected:
nsCOMPtr<nsIInspectorCSSUtils> mCSSUtils;
};
#endif // __inDOMUtils_h__

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

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

@ -1,136 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inDOMView_h__
#define __inDOMView_h__
#include "inIDOMView.h"
#include "inIDOMUtils.h"
#include "nsITreeView.h"
#include "nsITreeSelection.h"
#include "nsIDocumentObserver.h"
#include "nsIDOMNode.h"
#include "nsIDOMDocument.h"
#include "nsVoidArray.h"
#include "nsCOMArray.h"
#include "nsStaticAtom.h"
class inDOMViewNode;
class inDOMView : public inIDOMView,
public nsITreeView,
public nsIDocumentObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_INIDOMVIEW
NS_DECL_NSITREEVIEW
inDOMView();
virtual ~inDOMView();
// nsIDocumentObserver
NS_DECL_NSIDOCUMENTOBSERVER
static void InitAtoms();
protected:
static nsIAtom* kAnonymousAtom;
static nsIAtom* kElementNodeAtom;
static nsIAtom* kAttributeNodeAtom;
static nsIAtom* kTextNodeAtom;
static nsIAtom* kCDataSectionNodeAtom;
static nsIAtom* kEntityReferenceNodeAtom;
static nsIAtom* kEntityNodeAtom;
static nsIAtom* kProcessingInstructionNodeAtom;
static nsIAtom* kCommentNodeAtom;
static nsIAtom* kDocumentNodeAtom;
static nsIAtom* kDocumentTypeNodeAtom;
static nsIAtom* kDocumentFragmentNodeAtom;
static nsIAtom* kNotationNodeAtom;
static const nsStaticAtom Atoms_info[];
nsCOMPtr<nsITreeBoxObject> mTree;
nsCOMPtr<nsITreeSelection> mSelection;
nsCOMPtr<inIDOMUtils> mDOMUtils;
PRPackedBool mShowAnonymous;
PRPackedBool mShowSubDocuments;
PRPackedBool mShowWhitespaceNodes;
PRUint32 mWhatToShow;
nsCOMPtr<nsIDOMNode> mRootNode;
nsCOMPtr<nsIDOMDocument> mRootDocument;
nsVoidArray mNodes;
inDOMViewNode* GetNodeAt(PRInt32 aIndex);
PRInt32 GetRowCount();
PRInt32 NodeToRow(inDOMViewNode* aNode);
PRBool RowOutOfBounds(PRInt32 aRow, PRInt32 aCount);
inDOMViewNode* CreateNode(nsIDOMNode* aNode, inDOMViewNode* aParent);
void AppendNode(inDOMViewNode* aNode);
void InsertNode(inDOMViewNode* aNode, PRInt32 aIndex);
void RemoveNode(PRInt32 aIndex);
void ReplaceNode(inDOMViewNode* aNode, PRInt32 aIndex);
void InsertNodes(nsVoidArray& aNodes, PRInt32 aIndex);
void RemoveNodes(PRInt32 aIndex, PRInt32 aCount);
void RemoveAllNodes();
void ExpandNode(PRInt32 aRow);
void CollapseNode(PRInt32 aRow);
nsresult RowToNode(PRInt32 aRow, inDOMViewNode** aNode);
nsresult NodeToRow(nsIDOMNode* aNode, PRInt32* aRow);
void InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter);
void InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore);
void RemoveLink(inDOMViewNode* aNode);
void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode);
nsresult GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult);
nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsCOMArray<nsIDOMNode>& aArray);
nsresult AppendAttrsToArray(nsIDOMNamedNodeMap* aKids, nsCOMArray<nsIDOMNode>& aArray);
nsresult GetFirstDescendantOf(inDOMViewNode* aNode, PRInt32 aRow, PRInt32* aResult);
nsresult GetLastDescendantOf(inDOMViewNode* aNode, PRInt32 aRow, PRInt32* aResult);
nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling);
};
#endif // __inDOMView_h__

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

@ -1,341 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "inDeepTreeWalker.h"
#include "inLayoutUtils.h"
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "nsIDOMNodeFilter.h"
#include "nsIDOMNodeList.h"
#include "nsServiceManagerUtils.h"
#include "inIDOMUtils.h"
/*****************************************************************************
* This implementation does not currently operaate according to the W3C spec.
* So far, only parentNode() and nextNode() are implemented, and are not
* interoperable.
*****************************************************************************/
////////////////////////////////////////////////////
struct DeepTreeStackItem
{
DeepTreeStackItem() { MOZ_COUNT_CTOR(DeepTreeStackItem); }
~DeepTreeStackItem() { MOZ_COUNT_DTOR(DeepTreeStackItem); }
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIDOMNodeList> kids;
PRUint32 lastIndex;
};
////////////////////////////////////////////////////
inDeepTreeWalker::inDeepTreeWalker()
: mShowAnonymousContent(PR_FALSE),
mShowSubDocuments(PR_FALSE),
mWhatToShow(nsIDOMNodeFilter::SHOW_ALL)
{
}
inDeepTreeWalker::~inDeepTreeWalker()
{
for (PRInt32 i = mStack.Count() - 1; i >= 0; --i) {
delete NS_STATIC_CAST(DeepTreeStackItem*, mStack[i]);
}
}
NS_IMPL_ISUPPORTS1(inDeepTreeWalker, inIDeepTreeWalker)
////////////////////////////////////////////////////
// inIDeepTreeWalker
NS_IMETHODIMP
inDeepTreeWalker::GetShowAnonymousContent(PRBool *aShowAnonymousContent)
{
*aShowAnonymousContent = mShowAnonymousContent;
return NS_OK;
}
NS_IMETHODIMP
inDeepTreeWalker::SetShowAnonymousContent(PRBool aShowAnonymousContent)
{
mShowAnonymousContent = aShowAnonymousContent;
return NS_OK;
}
NS_IMETHODIMP
inDeepTreeWalker::GetShowSubDocuments(PRBool *aShowSubDocuments)
{
*aShowSubDocuments = mShowSubDocuments;
return NS_OK;
}
NS_IMETHODIMP
inDeepTreeWalker::SetShowSubDocuments(PRBool aShowSubDocuments)
{
mShowSubDocuments = aShowSubDocuments;
return NS_OK;
}
NS_IMETHODIMP
inDeepTreeWalker::Init(nsIDOMNode* aRoot, PRUint32 aWhatToShow)
{
mRoot = aRoot;
mWhatToShow = aWhatToShow;
PushNode(aRoot);
return NS_OK;
}
////////////////////////////////////////////////////
// nsIDOMTreeWalker
NS_IMETHODIMP
inDeepTreeWalker::GetRoot(nsIDOMNode** aRoot)
{
*aRoot = mRoot;
NS_IF_ADDREF(*aRoot);
return NS_OK;
}
NS_IMETHODIMP
inDeepTreeWalker::GetWhatToShow(PRUint32* aWhatToShow)
{
*aWhatToShow = mWhatToShow;
return NS_OK;
}
NS_IMETHODIMP
inDeepTreeWalker::GetFilter(nsIDOMNodeFilter** aFilter)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::GetExpandEntityReferences(PRBool* aExpandEntityReferences)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::GetCurrentNode(nsIDOMNode** aCurrentNode)
{
*aCurrentNode = mCurrentNode;
NS_IF_ADDREF(*aCurrentNode);
return NS_OK;
}
NS_IMETHODIMP
inDeepTreeWalker::SetCurrentNode(nsIDOMNode* aCurrentNode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::ParentNode(nsIDOMNode** _retval)
{
*_retval = nsnull;
if (!mCurrentNode) return NS_OK;
if (!mDOMUtils) {
mDOMUtils = do_GetService("@mozilla.org/inspector/dom-utils;1");
if (!mDOMUtils) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
nsresult rv = mDOMUtils->GetParentForNode(mCurrentNode, mShowAnonymousContent,
_retval);
mCurrentNode = *_retval;
return rv;
}
NS_IMETHODIMP
inDeepTreeWalker::FirstChild(nsIDOMNode **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::LastChild(nsIDOMNode **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::PreviousSibling(nsIDOMNode **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::NextSibling(nsIDOMNode **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::PreviousNode(nsIDOMNode **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inDeepTreeWalker::NextNode(nsIDOMNode **_retval)
{
if (!mCurrentNode) return NS_OK;
nsCOMPtr<nsIDOMNode> next;
while (1) {
DeepTreeStackItem* top = (DeepTreeStackItem*)mStack.ElementAt(mStack.Count()-1);
nsCOMPtr<nsIDOMNodeList> kids = top->kids;
PRUint32 childCount;
kids->GetLength(&childCount);
if (top->lastIndex == childCount) {
mStack.RemoveElementAt(mStack.Count()-1);
delete top;
if (mStack.Count() == 0) {
mCurrentNode = nsnull;
break;
}
} else {
kids->Item(top->lastIndex++, getter_AddRefs(next));
PushNode(next);
break;
}
}
*_retval = next;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
void
inDeepTreeWalker::PushNode(nsIDOMNode* aNode)
{
mCurrentNode = aNode;
if (!aNode) return;
DeepTreeStackItem* item = new DeepTreeStackItem();
item->node = aNode;
nsCOMPtr<nsIDOMNodeList> kids;
if (mShowSubDocuments) {
nsCOMPtr<nsIDOMDocument> domdoc = inLayoutUtils::GetSubDocumentFor(aNode);
if (domdoc) {
domdoc->GetChildNodes(getter_AddRefs(kids));
}
}
if (!kids) {
if (mShowAnonymousContent) {
nsCOMPtr<nsIBindingManager> bindingManager = inLayoutUtils::GetBindingManagerFor(aNode);
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (bindingManager) {
bindingManager->GetAnonymousNodesFor(content, getter_AddRefs(kids));
if (!kids)
bindingManager->GetContentListFor(content, getter_AddRefs(kids));
} else {
aNode->GetChildNodes(getter_AddRefs(kids));
}
} else
aNode->GetChildNodes(getter_AddRefs(kids));
}
item->kids = kids;
item->lastIndex = 0;
mStack.AppendElement((void*)item);
}
/*
// This NextNode implementation does not require the use of stacks,
// as does the one above. However, it does not handle anonymous
// content and sub-documents.
NS_IMETHODIMP
inDeepTreeWalker::NextNode(nsIDOMNode **_retval)
{
if (!mCurrentNode) return NS_OK;
// walk down the tree first
nsCOMPtr<nsIDOMNode> next;
mCurrentNode->GetFirstChild(getter_AddRefs(next));
if (!next) {
mCurrentNode->GetNextSibling(getter_AddRefs(next));
if (!next) {
// we've hit the end, so walk back up the tree until another
// downward opening is found, or the top of the tree
nsCOMPtr<nsIDOMNode> subject = mCurrentNode;
nsCOMPtr<nsIDOMNode> parent;
while (1) {
subject->GetParentNode(getter_AddRefs(parent));
if (!parent) // hit the top of the tree
break;
parent->GetNextSibling(getter_AddRefs(subject));
if (subject) { // found a downward opening
next = subject;
break;
} else // walk up another level
subject = parent;
}
}
}
mCurrentNode = next;
*_retval = next;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
char* getURL(nsIDOMDocument* aDoc)
{
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
nsIURI *uri = doc->GetDocumentURI();
char* s;
uri->GetSpec(&s);
return s;
}
*/

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

@ -1,72 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inDeepTreeWalker_h___
#define __inDeepTreeWalker_h___
#include "inIDeepTreeWalker.h"
#include "nsCOMPtr.h"
#include "nsIDOMNode.h"
#include "nsVoidArray.h"
class inIDOMUtils;
class inDeepTreeWalker : public inIDeepTreeWalker
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMTREEWALKER
NS_DECL_INIDEEPTREEWALKER
inDeepTreeWalker();
virtual ~inDeepTreeWalker();
protected:
void PushNode(nsIDOMNode* aNode);
PRBool mShowAnonymousContent;
PRBool mShowSubDocuments;
nsCOMPtr<nsIDOMNode> mRoot;
nsCOMPtr<nsIDOMNode> mCurrentNode;
PRUint32 mWhatToShow;
nsAutoVoidArray mStack;
nsCOMPtr<inIDOMUtils> mDOMUtils;
};
#endif // __inDeepTreeWalker_h___

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

@ -1,644 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "inFileSearch.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsReadableUtils.h"
///////////////////////////////////////////////////////////////////////////////
inFileSearch::inFileSearch()
: mSearchLoop(nsnull),
mBasePath(nsnull),
mTextCriteria(nsnull),
mFilenameCriteria(nsnull),
mDirsSearched(0),
mFilenameCriteriaCount(0),
mResultCount(0),
mIsActive(PR_FALSE),
mHoldResults(PR_FALSE),
mReturnRelativePaths(PR_FALSE),
mSearchRecursive(PR_FALSE)
{
}
inFileSearch::~inFileSearch()
{
delete mSearchLoop;
delete mTextCriteria;
}
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 {
mObserver->OnSearchError(this, NS_LITERAL_STRING("No search path has been provided"));
KillSearch(inISearchObserver::ERROR);
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SearchStop()
{
KillSearch(inISearchObserver::INTERRUPTED);
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::SearchStep(PRBool* _retval)
{
nsCOMPtr<nsIFile> nextDir;
PRBool more = GetNextSubDirectory(getter_AddRefs(nextDir));
if (more) {
SearchDirectory(nextDir, PR_FALSE);
} else {
KillSearch(inISearchObserver::SUCCESS);
*_retval = PR_TRUE;
}
return NS_OK;
}
NS_IMETHODIMP
inFileSearch::GetStringResultAt(PRInt32 aIndex, nsAString& _retval)
{
nsCOMPtr<nsIFile> file;
_retval.Truncate();
if (mHoldResults) {
if (aIndex < mResults.Count()) {
file = mResults[aIndex];
}
} else if (aIndex == mResultCount-1 && mLastResult) {
// get the path of the last result as an nsAutoString
file = mLastResult;
}
if (file) {
mLastResult->GetPath(_retval);
if (mReturnRelativePaths)
MakePathRelative(_retval);
} 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 = ToNewUnicode(*mBasePath);
} 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;
PRInt32 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 = ToNewUnicode(*mTextCriteria);
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) {
if (aIndex < mResults.Count()) {
NS_IF_ADDREF(*_retval = mResults[aIndex]);
}
} 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()
{
mResults.Clear();
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.AppendObject(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.Clear();
return NS_OK;
}
PRBool
inFileSearch::GetNextSubDirectory(nsIFile** aDir)
{
// get the enumerator on top of the stack
nsCOMPtr<nsISimpleEnumerator> nextDirs;
while (PR_TRUE) {
PRInt32 count = mDirStack.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
nextDirs = mDirStack[count-1];
// get the next directory from the enumerator
*aDir = GetNextDirectory(nextDirs).get();
if (*aDir) {
// this enumerator is ready to rock, so let's move on
return PR_TRUE;
}
// enumerator is done, so pop it off the stack
mDirStack.RemoveObjectAt(count-1);
}
return PR_TRUE;
}
nsresult
inFileSearch::PushSubDirectoryOnStack(nsIFile* aDir)
{
nsCOMPtr<nsISimpleEnumerator> entries;
aDir->GetDirectoryEntries(getter_AddRefs(entries));
mDirStack.AppendObject(entries);
return NS_OK;
}
already_AddRefed<nsIFile>
inFileSearch::GetNextDirectory(nsISimpleEnumerator* aEnum)
{
nsCOMPtr<nsIFile> file;
nsCOMPtr<nsISupports> supports;
PRBool isDir;
PRBool hasMoreElements;
while (PR_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)
{
nsAutoString fileName;
aFile->GetLeafName(fileName);
PRUnichar* fileNameUnicode = ToNewUnicode(fileName);
PRBool match;
for (PRUint32 i = 0; i < mFilenameCriteriaCount; ++i) {
match = MatchPattern(mFilenameCriteria[i], fileNameUnicode);
if (match) return PR_TRUE;
}
// XXX are we leaking fileNameUnicode?
return PR_FALSE;
}
PRBool
inFileSearch::MatchPattern(PRUnichar* aPattern, PRUnichar* aString)
{
PRInt32 index = 0;
PRBool matching = PR_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 PR_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 PR_TRUE;
} else if (*stringPtr == 0)
return PR_FALSE;
++stringPtr;
}
}
///////////////////////////////////////////////////////////////////////////////
// URL fixing
nsresult
inFileSearch::MakePathRelative(nsAString& aPath)
{
// get an nsAutoString version of the search path
nsAutoString searchPath;
mSearchPath->GetPath(searchPath);
nsAutoString result;
PRUint32 len = searchPath.Length();
if (Substring(aPath, 0, len) == searchPath) {
result = Substring(aPath, len+1, aPath.Length() - len - 1);
result.ReplaceChar('\\', '/');
}
aPath = 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;
}

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

@ -1,102 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inFileSearch_h__
#define __inFileSearch_h__
#include "inIFileSearch.h"
#include "nsString.h"
#include "nsISimpleEnumerator.h"
#include "nsCOMArray.h"
#include "inISearchObserver.h"
#include "nsIFile.h"
#include "inSearchLoop.h"
class inFileSearch : public inIFileSearch
{
public:
NS_DECL_ISUPPORTS
NS_DECL_INISEARCHPROCESS
NS_DECL_INIFILESEARCH
inFileSearch();
virtual ~inFileSearch();
protected:
nsCOMPtr<inISearchObserver> mObserver;
nsCOMArray<nsIFile> mResults;
nsCOMArray<nsISimpleEnumerator> mDirStack;
nsCOMPtr<nsIFile> mLastResult;
nsCOMPtr<nsIFile> mSearchPath;
inSearchLoop* mSearchLoop;
nsAutoString* mBasePath;
nsAutoString* mTextCriteria;
PRUnichar** mFilenameCriteria;
PRUint32 mDirsSearched;
PRUint32 mFilenameCriteriaCount;
PRInt32 mResultCount;
PRBool mIsActive;
PRBool mHoldResults;
PRBool mReturnRelativePaths;
PRBool mSearchRecursive;
// 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);
already_AddRefed<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(nsAString& aPath);
nsresult CountDirectoryDepth(nsIFile* aDir, PRUint32* aDepth);
};
#endif // __inFileSearch_h__

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

@ -1,260 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
* Christopher A. Aillon <christopher@aillon.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "inFlasher.h"
#include "inLayoutUtils.h"
#include "nsIServiceManager.h"
#include "nsIViewManager.h"
#include "nsIDeviceContext.h"
#include "nsIWidget.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsReadableUtils.h"
#include "prprf.h"
static NS_DEFINE_CID(kInspectorCSSUtilsCID, NS_INSPECTORCSSUTILS_CID);
///////////////////////////////////////////////////////////////////////////////
inFlasher::inFlasher() :
mColor(NS_RGB(0,0,0)),
mThickness(0),
mInvert(PR_FALSE)
{
mCSSUtils = do_GetService(kInspectorCSSUtilsCID);
}
inFlasher::~inFlasher()
{
}
NS_IMPL_ISUPPORTS1(inFlasher, inIFlasher)
///////////////////////////////////////////////////////////////////////////////
// inIFlasher
NS_IMETHODIMP
inFlasher::GetColor(nsAString& aColor)
{
// Copied from nsGenericHTMLElement::ColorToString()
char buf[10];
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
NS_GET_R(mColor), NS_GET_G(mColor), NS_GET_B(mColor));
CopyASCIItoUTF16(buf, aColor);
return NS_OK;
}
NS_IMETHODIMP
inFlasher::SetColor(const nsAString& aColor)
{
NS_ENSURE_FALSE(aColor.IsEmpty(), NS_ERROR_ILLEGAL_VALUE);
nsAutoString colorStr;
colorStr.Assign(aColor);
if (colorStr.CharAt(0) != '#') {
if (NS_ColorNameToRGB(colorStr, &mColor)) {
return NS_OK;
}
}
else {
colorStr.Cut(0, 1);
if (NS_HexToRGB(colorStr, &mColor)) {
return NS_OK;
}
}
return NS_ERROR_ILLEGAL_VALUE;
}
NS_IMETHODIMP
inFlasher::GetThickness(PRUint16 *aThickness)
{
NS_PRECONDITION(aThickness, "Null pointer");
*aThickness = mThickness;
return NS_OK;
}
NS_IMETHODIMP
inFlasher::SetThickness(PRUint16 aThickness)
{
mThickness = aThickness;
return NS_OK;
}
NS_IMETHODIMP
inFlasher::GetInvert(PRBool *aInvert)
{
NS_PRECONDITION(aInvert, "Null pointer");
*aInvert = mInvert;
return NS_OK;
}
NS_IMETHODIMP
inFlasher::SetInvert(PRBool aInvert)
{
mInvert = aInvert;
return NS_OK;
}
NS_IMETHODIMP
inFlasher::RepaintElement(nsIDOMElement* aElement)
{
nsCOMPtr<nsIDOMWindowInternal> window = inLayoutUtils::GetWindowFor(aElement);
if (!window) return NS_OK;
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
if (!presShell) return NS_OK;
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell);
if (!frame) return NS_OK;
nsIFrame* parentWithView = frame->GetAncestorWithViewExternal();
if (parentWithView) {
nsIView* view = parentWithView->GetViewExternal();
if (view) {
nsIViewManager* viewManager = view->GetViewManager();
if (viewManager) {
nsRect rect = parentWithView->GetRect();
viewManager->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC);
}
}
}
return NS_OK;
}
NS_IMETHODIMP
inFlasher::DrawElementOutline(nsIDOMElement* aElement)
{
nsCOMPtr<nsIDOMWindowInternal> window = inLayoutUtils::GetWindowFor(aElement);
if (!window) return NS_OK;
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
if (!presShell) return NS_OK;
nsPresContext *presContext = presShell->GetPresContext();
float p2t = presContext->PixelsToTwips();
PRBool isFirstFrame = PR_TRUE;
nsCOMPtr<nsIRenderingContext> rcontext;
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell);
while (frame) {
if (!rcontext) {
presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext));
}
// get view bounds in case this frame is being scrolled
nsRect rect = frame->GetRect();
nsPoint origin = inLayoutUtils::GetClientOrigin(frame);
rect.MoveTo(origin);
mCSSUtils->AdjustRectForMargins(frame, rect);
if (mInvert) {
rcontext->InvertRect(rect);
}
frame = frame->GetNextContinuation();
PRBool isLastFrame = (frame == nsnull);
DrawOutline(rect.x, rect.y, rect.width, rect.height, p2t, rcontext,
isFirstFrame, isLastFrame);
isFirstFrame = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
inFlasher::ScrollElementIntoView(nsIDOMElement *aElement)
{
NS_PRECONDITION(aElement, "Dude, where's my arg?!");
nsCOMPtr<nsIDOMWindowInternal> window = inLayoutUtils::GetWindowFor(aElement);
if (!window) {
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
if (!presShell) {
return NS_OK;
}
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell);
if (!frame) {
return NS_OK;
}
presShell->ScrollFrameIntoView(frame,
NS_PRESSHELL_SCROLL_ANYWHERE /* VPercent */,
NS_PRESSHELL_SCROLL_ANYWHERE /* HPercent */);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// inFlasher
void
inFlasher::DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aP2T, nsIRenderingContext* aRenderContext,
PRBool aDrawBegin, PRBool aDrawEnd)
{
aRenderContext->SetColor(mColor);
DrawLine(aX, aY, aWidth, DIR_HORIZONTAL, BOUND_OUTER, aP2T, aRenderContext);
if (aDrawBegin) {
DrawLine(aX, aY, aHeight, DIR_VERTICAL, BOUND_OUTER, aP2T, aRenderContext);
}
DrawLine(aX, aY+aHeight, aWidth, DIR_HORIZONTAL, BOUND_INNER, aP2T, aRenderContext);
if (aDrawEnd) {
DrawLine(aX+aWidth, aY, aHeight, DIR_VERTICAL, BOUND_INNER, aP2T, aRenderContext);
}
}
void
inFlasher::DrawLine(nscoord aX, nscoord aY, nscoord aLength,
PRBool aDir, PRBool aBounds, float aP2T,
nsIRenderingContext* aRenderContext)
{
nscoord thickTwips = NSIntPixelsToTwips(mThickness, aP2T);
if (aDir) { // horizontal
aRenderContext->FillRect(aX, aY+(aBounds?0:-thickTwips), aLength, thickTwips);
} else { // vertical
aRenderContext->FillRect(aX+(aBounds?0:-thickTwips), aY, thickTwips, aLength);
}
}

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

@ -1,80 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inFlasher_h__
#define __inFlasher_h__
#include "inIFlasher.h"
#include "nsIInspectorCSSUtils.h"
#include "nsIDOMElement.h"
#include "nsIRenderingContext.h"
#include "nsCOMPtr.h"
#define BOUND_INNER 0
#define BOUND_OUTER 1
#define DIR_VERTICAL 0
#define DIR_HORIZONTAL 1
class inFlasher : public inIFlasher
{
public:
NS_DECL_ISUPPORTS
NS_DECL_INIFLASHER
inFlasher();
virtual ~inFlasher();
protected:
void DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aP2T, nsIRenderingContext* aRenderContext,
PRBool aDrawBegin, PRBool aDrawEnd);
void DrawLine(nscoord aX, nscoord aY, nscoord aLength,
PRBool aDir, PRBool aBounds, float aP2T,
nsIRenderingContext* aRenderContext);
nsCOMPtr<nsIInspectorCSSUtils> mCSSUtils;
nscolor mColor;
PRUint16 mThickness;
PRPackedBool mInvert;
};
#endif // __inFlasher_h__

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

@ -1,190 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "inLayoutUtils.h"
#include "nsIDOMDocumentView.h"
#include "nsIDOMAbstractView.h"
#include "nsIDOMNodeList.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIContentViewer.h"
#include "nsPIDOMWindow.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIWebNavigation.h"
#include "nsIPresShell.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsPresContext.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
///////////////////////////////////////////////////////////////////////////////
nsIDOMWindowInternal*
inLayoutUtils::GetWindowFor(nsIDOMNode* aNode)
{
nsCOMPtr<nsIDOMDocument> doc1;
aNode->GetOwnerDocument(getter_AddRefs(doc1));
return GetWindowFor(doc1.get());
}
nsIDOMWindowInternal*
inLayoutUtils::GetWindowFor(nsIDOMDocument* aDoc)
{
nsCOMPtr<nsIDOMDocumentView> doc = do_QueryInterface(aDoc);
if (!doc) return nsnull;
nsCOMPtr<nsIDOMAbstractView> view;
doc->GetDefaultView(getter_AddRefs(view));
if (!view) return nsnull;
nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(view);
return window;
}
nsIPresShell*
inLayoutUtils::GetPresShellFor(nsISupports* aThing)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aThing);
nsCOMPtr<nsIPresShell> presShell;
window->GetDocShell()->GetPresShell(getter_AddRefs(presShell));
return presShell;
}
/*static*/
nsIFrame*
inLayoutUtils::GetFrameFor(nsIDOMElement* aElement, nsIPresShell* aShell)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
return aShell->GetPrimaryFrameFor(content);
}
already_AddRefed<nsIRenderingContext>
inLayoutUtils::GetRenderingContextFor(nsIPresShell* aShell)
{
nsCOMPtr<nsIWidget> widget;
aShell->GetViewManager()->GetWidget(getter_AddRefs(widget));
return widget->GetRenderingContext(); // AddRefs
}
nsIEventStateManager*
inLayoutUtils::GetEventStateManagerFor(nsIDOMElement *aElement)
{
NS_PRECONDITION(aElement, "Passing in a null element is bad");
nsCOMPtr<nsIDOMDocument> domDoc;
aElement->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if (!doc) {
NS_WARNING("Could not get an nsIDocument!");
return nsnull;
}
nsIPresShell *shell = doc->GetShellAt(0);
NS_ASSERTION(shell, "No pres shell");
return shell->GetPresContext()->EventStateManager();
}
nsPoint
inLayoutUtils::GetClientOrigin(nsIFrame* aFrame)
{
nsPoint result(0,0);
nsIView* view;
aFrame->GetOffsetFromView(result, &view);
nsIView* rootView = nsnull;
if (view) {
nsIViewManager* viewManager = view->GetViewManager();
NS_ASSERTION(viewManager, "View must have a viewmanager");
viewManager->GetRootView(rootView);
}
while (view) {
result += view->GetPosition();
if (view == rootView) {
break;
}
view = view->GetParent();
}
return result;
}
nsIBindingManager*
inLayoutUtils::GetBindingManagerFor(nsIDOMNode* aNode)
{
nsCOMPtr<nsIDOMDocument> domdoc;
aNode->GetOwnerDocument(getter_AddRefs(domdoc));
if (domdoc) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
return doc->BindingManager();
}
return nsnull;
}
nsIDOMDocument*
inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content) {
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (doc) {
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc->GetSubDocumentFor(content)));
return domdoc;
}
}
return nsnull;
}
nsIDOMNode*
inLayoutUtils::GetContainerFor(nsIDOMDocument* aDoc)
{
nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDoc));
nsCOMPtr<nsIDOMWindowInternal> win = inLayoutUtils::GetWindowFor(aDoc);
nsCOMPtr<nsIDOMElement> elem;
win->GetFrameElement(getter_AddRefs(elem));
return elem;
}

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

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inLayoutUtils_h__
#define __inLayoutUtils_h__
#include "nsCOMPtr.h"
#include "nsIDOMElement.h"
#include "nsIDOMWindowInternal.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsIRenderingContext.h"
#include "nsIEventStateManager.h"
#include "nsIDOMDocument.h"
#include "nsIBindingManager.h"
class inLayoutUtils
{
public:
static nsIDOMWindowInternal* GetWindowFor(nsIDOMNode* aNode);
static nsIDOMWindowInternal* GetWindowFor(nsIDOMDocument* aDoc);
static nsIPresShell* GetPresShellFor(nsISupports* aThing);
static nsIFrame* GetFrameFor(nsIDOMElement* aElement, nsIPresShell* aShell);
static already_AddRefed<nsIRenderingContext> GetRenderingContextFor(nsIPresShell* aShell);
static nsIEventStateManager* GetEventStateManagerFor(nsIDOMElement *aElement);
static nsIBindingManager* GetBindingManagerFor(nsIDOMNode* aNode);
static nsIDOMDocument* GetSubDocumentFor(nsIDOMNode* aNode);
static nsIDOMNode* GetContainerFor(nsIDOMDocument* aDoc);
/**
* This function returns the offset of a frame with respect to the
* root view of the aPresContext's viewmanager (for use by
* inFlasher::DrawElementOutline and the like)
*
* @param aFrame the frame whose offset we want
* @param aPresContext the presentation context
* @return the offset
*/
static nsPoint GetClientOrigin(nsIFrame* aFrame);
};
#endif // __inLayoutUtils_h__

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

@ -1,91 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "inSearchLoop.h"
#include "nsITimer.h"
#include "nsIServiceManager.h"
///////////////////////////////////////////////////////////////////////////////
inSearchLoop::inSearchLoop(inISearchProcess* aSearchProcess)
{
mSearchProcess = aSearchProcess;
nsresult rv;
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
}
inSearchLoop::~inSearchLoop()
{
}
///////////////////////////////////////////////////////////////////////////////
// inSearchLoop
nsresult
inSearchLoop::Start()
{
mTimer->InitWithFuncCallback(inSearchLoop::TimerCallback, (void*)this, 0, nsITimer::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();
}

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

@ -1,61 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __inSearchLoop_h__
#define __inSearchLoop_h__
#include "nsCOMPtr.h"
#include "nsITimer.h"
#include "inISearchProcess.h"
class inSearchLoop
{
public:
inSearchLoop(inISearchProcess* aSearchProcess);
virtual ~inSearchLoop();
nsresult Start();
nsresult Step();
nsresult Stop();
static void TimerCallback(nsITimer *aTimer, void *aClosure);
protected:
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<inISearchProcess> mSearchProcess;
};
#endif