Bug 647273 - Remove nsIContentUtils and nsIContentUtils2. r=sicking

--HG--
extra : rebase_source : 8a99a1401b7d7427bed4a136e0b38c475f6473a2
This commit is contained in:
Justin Lebar 2011-04-14 13:58:36 -07:00
parent 442235ace9
commit 5bc75b222e
14 changed files with 47 additions and 192 deletions

View File

@ -53,7 +53,6 @@ nsIContentIterator.h \
nsContentErrors.h \
nsContentPolicyUtils.h \
nsContentUtils.h \
nsIContentUtils.h \
nsIDocument.h \
nsIDocumentObserver.h \
nsIMutationObserver.h \

View File

@ -132,6 +132,7 @@ class nsPresContext;
class nsIChannel;
struct nsIntMargin;
class nsPIDOMWindow;
class nsIDocumentLoaderFactory;
#ifndef have_PrefChangedFunc_typedef
typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
@ -1758,6 +1759,18 @@ public:
*/
static bool AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal);
enum ContentViewerType
{
TYPE_UNSUPPORTED,
TYPE_CONTENT,
TYPE_PLUGIN,
TYPE_UNKNOWN
};
static already_AddRefed<nsIDocumentLoaderFactory>
FindInternalContentViewer(const char* aType,
ContentViewerType* aLoaderType = nsnull);
private:
static PRBool InitializeEventTable();

View File

@ -1,94 +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
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 nsIContentUtils_h__
#define nsIContentUtils_h__
#include "nsIDocumentLoaderFactory.h"
#include "nsCOMPtr.h"
#include "nsAString.h"
#include "nsMargin.h"
class nsIInterfaceRequestor;
// {3682DD99-8560-44f4-9B8F-CCCE9D7B96FB}
#define NS_ICONTENTUTILS_IID \
{ 0x3682dd99, 0x8560, 0x44f4, \
{ 0x9b, 0x8f, 0xcc, 0xce, 0x9d, 0x7b, 0x96, 0xfb } }
class nsIContentUtils : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTUTILS_IID)
NS_DECL_ISUPPORTS
virtual PRBool IsSafeToRunScript();
virtual PRBool ParseIntMarginValue(const nsAString& aString, nsIntMargin& result);
enum ContentViewerType
{
TYPE_UNSUPPORTED,
TYPE_CONTENT,
TYPE_PLUGIN,
TYPE_UNKNOWN
};
virtual already_AddRefed<nsIDocumentLoaderFactory>
FindInternalContentViewer(const char* aType,
ContentViewerType* aLoaderType = NULL);
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentUtils, NS_ICONTENTUTILS_IID)
// {c7193287-3e3d-467f-b6da-47b914eb4c83}
#define NS_ICONTENTUTILS2_IID \
{ 0xc7193287, 0x3e3d, 0x467f, \
{ 0xb6, 0xda, 0x47, 0xb9, 0x14, 0xeb, 0x4c, 0x83 } }
class nsIContentUtils2 : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTUTILS2_IID)
NS_DECL_ISUPPORTS
virtual nsIInterfaceRequestor* GetSameOriginChecker();
// Returns NS_OK for same origin, error (NS_ERROR_DOM_BAD_URI) if not.
virtual nsresult CheckSameOrigin(nsIChannel *aOldChannel, nsIChannel *aNewChannel);
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentUtils2, NS_ICONTENTUTILS2_IID)
#endif /* nsIContentUtils_h__ */

View File

@ -58,7 +58,6 @@
#include "nsIDOMScriptObjectFactory.h"
#include "nsDOMCID.h"
#include "nsContentUtils.h"
#include "nsIContentUtils.h"
#include "nsIXPConnect.h"
#include "nsIContent.h"
#include "mozilla/dom/Element.h"
@ -6466,23 +6465,9 @@ nsContentUtils::AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal)
IsSitePermAllow(princURI, "allowXULXBL"));
}
NS_IMPL_ISUPPORTS1(nsIContentUtils, nsIContentUtils)
PRBool
nsIContentUtils::IsSafeToRunScript()
{
return nsContentUtils::IsSafeToRunScript();
}
PRBool
nsIContentUtils::ParseIntMarginValue(const nsAString& aString, nsIntMargin& result)
{
return nsContentUtils::ParseIntMarginValue(aString, result);
}
already_AddRefed<nsIDocumentLoaderFactory>
nsIContentUtils::FindInternalContentViewer(const char* aType,
ContentViewerType* aLoaderType)
nsContentUtils::FindInternalContentViewer(const char* aType,
ContentViewerType* aLoaderType)
{
if (aLoaderType) {
*aLoaderType = TYPE_UNSUPPORTED;
@ -6506,7 +6491,7 @@ nsIContentUtils::FindInternalContentViewer(const char* aType,
*aLoaderType = TYPE_PLUGIN;
else
*aLoaderType = TYPE_UNKNOWN;
}
}
return docFactory.forget();
}
@ -6544,17 +6529,3 @@ nsIContentUtils::FindInternalContentViewer(const char* aType,
return NULL;
}
NS_IMPL_ISUPPORTS1(nsIContentUtils2, nsIContentUtils2)
nsIInterfaceRequestor*
nsIContentUtils2::GetSameOriginChecker()
{
return nsContentUtils::GetSameOriginChecker();
}
nsresult
nsIContentUtils2::CheckSameOrigin(nsIChannel *aOldChannel, nsIChannel *aNewChannel)
{
return nsContentUtils::CheckSameOrigin(aOldChannel, aNewChannel);
}

View File

@ -45,6 +45,7 @@
#define nsTextFragment_h___
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsTraceRefcnt.h"
class nsString;
class nsCString;

View File

@ -49,7 +49,6 @@
#include "nsIBrowserDOMWindow.h"
#include "nsIComponentManager.h"
#include "nsIContent.h"
#include "nsIContentUtils.h"
#include "mozilla/dom/Element.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
@ -6491,11 +6490,9 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
// too, of course.
mFiredUnloadEvent = PR_FALSE;
nsCOMPtr<nsIContentUtils> cutils = do_GetService("@mozilla.org/content/contentutils;1");
if (!cutils)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocumentLoaderFactory> docFactory =
nsContentUtils::FindInternalContentViewer("text/html");
nsCOMPtr<nsIDocumentLoaderFactory> docFactory = cutils->FindInternalContentViewer("text/html");
if (docFactory) {
// generate (about:blank) document to load
docFactory->CreateBlankDocument(mLoadGroup, aPrincipal,
@ -7520,13 +7517,8 @@ nsDocShell::NewContentViewerObj(const char *aContentType,
{
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);
nsCOMPtr<nsIContentUtils> cutils = do_GetService("@mozilla.org/content/contentutils;1");
if (!cutils) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
cutils->FindInternalContentViewer(aContentType);
nsContentUtils::FindInternalContentViewer(aContentType);
if (!docLoaderFactory) {
return NS_ERROR_FAILURE;
}

View File

@ -39,9 +39,9 @@
#include "nsIWebNavigation.h"
#include "nsString.h"
#include "nsServiceManagerUtils.h"
#include "nsIContentUtils.h"
#include "nsIDocumentLoaderFactory.h"
#include "nsIPluginHost.h"
#include "nsContentUtils.h"
NS_IMPL_ISUPPORTS1(nsWebNavigationInfo, nsIWebNavigationInfo)
@ -110,29 +110,25 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
NS_PRECONDITION(aIsSupported, "Null out param?");
nsCOMPtr<nsIContentUtils> cutils = do_GetService("@mozilla.org/content/contentutils;1");
if (!cutils)
return NS_ERROR_FAILURE;
nsIContentUtils::ContentViewerType vtype = nsIContentUtils::TYPE_UNSUPPORTED;
nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
cutils->FindInternalContentViewer(aType.get(), &vtype);
nsContentUtils::FindInternalContentViewer(aType.get(), &vtype);
switch (vtype) {
case nsIContentUtils::TYPE_UNSUPPORTED:
case nsContentUtils::TYPE_UNSUPPORTED:
*aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
break;
case nsIContentUtils::TYPE_PLUGIN:
case nsContentUtils::TYPE_PLUGIN:
*aIsSupported = nsIWebNavigationInfo::PLUGIN;
break;
case nsIContentUtils::TYPE_UNKNOWN:
case nsContentUtils::TYPE_UNKNOWN:
*aIsSupported = nsIWebNavigationInfo::OTHER;
break;
case nsIContentUtils::TYPE_CONTENT:
case nsContentUtils::TYPE_CONTENT:
PRBool isImage = PR_FALSE;
mImgLoader->SupportImageWithMimeType(aType.get(), &isImage);
if (isImage) {
@ -143,6 +139,6 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
}
break;
}
return NS_OK;
}

View File

@ -46,7 +46,6 @@
#include "nsNetUtil.h"
#include "nsWWJSUtils.h"
#include "plstr.h"
#include "nsIContentUtils.h"
#include "nsIBaseWindow.h"
#include "nsIDocShell.h"
@ -512,9 +511,7 @@ nsWindowWatcher::OpenWindowJSInternal(nsIDOMWindow *aParent,
NS_ENSURE_ARG_POINTER(_retval);
*_retval = 0;
nsCOMPtr<nsIContentUtils> utils =
do_GetService("@mozilla.org/content/contentutils;1");
if (utils && !utils->IsSafeToRunScript()) {
if (!nsContentUtils::IsSafeToRunScript()) {
return NS_ERROR_FAILURE;
}

View File

@ -238,14 +238,6 @@
#define NS_FOCUSMANAGER_CID \
{ 0xcf7fd51f, 0xaba2, 0x44c1, { 0x9f, 0xf0, 0x11, 0xf7, 0x50, 0x8e, 0xfc, 0xd4 } }
// {762C4AE7-B923-422F-B97E-B9BFC1EF7BF0}
#define NS_ICONTENTUTILS_CID \
{ 0x762C4AE7, 0xB923, 0x422F, { 0xB9, 0x7E, 0xB9, 0xBF, 0xC1, 0xEF, 0x7B, 0xF0 } }
// {1802442d-a59b-43b8-b8fd-070da5549593}
#define NS_ICONTENTUTILS2_CID \
{ 0x1802442d, 0xa59b, 0x43b8, { 0xb8, 0xfd, 0x07, 0x0d, 0xa5, 0x54, 0x95, 0x93 } }
// {1A26A7B7-D06E-4F45-8B45-D7AD60F7A9AB}
#define INDEXEDDB_MANAGER_CID \
{ 0x1a26a7b7, 0xd06e, 0x4f45, { 0x8b, 0x45, 0xd7, 0xad, 0x60, 0xf7, 0xa9, 0xab } }

View File

@ -94,7 +94,6 @@
#include "nsStyleSheetService.h"
#include "nsXULPopupManager.h"
#include "nsFocusManager.h"
#include "nsIContentUtils.h"
#include "ThirdPartyUtil.h"
#include "mozilla/Services.h"
@ -580,9 +579,6 @@ MAKE_CTOR(CreateVideoDocument, nsIDocument, NS_NewVid
#endif
MAKE_CTOR(CreateFocusManager, nsIFocusManager, NS_NewFocusManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIContentUtils)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIContentUtils2)
MAKE_CTOR(CreateCanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D, NS_NewCanvasRenderingContext2D)
MAKE_CTOR(CreateCanvasRenderingContextWebGL, nsIDOMWebGLRenderingContext, NS_NewCanvasRenderingContextWebGL)
@ -868,8 +864,6 @@ NS_DEFINE_NAMED_CID(NS_TEXTSERVICESDOCUMENT_CID);
NS_DEFINE_NAMED_CID(NS_GEOLOCATION_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_GEOLOCATION_CID);
NS_DEFINE_NAMED_CID(NS_FOCUSMANAGER_CID);
NS_DEFINE_NAMED_CID(NS_ICONTENTUTILS_CID);
NS_DEFINE_NAMED_CID(NS_ICONTENTUTILS2_CID);
NS_DEFINE_NAMED_CID(CSPSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_EVENTLISTENERSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_GLOBALMESSAGEMANAGER_CID);
@ -1019,8 +1013,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_GEOLOCATION_SERVICE_CID, false, NULL, nsGeolocationServiceConstructor },
{ &kNS_GEOLOCATION_CID, false, NULL, nsGeolocationConstructor },
{ &kNS_FOCUSMANAGER_CID, false, NULL, CreateFocusManager },
{ &kNS_ICONTENTUTILS_CID, false, NULL, nsIContentUtilsConstructor },
{ &kNS_ICONTENTUTILS2_CID, false, NULL, nsIContentUtils2Constructor },
{ &kCSPSERVICE_CID, false, NULL, CSPServiceConstructor },
{ &kNS_EVENTLISTENERSERVICE_CID, false, NULL, CreateEventListenerService },
{ &kNS_GLOBALMESSAGEMANAGER_CID, false, NULL, CreateGlobalMessageManager },
@ -1164,8 +1156,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ "@mozilla.org/geolocation/service;1", &kNS_GEOLOCATION_SERVICE_CID },
{ "@mozilla.org/geolocation;1", &kNS_GEOLOCATION_CID },
{ "@mozilla.org/focus-manager;1", &kNS_FOCUSMANAGER_CID },
{ "@mozilla.org/content/contentutils;1", &kNS_ICONTENTUTILS_CID },
{ "@mozilla.org/content/contentutils2;1", &kNS_ICONTENTUTILS2_CID },
{ CSPSERVICE_CONTRACTID, &kCSPSERVICE_CID },
{ NS_EVENTLISTENERSERVICE_CONTRACTID, &kNS_EVENTLISTENERSERVICE_CID },
{ NS_GLOBALMESSAGEMANAGER_CONTRACTID, &kNS_GLOBALMESSAGEMANAGER_CID },

View File

@ -54,10 +54,10 @@
#include "nsIMultiPartChannel.h"
#include "nsIInputStreamTee.h"
#include "nsPrintfCString.h"
#include "nsIContentUtils.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocument.h"
#include "nsIWebNavigation.h"
#include "nsContentUtils.h"
#define MAGIC_REQUEST_CONTEXT 0x01020304
@ -1423,9 +1423,7 @@ nsPluginStreamListenerPeer::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsICh
return rv;
}
if (method.EqualsLiteral("POST")) {
nsCOMPtr<nsIContentUtils2> contentUtils2 = do_GetService("@mozilla.org/content/contentutils2;1");
NS_ENSURE_TRUE(contentUtils2, NS_ERROR_FAILURE);
rv = contentUtils2->CheckSameOrigin(oldChannel, newChannel);
rv = nsContentUtils::CheckSameOrigin(oldChannel, newChannel);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -47,13 +47,17 @@ MODULE = test_widget
XPCSHELL_TESTS = unit
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
ifdef NS_ENABLE_TSF
#Test disabled because it uses the internal string APIs incorrectly (see bug 582863)
#CPP_UNIT_TESTS += TestWinTSF.cpp \
# $(NULL)
endif
CPP_UNIT_TESTS += TestChromeMargin.cpp \
$(NULL)
# Test disabled because it requires the internal API. Re-enabling this test is
# bug 652123.
#CPP_UNIT_TESTS += TestChromeMargin.cpp \
# $(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@ -37,11 +37,16 @@
* ***** END LICENSE BLOCK ***** */
/* This tests the margin parsing functionality in nsAttrValue.cpp, which
* is accessible via nsIContentUtils, and is used in setting chromemargins
* is accessible via nsContentUtils, and is used in setting chromemargins
* to widget windows. It's located here due to linking issues in the
* content directory.
*/
/* This test no longer compiles now that we've removed nsIContentUtils (bug
* 647273). We need to be internal code in order to include nsContentUtils.h,
* but defining MOZILLA_INTERNAL_API is not enough to make us internal.
*/
#include "TestHarness.h"
#ifndef MOZILLA_INTERNAL_API
@ -61,7 +66,7 @@ template<class T> class nsReadingIterator;
#endif
#include "nscore.h"
#include "nsIContentUtils.h"
#include "nsContentUtils.h"
#ifndef MOZILLA_INTERNAL_API
#undef nsString_h___
@ -115,19 +120,13 @@ const DATA Data[] = {
void DoAttrValueTest()
{
nsCOMPtr<nsIContentUtils> utils =
do_GetService("@mozilla.org/content/contentutils;1");
if (!utils)
fail("No nsIContentUtils");
int idx = -1;
bool didFail = false;
while (Data[++idx].margins) {
nsAutoString str;
str.AssignLiteral(Data[idx].margins);
nsIntMargin values(99,99,99,99);
bool result = utils->ParseIntMarginValue(str, values);
bool result = nsContentUtils::ParseIntMarginValue(str, values);
// if the parse fails
if (!result) {

View File

@ -92,7 +92,6 @@
#include "nsReadableUtils.h"
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "nsIContentUtils.h"
#include "nsWebShellWindow.h" // get rid of this one, too...
@ -1392,10 +1391,8 @@ void nsXULWindow::SyncAttributesToWidget()
// "chromemargin" attribute
nsIntMargin margins;
nsCOMPtr<nsIContentUtils> cutils =
do_GetService("@mozilla.org/content/contentutils;1");
rv = windowElement->GetAttribute(NS_LITERAL_STRING("chromemargin"), attr);
if (NS_SUCCEEDED(rv) && cutils && cutils->ParseIntMarginValue(attr, margins)) {
if (NS_SUCCEEDED(rv) && nsContentUtils::ParseIntMarginValue(attr, margins)) {
mWindow->SetNonClientMargins(margins);
}