Remove nsIXULContent. Bug 276698, r=sicking, sr=jst.

This commit is contained in:
bryner%brianryner.com 2005-01-19 20:05:02 +00:00
Родитель 3a26c3a61b
Коммит 956ddd5106
10 изменённых файлов: 85 добавлений и 226 удалений

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

@ -47,7 +47,6 @@ MODULE = xul
ifdef MOZ_XUL
EXPORTS = \
nsIXULPopupListener.h \
nsIXULContent.h \
$(NULL)
endif

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

@ -1,117 +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 Communicator client 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):
* Peter Annema <disttsc@bart.nl>
*
* 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 ***** */
/*
Private interface to XUL content.
*/
#ifndef nsIXULContent_h__
#define nsIXULContent_h__
#include "nsIXMLContent.h"
class nsIAtom;
class nsIRDFCompositeDataSource;
class nsIXULTemplateBuilder;
class nsString;
// {da87924c-2638-4249-8297-4cf814d52d47}
#define NS_IXULCONTENT_IID \
{ 0xda87924c, 0x2638, 0x4249, { 0x82, 0x97, 0x4c, 0xf8, 0x14, 0xd5, 0x2d, 0x47 } }
class nsIXULContent : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IXULCONTENT_IID)
/**
* Peek at a XUL element's child count without forcing children to be
* instantiated.
*/
NS_IMETHOD_(PRUint32) PeekChildCount() const = 0;
/**
* These flags are used to maintain bookkeeping information for partially-
* constructed content.
*
* eChildrenMustBeRebuilt
* The element's children are invalid or unconstructed, and should
* be reconstructed.
*
* eTemplateContentsBuilt
* Child content that is built from a XUL template has been
* constructed.
*
* eContainerContentsBuilt
* Child content that is built by following the ``containment''
* property in a XUL template has been built.
*/
enum LazyState {
eChildrenMustBeRebuilt = 0x1,
eTemplateContentsBuilt = 0x2,
eContainerContentsBuilt = 0x4
};
/**
* Set one or more ``lazy state'' flags.
* @aFlags a mask of flags to set
*/
NS_IMETHOD SetLazyState(LazyState aFlags) = 0;
/**
* Clear one or more ``lazy state'' flags.
* @aFlags a mask of flags to clear
*/
NS_IMETHOD ClearLazyState(LazyState aFlags) = 0;
/**
* Get the value of a single ``lazy state'' flag.
* @aFlag a flag to test
* @aResult the result
*/
NS_IMETHOD GetLazyState(LazyState aFlag, PRBool& aResult) = 0;
/**
* Add a script event listener to the element.
*/
NS_IMETHOD AddScriptEventListener(nsIAtom* aName, const nsAString& aValue) = 0;
};
#endif // nsIXULContent_h__

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

@ -118,7 +118,6 @@
#include "nsIURL.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsIXULContent.h"
#include "nsIXULDocument.h"
#include "nsIXULPopupListener.h"
#include "nsIXULPrototypeDocument.h"
@ -164,20 +163,17 @@
#include "nsIFrame.h"
#include "nsNodeInfoManager.h"
#define XUL_ELEMENT_LAZY_STATE_OFFSET ELEMENT_TYPE_SPECIFIC_BITS_OFFSET
/**
* Three bits are used for XUL Element's lazy state.
* @see nsIXULContent
*/
#define XUL_ELEMENT_CHILDREN_MUST_BE_REBUILT \
(nsIXULContent::eChildrenMustBeRebuilt << XUL_ELEMENT_LAZY_STATE_OFFSET)
(nsXULElement::eChildrenMustBeRebuilt << XUL_ELEMENT_LAZY_STATE_OFFSET)
#define XUL_ELEMENT_TEMPLATE_CONTENTS_BUILT \
(nsIXULContent::eTemplateContentsBuilt << XUL_ELEMENT_LAZY_STATE_OFFSET)
(nsXULElement::eTemplateContentsBuilt << XUL_ELEMENT_LAZY_STATE_OFFSET)
#define XUL_ELEMENT_CONTAINER_CONTENTS_BUILT \
(nsIXULContent::eContainerContentsBuilt << XUL_ELEMENT_LAZY_STATE_OFFSET)
(nsXULElement::eContainerContentsBuilt << XUL_ELEMENT_LAZY_STATE_OFFSET)
class nsIDocShell;
@ -559,8 +555,6 @@ nsXULElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
inst = NS_STATIC_CAST(nsIDOMElement *, this);
} else if (aIID.Equals(NS_GET_IID(nsIDOMXULElement))) {
inst = NS_STATIC_CAST(nsIDOMXULElement *, this);
} else if (aIID.Equals(NS_GET_IID(nsIXULContent))) {
inst = NS_STATIC_CAST(nsIXULContent *, this);
} else if (aIID.Equals(NS_GET_IID(nsIXMLContent))) {
inst = NS_STATIC_CAST(nsIXMLContent *, this);
} else if (aIID.Equals(NS_GET_IID(nsIScriptEventHandlerOwner))) {
@ -693,38 +687,7 @@ nsXULElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
return NS_OK;
}
//----------------------------------------------------------------------
// nsIXULContent interface
NS_IMETHODIMP_(PRUint32)
nsXULElement::PeekChildCount() const
{
return mAttrsAndChildren.ChildCount();
}
NS_IMETHODIMP
nsXULElement::SetLazyState(LazyState aFlags)
{
SetFlags(aFlags << XUL_ELEMENT_LAZY_STATE_OFFSET);
return NS_OK;
}
NS_IMETHODIMP
nsXULElement::ClearLazyState(LazyState aFlags)
{
UnsetFlags(aFlags << XUL_ELEMENT_LAZY_STATE_OFFSET);
return NS_OK;
}
NS_IMETHODIMP
nsXULElement::GetLazyState(LazyState aFlag, PRBool& aResult)
{
aResult = GetFlags() & (aFlag << XUL_ELEMENT_LAZY_STATE_OFFSET);
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsXULElement::AddScriptEventListener(nsIAtom* aName, const nsAString& aValue)
{
// XXX sXBL/XBL2 issue! Owner or current document?
@ -2323,7 +2286,7 @@ nsXULElement::EnsureContentsGenerated(void) const
xulele->GetBuilder(getter_AddRefs(builder));
if (builder) {
if (HasAttr(kNameSpaceID_None, nsXULAtoms::xulcontentsgenerated)) {
unconstThis->ClearLazyState(nsIXULContent::eChildrenMustBeRebuilt);
unconstThis->ClearLazyState(eChildrenMustBeRebuilt);
return NS_OK;
}

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

@ -70,7 +70,7 @@
#include "nsIBindingManager.h"
#include "nsIXBLBinding.h"
#include "nsIURI.h"
#include "nsIXULContent.h"
#include "nsIXMLContent.h"
#include "nsIXULPrototypeCache.h"
#include "nsIXULTemplateBuilder.h"
#include "nsIBoxObject.h"
@ -400,12 +400,44 @@ public:
*/
#define XUL_ELEMENT_LAZY_STATE_OFFSET ELEMENT_TYPE_SPECIFIC_BITS_OFFSET
class nsXULElement : public nsGenericElement,
public nsIXULContent,
public nsIDOMXULElement,
public nsIScriptEventHandlerOwner,
public nsIChromeEventHandler
{
public:
/**
* These flags are used to maintain bookkeeping information for partially-
* constructed content.
*
* eChildrenMustBeRebuilt
* The element's children are invalid or unconstructed, and should
* be reconstructed.
*
* eTemplateContentsBuilt
* Child content that is built from a XUL template has been
* constructed.
*
* eContainerContentsBuilt
* Child content that is built by following the ``containment''
* property in a XUL template has been built.
*/
enum LazyState {
eChildrenMustBeRebuilt = 0x1,
eTemplateContentsBuilt = 0x2,
eContainerContentsBuilt = 0x4
};
/** Typesafe, non-refcounting cast from nsIContent. Cheaper than QI. **/
static nsXULElement* FromContent(nsIContent *aContent)
{
if (aContent->IsContentOfType(eXUL))
return NS_STATIC_CAST(nsXULElement*, aContent);
return nsnull;
}
public:
static nsIXBLService* GetXBLService() {
if (!gXBLService)
@ -502,12 +534,17 @@ public:
PRInt32 aModType) const;
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
// nsIXULContent
NS_IMETHOD_(PRUint32) PeekChildCount() const;
NS_IMETHOD SetLazyState(LazyState aFlags);
NS_IMETHOD ClearLazyState(LazyState aFlags);
NS_IMETHOD GetLazyState(LazyState aFlag, PRBool& aValue);
NS_IMETHOD AddScriptEventListener(nsIAtom* aName, const nsAString& aValue);
// XUL element methods
PRUint32 PeekChildCount() const
{ return mAttrsAndChildren.ChildCount(); }
void SetLazyState(LazyState aFlags)
{ SetFlags(aFlags << XUL_ELEMENT_LAZY_STATE_OFFSET); }
void ClearLazyState(LazyState aFlags)
{ UnsetFlags(aFlags << XUL_ELEMENT_LAZY_STATE_OFFSET); }
PRBool GetLazyState(LazyState aFlag)
{ return GetFlags() & (aFlag << XUL_ELEMENT_LAZY_STATE_OFFSET); }
NS_HIDDEN_(nsresult) AddScriptEventListener(nsIAtom* aName,
const nsAString& aValue);
// nsIDOMNode
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericElement::)

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

@ -82,7 +82,6 @@
#include "nsIDocShell.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsIXULContent.h"
#include "nsIXULContentSink.h"
#include "nsXULContentUtils.h"
#include "nsIXULOverlayProvider.h"
@ -1840,7 +1839,7 @@ nsXULDocument::AddSubtreeToDocument(nsIContent* aElement)
if (NS_FAILED(rv)) return rv;
// Recurse to children
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
nsXULElement *xulcontent = nsXULElement::FromContent(aElement);
PRUint32 count =
xulcontent ? xulcontent->PeekChildCount() : aElement->GetChildCount();
@ -3475,11 +3474,11 @@ nsXULDocument::CreateTemplateBuilder(nsIContent* aElement)
builder->Init(aElement);
nsCOMPtr<nsIXULContent> xulContent = do_QueryInterface(aElement);
nsXULElement *xulContent = nsXULElement::FromContent(aElement);
if (xulContent) {
// Mark the XUL element as being lazy, so the template builder
// will run when layout first asks for these nodes.
xulContent->SetLazyState(nsIXULContent::eChildrenMustBeRebuilt);
xulContent->SetLazyState(nsXULElement::eChildrenMustBeRebuilt);
}
else {
// Force construction of immediate template sub-content _now_.

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

@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsContentSupportMap.h"
#include "nsIXULContent.h"
#include "nsXULElement.h"
PLDHashTableOps nsContentSupportMap::gOps = {
PL_DHashAllocTable,
@ -80,10 +80,10 @@ nsContentSupportMap::Remove(nsIContent* aElement)
PRUint32 count;
// If possible, use the special nsIXULContent interface to "peek"
// If possible, use the special nsXULElement interface to "peek"
// at the child count without accidentally creating children as a
// side effect, since we're about to rip 'em outta the map anyway.
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
nsXULElement *xulcontent = nsXULElement::FromContent(aElement);
if (xulcontent) {
count = xulcontent->PeekChildCount();
}

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

@ -40,6 +40,7 @@
#define nsTemplateMap_h__
#include "pldhash.h"
#include "nsXULElement.h"
class nsTemplateMap {
protected:
@ -85,11 +86,11 @@ public:
PRUint32 count;
// If possible, use the special nsIXULContent interface to
// If possible, use the special nsXULElement interface to
// "peek" at the child count without accidentally creating
// children as a side effect, since we're about to rip 'em
// outta the map anyway.
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aContent);
nsXULElement *xulcontent = nsXULElement::FromContent(aContent);
if (xulcontent) {
count = xulcontent->PeekChildCount();
}

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

@ -47,7 +47,6 @@
#include "nsIPrincipal.h"
#include "nsIServiceManager.h"
#include "nsITextContent.h"
#include "nsIXULContent.h"
#include "nsIXULDocument.h"
#include "nsIXULSortService.h"
@ -551,10 +550,9 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
// Mark the element's contents as being generated so
// that any re-entrant calls don't trigger an infinite
// recursion.
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(realKid);
nsXULElement *xulcontent = nsXULElement::FromContent(realKid);
if (xulcontent) {
rv = xulcontent->SetLazyState(nsIXULContent::eTemplateContentsBuilt);
if (NS_FAILED(rv)) return rv;
xulcontent->SetLazyState(nsXULElement::eTemplateContentsBuilt);
}
// Potentially remember the index of this element as the first
@ -750,7 +748,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(realKid);
nsXULElement *xulcontent = nsXULElement::FromContent(realKid);
if (xulcontent) {
PRUint32 count2 = tmplKid->GetChildCount();
@ -760,14 +758,14 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
// container contents built. This avoids a useless
// trip back to the template builder only to find
// that we've got no work to do!
xulcontent->SetLazyState(nsIXULContent::eTemplateContentsBuilt);
xulcontent->SetLazyState(nsIXULContent::eContainerContentsBuilt);
xulcontent->SetLazyState(nsXULElement::eTemplateContentsBuilt);
xulcontent->SetLazyState(nsXULElement::eContainerContentsBuilt);
}
else {
// Just mark the XUL element as requiring more work to
// be done. We'll get around to it when somebody asks
// for it.
xulcontent->SetLazyState(nsIXULContent::eChildrenMustBeRebuilt);
xulcontent->SetLazyState(nsXULElement::eChildrenMustBeRebuilt);
}
}
else {
@ -949,11 +947,9 @@ nsXULContentBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode,
// See if we've generated kids for this node yet. If we have, then
// recursively sync up template kids with content kids
PRBool contentsGenerated = PR_TRUE;
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aRealElement);
nsXULElement *xulcontent = nsXULElement::FromContent(aRealElement);
if (xulcontent) {
rv = xulcontent->GetLazyState(nsIXULContent::eTemplateContentsBuilt,
contentsGenerated);
if (NS_FAILED(rv)) return rv;
contentsGenerated = xulcontent->GetLazyState(nsXULElement::eTemplateContentsBuilt);
}
else {
// HTML content will _always_ have been generated up-front
@ -1182,18 +1178,14 @@ nsXULContentBuilder::CreateContainerContents(nsIContent* aElement,
// See if the element's templates contents have been generated:
// this prevents a re-entrant call from triggering another
// generation.
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
nsXULElement *xulcontent = nsXULElement::FromContent(aElement);
if (xulcontent) {
PRBool contentsGenerated;
rv = xulcontent->GetLazyState(nsIXULContent::eContainerContentsBuilt, contentsGenerated);
if (NS_FAILED(rv)) return rv;
if (contentsGenerated)
if (xulcontent->GetLazyState(nsXULElement::eContainerContentsBuilt))
return NS_OK;
// Now mark the element's contents as being generated so that
// any re-entrant calls don't trigger an infinite recursion.
rv = xulcontent->SetLazyState(nsIXULContent::eContainerContentsBuilt);
xulcontent->SetLazyState(nsXULElement::eContainerContentsBuilt);
}
else {
// HTML is always needs to be generated.
@ -1265,22 +1257,16 @@ nsXULContentBuilder::CreateTemplateContents(nsIContent* aElement,
// See if the element's templates contents have been generated:
// this prevents a re-entrant call from triggering another
// generation.
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
nsXULElement *xulcontent = nsXULElement::FromContent(aElement);
if (! xulcontent)
return NS_OK; // HTML content is _always_ generated up-front
PRBool contentsGenerated;
rv = xulcontent->GetLazyState(nsIXULContent::eTemplateContentsBuilt, contentsGenerated);
if (NS_FAILED(rv)) return rv;
if (contentsGenerated)
if (xulcontent->GetLazyState(nsXULElement::eTemplateContentsBuilt))
return NS_OK;
// Now mark the element's contents as being generated so that
// any re-entrant calls don't trigger an infinite recursion.
rv = xulcontent->SetLazyState(nsIXULContent::eTemplateContentsBuilt);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set template-contents-generated attribute");
if (NS_FAILED(rv)) return rv;
xulcontent->SetLazyState(nsXULElement::eTemplateContentsBuilt);
// Crawl up the content model until we find the "resource" element
// that spawned this template.
@ -1662,9 +1648,9 @@ nsXULContentBuilder::ReplaceMatch(nsIRDFResource* aMember,
// closed folder in a tree widget or on a menu that hasn't
// yet been dropped.
PRBool contentsGenerated = PR_TRUE;
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(content);
nsXULElement *xulcontent = nsXULElement::FromContent(content);
if (xulcontent)
xulcontent->GetLazyState(nsIXULContent::eContainerContentsBuilt, contentsGenerated);
contentsGenerated = xulcontent->GetLazyState(nsXULElement::eContainerContentsBuilt);
if (contentsGenerated) {
nsCOMPtr<nsIContent> tmpl;
@ -1884,15 +1870,11 @@ nsXULContentBuilder::RebuildAll()
// been generated. If so, short-circuit and bail; there's nothing
// for us to "rebuild" yet. They'll get built correctly the next
// time somebody asks for them.
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(mRoot);
nsXULElement *xulcontent = nsXULElement::FromContent(mRoot);
if (xulcontent) {
PRBool containerContentsBuilt = PR_FALSE;
xulcontent->GetLazyState(nsIXULContent::eContainerContentsBuilt, containerContentsBuilt);
if (! containerContentsBuilt)
return NS_OK;
}
if (xulcontent &&
!xulcontent->GetLazyState(nsXULElement::eContainerContentsBuilt))
return NS_OK;
// If we get here, then we've tried to generate content for this
// element. Remove it.
@ -1910,9 +1892,9 @@ nsXULContentBuilder::RebuildAll()
// Forces the XUL element to remember that it needs to
// re-generate its children next time around.
if (xulcontent) {
xulcontent->SetLazyState(nsIXULContent::eChildrenMustBeRebuilt);
xulcontent->ClearLazyState(nsIXULContent::eTemplateContentsBuilt);
xulcontent->ClearLazyState(nsIXULContent::eContainerContentsBuilt);
xulcontent->SetLazyState(nsXULElement::eChildrenMustBeRebuilt);
xulcontent->ClearLazyState(nsXULElement::eTemplateContentsBuilt);
xulcontent->ClearLazyState(nsXULElement::eContainerContentsBuilt);
}
// Now, regenerate both the template- and container-generated

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

@ -95,7 +95,6 @@
#include "nsIXULSortService.h"
#include "nsContentCID.h"
#include "nsRDFCID.h"
#include "nsIXULContent.h"
#include "nsXULContentUtils.h"
#include "nsRDFSort.h"
#include "nsRuleNetwork.h"
@ -832,7 +831,7 @@ nsXULTemplateBuilder::LoadDataSources(nsIDocument* doc)
// Now set the database on the element, so that script writers can
// access it.
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(mRoot);
nsXULElement *xulcontent = nsXULElement::FromContent(mRoot);
if (! xulcontent) {
// Hmm. This must be an HTML element. Try to set it as a
// JS property "by hand".

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

@ -79,10 +79,6 @@
#include "nsNetUtil.h"
#include "nsILocalFileMac.h"
#ifdef MOZ_XUL
#include "nsIXULContent.h"
#endif
#include "nsIDOMElement.h"
#include "nsIImageMac.h"
#include "nsIImage.h"
@ -141,8 +137,8 @@ nsDragService::ComputeGlobalRectFromFrame ( nsIDOMNode* aDOMNode, Rect & outScre
#if USE_TRANSLUCENT_DRAGGING && defined(MOZ_XUL)
// until bug 41237 is fixed, only do translucent dragging if the drag is in
// the chrome or it's a link.
nsCOMPtr<nsIXULContent> xulContent ( do_QueryInterface(aDOMNode) );
if ( !xulContent ) {
nsCOMPtr<nsIContent> content = do_QueryInterface(aDOMNode);
if (!content || !content->IsContentOfType(nsIContent::eXUL)) {
// the link node is the parent of the node we have (which is probably text or image).
nsCOMPtr<nsIDOMNode> parent;
aDOMNode->GetParentNode ( getter_AddRefs(parent) );