mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Added CreateElementWithNameSpace to proprietary document interface. Fixed GetTagName for HTML to uppercase tag names. Hooked up style rule addition and deletion to reconstruct frames. Fixed DOM generation problem
This commit is contained in:
parent
5a2239ba8a
commit
634e324575
@ -1569,6 +1569,14 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMNode methods
|
||||
//
|
||||
|
@ -280,6 +280,9 @@ public:
|
||||
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn);
|
||||
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets);
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName);
|
||||
|
@ -285,6 +285,14 @@ nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetTagName(nsString& aTagName)
|
||||
{
|
||||
nsGenericElement::GetTagName(aTagName);
|
||||
aTagName.ToUpperCase();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Implementation for nsIDOMHTMLElement
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetId(nsString& aId)
|
||||
|
@ -66,6 +66,7 @@ public:
|
||||
{
|
||||
return nsGenericElement::SetAttribute(aName, aValue);
|
||||
}
|
||||
nsresult GetTagName(nsString& aTagName);
|
||||
|
||||
// Implementation for nsIDOMHTMLElement
|
||||
nsresult GetId(nsString& aId);
|
||||
|
@ -1962,9 +1962,9 @@ CSSStyleSheetImpl::InsertRule(const nsString& aRule,
|
||||
nsICSSParser* css;
|
||||
nsresult result = NS_NewCSSParser(&css);
|
||||
if (NS_OK == result) {
|
||||
nsAutoString str(aRule);
|
||||
nsString* str = new nsString(aRule); // will be deleted by the input stream
|
||||
nsIUnicharInputStream* input = nsnull;
|
||||
result = NS_NewStringUnicharInputStream(&input, &str);
|
||||
result = NS_NewStringUnicharInputStream(&input, str);
|
||||
if (NS_OK == result) {
|
||||
nsICSSStyleSheet* tmp;
|
||||
css->SetStyleSheet(this);
|
||||
@ -1975,6 +1975,13 @@ CSSStyleSheetImpl::InsertRule(const nsString& aRule,
|
||||
NS_RELEASE(tmp);
|
||||
NS_RELEASE(input);
|
||||
*aReturn = mOrderedRules->Count();
|
||||
if (nsnull != mDocument) {
|
||||
nsICSSStyleRule* rule;
|
||||
|
||||
rule = (nsICSSStyleRule*)mOrderedRules->ElementAt(aIndex);
|
||||
mDocument->StyleRuleAdded(this, rule);
|
||||
NS_IF_RELEASE(rule);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(css);
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsExpatDTD.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
// XXX The XML world depends on the html atoms
|
||||
#include "nsHTMLAtoms.h"
|
||||
@ -513,22 +515,62 @@ nsXMLDocument::CreateProcessingInstruction(const nsString& aTarget, const nsStri
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static char kNameSpaceSeparator[] = ":";
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
// XXX Should actually check parse namespace, determine
|
||||
// current namespace scope and, potentially, create new
|
||||
// HTML content form tags with a HTML prefix.
|
||||
nsIXMLContent* content;
|
||||
nsIAtom* tag = NS_NewAtom(aTagName);
|
||||
nsresult rv = NS_NewXMLElement(&content, tag);
|
||||
NS_RELEASE(tag);
|
||||
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
PRInt32 nsID = kNameSpaceID_None;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if ((0 < aNameSpace.Length() && (nsnull != mNameSpaceManager))) {
|
||||
mNameSpaceManager->GetNameSpaceID(aNameSpace, nsID);
|
||||
}
|
||||
|
||||
nsIContent* content;
|
||||
if (nsID == kNameSpaceID_HTML) {
|
||||
nsIHTMLContent* htmlContent;
|
||||
|
||||
rv = NS_CreateHTMLElement(&htmlContent, aTagName);
|
||||
content = (nsIContent*)htmlContent;
|
||||
}
|
||||
else {
|
||||
nsIXMLContent* xmlContent;
|
||||
nsIAtom* tag;
|
||||
|
||||
tag = NS_NewAtom(aTagName);
|
||||
rv = NS_NewXMLElement(&xmlContent, tag);
|
||||
NS_RELEASE(tag);
|
||||
if (NS_OK == rv) {
|
||||
xmlContent->SetNameSpaceID(nsID);
|
||||
}
|
||||
content = (nsIXMLContent*)xmlContent;
|
||||
}
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,9 @@ public:
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD PrologElementAt(PRUint32 aOffset, nsIContent** aContent);
|
||||
|
@ -26,7 +26,7 @@ function sort(collection, key)
|
||||
|
||||
// Set user properties on the nodes in the collection
|
||||
// based on information found in its children. For example,
|
||||
// make a property "AUTHOR" based on the content of the
|
||||
// make a property "Author" based on the content of the
|
||||
// "Author" element found in the childNode list of the node.
|
||||
// This makes later sorting more efficient
|
||||
function collectInfo(nodes, propNames)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMStyleSheetCollection;
|
||||
|
||||
#define NS_IDOMNSDOCUMENT_IID \
|
||||
@ -35,16 +36,20 @@ public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMNSDOCUMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)=0;
|
||||
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMNSDOCUMENT \
|
||||
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets); \
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMNSDOCUMENT(_to) \
|
||||
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets) { return _to##GetStyleSheets(aStyleSheets); } \
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aReturn) { return _to##CreateElementWithNameSpace(aTagName, aNameSpace, aReturn); } \
|
||||
|
||||
|
||||
#endif // nsIDOMNSDocument_h__
|
||||
|
@ -27,6 +27,9 @@
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */
|
||||
|
||||
readonly attribute StyleSheetCollection styleSheets;
|
||||
Element createElementWithNameSpace(in DOMString tagName,
|
||||
in DOMString nameSpace)
|
||||
raises(DOMException);
|
||||
};
|
||||
|
||||
interface EventCapturer : EventReceiver {
|
||||
|
@ -1380,7 +1380,7 @@ EventCapturerCaptureEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
{
|
||||
nsIDOMWindow *privateThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMEventCapturer *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type EventCapturer");
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -1422,7 +1422,7 @@ EventCapturerReleaseEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
{
|
||||
nsIDOMWindow *privateThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMEventCapturer *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type EventCapturer");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -564,6 +564,52 @@ DocumentGetElementsByTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method CreateElementWithNameSpace
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NSDocumentCreateElementWithNameSpace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDocument *privateThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMNSDocument *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSDocumentIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type NSDocument");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElement* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->CreateElementWithNameSpace(b0, b1, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createElementWithNameSpace requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method CaptureEvent
|
||||
//
|
||||
@ -572,7 +618,7 @@ EventCapturerCaptureEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
{
|
||||
nsIDOMDocument *privateThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMEventCapturer *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type EventCapturer");
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -614,7 +660,7 @@ EventCapturerReleaseEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
{
|
||||
nsIDOMDocument *privateThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMEventCapturer *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kIEventCapturerIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type EventCapturer");
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -693,6 +739,7 @@ static JSFunctionSpec DocumentMethods[] =
|
||||
{"createAttribute", DocumentCreateAttribute, 1},
|
||||
{"createEntityReference", DocumentCreateEntityReference, 1},
|
||||
{"getElementsByTagName", DocumentGetElementsByTagName, 1},
|
||||
{"createElementWithNameSpace", NSDocumentCreateElementWithNameSpace, 2},
|
||||
{"captureEvent", EventCapturerCaptureEvent, 1},
|
||||
{"releaseEvent", EventCapturerReleaseEvent, 1},
|
||||
{0}
|
||||
|
@ -280,7 +280,7 @@ NSHTMLButtonElementBlur(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
{
|
||||
nsIDOMHTMLButtonElement *privateThis = (nsIDOMHTMLButtonElement*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMNSHTMLButtonElement *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLButtonElementIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLButtonElementIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type NSHTMLButtonElement");
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -319,7 +319,7 @@ NSHTMLButtonElementFocus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
{
|
||||
nsIDOMHTMLButtonElement *privateThis = (nsIDOMHTMLButtonElement*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMNSHTMLButtonElement *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLButtonElementIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLButtonElementIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type NSHTMLButtonElement");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ NSHTMLDocumentGetSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
||||
{
|
||||
nsIDOMHTMLDocument *privateThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMNSHTMLDocument *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLDocumentIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLDocumentIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -881,7 +881,7 @@ NSHTMLDocumentNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
{
|
||||
nsIDOMHTMLDocument *privateThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMNSHTMLDocument *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLDocumentIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLDocumentIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ NSHTMLFormElementNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
||||
{
|
||||
nsIDOMHTMLFormElement *privateThis = (nsIDOMHTMLFormElement*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMNSHTMLFormElement *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLFormElementIID, (void **)nativeThis)) {
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLFormElementIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type NSHTMLFormElement");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -836,7 +836,7 @@ static const char *kMethodBeginNonPrimaryStr = "\n\n"
|
||||
"{\n"
|
||||
" nsIDOM%s *privateThis = (nsIDOM%s*)JS_GetPrivate(cx, obj);\n"
|
||||
" nsIDOM%s *nativeThis = nsnull;\n"
|
||||
" if (NS_OK != privateThis->QueryInterface(kI%sIID, (void **)nativeThis)) {\n"
|
||||
" if (NS_OK != privateThis->QueryInterface(kI%sIID, (void **)&nativeThis)) {\n"
|
||||
" JS_ReportError(cx, \"Object must be of type %s\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n"
|
||||
|
@ -1688,7 +1688,8 @@ PresShell::StyleRuleAdded(nsIDocument *aDocument,
|
||||
EnterReflowLock();
|
||||
nsresult rv = mStyleSet->StyleRuleAdded(mPresContext, aStyleSheet, aStyleRule);
|
||||
ExitReflowLock();
|
||||
return rv;
|
||||
// XXX For now reconstruct everything
|
||||
return ReconstructFrames();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1699,7 +1700,8 @@ PresShell::StyleRuleRemoved(nsIDocument *aDocument,
|
||||
EnterReflowLock();
|
||||
nsresult rv = mStyleSet->StyleRuleRemoved(mPresContext, aStyleSheet, aStyleRule);
|
||||
ExitReflowLock();
|
||||
return rv;
|
||||
// XXX For now reconstruct everything
|
||||
return ReconstructFrames();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1569,6 +1569,14 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMNode methods
|
||||
//
|
||||
|
@ -280,6 +280,9 @@ public:
|
||||
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn);
|
||||
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets);
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName);
|
||||
|
@ -1688,7 +1688,8 @@ PresShell::StyleRuleAdded(nsIDocument *aDocument,
|
||||
EnterReflowLock();
|
||||
nsresult rv = mStyleSet->StyleRuleAdded(mPresContext, aStyleSheet, aStyleRule);
|
||||
ExitReflowLock();
|
||||
return rv;
|
||||
// XXX For now reconstruct everything
|
||||
return ReconstructFrames();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1699,7 +1700,8 @@ PresShell::StyleRuleRemoved(nsIDocument *aDocument,
|
||||
EnterReflowLock();
|
||||
nsresult rv = mStyleSet->StyleRuleRemoved(mPresContext, aStyleSheet, aStyleRule);
|
||||
ExitReflowLock();
|
||||
return rv;
|
||||
// XXX For now reconstruct everything
|
||||
return ReconstructFrames();
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,6 +285,14 @@ nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetTagName(nsString& aTagName)
|
||||
{
|
||||
nsGenericElement::GetTagName(aTagName);
|
||||
aTagName.ToUpperCase();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Implementation for nsIDOMHTMLElement
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetId(nsString& aId)
|
||||
|
@ -66,6 +66,7 @@ public:
|
||||
{
|
||||
return nsGenericElement::SetAttribute(aName, aValue);
|
||||
}
|
||||
nsresult GetTagName(nsString& aTagName);
|
||||
|
||||
// Implementation for nsIDOMHTMLElement
|
||||
nsresult GetId(nsString& aId);
|
||||
|
@ -1962,9 +1962,9 @@ CSSStyleSheetImpl::InsertRule(const nsString& aRule,
|
||||
nsICSSParser* css;
|
||||
nsresult result = NS_NewCSSParser(&css);
|
||||
if (NS_OK == result) {
|
||||
nsAutoString str(aRule);
|
||||
nsString* str = new nsString(aRule); // will be deleted by the input stream
|
||||
nsIUnicharInputStream* input = nsnull;
|
||||
result = NS_NewStringUnicharInputStream(&input, &str);
|
||||
result = NS_NewStringUnicharInputStream(&input, str);
|
||||
if (NS_OK == result) {
|
||||
nsICSSStyleSheet* tmp;
|
||||
css->SetStyleSheet(this);
|
||||
@ -1975,6 +1975,13 @@ CSSStyleSheetImpl::InsertRule(const nsString& aRule,
|
||||
NS_RELEASE(tmp);
|
||||
NS_RELEASE(input);
|
||||
*aReturn = mOrderedRules->Count();
|
||||
if (nsnull != mDocument) {
|
||||
nsICSSStyleRule* rule;
|
||||
|
||||
rule = (nsICSSStyleRule*)mOrderedRules->ElementAt(aIndex);
|
||||
mDocument->StyleRuleAdded(this, rule);
|
||||
NS_IF_RELEASE(rule);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(css);
|
||||
|
@ -1962,9 +1962,9 @@ CSSStyleSheetImpl::InsertRule(const nsString& aRule,
|
||||
nsICSSParser* css;
|
||||
nsresult result = NS_NewCSSParser(&css);
|
||||
if (NS_OK == result) {
|
||||
nsAutoString str(aRule);
|
||||
nsString* str = new nsString(aRule); // will be deleted by the input stream
|
||||
nsIUnicharInputStream* input = nsnull;
|
||||
result = NS_NewStringUnicharInputStream(&input, &str);
|
||||
result = NS_NewStringUnicharInputStream(&input, str);
|
||||
if (NS_OK == result) {
|
||||
nsICSSStyleSheet* tmp;
|
||||
css->SetStyleSheet(this);
|
||||
@ -1975,6 +1975,13 @@ CSSStyleSheetImpl::InsertRule(const nsString& aRule,
|
||||
NS_RELEASE(tmp);
|
||||
NS_RELEASE(input);
|
||||
*aReturn = mOrderedRules->Count();
|
||||
if (nsnull != mDocument) {
|
||||
nsICSSStyleRule* rule;
|
||||
|
||||
rule = (nsICSSStyleRule*)mOrderedRules->ElementAt(aIndex);
|
||||
mDocument->StyleRuleAdded(this, rule);
|
||||
NS_IF_RELEASE(rule);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(css);
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "prprf.h"
|
||||
#include "prmem.h"
|
||||
|
||||
@ -124,8 +125,13 @@ nsGenericXMLElement::ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom* nameAtom = NS_NewAtom(attrName);
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
|
||||
if ((nsnull != nameSpaceAtom) && (nsnull != mNameSpace)) {
|
||||
mNameSpace->FindNameSpaceID(nameSpaceAtom, aNameSpaceID);
|
||||
if (nsnull != nameSpaceAtom) {
|
||||
if (nameSpaceAtom == nsLayoutAtoms::xmlNameSpace) {
|
||||
aNameSpaceID = kNameSpaceID_XML;
|
||||
}
|
||||
else if (nsnull != mNameSpace) {
|
||||
mNameSpace->FindNameSpaceID(nameSpaceAtom, aNameSpaceID);
|
||||
}
|
||||
}
|
||||
|
||||
aName = nameAtom;
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsExpatDTD.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
// XXX The XML world depends on the html atoms
|
||||
#include "nsHTMLAtoms.h"
|
||||
@ -513,22 +515,62 @@ nsXMLDocument::CreateProcessingInstruction(const nsString& aTarget, const nsStri
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static char kNameSpaceSeparator[] = ":";
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
// XXX Should actually check parse namespace, determine
|
||||
// current namespace scope and, potentially, create new
|
||||
// HTML content form tags with a HTML prefix.
|
||||
nsIXMLContent* content;
|
||||
nsIAtom* tag = NS_NewAtom(aTagName);
|
||||
nsresult rv = NS_NewXMLElement(&content, tag);
|
||||
NS_RELEASE(tag);
|
||||
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
PRInt32 nsID = kNameSpaceID_None;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if ((0 < aNameSpace.Length() && (nsnull != mNameSpaceManager))) {
|
||||
mNameSpaceManager->GetNameSpaceID(aNameSpace, nsID);
|
||||
}
|
||||
|
||||
nsIContent* content;
|
||||
if (nsID == kNameSpaceID_HTML) {
|
||||
nsIHTMLContent* htmlContent;
|
||||
|
||||
rv = NS_CreateHTMLElement(&htmlContent, aTagName);
|
||||
content = (nsIContent*)htmlContent;
|
||||
}
|
||||
else {
|
||||
nsIXMLContent* xmlContent;
|
||||
nsIAtom* tag;
|
||||
|
||||
tag = NS_NewAtom(aTagName);
|
||||
rv = NS_NewXMLElement(&xmlContent, tag);
|
||||
NS_RELEASE(tag);
|
||||
if (NS_OK == rv) {
|
||||
xmlContent->SetNameSpaceID(nsID);
|
||||
}
|
||||
content = (nsIXMLContent*)xmlContent;
|
||||
}
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,9 @@ public:
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD PrologElementAt(PRUint32 aOffset, nsIContent** aContent);
|
||||
|
@ -26,7 +26,7 @@ function sort(collection, key)
|
||||
|
||||
// Set user properties on the nodes in the collection
|
||||
// based on information found in its children. For example,
|
||||
// make a property "AUTHOR" based on the content of the
|
||||
// make a property "Author" based on the content of the
|
||||
// "Author" element found in the childNode list of the node.
|
||||
// This makes later sorting more efficient
|
||||
function collectInfo(nodes, propNames)
|
||||
|
Loading…
Reference in New Issue
Block a user