This commit is contained in:
hyatt%netscape.com 2000-03-23 22:17:37 +00:00
Родитель 78540d4142
Коммит 16fdea9f7b
10 изменённых файлов: 168 добавлений и 32 удалений

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

@ -82,6 +82,7 @@
#include "nsIXULDocument.h"
#include "nsIXULPopupListener.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIXBLService.h"
#include "nsLayoutCID.h"
#include "nsRDFCID.h"
#include "nsRDFDOMNodeList.h"
@ -300,7 +301,6 @@ nsIAtom* nsXULElement::kRadioAtom;
nsIAtom* nsXULElement::kRadioGroupAtom;
nsIAtom* nsXULElement::kMenuListAtom;
nsIAtom* nsXULElement::kMenuButtonAtom;
nsIAtom* nsXULElement::kTextAreaAtom;
nsIAtom* nsXULElement::kTextFieldAtom;
#ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING
@ -374,7 +374,6 @@ nsXULElement::Init()
kRadioGroupAtom = NS_NewAtom("radiogroup");
kMenuListAtom = NS_NewAtom("menulist");
kMenuButtonAtom = NS_NewAtom("menubutton");
kTextAreaAtom = NS_NewAtom("textarea");
kTextFieldAtom = NS_NewAtom("textfield");
rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID,
@ -459,8 +458,7 @@ nsXULElement::~nsXULElement()
NS_IF_RELEASE(kMenuListAtom);
NS_IF_RELEASE(kMenuButtonAtom);
NS_IF_RELEASE(kTextFieldAtom);
NS_IF_RELEASE(kTextAreaAtom);
NS_IF_RELEASE(gNameSpaceManager);
if (gXULUtils) {
@ -3868,6 +3866,50 @@ nsXULElement::GetControllers(nsIControllers** aResult)
return NS_OK;
}
nsresult
nsXULElement::GetAnonymousContent(nsIDOMNodeList** aResult)
{
nsresult rv;
nsRDFDOMNodeList* elements;
// Addref happens on following line in the Create call.
if (NS_FAILED(rv = nsRDFDOMNodeList::Create(&elements))) {
NS_ERROR("unable to create node list");
return rv;
}
*aResult = elements;
// Use the XBL service to get a content list.
NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv);
if (!xblService)
return rv;
// Retrieve the anonymous content that we should build.
nsCOMPtr<nsISupportsArray> anonymousItems;
nsCOMPtr<nsIContent> childElement;
xblService->GetContentList(NS_STATIC_CAST(nsIStyledContent*, this), getter_AddRefs(anonymousItems), getter_AddRefs(childElement));
if (!anonymousItems)
return NS_OK;
PRUint32 count = 0;
anonymousItems->Count(&count);
for (PRUint32 i=0; i < count; i++)
{
// get our child's content and set its parent to our content
nsCOMPtr<nsISupports> node;
anonymousItems->GetElementAt(i,getter_AddRefs(node));
nsCOMPtr<nsIDOMNode> content(do_QueryInterface(node));
if (content)
elements->AppendNode(content);
}
return NS_OK;
}
// Methods for setting/getting attributes from nsIDOMXULElement
nsresult
nsXULElement::GetId(nsString& aId)
@ -4055,17 +4097,22 @@ nsXULElement::RemoveFocus(nsIPresContext* aPresContext)
return NS_OK;
}
PRBool
nsXULElement::IsFocusable(nsIAtom* aTag)
{
return (aTag == kTitledButtonAtom) || (aTag == kTreeAtom) || (aTag == kCheckboxAtom) || (aTag == kRadioAtom) ||
(aTag == kMenuListAtom) || (aTag == kMenuButtonAtom) || (aTag == kTextFieldAtom);
}
PRBool
nsXULElement::IsFocusableContent()
{
// XXX This method sucks. I mean it. It really really sucks.
nsCOMPtr<nsIAtom> tag;
GetBaseTag(getter_AddRefs(tag));
if (!tag)
tag = Tag();
return (tag.get() == kTitledButtonAtom) || (tag.get() == kTreeAtom) || (tag.get() == kCheckboxAtom) || (tag.get() == kRadioAtom) ||
(tag.get() == kMenuListAtom) || (tag.get() == kMenuButtonAtom) || (tag.get() == kTextFieldAtom) ||
(tag.get() == kTextAreaAtom);
// We HAVE to fix this before we ship.
nsCOMPtr<nsIAtom> baseTag;
GetBaseTag(getter_AddRefs(baseTag));
return IsFocusable(Tag()) || IsFocusable(baseTag);
}
// nsIBindableContent Interface

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

@ -359,7 +359,6 @@ protected:
static nsIAtom* kWindowAtom;
static nsIAtom* kMenuButtonAtom;
static nsIAtom* kMenuListAtom;
static nsIAtom* kTextAreaAtom;
static nsIAtom* kTextFieldAtom;
public:
@ -546,6 +545,8 @@ protected:
// Helper routine that crawls a parent chain looking for a tree element.
NS_IMETHOD GetParentTree(nsIDOMXULTreeElement** aTreeElement);
// XXX Both of these methods must die.
static PRBool IsFocusable(nsIAtom* aTag);
PRBool IsFocusableContent();
nsresult AddPopupListener(nsIAtom* aName);

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

@ -8,6 +8,7 @@ interface XULElement : Element {
attribute xpidl nsIRDFCompositeDataSource database;
readonly attribute xpidl nsIRDFResource resource;
readonly attribute xpidl nsIControllers controllers;
readonly attribute NodeList anonymousContent;
void addBroadcastListener(in DOMString attr, in Element element);
void removeBroadcastListener(in DOMString attr, in Element element);

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

@ -33,8 +33,8 @@ class nsIDOMElement;
class nsIDOMCSSStyleDeclaration;
class nsIRDFCompositeDataSource;
class nsIRDFResource;
class nsIControllers;
class nsIDOMNodeList;
class nsIControllers;
#define NS_IDOMXULELEMENT_IID \
{ 0x574ed81, 0xc088, 0x11d2, \
@ -59,6 +59,8 @@ public:
NS_IMETHOD GetControllers(nsIControllers** aControllers)=0;
NS_IMETHOD GetAnonymousContent(nsIDOMNodeList** aAnonymousContent)=0;
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
@ -85,6 +87,7 @@ public:
NS_IMETHOD SetDatabase(nsIRDFCompositeDataSource* aDatabase); \
NS_IMETHOD GetResource(nsIRDFResource** aResource); \
NS_IMETHOD GetControllers(nsIControllers** aControllers); \
NS_IMETHOD GetAnonymousContent(nsIDOMNodeList** aAnonymousContent); \
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
NS_IMETHOD DoCommand(); \
@ -105,6 +108,7 @@ public:
NS_IMETHOD SetDatabase(nsIRDFCompositeDataSource* aDatabase) { return _to SetDatabase(aDatabase); } \
NS_IMETHOD GetResource(nsIRDFResource** aResource) { return _to GetResource(aResource); } \
NS_IMETHOD GetControllers(nsIControllers** aControllers) { return _to GetControllers(aControllers); } \
NS_IMETHOD GetAnonymousContent(nsIDOMNodeList** aAnonymousContent) { return _to GetAnonymousContent(aAnonymousContent); } \
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to AddBroadcastListener(aAttr, aElement); } \
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to RemoveBroadcastListener(aAttr, aElement); } \
NS_IMETHOD DoCommand() { return _to DoCommand(); } \

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

@ -39,8 +39,8 @@
#include "nsIRDFCompositeDataSource.h"
#include "nsIDOMXULElement.h"
#include "nsIRDFResource.h"
#include "nsIControllers.h"
#include "nsIDOMNodeList.h"
#include "nsIControllers.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
@ -51,8 +51,8 @@ static NS_DEFINE_IID(kICSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID);
static NS_DEFINE_IID(kIRDFCompositeDataSourceIID, NS_IRDFCOMPOSITEDATASOURCE_IID);
static NS_DEFINE_IID(kIXULElementIID, NS_IDOMXULELEMENT_IID);
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID);
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID);
//
// XULElement property ids
@ -63,7 +63,8 @@ enum XULElement_slots {
XULELEMENT_STYLE = -3,
XULELEMENT_DATABASE = -4,
XULELEMENT_RESOURCE = -5,
XULELEMENT_CONTROLLERS = -6
XULELEMENT_CONTROLLERS = -6,
XULELEMENT_ANONYMOUSCONTENT = -7
};
/***********************************************************************/
@ -162,6 +163,19 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case XULELEMENT_ANONYMOUSCONTENT:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULELEMENT_ANONYMOUSCONTENT, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsIDOMNodeList* prop;
rv = a->GetAnonymousContent(&prop);
if (NS_SUCCEEDED(rv)) {
// get the js object
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp);
}
}
break;
}
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);
}
@ -591,6 +605,7 @@ static JSPropertySpec XULElementProperties[] =
{"database", XULELEMENT_DATABASE, JSPROP_ENUMERATE},
{"resource", XULELEMENT_RESOURCE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"controllers", XULELEMENT_CONTROLLERS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"anonymousContent", XULELEMENT_ANONYMOUSCONTENT, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};

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

@ -8,6 +8,7 @@ interface XULElement : Element {
attribute xpidl nsIRDFCompositeDataSource database;
readonly attribute xpidl nsIRDFResource resource;
readonly attribute xpidl nsIControllers controllers;
readonly attribute NodeList anonymousContent;
void addBroadcastListener(in DOMString attr, in Element element);
void removeBroadcastListener(in DOMString attr, in Element element);

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

@ -33,8 +33,8 @@ class nsIDOMElement;
class nsIDOMCSSStyleDeclaration;
class nsIRDFCompositeDataSource;
class nsIRDFResource;
class nsIControllers;
class nsIDOMNodeList;
class nsIControllers;
#define NS_IDOMXULELEMENT_IID \
{ 0x574ed81, 0xc088, 0x11d2, \
@ -59,6 +59,8 @@ public:
NS_IMETHOD GetControllers(nsIControllers** aControllers)=0;
NS_IMETHOD GetAnonymousContent(nsIDOMNodeList** aAnonymousContent)=0;
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
@ -85,6 +87,7 @@ public:
NS_IMETHOD SetDatabase(nsIRDFCompositeDataSource* aDatabase); \
NS_IMETHOD GetResource(nsIRDFResource** aResource); \
NS_IMETHOD GetControllers(nsIControllers** aControllers); \
NS_IMETHOD GetAnonymousContent(nsIDOMNodeList** aAnonymousContent); \
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
NS_IMETHOD DoCommand(); \
@ -105,6 +108,7 @@ public:
NS_IMETHOD SetDatabase(nsIRDFCompositeDataSource* aDatabase) { return _to SetDatabase(aDatabase); } \
NS_IMETHOD GetResource(nsIRDFResource** aResource) { return _to GetResource(aResource); } \
NS_IMETHOD GetControllers(nsIControllers** aControllers) { return _to GetControllers(aControllers); } \
NS_IMETHOD GetAnonymousContent(nsIDOMNodeList** aAnonymousContent) { return _to GetAnonymousContent(aAnonymousContent); } \
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to AddBroadcastListener(aAttr, aElement); } \
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to RemoveBroadcastListener(aAttr, aElement); } \
NS_IMETHOD DoCommand() { return _to DoCommand(); } \

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

@ -39,8 +39,8 @@
#include "nsIRDFCompositeDataSource.h"
#include "nsIDOMXULElement.h"
#include "nsIRDFResource.h"
#include "nsIControllers.h"
#include "nsIDOMNodeList.h"
#include "nsIControllers.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
@ -51,8 +51,8 @@ static NS_DEFINE_IID(kICSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID);
static NS_DEFINE_IID(kIRDFCompositeDataSourceIID, NS_IRDFCOMPOSITEDATASOURCE_IID);
static NS_DEFINE_IID(kIXULElementIID, NS_IDOMXULELEMENT_IID);
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID);
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID);
//
// XULElement property ids
@ -63,7 +63,8 @@ enum XULElement_slots {
XULELEMENT_STYLE = -3,
XULELEMENT_DATABASE = -4,
XULELEMENT_RESOURCE = -5,
XULELEMENT_CONTROLLERS = -6
XULELEMENT_CONTROLLERS = -6,
XULELEMENT_ANONYMOUSCONTENT = -7
};
/***********************************************************************/
@ -162,6 +163,19 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case XULELEMENT_ANONYMOUSCONTENT:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULELEMENT_ANONYMOUSCONTENT, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsIDOMNodeList* prop;
rv = a->GetAnonymousContent(&prop);
if (NS_SUCCEEDED(rv)) {
// get the js object
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp);
}
}
break;
}
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);
}
@ -591,6 +605,7 @@ static JSPropertySpec XULElementProperties[] =
{"database", XULELEMENT_DATABASE, JSPROP_ENUMERATE},
{"resource", XULELEMENT_RESOURCE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"controllers", XULELEMENT_CONTROLLERS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"anonymousContent", XULELEMENT_ANONYMOUSCONTENT, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};

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

@ -82,6 +82,7 @@
#include "nsIXULDocument.h"
#include "nsIXULPopupListener.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIXBLService.h"
#include "nsLayoutCID.h"
#include "nsRDFCID.h"
#include "nsRDFDOMNodeList.h"
@ -300,7 +301,6 @@ nsIAtom* nsXULElement::kRadioAtom;
nsIAtom* nsXULElement::kRadioGroupAtom;
nsIAtom* nsXULElement::kMenuListAtom;
nsIAtom* nsXULElement::kMenuButtonAtom;
nsIAtom* nsXULElement::kTextAreaAtom;
nsIAtom* nsXULElement::kTextFieldAtom;
#ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING
@ -374,7 +374,6 @@ nsXULElement::Init()
kRadioGroupAtom = NS_NewAtom("radiogroup");
kMenuListAtom = NS_NewAtom("menulist");
kMenuButtonAtom = NS_NewAtom("menubutton");
kTextAreaAtom = NS_NewAtom("textarea");
kTextFieldAtom = NS_NewAtom("textfield");
rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID,
@ -459,8 +458,7 @@ nsXULElement::~nsXULElement()
NS_IF_RELEASE(kMenuListAtom);
NS_IF_RELEASE(kMenuButtonAtom);
NS_IF_RELEASE(kTextFieldAtom);
NS_IF_RELEASE(kTextAreaAtom);
NS_IF_RELEASE(gNameSpaceManager);
if (gXULUtils) {
@ -3868,6 +3866,50 @@ nsXULElement::GetControllers(nsIControllers** aResult)
return NS_OK;
}
nsresult
nsXULElement::GetAnonymousContent(nsIDOMNodeList** aResult)
{
nsresult rv;
nsRDFDOMNodeList* elements;
// Addref happens on following line in the Create call.
if (NS_FAILED(rv = nsRDFDOMNodeList::Create(&elements))) {
NS_ERROR("unable to create node list");
return rv;
}
*aResult = elements;
// Use the XBL service to get a content list.
NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv);
if (!xblService)
return rv;
// Retrieve the anonymous content that we should build.
nsCOMPtr<nsISupportsArray> anonymousItems;
nsCOMPtr<nsIContent> childElement;
xblService->GetContentList(NS_STATIC_CAST(nsIStyledContent*, this), getter_AddRefs(anonymousItems), getter_AddRefs(childElement));
if (!anonymousItems)
return NS_OK;
PRUint32 count = 0;
anonymousItems->Count(&count);
for (PRUint32 i=0; i < count; i++)
{
// get our child's content and set its parent to our content
nsCOMPtr<nsISupports> node;
anonymousItems->GetElementAt(i,getter_AddRefs(node));
nsCOMPtr<nsIDOMNode> content(do_QueryInterface(node));
if (content)
elements->AppendNode(content);
}
return NS_OK;
}
// Methods for setting/getting attributes from nsIDOMXULElement
nsresult
nsXULElement::GetId(nsString& aId)
@ -4055,17 +4097,22 @@ nsXULElement::RemoveFocus(nsIPresContext* aPresContext)
return NS_OK;
}
PRBool
nsXULElement::IsFocusable(nsIAtom* aTag)
{
return (aTag == kTitledButtonAtom) || (aTag == kTreeAtom) || (aTag == kCheckboxAtom) || (aTag == kRadioAtom) ||
(aTag == kMenuListAtom) || (aTag == kMenuButtonAtom) || (aTag == kTextFieldAtom);
}
PRBool
nsXULElement::IsFocusableContent()
{
// XXX This method sucks. I mean it. It really really sucks.
nsCOMPtr<nsIAtom> tag;
GetBaseTag(getter_AddRefs(tag));
if (!tag)
tag = Tag();
return (tag.get() == kTitledButtonAtom) || (tag.get() == kTreeAtom) || (tag.get() == kCheckboxAtom) || (tag.get() == kRadioAtom) ||
(tag.get() == kMenuListAtom) || (tag.get() == kMenuButtonAtom) || (tag.get() == kTextFieldAtom) ||
(tag.get() == kTextAreaAtom);
// We HAVE to fix this before we ship.
nsCOMPtr<nsIAtom> baseTag;
GetBaseTag(getter_AddRefs(baseTag));
return IsFocusable(Tag()) || IsFocusable(baseTag);
}
// nsIBindableContent Interface

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

@ -359,7 +359,6 @@ protected:
static nsIAtom* kWindowAtom;
static nsIAtom* kMenuButtonAtom;
static nsIAtom* kMenuListAtom;
static nsIAtom* kTextAreaAtom;
static nsIAtom* kTextFieldAtom;
public:
@ -546,6 +545,8 @@ protected:
// Helper routine that crawls a parent chain looking for a tree element.
NS_IMETHOD GetParentTree(nsIDOMXULTreeElement** aTreeElement);
// XXX Both of these methods must die.
static PRBool IsFocusable(nsIAtom* aTag);
PRBool IsFocusableContent();
nsresult AddPopupListener(nsIAtom* aName);