diff --git a/mozilla/layout/inspector/public/Makefile.in b/mozilla/layout/inspector/public/Makefile.in index 7bbb1ad3578..813e994362f 100644 --- a/mozilla/layout/inspector/public/Makefile.in +++ b/mozilla/layout/inspector/public/Makefile.in @@ -30,8 +30,7 @@ include $(DEPTH)/config/autoconf.mk MODULE=inspector XPIDL_MODULE=inspector -XPIDLSRCS = inIDOMDataSource.idl \ - inIDOMRDFResource.idl \ +XPIDLSRCS = inIDOMView.idl \ inIDeepTreeWalker.idl \ inIFlasher.idl \ inISearchProcess.idl \ diff --git a/mozilla/layout/inspector/public/inIDOMView.idl b/mozilla/layout/inspector/public/inIDOMView.idl new file mode 100644 index 00000000000..71b33c1c622 --- /dev/null +++ b/mozilla/layout/inspector/public/inIDOMView.idl @@ -0,0 +1,60 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Hewitt (original author) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIDOMNode; + +[scriptable, uuid(3EB4C760-DFFD-4983-94A8-18BCB99100E4)] +interface inIDOMView : nsISupports +{ + attribute nsIDOMNode rootNode; + + attribute boolean showAnonymousContent; + attribute boolean showSubDocuments; + + nsIDOMNode getNodeFromRowIndex(in long rowIndex); + long getRowIndexFromNode(in nsIDOMNode node); + + void addFilterByType(in unsigned short type, in boolean exclusive); + void removeFilterByType(in unsigned short type); + boolean isFiltered(in unsigned short type); + + + void rebuild(); +}; diff --git a/mozilla/layout/inspector/public/inIFlasher.idl b/mozilla/layout/inspector/public/inIFlasher.idl index 23d2076fac6..a02091aaf43 100644 --- a/mozilla/layout/inspector/public/inIFlasher.idl +++ b/mozilla/layout/inspector/public/inIFlasher.idl @@ -45,7 +45,7 @@ interface nsIDOMWindowInternal; [scriptable, uuid(7B4A099F-6F6E-4565-977B-FB622ADBFF49)] interface inIFlasher : nsISupports { - void drawElementOutline(in nsIDOMElement aElement, in wstring aColor, in long aThickness); + void drawElementOutline(in nsIDOMElement aElement, in wstring aColor, in long aThickness, in boolean aInvert); void repaintElement(in nsIDOMElement aElement); }; diff --git a/mozilla/layout/inspector/public/inISearchObserver.idl b/mozilla/layout/inspector/public/inISearchObserver.idl index 5414706f63d..73ba9d67d33 100644 --- a/mozilla/layout/inspector/public/inISearchObserver.idl +++ b/mozilla/layout/inspector/public/inISearchObserver.idl @@ -51,5 +51,5 @@ interface inISearchObserver : nsISupports void onSearchStart(in inISearchProcess aModule); void onSearchResult(in inISearchProcess aModule); void onSearchEnd(in inISearchProcess aModule, in short aResult); - void onSearchError(in inISearchProcess aModule, in wstring aMessage); + void onSearchError(in inISearchProcess aModule, in AString aMessage); }; diff --git a/mozilla/layout/inspector/public/inISearchProcess.idl b/mozilla/layout/inspector/public/inISearchProcess.idl index 2e03e0798c4..576f69ed32a 100644 --- a/mozilla/layout/inspector/public/inISearchProcess.idl +++ b/mozilla/layout/inspector/public/inISearchProcess.idl @@ -36,8 +36,10 @@ * * ***** END LICENSE BLOCK ***** */ + #include "nsISupports.idl" +interface nsAString; interface inISearchObserver; interface nsISupportsArray; @@ -74,7 +76,7 @@ interface inISearchProcess : nsISupports // methods for getting results of specific types - wstring getStringResultAt(in long aIndex); + AString getStringResultAt(in long aIndex); long getIntResultAt(in long aIndex); diff --git a/mozilla/layout/inspector/src/Makefile.in b/mozilla/layout/inspector/src/Makefile.in index 34879f32b45..04c0b888226 100644 --- a/mozilla/layout/inspector/src/Makefile.in +++ b/mozilla/layout/inspector/src/Makefile.in @@ -35,6 +35,7 @@ REQUIRES = xpcom \ rdfutil \ gfx \ layout \ + layout_xul \ content \ widget \ locale \ @@ -51,15 +52,14 @@ REQUIRES = xpcom \ $(NULL) CPPSRCS= \ - inDOMDataSource.cpp \ - inDOMRDFResource.cpp \ + inDOMView.cpp \ inDeepTreeWalker.cpp \ - inFlasher.cpp \ - inSearchLoop.cpp \ - inCSSValueSearch.cpp \ - inFileSearch.cpp \ - inDOMUtils.cpp \ - inLayoutUtils.cpp \ + inFlasher.cpp \ + inSearchLoop.cpp \ + inCSSValueSearch.cpp \ + inFileSearch.cpp \ + inDOMUtils.cpp \ + inLayoutUtils.cpp \ inBitmap.cpp \ inBitmapDepot.cpp \ inBitmapDecoder.cpp \ diff --git a/mozilla/layout/inspector/src/inCSSValueSearch.cpp b/mozilla/layout/inspector/src/inCSSValueSearch.cpp index 36f27364dd9..8c253300377 100644 --- a/mozilla/layout/inspector/src/inCSSValueSearch.cpp +++ b/mozilla/layout/inspector/src/inCSSValueSearch.cpp @@ -143,13 +143,13 @@ inCSSValueSearch::SearchStep(PRBool* _retval) NS_IMETHODIMP -inCSSValueSearch::GetStringResultAt(PRInt32 aIndex, PRUnichar **_retval) +inCSSValueSearch::GetStringResultAt(PRInt32 aIndex, nsAString& _retval) { if (mHoldResults) { nsAutoString* result = (nsAutoString*)mResults->ElementAt(aIndex); - *_retval = ToNewUnicode(*result); + _retval = *result; } else if (aIndex == mResultCount-1) { - *_retval = ToNewUnicode(*mLastResult); + _retval = *mLastResult; } else { return NS_ERROR_FAILURE; } @@ -329,7 +329,7 @@ inCSSValueSearch::SearchStyleRule(nsIStyleRule* aStyleRule) nsresult inCSSValueSearch::SearchStyleValue(nsICSSDeclaration* aDec, nsCSSProperty aProp) { - nsCString cstring = nsCSSProps::GetStringValue(aProp); + const nsCString& cstring = nsCSSProps::GetStringValue(aProp); nsCSSValue value; aDec->GetValue(aProp, value); diff --git a/mozilla/layout/inspector/src/inDOMUtils.cpp b/mozilla/layout/inspector/src/inDOMUtils.cpp index db708394ba9..640f001fe59 100644 --- a/mozilla/layout/inspector/src/inDOMUtils.cpp +++ b/mozilla/layout/inspector/src/inDOMUtils.cpp @@ -40,19 +40,12 @@ #include "inDOMUtils.h" #include "inLayoutUtils.h" -#include "nsCOMPtr.h" #include "nsString.h" #include "nsIDOMElement.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" -#include "nsIComponentManager.h" -#include "nsISupportsArray.h" #include "nsEnumeratorUtils.h" -#include "nsIAtom.h" -#include "nsIContent.h" -#include "nsIBindingManager.h" #include "nsIXBLBinding.h" - #include "nsIStyleContext.h" #include "nsRuleNode.h" #include "nsIStyleRule.h" @@ -90,7 +83,7 @@ inDOMUtils::GetStyleRules(nsIDOMElement *aElement, nsISupportsArray **_retval) nsCOMPtr content; content = do_QueryInterface(aElement); - nsIFrame* frame; + nsIFrame* frame = nsnull; nsCOMPtr styleContext; nsresult rv = shell->GetPrimaryFrameFor(content, &frame); if (NS_FAILED(rv) || !frame) return rv; @@ -99,7 +92,7 @@ inDOMUtils::GetStyleRules(nsIDOMElement *aElement, nsISupportsArray **_retval) // create a resource for all the style rules from the // context and add them to aArcs - nsRuleNode* ruleNode; + nsRuleNode* ruleNode = nsnull; styleContext->GetRuleNode(&ruleNode); nsCOMPtr srule; @@ -110,7 +103,7 @@ inDOMUtils::GetStyleRules(nsIDOMElement *aElement, nsISupportsArray **_retval) ruleNode = ruleNode->GetParent(); // don't be adding that there root node - if (ruleNode->IsRoot()) + if (!ruleNode || ruleNode->IsRoot()) break; } @@ -186,28 +179,36 @@ inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsISimpleEnumerator **_retva NS_IMETHODIMP inDOMUtils::SetContentState(nsIDOMElement *aElement, PRInt32 aState) { + if (!aElement) + return NS_ERROR_NULL_POINTER; + nsCOMPtr esm = inLayoutUtils::GetEventStateManagerFor(aElement); if (esm) { nsCOMPtr content; content = do_QueryInterface(aElement); - - esm->SetContentState(content, aState); + + return esm->SetContentState(content, aState); } - return NS_OK; + return NS_ERROR_FAILURE; } NS_IMETHODIMP inDOMUtils::GetContentState(nsIDOMElement *aElement, PRInt32* aState) { + *aState = NS_EVENT_STATE_UNSPECIFIED; + + if (!aElement) + return NS_ERROR_NULL_POINTER; + nsCOMPtr esm = inLayoutUtils::GetEventStateManagerFor(aElement); if (esm) { nsCOMPtr content; content = do_QueryInterface(aElement); - - esm->GetContentState(content, *aState); + + return esm->GetContentState(content, *aState); } - return NS_OK; + return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/inspector/src/inDOMView.cpp b/mozilla/layout/inspector/src/inDOMView.cpp index 2c4681f3844..c40d0ab8095 100644 --- a/mozilla/layout/inspector/src/inDOMView.cpp +++ b/mozilla/layout/inspector/src/inDOMView.cpp @@ -77,10 +77,10 @@ public: inDOMViewNode::inDOMViewNode(nsIDOMNode* aNode) : node(aNode), - level(0), parent(nsnull), next(nsnull), previous(nsnull), + level(0), isOpen(PR_FALSE), isContainer(PR_FALSE), hasAnonymous(PR_FALSE), @@ -110,8 +110,8 @@ nsIAtom* inDOMView::kDocumentFragmentNodeAtom = nsnull; nsIAtom* inDOMView::kNotationNodeAtom = nsnull; inDOMView::inDOMView() : - mShowSubDocuments(PR_FALSE), mShowAnonymous(PR_FALSE), + mShowSubDocuments(PR_FALSE), mFilters(65535) // show all node types by default { @@ -849,7 +849,6 @@ inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsICon if (NS_FAILED(rv = RowToNode(row, &oldNode))) return rv; - PRInt32 oldRowCount = GetRowCount(); if (oldNode->isOpen) CollapseNode(row); @@ -1008,8 +1007,6 @@ inDOMView::CollapseNode(PRInt32 aRow) inDOMViewNode* node = nsnull; RowToNode(aRow, &node); - PRUint32 ourLevel = node->level; - PRInt32 row = 0; GetLastDescendantOf(node, aRow, &row); diff --git a/mozilla/layout/inspector/src/inDOMView.h b/mozilla/layout/inspector/src/inDOMView.h new file mode 100644 index 00000000000..6cebaf7337b --- /dev/null +++ b/mozilla/layout/inspector/src/inDOMView.h @@ -0,0 +1,179 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Hewitt (original author) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __inDOMView_h__ +#define __inDOMView_h__ + +#include "inIDOMView.h" + +#include "nsIOutlinerView.h" +#include "nsIOutlinerSelection.h" +#include "nsIDocumentObserver.h" +#include "nsIDOMNode.h" +#include "nsIDOMDocument.h" +#include "nsVoidArray.h" + +class inDOMViewNode; + +class inDOMView : public inIDOMView, + public nsIOutlinerView, + public nsIDocumentObserver +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_INIDOMVIEW + NS_DECL_NSIOUTLINERVIEW + + inDOMView(); + virtual ~inDOMView(); + + // nsIDocumentObserver + NS_IMETHOD AttributeChanged(nsIDocument *aDocument, + nsIContent* aContent, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType, + PRInt32 aHint); + NS_IMETHOD ContentAppended(nsIDocument *aDocument, + nsIContent* aContainer, + PRInt32 aNewIndexInContainer); + NS_IMETHOD ContentInserted(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + NS_IMETHOD ContentReplaced(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aOldChild, + nsIContent* aNewChild, + PRInt32 aIndexInContainer); + NS_IMETHOD ContentRemoved(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + // Not implemented + NS_IMETHOD ContentChanged(nsIDocument *aDocument, + nsIContent* aContent, + nsISupports* aSubContent) { return NS_OK; } + NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument, + nsIContent* aContent1, + nsIContent* aContent2) { return NS_OK; } + NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) { return NS_OK; } + NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) { return NS_OK; } + NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet) { return NS_OK; } + NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet) { return NS_OK; } + NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet, + PRBool aDisabled) { return NS_OK; } + NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet, + nsIStyleRule* aStyleRule, + PRInt32 aHint) { return NS_OK; } + NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet, + nsIStyleRule* aStyleRule) { return NS_OK; } + NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet, + nsIStyleRule* aStyleRule) { return NS_OK; } + NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument) { return NS_OK; }; + +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; + + nsCOMPtr mOutliner; + nsCOMPtr mSelection; + + PRBool mShowAnonymous; + PRBool mShowSubDocuments; + PRUint32 mFilters; + + nsCOMPtr mRootNode; + nsCOMPtr mRootDocument; + + nsVoidArray mNodes; + + inDOMViewNode* GetNodeAt(PRInt32 aIndex); + PRInt32 GetRowCount(); + 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); + + PRUint16 GetNodeTypeKey(PRUint16 aType); + nsresult GetChildNodesFor(nsIDOMNode* aNode, nsISupportsArray **aResult); + nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsISupportsArray* aArray); + nsresult AppendAttrsToArray(nsIDOMNamedNodeMap* aKids, nsISupportsArray* aArray); + nsresult GetFirstDescendantOf(inDOMViewNode* aNode, PRInt32 aRow, PRInt32* aResult); + nsresult GetLastDescendantOf(inDOMViewNode* aNode, PRInt32 aRow, PRInt32* aResult); + nsresult GetRealParent(nsIDOMNode* aNode, nsIDOMNode** aParent); + nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling); +}; + +#endif // __inDOMView_h__ + + diff --git a/mozilla/layout/inspector/src/inDeepTreeWalker.cpp b/mozilla/layout/inspector/src/inDeepTreeWalker.cpp index acff273c085..c9dd8ed9f87 100644 --- a/mozilla/layout/inspector/src/inDeepTreeWalker.cpp +++ b/mozilla/layout/inspector/src/inDeepTreeWalker.cpp @@ -43,13 +43,6 @@ #include "nsIDOMDocument.h" #include "nsIDOMNodeFilter.h" #include "nsIDOMNodeList.h" -#include "nsIContent.h" -#include "nsIDOMWindowInternal.h" -#include "nsIDOMWindow.h" -#include "nsIDocShell.h" -#include "nsIDocShellTreeItem.h" -#include "nsIWebNavigation.h" -#include "nsIScriptGlobalObject.h" /***************************************************************************** * This implementation does not currently operaate according to the W3C spec. diff --git a/mozilla/layout/inspector/src/inFileSearch.cpp b/mozilla/layout/inspector/src/inFileSearch.cpp index bc32634da68..d723058ed60 100644 --- a/mozilla/layout/inspector/src/inFileSearch.cpp +++ b/mozilla/layout/inspector/src/inFileSearch.cpp @@ -124,9 +124,7 @@ inFileSearch::SearchAsync(inISearchObserver *aObserver) KillSearch(inISearchObserver::SUCCESS); } } else { - nsAutoString msg; - msg.AssignWithConversion("No search path has been provided"); - mObserver->OnSearchError(this, ToNewUnicode(msg)); + mObserver->OnSearchError(this, NS_LITERAL_STRING("No search path has been provided")); KillSearch(inISearchObserver::ERROR); } @@ -157,10 +155,12 @@ inFileSearch::SearchStep(PRBool* _retval) } NS_IMETHODIMP -inFileSearch::GetStringResultAt(PRInt32 aIndex, PRUnichar **_retval) +inFileSearch::GetStringResultAt(PRInt32 aIndex, nsAString& _retval) { nsCOMPtr file; + _retval = NS_LITERAL_STRING(""); + if (mHoldResults) { nsCOMPtr supports; mResults->GetElementAt(aIndex, getter_AddRefs(supports)); @@ -171,13 +171,11 @@ inFileSearch::GetStringResultAt(PRInt32 aIndex, PRUnichar **_retval) } if (file) { - char* temp; - mLastResult->GetPath(&temp); - nsAutoString path; - path.AssignWithConversion(temp); + nsXPIDLCString temp; + mLastResult->GetPath(getter_Copies(temp)); + _retval = NS_ConvertASCIItoUCS2(temp); if (mReturnRelativePaths) - MakePathRelative(&path); - *_retval = ToNewUnicode(path); + MakePathRelative(_retval); } else { return NS_ERROR_FAILURE; } @@ -608,9 +606,8 @@ inFileSearch::AdvanceWildcard(PRUnichar** aString, PRUnichar* aNextChar) // URL fixing nsresult -inFileSearch::MakePathRelative(nsAutoString* aPath) +inFileSearch::MakePathRelative(nsAString& aPath) { - nsAutoString result; // get an nsAutoString version of the search path char* temp; @@ -618,13 +615,13 @@ inFileSearch::MakePathRelative(nsAutoString* aPath) nsAutoString searchPath; searchPath.AssignWithConversion(temp); - PRInt32 found = aPath->Find(searchPath, PR_FALSE, 0, 1); - if (found == 0) { - PRUint32 len = searchPath.Length(); - aPath->Mid(result, len+1, aPath->Length()-len); + nsAutoString result; + PRUint32 len = searchPath.Length(); + if (Substring(aPath, 0, len) == searchPath) { + result = Substring(aPath, len+1, aPath.Length() - len - 1); result.ReplaceChar('\\', '/'); } - aPath->Assign(result); + aPath = result; return NS_OK; } diff --git a/mozilla/layout/inspector/src/inFileSearch.h b/mozilla/layout/inspector/src/inFileSearch.h index f45167c4e6e..13ec54a2875 100644 --- a/mozilla/layout/inspector/src/inFileSearch.h +++ b/mozilla/layout/inspector/src/inFileSearch.h @@ -100,7 +100,7 @@ protected: static PRBool AdvanceWildcard(PRUnichar** aString, PRUnichar* aNextChar); // misc - nsresult MakePathRelative(nsAutoString* aPath); + nsresult MakePathRelative(nsAString& aPath); nsresult CountDirectoryDepth(nsIFile* aDir, PRUint32* aDepth); }; diff --git a/mozilla/layout/inspector/src/inFlasher.cpp b/mozilla/layout/inspector/src/inFlasher.cpp index df991abf8f3..eec86c5e7ee 100644 --- a/mozilla/layout/inspector/src/inFlasher.cpp +++ b/mozilla/layout/inspector/src/inFlasher.cpp @@ -37,27 +37,12 @@ * ***** END LICENSE BLOCK ***** */ #include "inFlasher.h" -#include "dsinfo.h" - -#include "nsCOMPtr.h" -#include "nsString.h" -#include "nsIServiceManager.h" -#include "nsIFile.h" -#include "nsDirectoryServiceDefs.h" -#include "nsIDocument.h" -#include "nsIDocShell.h" -#include "nsIPresShell.h" -#include "nsIPresContext.h" -#include "nsIRenderingContext.h" -#include "nsIContent.h" -#include "nsIFrame.h" -#include "nsIDOMWindowInternal.h" -#include "nsIDOMElement.h" -#include "nsIView.h" -#include "nsIViewManager.h" -#include "nsIScriptGlobalObject.h" #include "inLayoutUtils.h" +#include "nsIViewManager.h" +#include "nsIDeviceContext.h" +#include "nsIWidget.h" + /////////////////////////////////////////////////////////////////////////////// inFlasher::inFlasher() @@ -108,7 +93,7 @@ inFlasher::RepaintElement(nsIDOMElement* aElement) } NS_IMETHODIMP -inFlasher::DrawElementOutline(nsIDOMElement* aElement, const PRUnichar* aColor, PRInt32 aThickness) +inFlasher::DrawElementOutline(nsIDOMElement* aElement, const PRUnichar* aColor, PRInt32 aThickness, PRBool aInvert) { nsCOMPtr window = inLayoutUtils::GetWindowFor(aElement); if (!window) return NS_OK; @@ -116,25 +101,38 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement, const PRUnichar* aColor, nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell); if (!frame) return NS_OK; - nsCOMPtr pcontext; - presShell->GetPresContext(getter_AddRefs(pcontext)); + nsCOMPtr presContext; + presShell->GetPresContext(getter_AddRefs(presContext)); nsCOMPtr rcontext; presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext)); + // get view bounds in case this frame is being scrolled + nsIFrame* parentFrame = nsnull; + frame->GetParentWithView(presContext, &parentFrame); + if (!parentFrame) + return NS_OK; + nsIView* parentView = nsnull; + parentFrame->GetView(presContext, &parentView); + nsRect bounds; + parentView->GetBounds(bounds); + + nsRect rect; + frame->GetRect(rect); + nsPoint origin = inLayoutUtils::GetClientOrigin(frame); + rect.x = origin.x + bounds.x; + rect.y = origin.y + bounds.y; + inLayoutUtils::AdjustRectForMargins(aElement, rect); + nsAutoString colorStr; colorStr.Assign(aColor); nscolor color; NS_HexToRGB(colorStr, &color); - nsRect rect; - frame->GetRect(rect); - nsPoint origin = inLayoutUtils::GetClientOrigin(frame); - rect.x = origin.x; - rect.y = origin.y; - inLayoutUtils::AdjustRectForMargins(aElement, rect); - float p2t; - pcontext->GetPixelsToTwips(&p2t); + presContext->GetPixelsToTwips(&p2t); + + if (aInvert) + rcontext->InvertRect(rect.x, rect.y, rect.width, rect.height); DrawOutline(rect.x, rect.y, rect.width, rect.height, color, aThickness, p2t, rcontext);