Bug 1427519 - Remove unused inCSSValueSearch and related interfaces. r=jryans

MozReview-Commit-ID: 1FR5tsi1Ll6
This commit is contained in:
Cameron McCormack 2018-01-11 12:59:40 +08:00
Родитель 3f840ba7f5
Коммит 3ddc9f5f5f
7 изменённых файлов: 0 добавлений и 578 удалений

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

@ -145,7 +145,6 @@ class nsIDocumentLoaderFactory;
#endif /* MOZ_XUL */
#include "inDeepTreeWalker.h"
#include "inCSSValueSearch.h"
#ifdef MOZ_XUL
#include "nsIXULDocument.h"
@ -423,7 +422,6 @@ MAKE_CTOR(CreateNewContainerBoxObject, nsIBoxObject, NS_NewContainerB
NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMView)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(inDeepTreeWalker)
NS_GENERIC_FACTORY_CONSTRUCTOR(inCSSValueSearch)
MAKE_CTOR2(CreateContentViewer, nsIContentViewer, NS_NewContentViewer)
MAKE_CTOR(CreateHTMLDocument, nsIDocument, NS_NewHTMLDocument)
@ -572,7 +570,6 @@ NS_DEFINE_NAMED_CID(NS_TREEBOXOBJECT_CID);
NS_DEFINE_NAMED_CID(IN_DOMVIEW_CID);
#endif
NS_DEFINE_NAMED_CID(IN_DEEPTREEWALKER_CID);
NS_DEFINE_NAMED_CID(IN_CSSVALUESEARCH_CID);
NS_DEFINE_NAMED_CID(NS_CONTENT_VIEWER_CID);
NS_DEFINE_NAMED_CID(NS_HTMLDOCUMENT_CID);
NS_DEFINE_NAMED_CID(NS_XMLDOCUMENT_CID);
@ -827,7 +824,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kIN_DOMVIEW_CID, false, nullptr, inDOMViewConstructor },
#endif
{ &kIN_DEEPTREEWALKER_CID, false, nullptr, inDeepTreeWalkerConstructor },
{ &kIN_CSSVALUESEARCH_CID, false, nullptr, inCSSValueSearchConstructor },
{ &kNS_CONTENT_VIEWER_CID, false, nullptr, CreateContentViewer },
{ &kNS_HTMLDOCUMENT_CID, false, nullptr, CreateHTMLDocument },
{ &kNS_XMLDOCUMENT_CID, false, nullptr, CreateXMLDocument },
@ -949,7 +945,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ "@mozilla.org/inspector/dom-view;1", &kIN_DOMVIEW_CID },
#endif
{ "@mozilla.org/inspector/deep-tree-walker;1", &kIN_DEEPTREEWALKER_CID },
{ "@mozilla.org/inspector/search;1?type=cssvalue", &kIN_CSSVALUESEARCH_CID },
{ "@mozilla.org/xml/xml-document;1", &kNS_XMLDOCUMENT_CID },
{ "@mozilla.org/svg/svg-document;1", &kNS_SVGDOCUMENT_CID },
{ "@mozilla.org/content/dom-selection;1", &kNS_DOMSELECTION_CID },

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

@ -1,409 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "inCSSValueSearch.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/dom/StyleSheetList.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsReadableUtils.h"
#include "nsIDOMDocument.h"
#include "nsIDOMStyleSheetList.h"
#include "nsIDOMCSSStyleSheet.h"
#include "nsIDOMCSSRuleList.h"
#include "nsIDOMCSSStyleRule.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMCSSImportRule.h"
#include "nsIDOMCSSMediaRule.h"
#include "nsIDOMCSSSupportsRule.h"
#include "nsIDOMCSSRule.h"
#include "nsIURI.h"
#include "nsIDocument.h"
#include "nsNetUtil.h"
using namespace mozilla;
///////////////////////////////////////////////////////////////////////////////
inCSSValueSearch::inCSSValueSearch()
: mResults(nullptr),
mProperties(nullptr),
mResultCount(0),
mPropertyCount(0),
mIsActive(false),
mHoldResults(true),
mReturnRelativeURLs(true),
mNormalizeChromeURLs(false)
{
nsCSSProps::AddRefTable();
mProperties = new nsCSSPropertyID[100];
}
inCSSValueSearch::~inCSSValueSearch()
{
delete[] mProperties;
delete mResults;
nsCSSProps::ReleaseTable();
}
NS_IMPL_ISUPPORTS(inCSSValueSearch, inISearchProcess, inICSSValueSearch)
///////////////////////////////////////////////////////////////////////////////
// inISearchProcess
NS_IMETHODIMP
inCSSValueSearch::GetIsActive(bool *aIsActive)
{
*aIsActive = mIsActive;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetResultCount(int32_t *aResultCount)
{
*aResultCount = mResultCount;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetHoldResults(bool *aHoldResults)
{
*aHoldResults = mHoldResults;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetHoldResults(bool aHoldResults)
{
mHoldResults = aHoldResults;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SearchSync()
{
InitSearch();
if (!mDocument) {
return NS_OK;
}
nsCOMPtr<nsIDocument> document = do_QueryInterface(mDocument);
MOZ_ASSERT(document);
nsCOMPtr<nsIURI> baseURI = document->GetBaseURI();
RefPtr<dom::StyleSheetList> sheets = document->StyleSheets();
MOZ_ASSERT(sheets);
uint32_t length = sheets->Length();
for (uint32_t i = 0; i < length; ++i) {
RefPtr<StyleSheet> sheet = sheets->Item(i);
SearchStyleSheet(sheet, baseURI);
}
// 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::IN_INTERRUPTED);
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SearchStep(bool* _retval)
{
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetStringResultAt(int32_t aIndex, nsAString& _retval)
{
if (mHoldResults) {
nsAutoString* result = mResults->ElementAt(aIndex);
_retval = *result;
} else if (aIndex == mResultCount-1) {
_retval = mLastResult;
} else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetIntResultAt(int32_t aIndex, int32_t *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
inCSSValueSearch::GetUIntResultAt(int32_t aIndex, uint32_t *_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(char16_t** aBaseURL)
{
if (!(*aBaseURL = ToNewUnicode(mBaseURL)))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetBaseURL(const char16_t* aBaseURL)
{
mBaseURL.Assign(aBaseURL);
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetReturnRelativeURLs(bool* aReturnRelativeURLs)
{
*aReturnRelativeURLs = mReturnRelativeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetReturnRelativeURLs(bool aReturnRelativeURLs)
{
mReturnRelativeURLs = aReturnRelativeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetNormalizeChromeURLs(bool *aNormalizeChromeURLs)
{
*aNormalizeChromeURLs = mNormalizeChromeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetNormalizeChromeURLs(bool aNormalizeChromeURLs)
{
mNormalizeChromeURLs = aNormalizeChromeURLs;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::AddPropertyCriteria(const char16_t *aPropName)
{
nsCSSPropertyID prop =
nsCSSProps::LookupProperty(nsDependentString(aPropName),
CSSEnabledState::eIgnoreEnabledState);
mProperties[mPropertyCount] = prop;
mPropertyCount++;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::GetTextCriteria(char16_t** aTextCriteria)
{
if (!(*aTextCriteria = ToNewUnicode(mTextCriteria)))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
inCSSValueSearch::SetTextCriteria(const char16_t* aTextCriteria)
{
mTextCriteria.Assign(aTextCriteria);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// inCSSValueSearch
nsresult
inCSSValueSearch::InitSearch()
{
if (mHoldResults) {
mResults = new nsTArray<nsAutoString *>();
}
mResultCount = 0;
return NS_OK;
}
nsresult
inCSSValueSearch::KillSearch(int16_t aResult)
{
mIsActive = 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, nullptr, 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)
{
uint32_t length;
aRuleList->GetLength(&length);
for (uint32_t i = 0; i < length; ++i) {
nsCOMPtr<nsIDOMCSSRule> rule;
aRuleList->Item(i, getter_AddRefs(rule));
uint16_t 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;
case nsIDOMCSSRule::SUPPORTS_RULE: {
nsCOMPtr<nsIDOMCSSSupportsRule> supportsRule = do_QueryInterface(rule);
nsCOMPtr<nsIDOMCSSRuleList> childRules;
supportsRule->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);
uint32_t length;
decl->GetLength(&length);
nsAutoString property, value;
for (uint32_t 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 nsString& aValue, nsIURI* aBaseURL)
{
if (StringBeginsWith(aValue, NS_LITERAL_STRING("url(")) &&
StringEndsWith(aValue, NS_LITERAL_STRING(")"))) {
const nsAString& 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, nullptr, aBaseURL);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString spec;
rv = uri->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
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://", false, 0, 1) >= 0) {
uint32_t len = aURL->Length();
char16_t* result = new char16_t[len-8];
const char16_t* src = aURL->get();
uint32_t i = 9;
uint32_t milestone = 0;
uint32_t 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->Assign(result);
delete [] result;
}
} else {
}
return NS_OK;
}

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

@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __inCSSValueSearch_h__
#define __inCSSValueSearch_h__
#include "inICSSValueSearch.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "inISearchObserver.h"
#include "nsTArray.h"
#include "nsCSSProps.h"
class nsIDOMCSSStyleSheet;
class nsIDOMCSSRuleList;
class nsIDOMCSSStyleRule;
class nsIURI;
class inCSSValueSearch final : public inICSSValueSearch
{
public:
NS_DECL_ISUPPORTS
NS_DECL_INISEARCHPROCESS
NS_DECL_INICSSVALUESEARCH
inCSSValueSearch();
protected:
virtual ~inCSSValueSearch();
nsCOMPtr<inISearchObserver> mObserver;
nsCOMPtr<nsIDOMDocument> mDocument;
nsTArray<nsAutoString *>* mResults;
nsCSSPropertyID* mProperties;
nsString mLastResult;
nsString mBaseURL;
nsString mTextCriteria;
int32_t mResultCount;
uint32_t mPropertyCount;
bool mIsActive;
bool mHoldResults;
bool mReturnRelativeURLs;
bool mNormalizeChromeURLs;
nsresult InitSearch();
nsresult KillSearch(int16_t aResult);
nsresult SearchStyleSheet(nsIDOMCSSStyleSheet* aStyleSheet, nsIURI* aBaseURI);
nsresult SearchRuleList(nsIDOMCSSRuleList* aRuleList, nsIURI* aBaseURI);
nsresult SearchStyleRule(nsIDOMCSSStyleRule* aStyleRule, nsIURI* aBaseURI);
nsresult SearchStyleValue(const nsString& aValue, nsIURI* aBaseURI);
nsresult EqualizeURL(nsAutoString* aURL);
};
// {4D977F60-FBE7-4583-8CB7-F5ED882293EF}
#define IN_CSSVALUESEARCH_CID \
{ 0x4d977f60, 0xfbe7, 0x4583, { 0x8c, 0xb7, 0xf5, 0xed, 0x88, 0x22, 0x93, 0xef } }
#endif // __inCSSValueSearch_h__

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

@ -1,29 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#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,21 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface inISearchProcess;
[scriptable, uuid(46226D9B-E398-4106-8D9B-225D4D0589F5)]
interface inISearchObserver : nsISupports
{
// result codes which are sent to onSearchEnd
const short IN_SUCCESS = 1; // search completed successfully
const short IN_INTERRUPTED = 2; // search stopped due to user interruption
const short IN_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,48 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface inISearchObserver;
[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);
};

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

@ -9,11 +9,8 @@ if CONFIG['ENABLE_TESTS']:
MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
XPIDL_SOURCES += [
'inICSSValueSearch.idl',
'inIDeepTreeWalker.idl',
'inIDOMView.idl',
'inISearchObserver.idl',
'inISearchProcess.idl',
]
XPIDL_MODULE = 'inspector'
@ -28,7 +25,6 @@ EXPORTS.mozilla.dom += [
]
UNIFIED_SOURCES += [
'inCSSValueSearch.cpp',
'inDeepTreeWalker.cpp',
'inLayoutUtils.cpp',
'InspectorFontFace.cpp',