This commit is contained in:
peterl%netscape.com 1998-12-20 01:21:23 +00:00
Родитель 7dd7b861c5
Коммит 887cd5f867
195 изменённых файлов: 2030 добавлений и 2299 удалений

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

@ -21,6 +21,9 @@
#include "nsIDOMNode.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocument.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms
nsContentList::nsContentList(nsIDocument *aDocument)
{
@ -197,9 +200,9 @@ nsContentList::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
if (nsnull != content) {
nsAutoString name;
// XXX Should it be an EqualsIgnoreCase?
if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
if (((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name))) ||
((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name)))) {
return content->QueryInterface(kIDOMNodeIID, (void **)aReturn);
}

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

@ -55,7 +55,6 @@
#include "prmem.h"
#include "nsHTMLAtoms.h"
#include "nsIHTMLAttributes.h"
NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
@ -366,7 +365,13 @@ nsDOMAttributeMap::GetNamedItem(const nsString &aAttrName,
nsIDOMNode** aAttribute)
{
nsAutoString value;
mContent->GetAttribute(aAttrName, value);
// XXX need to parse namespace fom attribute name
// XXX need to uppercace name only if HTML namespace
nsAutoString upper;
aAttrName.ToUpperCase(upper);
nsIAtom* nameAtom = NS_NewAtom(upper);
mContent->GetAttribute(kNameSpaceID_HTML, nameAtom, value);
NS_RELEASE(nameAtom);
*aAttribute = (nsIDOMNode *) new nsDOMAttribute(aAttrName, value);
return NS_OK;
}
@ -387,7 +392,12 @@ nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
attribute->GetValue(value);
NS_RELEASE(attribute);
mContent->SetAttribute(name, value, PR_TRUE);
// XXX need to parse namespace from attribute name
// XXX also need to uppercase name only if HTML namespace
name.ToUpperCase();
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->SetAttribute(kNameSpaceID_HTML, nameAtom, value, PR_TRUE);
NS_RELEASE(nameAtom);
return NS_OK;
}
@ -396,10 +406,12 @@ nsDOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
{
nsresult res = GetNamedItem(aName, aReturn);
if (NS_OK == res) {
// XXX need to parse namespace from attribute name
// XXX need to uppercase only if HTML namespace
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr, PR_TRUE);
mContent->UnsetAttribute(kNameSpaceID_HTML, attr, PR_TRUE);
}
return res;
@ -409,27 +421,19 @@ nsresult
nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{
nsresult res = NS_ERROR_FAILURE;
nsAutoString name, value;
nsISupportsArray *attributes = nsnull;
if (NS_OK == NS_NewISupportsArray(&attributes)) {
PRInt32 count;
mContent->GetAllAttributeNames(attributes, count);
if (count > 0) {
if ((PRInt32)aIndex < count) {
nsISupports *att = attributes->ElementAt(aIndex);
static NS_DEFINE_IID(kIAtom, NS_IATOM_IID);
nsIAtom *atName = nsnull;
if (nsnull != att && NS_OK == att->QueryInterface(kIAtom, (void**)&atName)) {
atName->ToString(name);
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(name, value)) {
*aReturn = (nsIDOMNode *)new nsDOMAttribute(name, value);
res = NS_OK;
}
NS_RELEASE(atName);
}
}
PRInt32 nameSpaceID;
nsIAtom* nameAtom = nsnull;
if (NS_SUCCEEDED(mContent->GetAttributeNameAt(aIndex, nameSpaceID, nameAtom))) {
nsAutoString value;
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(nameSpaceID, nameAtom, value)) {
// XXX need to prefix namespace if present
nsAutoString name;
nameAtom->ToString(name);
*aReturn = (nsIDOMNode *)new nsDOMAttribute(name, value);
res = NS_OK;
}
NS_RELEASE(attributes);
NS_RELEASE(nameAtom);
}
return res;
@ -745,6 +749,8 @@ nsGenericElement::GetTagName(nsString& aTagName)
{
aTagName.Truncate();
if (nsnull != mTag) {
// note that we assume no namespace here, subclasses that support
// namespaces must override
mTag->ToString(aTagName);
}
return NS_OK;
@ -753,37 +759,52 @@ nsGenericElement::GetTagName(nsString& aTagName)
nsresult
nsGenericElement::GetDOMAttribute(const nsString& aName, nsString& aReturn)
{
mContent->GetAttribute(aName, aReturn);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
mContent->GetAttribute(kNameSpaceID_None, nameAtom, aReturn);
NS_RELEASE(nameAtom);
return NS_OK;
}
nsresult
nsGenericElement::SetDOMAttribute(const nsString& aName,
const nsString& aValue)
const nsString& aValue)
{
mContent->SetAttribute(aName, aValue, PR_TRUE);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
mContent->SetAttribute(kNameSpaceID_None, nameAtom, aValue, PR_TRUE);
NS_RELEASE(nameAtom);
return NS_OK;
}
nsresult
nsGenericElement::RemoveAttribute(const nsString& aName)
{
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr, PR_TRUE);
NS_RELEASE(attr);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
mContent->UnsetAttribute(kNameSpaceID_None, nameAtom, PR_TRUE);
NS_RELEASE(nameAtom);
return NS_OK;
}
nsresult
nsGenericElement::GetAttributeNode(const nsString& aName,
nsIDOMAttr** aReturn)
nsIDOMAttr** aReturn)
{
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
nsAutoString value;
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(aName, value)) {
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(kNameSpaceID_None, nameAtom, value)) {
*aReturn = new nsDOMAttribute(aName, value);
}
else {
*aReturn = nsnull;
}
NS_RELEASE(nameAtom);
return NS_OK;
}
@ -801,7 +822,11 @@ nsGenericElement::SetAttributeNode(nsIDOMAttr* aAttribute,
if (NS_OK == res) {
res = aAttribute->GetValue(value);
if (NS_OK == res) {
mContent->SetAttribute(name, value, PR_TRUE);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->SetAttribute(kNameSpaceID_None, nameAtom, value, PR_TRUE);
NS_RELEASE(nameAtom);
}
}
}
@ -820,10 +845,11 @@ nsGenericElement::RemoveAttributeNode(nsIDOMAttr* aAttribute,
nsAutoString name;
res = aAttribute->GetName(name);
if (NS_OK == res) {
nsAutoString upper;
name.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr, PR_TRUE);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->UnsetAttribute(kNameSpaceID_None, nameAtom, PR_TRUE);
NS_RELEASE(nameAtom);
}
}
@ -1454,57 +1480,25 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute,
//----------------------------------------------------------------------
// Nothing for now, though XMLContent might want to define this
// to deal with certain types of attributes with the HTML namespace
static void
MapAttributesInto(nsIHTMLAttributes* aAttributes,
nsIStyleContext* aContext,
nsIPresContext* aPresContext)
struct nsGenericAttribute
{
}
// XXX This routine was copied from EnsureWriteableAttributes and
// modified slightly. Could be shared code.
static nsresult EnsureWritableAttributes(nsIContent* aContent,
nsIHTMLAttributes*& aAttributes,
PRBool aCreate)
{
nsresult result = NS_OK;
if (nsnull == aAttributes) {
if (PR_TRUE == aCreate) {
if (NS_OK == result) {
result = NS_NewHTMLAttributes(&aAttributes, nsnull, &MapAttributesInto);
if (NS_OK == result) {
aAttributes->AddContentRef();
}
}
}
nsGenericAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue)
: mNameSpaceID(aNameSpaceID),
mName(aName),
mValue(aValue)
{
NS_IF_ADDREF(mName);
}
else {
// To allow for the case where the attribute set is shared
// between content.
PRInt32 contentRefCount;
aAttributes->GetContentRefCount(contentRefCount);
if (1 < contentRefCount) {
nsIHTMLAttributes* attrs;
result = aAttributes->Clone(&attrs);
if (NS_OK == result) {
aAttributes->ReleaseContentRef();
NS_RELEASE(aAttributes);
aAttributes = attrs;
aAttributes->AddContentRef();
}
}
}
return result;
}
static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes)
{
aAttributes->ReleaseContentRef();
NS_RELEASE(aAttributes);
}
~nsGenericAttribute(void)
{
NS_IF_RELEASE(mName);
}
PRInt32 mNameSpaceID;
nsIAtom* mName;
nsString mValue;
};
nsGenericContainerElement::nsGenericContainerElement()
{
@ -1513,13 +1507,19 @@ nsGenericContainerElement::nsGenericContainerElement()
nsGenericContainerElement::~nsGenericContainerElement()
{
PRInt32 n = mChildren.Count();
for (PRInt32 i = 0; i < n; i++) {
nsIContent* kid = (nsIContent *)mChildren.ElementAt(i);
PRInt32 count = mChildren.Count();
PRInt32 index;
for (index = 0; index < count; index++) {
nsIContent* kid = (nsIContent *)mChildren.ElementAt(index);
NS_RELEASE(kid);
}
if (nsnull != mAttributes) {
ReleaseAttributes(mAttributes);
count = mAttributes->Count();
for (index = 0; index < count; index++) {
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
delete attr;
}
delete mAttributes;
}
}
@ -1823,162 +1823,173 @@ nsGenericContainerElement::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aRetu
nsresult
nsGenericContainerElement::SetAttribute(const nsString& aName,
nsGenericContainerElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue,
PRBool aNotify)
{
nsresult rv = NS_OK;;
nsIAtom* attr = NS_NewAtom(aName);
rv = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
PRInt32 count;
rv = mAttributes->SetAttribute(attr, aValue, count);
if (0 == count) {
ReleaseAttributes(mAttributes);
}
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, attr, NS_STYLE_HINT_UNKNOWN);
}
NS_ASSERTION(kNameSpaceID_Unknown != aNameSpaceID, "must have name space ID");
if (kNameSpaceID_Unknown == aNameSpaceID) {
return NS_ERROR_ILLEGAL_VALUE;
}
NS_ASSERTION(nsnull != aName, "must have attribute name");
if (nsnull == aName) {
return NS_ERROR_NULL_POINTER;
}
NS_RELEASE(attr);
return rv;
}
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
nsresult
nsGenericContainerElement::GetAttribute(const nsString& aName,
nsString& aResult) const
{
nsresult rv = NS_OK;;
nsIAtom* attr = NS_NewAtom(aName);
nsHTMLValue value;
char cbuf[20];
nscolor color;
if (nsnull == mAttributes) {
mAttributes = new nsVoidArray();
}
if (nsnull != mAttributes) {
rv = mAttributes->GetAttribute(attr, value);
if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
// XXX Again this is code that is copied from nsGenericHTMLElement
// and could potentially be shared. In any case, we don't expect
// anything that's not a string.
// Provide default conversions for most everything
switch (value.GetUnit()) {
case eHTMLUnit_Empty:
aResult.Truncate();
break;
case eHTMLUnit_String:
case eHTMLUnit_Null:
value.GetStringValue(aResult);
break;
case eHTMLUnit_Integer:
aResult.Truncate();
aResult.Append(value.GetIntValue(), 10);
break;
case eHTMLUnit_Pixel:
aResult.Truncate();
aResult.Append(value.GetPixelValue(), 10);
break;
case eHTMLUnit_Percent:
aResult.Truncate(0);
aResult.Append(PRInt32(value.GetPercentValue() * 100.0f), 10);
aResult.Append('%');
break;
case eHTMLUnit_Color:
color = nscolor(value.GetColorValue());
PR_snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
NS_GET_R(color), NS_GET_G(color), NS_GET_B(color));
aResult.Truncate(0);
aResult.Append(cbuf);
break;
default:
case eHTMLUnit_Enumerated:
NS_NOTREACHED("no default enumerated value to string conversion");
rv = NS_CONTENT_ATTR_NOT_THERE;
break;
nsGenericAttribute* attr;
PRInt32 index;
PRInt32 count = mAttributes->Count();
for (index = 0; index < count; index++) {
attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
if ((aNameSpaceID == attr->mNameSpaceID) && (aName == attr->mName)) {
attr->mValue = aValue;
rv = NS_OK;
break;
}
}
if (index >= count) { // didn't find it
attr = new nsGenericAttribute(aNameSpaceID, aName, aValue);
if (nsnull != attr) {
mAttributes->AppendElement(attr);
rv = NS_OK;
}
}
}
else {
rv = NS_CONTENT_ATTR_NOT_THERE;
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aName, NS_STYLE_HINT_UNKNOWN);
}
NS_RELEASE(attr);
return rv;
}
nsresult
nsGenericContainerElement::UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify)
nsGenericContainerElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const
{
nsresult rv = NS_OK;;
NS_ASSERTION(nsnull != aName, "must have attribute name");
if (nsnull == aName) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv = NS_CONTENT_ATTR_NOT_THERE;
rv = EnsureWritableAttributes(mContent, mAttributes, PR_FALSE);
if (nsnull != mAttributes) {
PRInt32 count;
rv = mAttributes->UnsetAttribute(aAttribute, count);
if (0 == count) {
ReleaseAttributes(mAttributes);
PRInt32 count = mAttributes->Count();
PRInt32 index;
for (index = 0; index < count; index++) {
const nsGenericAttribute* attr = (const nsGenericAttribute*)mAttributes->ElementAt(index);
if ((attr->mNameSpaceID == aNameSpaceID) && (attr->mName == aName)) {
aResult = attr->mValue;
if (0 < aResult.Length()) {
rv = NS_CONTENT_ATTR_HAS_VALUE;
}
else {
rv = NS_CONTENT_ATTR_NO_VALUE;
}
break;
}
}
}
return rv;
}
nsresult
nsGenericContainerElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify)
{
NS_ASSERTION(nsnull != aName, "must have attribute name");
if (nsnull == aName) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv = NS_OK;
if (nsnull != mAttributes) {
PRInt32 count = mAttributes->Count();
PRInt32 index;
for (index = 0; index < count; index++) {
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
if ((attr->mNameSpaceID == aNameSpaceID) && (attr->mName == aName)) {
mAttributes->RemoveElementAt(index);
delete attr;
break;
}
}
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aAttribute, NS_STYLE_HINT_UNKNOWN);
mDocument->AttributeChanged(mContent, aName, NS_STYLE_HINT_UNKNOWN);
}
}
return rv;
}
nsresult
nsGenericContainerElement::GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const
nsresult
nsGenericContainerElement::GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
{
if (nsnull != mAttributes) {
return mAttributes->GetAllAttributeNames(aArray, aCount);
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(aIndex);
if (nsnull != attr) {
aNameSpaceID = attr->mNameSpaceID;
aName = attr->mName;
NS_IF_ADDREF(aName);
return NS_OK;
}
}
aCount = 0;
return NS_OK;
aNameSpaceID = kNameSpaceID_None;
aName = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
}
nsresult
nsGenericContainerElement::GetAttributeCount(PRInt32& aResult) const
{
if (nsnull != mAttributes) {
return mAttributes->Count(aResult);
aResult = mAttributes->Count();
}
else {
aResult = 0;
}
aResult = 0;
return NS_OK;
}
void
nsGenericContainerElement::ListAttributes(FILE* out) const
{
nsISupportsArray* attrs;
if (NS_OK == NS_NewISupportsArray(&attrs)) {
PRInt32 index, count;
GetAllAttributeNames(attrs, count);
for (index = 0; index < count; index++) {
// name
nsIAtom* attr = (nsIAtom*)attrs->ElementAt(index);
nsAutoString buffer;
attr->ToString(buffer);
PRInt32 index, count;
GetAttributeCount(count);
// value
nsAutoString value;
GetAttribute(buffer, value);
buffer.Append("=");
buffer.Append(value);
for (index = 0; index < count; index++) {
const nsGenericAttribute* attr = (const nsGenericAttribute*)mAttributes->ElementAt(index);
nsAutoString buffer;
fputs(" ", out);
fputs(buffer, out);
NS_RELEASE(attr);
if (kNameSpaceID_None != attr->mNameSpaceID) { // prefix namespace
buffer.Append(attr->mNameSpaceID, 10);
buffer.Append(':');
}
NS_RELEASE(attrs);
// name
nsAutoString name;
attr->mName->ToString(name);
buffer.Append(name);
// value
buffer.Append("=");
buffer.Append(attr->mValue);
fputs(" ", out);
fputs(buffer, out);
}
}

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

@ -45,7 +45,6 @@ class nsISupportsArray;
class nsIDOMScriptObjectFactory;
class nsDOMCSSDeclaration;
class nsIDOMCSSStyleDeclaration;
class nsIHTMLAttributes;
// Attribute helper class used to wrap up an attribute with a dom
// object that implements nsIDOMAttr and nsIDOMNode and
@ -297,12 +296,16 @@ public:
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
// Remainder of nsIContent
nsresult SetAttribute(const nsString& aName, const nsString& aValue,
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue,
PRBool aNotify);
nsresult GetAttribute(const nsString& aName, nsString& aResult) const;
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const;
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const;
nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify);
nsresult GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const;
nsresult GetAttributeCount(PRInt32& aResult) const;
nsresult List(FILE* out, PRInt32 aIndent) const;
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
@ -320,7 +323,7 @@ public:
void ListAttributes(FILE* out) const;
nsIHTMLAttributes* mAttributes;
nsVoidArray* mAttributes;
nsVoidArray mChildren;
};
@ -495,20 +498,22 @@ public:
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
return _g.GetTag(aResult); \
} \
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, \
PRBool aNotify) { \
return _g.SetAttribute(aName, aValue, aNotify); \
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
const nsString& aValue, PRBool aNotify) { \
return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \
} \
NS_IMETHOD GetAttribute(const nsString& aName, \
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
nsString& aResult) const { \
return _g.GetAttribute(aName, aResult); \
return _g.GetAttribute(aNameSpaceID, aName, aResult); \
} \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
return _g.UnsetAttribute(aAttribute, aNotify); \
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
PRBool aNotify) { \
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
} \
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
PRInt32& aResult) const { \
return _g.GetAllAttributeNames(aArray, aResult); \
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
PRInt32& aNameSpaceID, \
nsIAtom*& aName) const { \
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
} \
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
return _g.GetAttributeCount(aResult); \

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

@ -48,34 +48,23 @@ public:
*/
NS_IMETHOD Compact() = 0;
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue,
PRBool aNotify) = 0;
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify) = 0;
NS_IMETHOD SetAttribute(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
PRBool aNotify) = 0;
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
PRBool aNotify) = 0;
NS_IMETHOD GetAttribute(const nsString& aName,
nsString& aResult) const = 0;
NS_IMETHOD GetAttribute(nsIAtom *aAttribute,
nsString &aResult) const = 0;
NS_IMETHOD GetAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const = 0;
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const = 0;
NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const = 0;
NS_IMETHOD SetID(nsIAtom* aID) = 0;
NS_IMETHOD GetID(nsIAtom*& aResult) const = 0;
// XXX this will have to change for CSS2
NS_IMETHOD SetClass(nsIAtom* aClass) = 0;
// XXX this will have to change for CSS2
NS_IMETHOD GetClass(nsIAtom*& aResult) const = 0;
NS_IMETHOD GetClasses(nsVoidArray& aArray) const = 0;
NS_IMETHOD HasClass(nsIAtom* aClass) const = 0;
NS_IMETHOD GetContentStyleRule(nsIStyleRule*& aResult) = 0;
NS_IMETHOD GetInlineStyleRule(nsIStyleRule*& aResult) = 0;
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const = 0;
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
@ -99,7 +88,6 @@ public:
* an attribute on this node changes.
*/
NS_IMETHOD GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const = 0;

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

@ -128,7 +128,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsICSSDeclaration **aDecl,
*aDecl = nsnull;
if (nsnull != mContent) {
mContent->GetAttribute(nsHTMLAtoms::style, val);
mContent->GetHTMLAttribute(nsHTMLAtoms::style, val);
if (eHTMLUnit_ISupports == val.GetUnit()) {
rule = (nsIStyleRule*) val.GetISupportsValue();
result = rule->QueryInterface(kICSSStyleRuleIID, (void**)&cssRule);
@ -146,9 +146,9 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsICSSDeclaration **aDecl,
cssRule->SetDeclaration(*aDecl);
cssRule->SetWeight(0x7fffffff);
rule = (nsIStyleRule *)cssRule;
result = mContent->SetAttribute(nsHTMLAtoms::style,
nsHTMLValue(cssRule),
PR_FALSE);
result = mContent->SetHTMLAttribute(nsHTMLAtoms::style,
nsHTMLValue(cssRule),
PR_FALSE);
NS_RELEASE(cssRule);
}
else {
@ -242,73 +242,156 @@ nsGenericHTMLElement::~nsGenericHTMLElement()
}
}
// Implementation for nsIDOMElement
nsresult
nsGenericHTMLElement::GetDOMAttribute(const nsString& aName, nsString& aReturn)
{
nsAutoString upper;
aName.ToUpperCase(upper);
return nsGenericElement::GetDOMAttribute(upper, aReturn);
}
nsresult
nsGenericHTMLElement::SetDOMAttribute(const nsString& aName, const nsString& aValue)
{
nsAutoString upper;
aName.ToUpperCase(upper);
return nsGenericElement::SetDOMAttribute(upper, aValue);
}
nsresult
nsGenericHTMLElement::RemoveAttribute(const nsString& aName)
{
nsAutoString upper;
aName.ToUpperCase(upper);
return nsGenericElement::RemoveAttribute(upper);
}
nsresult
nsGenericHTMLElement::GetAttributeNode(const nsString& aName,
nsIDOMAttr** aReturn)
{
nsAutoString upper;
aName.ToUpperCase(upper);
return nsGenericElement::GetAttributeNode(upper, aReturn);
}
nsresult
nsGenericHTMLElement::SetAttributeNode(nsIDOMAttr* aAttribute, nsIDOMAttr** aReturn)
{
NS_PRECONDITION(nsnull != aAttribute, "null attribute");
nsresult res = NS_ERROR_FAILURE;
if (nsnull != aAttribute) {
nsAutoString name, value;
res = aAttribute->GetName(name);
if (NS_OK == res) {
res = aAttribute->GetValue(value);
if (NS_OK == res) {
// XXX need to parse out namespace
// XXX need to only uppercase if HTML namespace (or none since this is an HTML element)
name.ToUpperCase();
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->SetAttribute(kNameSpaceID_HTML, nameAtom, value, PR_TRUE);
NS_RELEASE(nameAtom);
}
}
}
return res;
}
nsresult
nsGenericHTMLElement::RemoveAttributeNode(nsIDOMAttr* aAttribute, nsIDOMAttr** aReturn)
{
NS_PRECONDITION(nsnull != aAttribute, "null attribute");
nsresult res = NS_ERROR_FAILURE;
if (nsnull != aAttribute) {
nsAutoString name;
res = aAttribute->GetName(name);
if (NS_OK == res) {
// XXX need to parse out namespace
// XXX need to only uppercase if HTML namespace (or none since this is an HTML element)
name.ToUpperCase();
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->UnsetAttribute(kNameSpaceID_HTML, nameAtom, PR_TRUE);
NS_RELEASE(nameAtom);
}
}
return res;
}
nsresult
nsGenericHTMLElement::GetId(nsString& aId)
{
GetAttribute(nsHTMLAtoms::id, aId);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, aId);
return NS_OK;
}
nsresult
nsGenericHTMLElement::SetId(const nsString& aId)
{
SetAttribute(nsHTMLAtoms::id, aId, PR_TRUE);
SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, aId, PR_TRUE);
return NS_OK;
}
nsresult
nsGenericHTMLElement::GetTitle(nsString& aTitle)
{
GetAttribute(nsHTMLAtoms::title, aTitle);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::title, aTitle);
return NS_OK;
}
nsresult
nsGenericHTMLElement::SetTitle(const nsString& aTitle)
{
SetAttribute(nsHTMLAtoms::title, aTitle, PR_TRUE);
SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::title, aTitle, PR_TRUE);
return NS_OK;
}
nsresult
nsGenericHTMLElement::GetLang(nsString& aLang)
{
GetAttribute(nsHTMLAtoms::lang, aLang);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::lang, aLang);
return NS_OK;
}
nsresult
nsGenericHTMLElement::SetLang(const nsString& aLang)
{
SetAttribute(nsHTMLAtoms::lang, aLang, PR_TRUE);
SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::lang, aLang, PR_TRUE);
return NS_OK;
}
nsresult
nsGenericHTMLElement::GetDir(nsString& aDir)
{
GetAttribute(nsHTMLAtoms::dir, aDir);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::dir, aDir);
return NS_OK;
}
nsresult
nsGenericHTMLElement::SetDir(const nsString& aDir)
{
SetAttribute(nsHTMLAtoms::dir, aDir, PR_TRUE);
SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::dir, aDir, PR_TRUE);
return NS_OK;
}
nsresult
nsGenericHTMLElement::GetClassName(nsString& aClassName)
{
GetAttribute(nsHTMLAtoms::kClass, aClassName);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, aClassName);
return NS_OK;
}
nsresult
nsGenericHTMLElement::SetClassName(const nsString& aClassName)
{
SetAttribute(nsHTMLAtoms::kClass, aClassName, PR_TRUE);
SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, aClassName, PR_TRUE);
return NS_OK;
}
@ -398,19 +481,6 @@ nsGenericHTMLElement::GetNameSpaceID(PRInt32& aID) const
// }
//}
nsresult
nsGenericHTMLElement::SetAttribute(const nsString& aName,
const nsString& aValue,
PRBool aNotify)
{
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
nsresult rv = SetAttribute(attr, aValue, aNotify);
NS_RELEASE(attr);
return rv;
}
#if 0
static nsGenericHTMLElement::EnumTable kDirTable[] = {
{ "ltr", NS_STYLE_DIRECTION_LTR },
@ -420,29 +490,21 @@ static nsGenericHTMLElement::EnumTable kDirTable[] = {
#endif
nsresult
nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
const nsString& aValue,
PRBool aNotify)
{
nsresult result = NS_OK;
#if 0
if (nsHTMLAtoms::dir == aAttribute) {
nsHTMLValue val;
if (ParseEnumValue(aValue, kDirTable, val)) {
result = SetAttribute(aAttribute, val, aNotify);
}
else {
result = SetStringAttribute(aAttribute, aValue, aNotify);
}
NS_ASSERTION((kNameSpaceID_HTML == aNameSpaceID) ||
(kNameSpaceID_Unknown == aNameSpaceID),
"html content only holds HTML attributes");
if ((kNameSpaceID_HTML != aNameSpaceID) &&
(kNameSpaceID_Unknown != aNameSpaceID)) {
return NS_ERROR_ILLEGAL_VALUE;
}
else if (nsHTMLAtoms::lang == aAttribute) {
result = SetStringAttribute(aAttribute, aValue, aNotify);
}
else if (nsHTMLAtoms::title == aAttribute) {
result = SetStringAttribute(aAttribute, aValue, aNotify);
}
else
#endif
if (nsHTMLAtoms::style == aAttribute) {
// XXX the style sheet language is a document property that
// should be used to lookup the style sheet parser to parse the
@ -455,7 +517,7 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
nsIStyleRule* rule;
result = css->ParseDeclarations(aValue, nsnull, rule);
if ((NS_OK == result) && (nsnull != rule)) {
result = SetAttribute(aAttribute, nsHTMLValue(rule), aNotify);
result = SetHTMLAttribute(aAttribute, nsHTMLValue(rule), aNotify);
NS_RELEASE(rule);
}
NS_RELEASE(css);
@ -490,16 +552,7 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
AddScriptEventListener(aAttribute, aValue, kIDOMFormListenerIID);
else if (nsHTMLAtoms::onpaint == aAttribute)
AddScriptEventListener(aAttribute, aValue, kIDOMPaintListenerIID);
// check for class and upper case it
else if (nsHTMLAtoms::kClass == aAttribute) {
nsAutoString buffer;
aValue.ToUpperCase(buffer);
nsIAtom* classAtom = NS_NewAtom(buffer);
result = SetClass(classAtom);
NS_RELEASE(classAtom);
return result;
}
nsHTMLValue val;
nsIHTMLContent* htmlContent;
@ -510,7 +563,7 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
if (NS_CONTENT_ATTR_NOT_THERE !=
htmlContent->StringToAttribute(aAttribute, aValue, val)) {
// string value was mapped to nsHTMLValue, set it that way
result = SetAttribute(aAttribute, val, aNotify);
result = SetHTMLAttribute(aAttribute, val, aNotify);
NS_RELEASE(htmlContent);
return result;
}
@ -544,9 +597,9 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
}
nsresult
nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
PRBool aNotify)
nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
PRBool aNotify)
{
nsresult result = NS_OK;
nsIHTMLContent* htmlContent;
@ -600,9 +653,19 @@ nsGenericHTMLElement::MapCommonAttributesInto(nsIHTMLAttributes* aAttributes,
}
nsresult
nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify)
nsGenericHTMLElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify)
{
nsresult result = NS_OK;
NS_ASSERTION((kNameSpaceID_HTML == aNameSpaceID) ||
(kNameSpaceID_Unknown == aNameSpaceID),
"html content only holds HTML attributes");
if ((kNameSpaceID_HTML != aNameSpaceID) &&
(kNameSpaceID_Unknown != aNameSpaceID)) {
return NS_ERROR_ILLEGAL_VALUE;
}
nsIHTMLContent* htmlContent;
result = mContent->QueryInterface(kIHTMLContentIID, (void **)&htmlContent);
@ -634,23 +697,20 @@ nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify)
}
nsresult
nsGenericHTMLElement::GetAttribute(const nsString& aName,
nsString& aResult) const
{
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
nsresult result = GetAttribute(attr, aResult);
NS_RELEASE(attr);
return result;
}
nsresult
nsGenericHTMLElement::GetAttribute(nsIAtom *aAttribute,
nsGenericHTMLElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
nsString &aResult) const
{
NS_ASSERTION((kNameSpaceID_HTML == aNameSpaceID) ||
(kNameSpaceID_Unknown == aNameSpaceID),
"html content only holds HTML attributes");
if ((kNameSpaceID_HTML != aNameSpaceID) &&
(kNameSpaceID_Unknown != aNameSpaceID)) {
return NS_ERROR_ILLEGAL_VALUE;
}
nsHTMLValue value;
nsresult result = GetAttribute(aAttribute, value);
nsresult result = GetHTMLAttribute(aAttribute, value);
char cbuf[20];
nscolor color;
@ -714,8 +774,8 @@ nsGenericHTMLElement::GetAttribute(nsIAtom *aAttribute,
}
nsresult
nsGenericHTMLElement::GetAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const
nsGenericHTMLElement::GetHTMLAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const
{
if (nsnull != mAttributes) {
return mAttributes->GetAttribute(aAttribute, aValue);
@ -724,58 +784,29 @@ nsGenericHTMLElement::GetAttribute(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_NOT_THERE;
}
nsresult
nsGenericHTMLElement::GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const
nsresult
nsGenericHTMLElement::GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
{
aNameSpaceID = kNameSpaceID_HTML;
if (nsnull != mAttributes) {
return mAttributes->GetAllAttributeNames(aArray, aCount);
return mAttributes->GetAttributeNameAt(aIndex, aName);
}
aCount = 0;
return NS_OK;
aName = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
}
nsresult
nsGenericHTMLElement::GetAttributeCount(PRInt32& aCount) const
{
if (nsnull != mAttributes) {
return mAttributes->Count(aCount);
return mAttributes->GetAttributeCount(aCount);
}
aCount = 0;
return NS_OK;
}
nsresult
nsGenericHTMLElement::SetID(nsIAtom* aID)
{
nsresult result = NS_OK;
nsIHTMLContent* htmlContent;
result = mContent->QueryInterface(kIHTMLContentIID, (void **)&htmlContent);
if (NS_OK != result) {
return result;
}
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
if (nsnull != sheet) {
result = sheet->SetIDFor(aID, htmlContent, mAttributes);
NS_RELEASE(sheet);
}
}
else { // manage this ourselves and re-sync when we connect to doc
EnsureWritableAttributes(htmlContent, mAttributes, PRBool(nsnull != aID));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetID(aID, count);
if (0 == count) {
ReleaseAttributes(mAttributes);
}
}
}
NS_RELEASE(htmlContent);
return result;
}
nsresult
nsGenericHTMLElement::GetID(nsIAtom*& aResult) const
{
@ -787,44 +818,21 @@ nsGenericHTMLElement::GetID(nsIAtom*& aResult) const
}
nsresult
nsGenericHTMLElement::SetClass(nsIAtom* aClass)
nsGenericHTMLElement::GetClasses(nsVoidArray& aArray) const
{
nsresult result = NS_OK;
nsIHTMLContent* htmlContent;
result = mContent->QueryInterface(kIHTMLContentIID, (void **)&htmlContent);
if (NS_OK != result) {
return result;
if (nsnull != mAttributes) {
return mAttributes->GetClasses(aArray);
}
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
if (nsnull != sheet) {
result = sheet->SetClassFor(aClass, htmlContent, mAttributes);
NS_RELEASE(sheet);
}
}
else { // manage this ourselves and re-sync when we connect to doc
EnsureWritableAttributes(htmlContent, mAttributes, PRBool(nsnull != aClass));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetClass(aClass, count);
if (0 == count) {
ReleaseAttributes(mAttributes);
}
}
}
NS_RELEASE(htmlContent);
return result;
return NS_OK;
}
nsresult
nsGenericHTMLElement::GetClass(nsIAtom*& aResult) const
nsGenericHTMLElement::HasClass(nsIAtom* aClass) const
{
if (nsnull != mAttributes) {
return mAttributes->GetClass(aResult);
return mAttributes->HasClass(aClass);
}
aResult = nsnull;
return NS_OK;
return NS_COMFALSE;
}
nsresult
@ -863,27 +871,25 @@ nsGenericHTMLElement::GetInlineStyleRule(nsIStyleRule*& aResult)
void
nsGenericHTMLElement::ListAttributes(FILE* out) const
{
nsISupportsArray* attrs;
if (NS_OK == NS_NewISupportsArray(&attrs)) {
PRInt32 index, count;
GetAllAttributeNames(attrs, count);
for (index = 0; index < count; index++) {
// name
nsIAtom* attr = (nsIAtom*)attrs->ElementAt(index);
nsAutoString buffer;
attr->ToString(buffer);
PRInt32 index, count;
GetAttributeCount(count);
for (index = 0; index < count; index++) {
// name
nsIAtom* attr = nsnull;
PRInt32 nameSpaceID;
GetAttributeNameAt(index, nameSpaceID, attr);
nsAutoString buffer;
attr->ToString(buffer);
// value
nsAutoString value;
GetAttribute(buffer, value);
buffer.Append("=");
buffer.Append(value);
// value
nsAutoString value;
GetAttribute(nameSpaceID, attr, value);
buffer.Append("=");
buffer.Append(value);
fputs(" ", out);
fputs(buffer, out);
NS_RELEASE(attr);
}
NS_RELEASE(attrs);
fputs(" ", out);
fputs(buffer, out);
NS_RELEASE(attr);
}
}
@ -982,26 +988,23 @@ nsGenericHTMLElement::ToHTMLString(nsString& aBuf) const
}
if (nsnull != mAttributes) {
nsISupportsArray* attrs;
nsresult rv = NS_NewISupportsArray(&attrs);
if (NS_OK == rv) {
PRInt32 i, n;
mAttributes->GetAllAttributeNames(attrs, n);
nsAutoString name, value, quotedValue;
for (i = 0; i < n; i++) {
nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i);
atom->ToString(name);
aBuf.Append(' ');
aBuf.Append(name);
value.Truncate();
GetAttribute(name, value);
if (value.Length() > 0) {
aBuf.Append('=');
NS_QuoteForHTML(value, quotedValue);
aBuf.Append(quotedValue);
}
PRInt32 index, count;
mAttributes->GetAttributeCount(count);
nsAutoString name, value, quotedValue;
for (index = 0; index < count; index++) {
nsIAtom* atom = nsnull;
mAttributes->GetAttributeNameAt(index, atom);
atom->ToString(name);
aBuf.Append(' ');
aBuf.Append(name);
value.Truncate();
GetAttribute(kNameSpaceID_HTML, atom, value);
NS_RELEASE(atom);
if (value.Length() > 0) {
aBuf.Append('=');
NS_QuoteForHTML(value, quotedValue);
aBuf.Append(quotedValue);
}
NS_RELEASE(attrs);
}
}
@ -1014,7 +1017,7 @@ nsGenericHTMLElement::ToHTMLString(nsString& aBuf) const
nsresult
nsGenericHTMLElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (nsHTMLAtoms::style == aAttribute) {
@ -1836,24 +1839,20 @@ nsGenericHTMLLeafElement::BeginConvertToXIF(nsXIFConverter& aConverter) const
// Add all attributes to the convert
if (nsnull != mAttributes)
{
nsISupportsArray* attrs;
rv = NS_NewISupportsArray(&attrs);
if (NS_OK == rv)
PRInt32 index, count;
mAttributes->GetAttributeCount(count);
nsAutoString name, value;
for (index = 0; index < count; index++)
{
PRInt32 i, n;
mAttributes->GetAllAttributeNames(attrs, n);
nsAutoString name, value;
for (i = 0; i < n; i++)
{
nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i);
atom->ToString(name);
nsIAtom* atom = nsnull;
mAttributes->GetAttributeNameAt(index, atom);
atom->ToString(name);
value.Truncate();
GetAttribute(name, value);
aConverter.AddHTMLAttribute(name,value);
}
NS_RELEASE(attrs);
value.Truncate();
GetAttribute(kNameSpaceID_HTML, atom, value);
NS_RELEASE(atom);
aConverter.AddHTMLAttribute(name,value);
}
}
return rv;
@ -2205,24 +2204,20 @@ nsGenericHTMLContainerElement::BeginConvertToXIF(nsXIFConverter& aConverter) con
// Add all attributes to the convert
if (nsnull != mAttributes)
{
nsISupportsArray* attrs;
rv = NS_NewISupportsArray(&attrs);
if (NS_OK == rv)
PRInt32 index, count;
mAttributes->GetAttributeCount(count);
nsAutoString name, value;
for (index = 0; index < count; index++)
{
PRInt32 i, n;
mAttributes->GetAllAttributeNames(attrs, n);
nsAutoString name, value;
for (i = 0; i < n; i++)
{
nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i);
atom->ToString(name);
nsIAtom* atom = nsnull;
mAttributes->GetAttributeNameAt(index, atom);
atom->ToString(name);
value.Truncate();
GetAttribute(name, value);
aConverter.AddHTMLAttribute(name,value);
}
NS_RELEASE(attrs);
value.Truncate();
GetAttribute(kNameSpaceID_HTML, atom, value);
NS_RELEASE(atom);
aConverter.AddHTMLAttribute(name,value);
}
}
return NS_OK;

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

@ -26,6 +26,7 @@
#include "nsHTMLValue.h"
#include "nsVoidArray.h"
#include "nsIJSScriptObject.h"
#include "nsINameSpaceManager.h" // for kNameSpaceID_HTML
extern const nsIID kIDOMHTMLElementIID;
extern const nsIID kIHTMLContentIID;
@ -50,6 +51,15 @@ public:
nsGenericHTMLElement();
~nsGenericHTMLElement();
// Implementation for nsIDOMElement
nsresult GetDOMAttribute(const nsString& aName, nsString& aReturn);
nsresult SetDOMAttribute(const nsString& aName, const nsString& aValue);
nsresult RemoveAttribute(const nsString& aName);
nsresult GetAttributeNode(const nsString& aName,
nsIDOMAttr** aReturn);
nsresult SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn);
nsresult RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn);
// Implementation for nsIDOMHTMLElement
nsresult GetId(nsString& aId);
nsresult SetId(const nsString& aId);
@ -66,27 +76,24 @@ public:
// Implementation for nsIContent
nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const;
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
nsresult SetAttribute(const nsString& aName, const nsString& aValue,
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue,
PRBool aNotify);
nsresult GetAttribute(const nsString& aName, nsString& aResult) const;
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const;
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
nsresult GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const;
nsresult GetAttributeCount(PRInt32& aResult) const;
nsresult List(FILE* out, PRInt32 aIndent) const;
// Implementation for nsIHTMLContent
nsresult Compact();
nsresult SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
nsresult SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
PRBool aNotify);
nsresult GetAttribute(nsIAtom *aAttribute, nsString &aResult) const;
nsresult GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const;
nsresult SetID(nsIAtom* aID);
nsresult SetHTMLAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
PRBool aNotify);
nsresult GetHTMLAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const;
nsresult GetID(nsIAtom*& aResult) const;
nsresult SetClass(nsIAtom* aClass);
nsresult GetClass(nsIAtom*& aResult) const;
nsresult GetClasses(nsVoidArray& aArray) const;
nsresult HasClass(nsIAtom* aClass) const;
nsresult GetContentStyleRule(nsIStyleRule*& aResult);
nsresult GetInlineStyleRule(nsIStyleRule*& aResult);
nsresult ToHTMLString(nsString& aResult) const;
@ -94,7 +101,7 @@ public:
//----------------------------------------
nsresult AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const;
void ListAttributes(FILE* out) const;
@ -399,33 +406,22 @@ public:
NS_IMETHOD Compact() { \
return _g.Compact(); \
} \
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, \
PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute, \
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetHTMLAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, \
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
nsString &aResult) const { \
return _g.GetAttribute(aAttribute, aResult); \
} \
NS_IMETHOD GetAttribute(nsIAtom* aAttribute, \
nsHTMLValue& aValue) const { \
return _g.GetAttribute(aAttribute, aValue); \
} \
NS_IMETHOD SetID(nsIAtom* aID) { \
return _g.SetID(aID); \
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute, \
nsHTMLValue& aValue) const { \
return _g.GetHTMLAttribute(aAttribute, aValue); \
} \
NS_IMETHOD GetID(nsIAtom*& aResult) const { \
return _g.GetID(aResult); \
} \
NS_IMETHOD SetClass(nsIAtom* aClass) { \
return _g.SetClass(aClass); \
NS_IMETHOD GetClasses(nsVoidArray& aArray) const { \
return _g.GetClasses(aArray); \
} \
NS_IMETHOD GetClass(nsIAtom*& aResult) const { \
return _g.GetClass(aResult); \
NS_IMETHOD HasClass(nsIAtom* aClass) const { \
return _g.HasClass(aClass); \
} \
NS_IMETHOD GetContentStyleRule(nsIStyleRule*& aResult) { \
return _g.GetContentStyleRule(aResult); \
@ -443,45 +439,32 @@ public:
const nsString& aValue, \
nsHTMLValue& aResult); \
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
nsHTMLValue& aValue, \
const nsHTMLValue& aValue, \
nsString& aResult) const; \
NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const; \
NS_IMETHOD GetStyleHintForAttributeChange( \
const nsIContent *aNode, \
const nsIAtom* aAttribute, \
PRInt32 *aHint) const;
NS_IMETHOD GetStyleHintForAttributeChange(const nsIAtom* aAttribute, \
PRInt32 *aHint) const;
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC2(_g) \
NS_IMETHOD Compact() { \
return _g.Compact(); \
} \
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, \
PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute, \
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetHTMLAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, \
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
nsString &aResult) const { \
return _g.GetAttribute(aAttribute, aResult); \
} \
NS_IMETHOD GetAttribute(nsIAtom* aAttribute, \
nsHTMLValue& aValue) const { \
return _g.GetAttribute(aAttribute, aValue); \
} \
NS_IMETHOD SetID(nsIAtom* aID) { \
return _g.SetID(aID); \
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute, \
nsHTMLValue& aValue) const { \
return _g.GetHTMLAttribute(aAttribute, aValue); \
} \
NS_IMETHOD GetID(nsIAtom*& aResult) const { \
return _g.GetID(aResult); \
} \
NS_IMETHOD SetClass(nsIAtom* aClass) { \
return _g.SetClass(aClass); \
NS_IMETHOD GetClasses(nsVoidArray& aArray) const { \
return _g.GetClasses(aArray); \
} \
NS_IMETHOD GetClass(nsIAtom*& aResult) const { \
return _g.GetClass(aResult); \
NS_IMETHOD HasClass(nsIAtom* aClass) const { \
return _g.HasClass(aClass); \
} \
NS_IMETHOD GetContentStyleRule(nsIStyleRule*& aResult); \
NS_IMETHOD GetInlineStyleRule(nsIStyleRule*& aResult); \
@ -495,13 +478,11 @@ public:
const nsString& aValue, \
nsHTMLValue& aResult); \
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
nsHTMLValue& aValue, \
const nsHTMLValue& aValue, \
nsString& aResult) const; \
NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const; \
NS_IMETHOD GetStyleHintForAttributeChange( \
const nsIContent *aNode, \
const nsIAtom* aAttribute, \
PRInt32 *aHint) const;
NS_IMETHOD GetStyleHintForAttributeChange(const nsIAtom* aAttribute, \
PRInt32 *aHint) const;
/**
* This macro implements the portion of query interface that is
@ -531,13 +512,13 @@ public:
NS_IMETHODIMP \
_class::Get##_method(nsString& aValue) \
{ \
mInner.GetAttribute(nsHTMLAtoms::_atom, aValue); \
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_atom, aValue); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(const nsString& aValue) \
{ \
return mInner.SetAttribute(nsHTMLAtoms::_atom, aValue, PR_TRUE); \
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_atom, aValue, PR_TRUE); \
}
/**
@ -550,19 +531,19 @@ public:
_class::Get##_method(PRBool* aValue) \
{ \
nsHTMLValue val; \
nsresult rv = mInner.GetAttribute(nsHTMLAtoms::_atom, val); \
nsresult rv = mInner.GetHTMLAttribute(nsHTMLAtoms::_atom, val); \
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRBool aValue) \
{ \
nsAutoString empty; \
nsHTMLValue empty(eHTMLUnit_Empty); \
if (aValue) { \
return mInner.SetAttribute(nsHTMLAtoms::_atom, empty, PR_TRUE); \
return mInner.SetHTMLAttribute(nsHTMLAtoms::_atom, empty, PR_TRUE); \
} \
else { \
mInner.UnsetAttribute(nsHTMLAtoms::_atom, PR_TRUE); \
mInner.UnsetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_atom, PR_TRUE); \
return NS_OK; \
} \
}
@ -579,7 +560,7 @@ public:
nsHTMLValue value; \
*aValue = -1; \
if (NS_CONTENT_ATTR_HAS_VALUE == \
mInner.GetAttribute(nsHTMLAtoms::_atom, value)) { \
mInner.GetHTMLAttribute(nsHTMLAtoms::_atom, value)) { \
if (value.GetUnit() == eHTMLUnit_Integer) { \
*aValue = value.GetIntValue(); \
} \
@ -590,7 +571,7 @@ public:
_class::Set##_method(PRInt32 aValue) \
{ \
nsHTMLValue value(aValue, eHTMLUnit_Integer); \
return mInner.SetAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
return mInner.SetHTMLAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
}
#endif /* nsGenericHTMLElement_h___ */

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

@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsINameSpaceManager.h"
#include "nsIEventStateManager.h"
#include "nsDOMEvent.h"
@ -208,7 +209,7 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLAnchorElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -245,7 +246,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
// If this anchor element has an HREF then it is sensitive to
// mouse events (otherwise ignore them).
nsAutoString href;
nsresult result = GetAttribute(nsString("href"), href);
nsresult result = GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
switch (aEvent->message) {
case NS_MOUSE_LEFT_BUTTON_DOWN:
@ -271,10 +272,10 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
if (activeLink == this) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString base, target;
GetAttribute(nsString(NS_HTML_BASE_HREF), base);
GetAttribute(nsString("target"), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
if (target.Length() == 0) {
GetAttribute(nsString(NS_HTML_BASE_TARGET), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
}
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
base, href, target, PR_TRUE);
@ -291,10 +292,10 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
case NS_MOUSE_ENTER:
{
nsAutoString base, target;
GetAttribute(nsString(NS_HTML_BASE_HREF), base);
GetAttribute(nsString("target"), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
if (target.Length() == 0) {
GetAttribute(nsString(NS_HTML_BASE_TARGET), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
}
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
base, href, target, PR_FALSE);
@ -320,10 +321,9 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLAnchorElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -173,7 +173,7 @@ nsHTMLAppletElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -222,10 +222,9 @@ nsHTMLAppletElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLAppletElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -155,7 +155,7 @@ nsHTMLAreaElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLAreaElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -190,10 +190,9 @@ nsHTMLAreaElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLAreaElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -148,7 +148,7 @@ nsHTMLBRElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::clear) {
@ -198,10 +198,9 @@ nsHTMLBRElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLBRElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -137,7 +137,7 @@ nsHTMLBaseElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLBaseElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -172,10 +172,9 @@ nsHTMLBaseElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLBaseElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -141,7 +141,7 @@ nsHTMLBaseFontElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLBaseFontElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -179,10 +179,9 @@ nsHTMLBaseFontElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLBaseFontElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -60,7 +60,7 @@ public:
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
// Strength is an out-of-band weighting, always 0 here
NS_IMETHOD GetStrength(PRInt32& aStrength);
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
NS_IMETHOD MapStyleInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
@ -84,7 +84,7 @@ public:
NS_IMETHOD HashValue(PRUint32& aValue) const;
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
// Strength is an out-of-band weighting, always maxint here
NS_IMETHOD GetStrength(PRInt32& aStrength);
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
NS_IMETHOD MapStyleInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
@ -243,7 +243,7 @@ BodyRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
// Strength is an out-of-band weighting, useful for mapping CSS ! important
// always 0 here
NS_IMETHODIMP
BodyRule::GetStrength(PRInt32& aStrength)
BodyRule::GetStrength(PRInt32& aStrength) const
{
aStrength = 0;
return NS_OK;
@ -266,14 +266,14 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
if (0 < attrCount) {
// if marginwidth/marginheigth is set in our attribute zero out left,right/top,bottom padding
// nsBodyFrame::DidSetStyleContext will add the appropriate values to padding
mPart->GetAttribute(nsHTMLAtoms::marginwidth, value);
mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
styleSpacing->mPadding.SetLeft(zero);
styleSpacing->mPadding.SetRight(zero);
count++;
}
mPart->GetAttribute(nsHTMLAtoms::marginheight, value);
mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
styleSpacing->mPadding.SetTop(zero);
styleSpacing->mPadding.SetBottom(zero);
@ -394,7 +394,7 @@ BodyFixupRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
// Strength is an out-of-band weighting, always MaxInt here
NS_IMETHODIMP
BodyFixupRule::GetStrength(PRInt32& aStrength)
BodyFixupRule::GetStrength(PRInt32& aStrength) const
{
aStrength = 2000000000;
return NS_OK;
@ -525,7 +525,7 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -729,10 +729,9 @@ nsHTMLBodyElement::GetInlineStyleRule(nsIStyleRule*& aResult)
NS_IMETHODIMP
nsHTMLBodyElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -271,7 +271,7 @@ nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLButtonElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::type) {
@ -334,11 +334,11 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
if (activeLink == this) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString base, href, target;
GetAttribute(nsString(NS_HTML_BASE_HREF), base);
GetAttribute(nsString("href"), href);
GetAttribute(nsString("target"), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
if (target.Length() == 0) {
GetAttribute(nsString(NS_HTML_BASE_TARGET), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
}
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, base, href, target, PR_TRUE);
aEventStatus = nsEventStatus_eConsumeNoDefault;
@ -355,11 +355,11 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
//mouse enter doesn't work yet. Use move until then.
{
nsAutoString base, href, target;
GetAttribute(nsString(NS_HTML_BASE_HREF), base);
GetAttribute(nsString("href"), href);
GetAttribute(nsString("target"), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
if (target.Length() == 0) {
GetAttribute(nsString(NS_HTML_BASE_TARGET), target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
}
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, base, href, target, PR_FALSE);
aEventStatus = nsEventStatus_eConsumeDoDefault;
@ -419,10 +419,9 @@ nsHTMLButtonElement::SetForm(nsIDOMHTMLFormElement* aForm)
NS_IMETHODIMP
nsHTMLButtonElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -139,7 +139,7 @@ nsHTMLDListElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -185,10 +185,9 @@ nsHTMLDListElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLDListElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -138,7 +138,7 @@ nsHTMLDelElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLDelElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -175,10 +175,9 @@ nsHTMLDelElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLDelElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -154,7 +154,7 @@ nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLDirectoryElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::type) {
@ -211,10 +211,9 @@ nsHTMLDirectoryElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLDirectoryElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -155,7 +155,7 @@ nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -205,10 +205,9 @@ nsHTMLDivElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLDivElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -143,7 +143,7 @@ nsHTMLEmbedElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLEmbedElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -191,10 +191,9 @@ nsHTMLEmbedElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLEmbedElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -214,7 +214,7 @@ nsHTMLFieldSetElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLFieldSetElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -269,10 +269,9 @@ nsHTMLFieldSetElement::SetWidget(nsIWidget* aWidget)
NS_IMETHODIMP
nsHTMLFieldSetElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -162,7 +162,7 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if ((aAttribute == nsHTMLAtoms::size) ||
@ -334,10 +334,9 @@ nsHTMLFontElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLFontElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}

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

@ -252,13 +252,13 @@ nsHTMLFormElement::GetElements(nsIDOMHTMLCollection** aElements)
NS_IMETHODIMP
nsHTMLFormElement::GetName(nsString& aValue)
{
return mInner.GetAttribute(nsHTMLAtoms::name, aValue);
return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, aValue);
}
NS_IMETHODIMP
nsHTMLFormElement::SetName(const nsString& aValue)
{
return mInner.SetAttribute(nsHTMLAtoms::name, aValue, PR_TRUE);
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, aValue, PR_TRUE);
}
NS_IMPL_STRING_ATTR(nsHTMLFormElement, AcceptCharset, acceptcharset)
@ -352,7 +352,7 @@ nsHTMLFormElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLFormElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::method) {
@ -439,7 +439,7 @@ nsHTMLFormElement::RemoveElement(nsIFormControl* aChild, PRBool aChildIsRef)
NS_IMETHODIMP
nsHTMLFormElement::GetEncoding(nsString& aEncoding)
{
return mInner.GetAttribute(nsHTMLAtoms::encoding, aEncoding);
return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::encoding, aEncoding);
}
NS_IMETHODIMP
@ -581,9 +581,9 @@ nsFormControlList::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
if (NS_OK == result) {
nsAutoString name;
// XXX Should it be an EqualsIgnoreCase?
if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
if (((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name))) ||
((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name)))) {
result = control->QueryInterface(kIDOMNodeIID, (void **)aReturn);
}
@ -597,10 +597,9 @@ nsFormControlList::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
NS_IMETHODIMP
nsHTMLFormElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -182,7 +182,7 @@ nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLFrameElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::frameborder) {
@ -224,10 +224,9 @@ nsHTMLFrameElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLFrameElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -150,7 +150,7 @@ nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLFrameSetElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::frameborder) {
@ -189,10 +189,9 @@ nsHTMLFrameSetElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLFrameSetElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -194,7 +194,7 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -259,10 +259,9 @@ nsHTMLHRElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLHRElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -134,7 +134,7 @@ nsHTMLHeadElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLHeadElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -169,10 +169,9 @@ nsHTMLHeadElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLHeadElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -140,7 +140,7 @@ nsHTMLHeadingElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -190,10 +190,9 @@ nsHTMLHeadingElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLHeadingElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -140,7 +140,7 @@ nsHTMLHtmlElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLHtmlElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -178,10 +178,9 @@ nsHTMLHtmlElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLHtmlElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -202,7 +202,7 @@ nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLIFrameElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::frameborder) {
@ -283,10 +283,9 @@ nsHTMLIFrameElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLIFrameElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -212,7 +212,7 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -351,13 +351,12 @@ nsHTMLImageElement::Finalize(JSContext *aContext)
NS_IMETHODIMP
nsHTMLImageElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (aAttribute == nsHTMLAtoms::src)
*aHint = NS_STYLE_HINT_CONTENT;
else
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -133,7 +133,7 @@ protected:
PRBool IsImage() const {
nsAutoString tmp;
mInner.GetAttribute(nsHTMLAtoms::type, tmp);
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
return tmp.EqualsIgnoreCase("image");
}
};
@ -252,20 +252,20 @@ nsHTMLInputElement::GetForm(nsIDOMHTMLFormElement** aForm)
NS_IMETHODIMP
nsHTMLInputElement::GetDefaultValue(nsString& aDefaultValue)
{
return mInner.GetAttribute(nsHTMLAtoms::value, aDefaultValue);
return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aDefaultValue);
}
NS_IMETHODIMP
nsHTMLInputElement::SetDefaultValue(const nsString& aDefaultValue)
{
return mInner.SetAttribute(nsHTMLAtoms::value, aDefaultValue, PR_TRUE);
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aDefaultValue, PR_TRUE);
}
NS_IMETHODIMP
nsHTMLInputElement::GetDefaultChecked(PRBool* aDefaultChecked)
{
nsHTMLValue val;
nsresult rv = mInner.GetAttribute(nsHTMLAtoms::checked, val);
nsresult rv = mInner.GetHTMLAttribute(nsHTMLAtoms::checked, val);
*aDefaultChecked = (NS_CONTENT_ATTR_NOT_THERE != rv);
return NS_OK;
}
@ -273,11 +273,11 @@ nsHTMLInputElement::GetDefaultChecked(PRBool* aDefaultChecked)
NS_IMETHODIMP
nsHTMLInputElement::SetDefaultChecked(PRBool aDefaultChecked)
{
nsAutoString empty;
nsHTMLValue empty(eHTMLUnit_Empty);
if (aDefaultChecked) {
return mInner.SetAttribute(nsHTMLAtoms::checked, empty, PR_TRUE);
return mInner.SetHTMLAttribute(nsHTMLAtoms::checked, empty, PR_TRUE);
} else {
mInner.UnsetAttribute(nsHTMLAtoms::checked, PR_TRUE);
mInner.UnsetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::checked, PR_TRUE);
return NS_OK;
}
}
@ -302,7 +302,7 @@ NS_IMPL_STRING_ATTR(nsHTMLInputElement, UseMap, usemap)
NS_IMETHODIMP
nsHTMLInputElement::GetType(nsString& aValue)
{
mInner.GetAttribute(nsHTMLAtoms::type, aValue);
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, aValue);
return NS_OK;
}
@ -323,7 +323,7 @@ nsHTMLInputElement::GetValue(nsString& aValue)
}
}
return mInner.GetAttribute(nsHTMLAtoms::value, aValue);
return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue);
}
@ -343,7 +343,7 @@ nsHTMLInputElement::SetValue(const nsString& aValue)
}
}
return mInner.SetAttribute(nsHTMLAtoms::value, aValue, PR_TRUE);
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue, PR_TRUE);
}
NS_IMETHODIMP
@ -382,8 +382,8 @@ nsHTMLInputElement::SetChecked(PRBool aValue)
GetType(&type);
if ((NS_FORM_INPUT_CHECKBOX == type) || (NS_FORM_INPUT_RADIO == type)) {
nsAutoString value;
value = (aValue) ? "1" : "0";
mInner.SetAttribute("checked", value, PR_TRUE);
value = (aValue) ? "1" : "0"; // XXX this should use nsHTMLValue and store an empty or not
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::checked, value, PR_TRUE);
}
return SetDefaultChecked(aValue);
@ -524,7 +524,7 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::type) {
@ -675,7 +675,6 @@ nsHTMLInputElement::SetWidget(nsIWidget* aWidget)
NS_IMETHODIMP
nsHTMLInputElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
@ -683,7 +682,7 @@ nsHTMLInputElement::GetStyleHintForAttributeChange(
nsHTMLAtoms::value == aAttribute) {
*aHint = (nsnull != mWidget ? NS_STYLE_HINT_CONTENT : NS_STYLE_HINT_REFLOW);
} else {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}
}

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

@ -138,7 +138,7 @@ nsHTMLInsElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLInsElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -175,10 +175,9 @@ nsHTMLInsElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLInsElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -144,7 +144,7 @@ nsHTMLIsIndexElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLIsIndexElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -181,10 +181,9 @@ nsHTMLIsIndexElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLIsIndexElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -159,7 +159,7 @@ nsHTMLLIElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::type) {
@ -209,10 +209,9 @@ nsHTMLLIElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLLIElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -214,7 +214,7 @@ NS_IMPL_STRING_ATTR(nsHTMLLabelElement, AccessKey, accesskey)
NS_IMETHODIMP
nsHTMLLabelElement::GetHtmlFor(nsString& aValue)
{
mInner.GetAttribute(nsHTMLAtoms::_for, aValue);
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_for, aValue);
return NS_OK;
}
@ -225,7 +225,7 @@ nsHTMLLabelElement::SetHtmlFor(const nsString& aValue)
static char whitespace[] = " \r\n\t";
nsString value(aValue);
value.Trim(whitespace, PR_TRUE, PR_TRUE);
return mInner.SetAttribute(nsHTMLAtoms::defaultvalue, value, PR_TRUE);
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::defaultvalue, value, PR_TRUE);
}
NS_IMETHODIMP
@ -238,7 +238,7 @@ nsHTMLLabelElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLLabelElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -272,10 +272,9 @@ nsHTMLLabelElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLLabelElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -176,7 +176,7 @@ nsHTMLLegendElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLLegendElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -217,10 +217,9 @@ nsHTMLLegendElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLLegendElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -158,7 +158,7 @@ nsHTMLLinkElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLLinkElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -193,10 +193,9 @@ nsHTMLLinkElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLLinkElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -144,7 +144,7 @@ nsHTMLMapElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLMapElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -181,10 +181,9 @@ nsHTMLMapElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLMapElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -154,7 +154,7 @@ nsHTMLMenuElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLMenuElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::type) {
@ -210,10 +210,9 @@ nsHTMLMenuElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLMenuElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -143,7 +143,7 @@ nsHTMLMetaElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLMetaElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -178,10 +178,9 @@ nsHTMLMetaElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLMetaElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -138,7 +138,7 @@ nsHTMLModElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLModElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -175,10 +175,9 @@ nsHTMLModElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLModElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -181,7 +181,7 @@ nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLOListElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::type) {
@ -237,10 +237,9 @@ nsHTMLOListElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLOListElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -199,7 +199,7 @@ nsHTMLObjectElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -247,10 +247,9 @@ nsHTMLObjectElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLObjectElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -138,7 +138,7 @@ nsHTMLOptGroupElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLOptGroupElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -175,10 +175,9 @@ nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLOptGroupElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -184,7 +184,7 @@ NS_IMETHODIMP
nsHTMLOptionElement::GetSelected(PRBool *aSelected)
{
nsHTMLValue val;
nsresult rv = mInner.GetAttribute(nsHTMLAtoms::selected, val);
nsresult rv = mInner.GetHTMLAttribute(nsHTMLAtoms::selected, val);
*aSelected = NS_CONTENT_ATTR_NOT_THERE != rv;
return NS_OK;
}
@ -213,7 +213,7 @@ nsHTMLOptionElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLOptionElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -267,10 +267,9 @@ nsHTMLOptionElement::GetText(nsString& aText)
NS_IMETHODIMP
nsHTMLOptionElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -147,7 +147,7 @@ nsHTMLParagraphElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -198,10 +198,9 @@ nsHTMLParagraphElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLParagraphElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -144,7 +144,7 @@ nsHTMLParamElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLParamElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -181,10 +181,9 @@ nsHTMLParamElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLParamElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -162,7 +162,7 @@ nsHTMLPreElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLPreElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -226,10 +226,9 @@ nsHTMLPreElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLPreElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -135,7 +135,7 @@ nsHTMLQuoteElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLQuoteElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -172,10 +172,9 @@ nsHTMLQuoteElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLQuoteElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -198,7 +198,7 @@ nsHTMLScriptElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLScriptElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -233,10 +233,9 @@ nsHTMLScriptElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLScriptElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -360,7 +360,7 @@ nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLSelectElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -619,9 +619,9 @@ nsOptionList::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
if (NS_OK == result) {
nsAutoString name;
// XXX Should it be an EqualsIgnoreCase?
if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
if (((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name))) ||
((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name)))) {
result = option->QueryInterface(kIDOMNodeIID, (void **)aReturn);
}
@ -647,10 +647,9 @@ nsOptionList::Clear()
NS_IMETHODIMP
nsHTMLSelectElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -199,7 +199,7 @@ nsHTMLObjectElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -247,10 +247,9 @@ nsHTMLObjectElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLObjectElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -147,7 +147,7 @@ nsHTMLSpacerElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLSpacerElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -221,10 +221,9 @@ nsHTMLSpacerElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLSpacerElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -121,7 +121,7 @@ nsHTMLSpanElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLSpanElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
@ -158,10 +158,9 @@ nsHTMLSpanElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLSpanElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -142,7 +142,7 @@ nsHTMLStyleElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLStyleElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -177,10 +177,9 @@ nsHTMLStyleElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLStyleElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -148,7 +148,7 @@ nsHTMLTableCaptionElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTableCaptionElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
@ -215,10 +215,9 @@ nsHTMLTableCaptionElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLTableCaptionElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -358,7 +358,7 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
/* ignore these attributes, stored already as strings
@ -479,11 +479,10 @@ nsHTMLTableCellElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLTableCellElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode,
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(this,
aAttribute, aHint)) {
// Do nothing
}
@ -495,4 +494,4 @@ nsHTMLTableCellElement::GetStyleHintForAttributeChange(
*aHint = NS_STYLE_HINT_REFLOW;
}
return NS_OK;
}
}

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

@ -192,7 +192,7 @@ nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
/* ignore these attributes, stored already as strings
@ -317,11 +317,10 @@ NS_METHOD nsHTMLTableColElement::GetSpanValue(PRInt32* aSpan)
NS_IMETHODIMP
nsHTMLTableColElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode,
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(this,
aAttribute, aHint)) {
// Do nothing
}
@ -329,4 +328,4 @@ nsHTMLTableColElement::GetStyleHintForAttributeChange(
*aHint = NS_STYLE_HINT_REFLOW;
}
return NS_OK;
}
}

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

@ -181,7 +181,7 @@ nsHTMLTableColGroupElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTableColGroupElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
/* ignore these attributes, stored already as strings
@ -292,11 +292,10 @@ nsHTMLTableColGroupElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLTableColGroupElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode,
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(this,
aAttribute, aHint)) {
// Do nothing
}
@ -304,4 +303,4 @@ nsHTMLTableColGroupElement::GetStyleHintForAttributeChange(
*aHint = NS_STYLE_HINT_REFLOW;
}
return NS_OK;
}
}

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

@ -917,7 +917,7 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
/* ignore summary, just a string */
@ -1230,11 +1230,10 @@ nsHTMLTableElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLTableElement::GetStyleHintForAttributeChange(
const nsIContent* aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode,
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(this,
aAttribute, aHint)) {
// Do nothing
}

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

@ -526,7 +526,7 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTableRowElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
/* ignore these attributes, stored already as strings
@ -615,11 +615,10 @@ nsHTMLTableRowElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLTableRowElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode,
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(this,
aAttribute, aHint)) {
// Do nothing
}

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

@ -261,7 +261,7 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTableSectionElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
/* ignore these attributes, stored already as strings
@ -351,11 +351,10 @@ nsHTMLTableSectionElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLTableSectionElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode,
if (PR_TRUE == nsGenericHTMLElement::SetStyleHintForCommonAttributes(this,
aAttribute, aHint)) {
// Do nothing
}
@ -363,4 +362,4 @@ nsHTMLTableSectionElement::GetStyleHintForAttributeChange(
*aHint = NS_STYLE_HINT_REFLOW;
}
return NS_OK;
}
}

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

@ -275,7 +275,7 @@ nsHTMLTextAreaElement::GetValue(nsString& aValue)
}
}
return mInner.GetAttribute(nsHTMLAtoms::value, aValue);
return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue);
}
@ -291,13 +291,13 @@ nsHTMLTextAreaElement::SetValue(const nsString& aValue)
}
}
return mInner.SetAttribute(nsHTMLAtoms::value, aValue, PR_TRUE);
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue, PR_TRUE);
}
NS_IMETHODIMP
nsHTMLTextAreaElement::GetDefaultValue(nsString& aDefaultValue)
{
mInner.GetAttribute(nsHTMLAtoms::defaultvalue, aDefaultValue);
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::defaultvalue, aDefaultValue);
return NS_OK;
}
@ -308,8 +308,8 @@ nsHTMLTextAreaElement::SetDefaultValue(const nsString& aDefaultValue)
static char whitespace[] = " \r\n\t";
nsString value(aDefaultValue);
value.Trim(whitespace, PR_TRUE, PR_FALSE);
mInner.SetAttribute(nsHTMLAtoms::defaultvalue, value, PR_TRUE);
mInner.SetAttribute(nsHTMLAtoms::value, value, PR_TRUE);
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::defaultvalue, value, PR_TRUE);
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, value, PR_TRUE);
return NS_OK;
}
@ -344,7 +344,7 @@ nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTextAreaElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -447,10 +447,9 @@ nsHTMLTextAreaElement::SetForm(nsIDOMHTMLFormElement* aForm)
NS_IMETHODIMP
nsHTMLTextAreaElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -135,7 +135,7 @@ nsHTMLTitleElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLTitleElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -171,10 +171,9 @@ nsHTMLTitleElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLTitleElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -159,7 +159,7 @@ nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLUListElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::type) {
@ -215,10 +215,9 @@ nsHTMLUListElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLUListElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -132,7 +132,7 @@ nsHTMLWBRElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLWBRElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
const nsHTMLValue& aValue,
nsString& aResult) const
{
return mInner.AttributeToString(aAttribute, aValue, aResult);
@ -168,10 +168,9 @@ nsHTMLWBRElement::HandleDOMEvent(nsIPresContext& aPresContext,
NS_IMETHODIMP
nsHTMLWBRElement::GetStyleHintForAttributeChange(
const nsIContent * aNode,
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::SetStyleHintForCommonAttributes(aNode, aAttribute, aHint);
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK;
}
}

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

@ -53,6 +53,7 @@
#include "nsIWebShell.h"
#include "nsIHTMLDocument.h"
#include "nsINameSpaceManager.h"
// XXX Go through a factory for this one
#include "nsICSSParser.h"
@ -462,12 +463,12 @@ AddAttributes(const nsIParserNode& aNode,
nsHTMLValue value;
if (NS_CONTENT_ATTR_NOT_THERE ==
aContent->GetAttribute(keyAtom, value)) {
aContent->GetHTMLAttribute(keyAtom, value)) {
// Get value and remove mandatory quotes
GetAttributeValueAt(aNode, i, v, aScriptContextOwner);
// Add attribute to content
aContent->SetAttribute(keyAtom, v, PR_FALSE);
aContent->SetAttribute(kNameSpaceID_HTML, keyAtom, v, PR_FALSE);
}
NS_RELEASE(keyAtom);
}
@ -1982,12 +1983,10 @@ void
HTMLContentSink::AddBaseTagInfo(nsIHTMLContent* aContent)
{
if (mBaseHREF.Length() > 0) {
nsHTMLValue value(mBaseHREF);
aContent->SetAttribute(nsHTMLAtoms::_baseHref, value, PR_FALSE);
aContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, mBaseHREF, PR_FALSE);
}
if (mBaseTarget.Length() > 0) {
nsHTMLValue value(mBaseTarget);
aContent->SetAttribute(nsHTMLAtoms::_baseTarget, value, PR_FALSE);
aContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, mBaseTarget, PR_FALSE);
}
}
@ -1998,7 +1997,7 @@ HTMLContentSink::ProcessATag(const nsIParserNode& aNode,
AddBaseTagInfo(aContent);
if ((nsnull != mRef) && (nsnull == mRefContent)) {
nsHTMLValue value;
aContent->GetAttribute(nsHTMLAtoms::name, value);
aContent->GetHTMLAttribute(nsHTMLAtoms::name, value);
if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString tmp;
value.GetStringValue(tmp);
@ -2249,10 +2248,10 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
rv = mDocumentURL->QueryInterface(kIHTTPURLIID, (void **)&httpUrl);
if (NS_OK == rv) {
nsAutoString header;
it->GetAttribute(nsHTMLAtoms::httpEquiv, header);
it->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::httpEquiv, header);
if (header.Length() > 0) {
nsAutoString result;
it->GetAttribute(nsHTMLAtoms::content, result);
it->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::content, result);
if (result.Length() > 0) {
char* value = result.ToNewCString(), *csHeader;
if (!value) {

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

@ -49,6 +49,7 @@
#include "nsRepository.h"
#include "nsParserCIID.h"
#include "nsIDOMHTMLElement.h"
#include "nsINameSpaceManager.h"
#ifdef PCB_USE_PROTOCOL_CONNECTION
// beard: how else would we get the referrer to a URL?
@ -697,7 +698,7 @@ nsHTMLDocument::MatchLinks(nsIContent *aContent)
if ((nsnull != name) &&
(area.EqualsIgnoreCase(name) || anchor.EqualsIgnoreCase(name)) &&
(NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute("HREF", attr))) {
(NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, attr))) {
result = PR_TRUE;
}
@ -733,7 +734,7 @@ nsHTMLDocument::MatchAnchors(nsIContent *aContent)
if ((nsnull != name) &&
anchor.EqualsIgnoreCase(name) &&
(NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute("NAME", attr))) {
(NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, attr))) {
result = PR_TRUE;
}
@ -860,15 +861,14 @@ nsHTMLDocument::Writeln(JSContext *cx, jsval *argv, PRUint32 argc)
nsIContent *
nsHTMLDocument::MatchName(nsIContent *aContent, const nsString& aName)
{
static nsAutoString name("NAME"), id("ID");
nsAutoString value;
nsIContent *result = nsnull;
if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(id, value)) &&
if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, value)) &&
aName.Equals(value)) {
return aContent;
}
else if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(name, value)) &&
else if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, value)) &&
aName.Equals(value)) {
return aContent;
}
@ -1050,8 +1050,6 @@ static PRBool
IsNamedItem(nsIContent* aContent, nsIAtom *aTag,
PRBool aInForm, nsString& aName)
{
static nsAutoString name("NAME");
// Only the content types reflected in Level 0 with a NAME
// attribute are registered. Images and forms always get
// reflected up to the document. Applets and embeds only go
@ -1059,7 +1057,7 @@ IsNamedItem(nsIContent* aContent, nsIAtom *aTag,
if ((aTag == nsHTMLAtoms::img) || (aTag == nsHTMLAtoms::form) ||
(!aInForm && ((aTag == nsHTMLAtoms::applet) ||
(aTag == nsHTMLAtoms::embed)))) {
if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(name, aName)) {
if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, aName)) {
return PR_TRUE;
}
}

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

@ -313,8 +313,8 @@ nsImageDocument::CreateSyntheticDocument()
mDocumentURL->ToString(&src);
nsHTMLValue val(src);
delete src;
image->SetAttribute(nsHTMLAtoms::src, val, PR_FALSE);
image->SetAttribute(nsHTMLAtoms::alt, val, PR_FALSE);
image->SetHTMLAttribute(nsHTMLAtoms::src, val, PR_FALSE);
image->SetHTMLAttribute(nsHTMLAtoms::alt, val, PR_FALSE);
root->AppendChildTo(body, PR_FALSE);
center->AppendChildTo(image, PR_FALSE);

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

@ -43,6 +43,7 @@
#include "nsIXMLDocument.h"
#include "nsIWebShell.h"
#include "nsHTMLContainerFrame.h"
#include "nsINameSpaceManager.h"
static NS_DEFINE_IID(kIHTMLStyleSheetIID, NS_IHTML_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
@ -63,7 +64,7 @@ public:
NS_IMETHOD HashValue(PRUint32& aValue) const;
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
// Strength is an out-of-band weighting, always 0 here
NS_IMETHOD GetStrength(PRInt32& aStrength);
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
@ -109,7 +110,7 @@ HTMLAnchorRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
// Strength is an out-of-band weighting, always 0 here
NS_IMETHODIMP
HTMLAnchorRule::GetStrength(PRInt32& aStrength)
HTMLAnchorRule::GetStrength(PRInt32& aStrength) const
{
aStrength = 0;
return NS_OK;
@ -254,10 +255,6 @@ public:
// Attribute management methods, aAttributes is an in/out param
NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
NS_IMETHOD SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue,
nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
@ -395,9 +392,6 @@ protected:
nsIFrame* GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext,
nsIContent* aContent);
PRBool AttributeRequiresRepaint(nsIAtom* aAttribute);
PRBool AttributeRequiresReflow (nsIAtom* aAttribute);
protected:
PRUint32 mInHeap : 1;
PRUint32 mRefCnt : 31;
@ -536,7 +530,7 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) &&
(nsnull != linkHandler)) {
nsAutoString base, href; // XXX base??
nsresult attrState = htmlContent->GetAttribute("href", href);
nsresult attrState = htmlContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
if (NS_CONTENT_ATTR_HAS_VALUE == attrState) {
nsIURL* docURL = nsnull;
@ -762,49 +756,6 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIHTMLContent* aContent, nsI
return NS_OK;
}
NS_IMETHODIMP HTMLStyleSheetImpl::SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aID);
nsMapAttributesFunc mapFunc;
aContent->GetAttributeMappingFunction(mapFunc);
result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetID(aID, count);
result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aClass);
nsMapAttributesFunc mapFunc;
aContent->GetAttributeMappingFunction(mapFunc);
result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetClass(aClass, count);
result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
const nsString& aValue,
nsIHTMLContent* aContent,
@ -1033,7 +984,7 @@ HTMLStyleSheetImpl::CreateInputFrame(nsIContent* aContent, nsIFrame*& aFrame)
// Figure out which type of input frame to create
nsAutoString val;
if (NS_OK == aContent->GetAttribute(nsAutoString("type"), val)) {
if (NS_OK == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, val)) {
if (val.EqualsIgnoreCase("submit")) {
rv = NS_NewButtonControlFrame(aFrame);
}
@ -2562,7 +2513,7 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext,
if (NS_OK == result) {
// Get style hint from HTML content object.
htmlContent->GetStyleHintForAttributeChange(aContent, aAttribute, &aHint);
htmlContent->GetStyleHintForAttributeChange(aAttribute, &aHint);
NS_RELEASE(htmlContent);
}
}

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

@ -37,34 +37,32 @@ class nsIHTMLStyleSheet;
class nsIHTMLAttributes : public nsISupports {
public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
PRInt32& aCount) = 0;
PRInt32& aAttrCount) = 0;
// this string value version lets you avoid an extra string copy,
// the value is still stored in a nsHTMLValue
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRInt32& aCount) = 0;
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRInt32& aCount) = 0;
PRInt32& aAttrCount) = 0;
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRInt32& aAttrCount) = 0;
NS_IMETHOD GetAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const = 0;
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const = 0;
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
nsIAtom*& aName) const = 0;
NS_IMETHOD Count(PRInt32& aCount) const = 0;
NS_IMETHOD GetAttributeCount(PRInt32& aAttrCount) const = 0;
NS_IMETHOD Equals(const nsIHTMLAttributes* aAttributes, PRBool& aResult) const = 0;
NS_IMETHOD HashValue(PRUint32& aValue) const = 0;
NS_IMETHOD SetID(nsIAtom* aID, PRInt32& aCount) = 0;
NS_IMETHOD GetID(nsIAtom*& aResult) const = 0;
NS_IMETHOD SetClass(nsIAtom* aClass, PRInt32& aCount) = 0; // XXX this will have to change for CSS2
NS_IMETHOD GetClass(nsIAtom*& aResult) const = 0; // XXX this will have to change for CSS2
NS_IMETHOD GetClasses(nsVoidArray& aArray) const = 0;
NS_IMETHOD HasClass(nsIAtom* aClass) const = 0;
NS_IMETHOD AddContentRef(void) = 0;
NS_IMETHOD ReleaseContentRef(void) = 0;
NS_IMETHOD GetContentRefCount(PRInt32& aCount) = 0;
NS_IMETHOD GetContentRefCount(PRInt32& aCount) const = 0;
NS_IMETHOD Clone(nsIHTMLAttributes** aInstancePtrResult) = 0;
NS_IMETHOD Clone(nsIHTMLAttributes** aInstancePtrResult) const = 0;
NS_IMETHOD Reset(void) = 0;
NS_IMETHOD SetMappingFunction(nsMapAttributesFunc aMapFunc) = 0;
NS_IMETHOD SetStyleSheet(nsIHTMLStyleSheet* aSheet) = 0;

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

@ -21,7 +21,6 @@
#include "nsIDocument.h"
#include "nsIAtom.h"
#include "nsIEventListenerManager.h"
#include "nsIHTMLAttributes.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsIEventStateManager.h"
@ -45,6 +44,10 @@ NS_NewXMLElement(nsIXMLContent** aInstancePtrResult, nsIAtom* aTag)
return it->QueryInterface(kIXMLContentIID, (void**) aInstancePtrResult);
}
static nsIAtom* kLinkAtom; // XXX these should get moved to nsXMLAtoms
static nsIAtom* kHrefAtom;
static nsIAtom* kShowAtom;
nsXMLElement::nsXMLElement(nsIAtom *aTag)
{
NS_INIT_REFCNT();
@ -53,11 +56,26 @@ nsXMLElement::nsXMLElement(nsIAtom *aTag)
mNameSpaceID = kNameSpaceID_None;
mScriptObject = nsnull;
mIsLink = PR_FALSE;
if (nsnull == kLinkAtom) {
kLinkAtom = NS_NewAtom("link");
kHrefAtom = NS_NewAtom("href");
kShowAtom = NS_NewAtom("show");
}
else {
NS_ADDREF(kLinkAtom);
NS_ADDREF(kHrefAtom);
NS_ADDREF(kShowAtom);
}
}
nsXMLElement::~nsXMLElement()
{
NS_IF_RELEASE(mNameSpacePrefix);
nsrefcnt refcnt;
NS_RELEASE2(kLinkAtom, refcnt);
NS_RELEASE2(kHrefAtom, refcnt);
NS_RELEASE2(kShowAtom, refcnt);
}
NS_IMETHODIMP
@ -166,20 +184,19 @@ nsXMLElement::GetNameSpaceID(PRInt32& aNameSpaceID) const
}
NS_IMETHODIMP
nsXMLElement::SetAttribute(const nsString& aName,
const nsString& aValue,
PRBool aNotify)
nsXMLElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue,
PRBool aNotify)
{
// XXX It sucks that we have to do a couple of strcmps for
// XXX It sucks that we have to do a strcmp for
// every attribute set. It might be a bit more expensive
// to create an atom.
// XXX this is wrong anyway, the attributes need to use the
// namespace ID, not the prefix
if (aName.Equals("xml:link") && (aValue.Equals("simple"))) {
if ((kNameSpaceID_XML == aNameSpaceID) &&
(aName == kLinkAtom) && (aValue.Equals("simple"))) {
mIsLink = PR_TRUE;
}
return mInner.SetAttribute(aName, aValue, aNotify);
return mInner.SetAttribute(aNameSpaceID, aName, aValue, aNotify);
}
NS_IMETHODIMP
@ -221,8 +238,8 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsLinkVerb verb = eLinkVerb_Replace;
base.Truncate();
target.Truncate();
GetAttribute(nsString("href"), href);
GetAttribute(nsString("show"), show);
GetAttribute(kNameSpaceID_XML, kHrefAtom, href);
GetAttribute(kNameSpaceID_XML, kShowAtom, show);
// XXX Should probably do this using atoms
if (show.Equals("new")) {
verb = eLinkVerb_New;
@ -245,9 +262,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
//mouse enter doesn't work yet. Use move until then.
{
nsAutoString base, href, target;
base.Truncate();
target.Truncate();
GetAttribute(nsString("href"), href);
GetAttribute(kNameSpaceID_XML, kHrefAtom, href);
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, base, href, target, PR_FALSE);
aEventStatus = nsEventStatus_eConsumeDoDefault;
}

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

@ -101,18 +101,19 @@ public:
NS_IMETHOD GetTag(nsIAtom*& aResult) const {
return mInner.GetTag(aResult);
}
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue,
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue,
PRBool aNotify);
NS_IMETHOD GetAttribute(const nsString& aName,
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const {
return mInner.GetAttribute(aName, aResult);
return mInner.GetAttribute(aNameSpaceID, aName, aResult);
}
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) {
return mInner.UnsetAttribute(aAttribute, aNotify);
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify) {
return mInner.UnsetAttribute(aNameSpaceID, aName, aNotify);
}
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aResult) const {
return mInner.GetAllAttributeNames(aArray, aResult);
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const {
return mInner.GetAttributeNameAt(aIndex, aNameSpaceID, aName);
}
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const {
return mInner.GetAttributeCount(aResult);

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

@ -405,35 +405,38 @@ GetAttributeValueAt(const nsIParserNode& aNode,
}
// XXX Code copied from nsHTMLContentSink. It should be shared.
static nsresult
AddAttributes(const nsIParserNode& aNode,
nsIContent* aContent,
PRBool aIsHTML)
nsresult
nsXMLContentSink::AddAttributes(const nsIParserNode& aNode,
nsIContent* aContent,
PRBool aIsHTML)
{
// Add tag attributes to the content attributes
nsAutoString k, v;
nsAutoString name, v;
PRInt32 ac = aNode.GetAttributeCount();
for (PRInt32 i = 0; i < ac; i++) {
// Get upper-cased key
const nsString& key = aNode.GetKeyAt(i);
k.Truncate();
k.Append(key);
name.Truncate();
name.Append(key);
if (aIsHTML) {
k.ToUpperCase();
name.ToUpperCase();
}
// XXX TODO Currently we don't look for namespace identifiers
// in the attribute name
nsIAtom* nameSpacePrefix = CutNameSpacePrefix(name);
nsIAtom* nameAtom = NS_NewAtom(name);
PRInt32 nameSpaceID = GetNameSpaceId(nameSpacePrefix);
nsAutoString value;
if (NS_CONTENT_ATTR_NOT_THERE ==
aContent->GetAttribute(k, value)) {
aContent->GetAttribute(nameSpaceID, nameAtom, value)) {
// Get value and remove mandatory quotes
GetAttributeValueAt(aNode, i, v);
// Add attribute to content
aContent->SetAttribute(k, v, PR_FALSE);
aContent->SetAttribute(nameSpaceID, nameAtom, v, PR_FALSE);
}
NS_RELEASE(nameAtom);
NS_IF_RELEASE(nameSpacePrefix);
}
return NS_OK;
}
@ -1058,6 +1061,9 @@ nsXMLContentSink::AddEntityReference(const nsIParserNode& aNode)
PRInt32
nsXMLContentSink::GetNameSpaceId(nsIAtom* aPrefix)
{
if (nsnull == aPrefix) {
return kNameSpaceID_None;
}
PRInt32 id = kNameSpaceID_Unknown;
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
PRInt32 index = mNameSpaceStack->Count() - 1;

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

@ -91,6 +91,9 @@ protected:
nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
PRBool* aDidFlush=nsnull);
nsresult AddAttributes(const nsIParserNode& aNode,
nsIContent* aContent,
PRBool aIsHTML);
nsresult AddContentAsLeaf(nsIContent *aContent);
void PushNameSpacesFrom(const nsIParserNode& aNode);
nsIAtom* CutNameSpacePrefix(nsString& aString);

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

@ -21,6 +21,9 @@
#include "nsIDOMNode.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocument.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms
nsContentList::nsContentList(nsIDocument *aDocument)
{
@ -197,9 +200,9 @@ nsContentList::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
if (nsnull != content) {
nsAutoString name;
// XXX Should it be an EqualsIgnoreCase?
if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
if (((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name))) ||
((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) &&
((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
(aName.Equals(name)))) {
return content->QueryInterface(kIDOMNodeIID, (void **)aReturn);
}

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

@ -129,19 +129,22 @@ public:
{ return mInner.RemoveChildAt(aIndex, aNotify); }
NS_IMETHOD IsSynthetic(PRBool& aResult)
{ return mInner.IsSynthetic(aResult); }
NS_IMETHOD SetAttribute(const nsString& aName,
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue,
PRBool aNotify)
{ return NS_OK; }
NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const
{ return NS_CONTENT_ATTR_NOT_THERE; }
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify)
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify)
{ return NS_OK; }
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCountResult) const
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
{
aCountResult = 0;
return NS_OK;
aName = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
}
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const
{

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

@ -25,6 +25,7 @@
#include "nsIURL.h"
#include "nsIInputStream.h"
#include "nsHTMLEntities.h"
#include "nsINameSpaceManager.h"
#include "stdlib.h"
static NS_DEFINE_IID(kIFrameUtilIID, NS_IFRAME_UTIL_IID);
@ -164,22 +165,24 @@ static nsresult
AddAttributes(const nsIParserNode& aNode, nsIContent* aContent)
{
// Add tag attributes to the content attributes
nsAutoString k, v;
nsAutoString name, value;
PRInt32 ac = aNode.GetAttributeCount();
for (PRInt32 i = 0; i < ac; i++) {
// Get upper-cased key
const nsString& key = aNode.GetKeyAt(i);
k.Truncate();
k.Append(key);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
key.ToUpperCase(name);
nsAutoString value;
if (NS_CONTENT_ATTR_NOT_THERE == aContent->GetAttribute(k, value)) {
nsIAtom* nameAtom = NS_NewAtom(name);
if (NS_CONTENT_ATTR_NOT_THERE == aContent->GetAttribute(kNameSpaceID_None, nameAtom, value)) {
// Get value and remove mandatory quotes
GetAttributeValueAt(aNode, i, v);
GetAttributeValueAt(aNode, i, value);
// Add attribute to content
aContent->SetAttribute(k, v, PR_FALSE);
aContent->SetAttribute(kNameSpaceID_None, nameAtom, value, PR_FALSE);
}
NS_RELEASE(nameAtom);
}
return NS_OK;
}

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

@ -55,7 +55,6 @@
#include "prmem.h"
#include "nsHTMLAtoms.h"
#include "nsIHTMLAttributes.h"
NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
@ -366,7 +365,13 @@ nsDOMAttributeMap::GetNamedItem(const nsString &aAttrName,
nsIDOMNode** aAttribute)
{
nsAutoString value;
mContent->GetAttribute(aAttrName, value);
// XXX need to parse namespace fom attribute name
// XXX need to uppercace name only if HTML namespace
nsAutoString upper;
aAttrName.ToUpperCase(upper);
nsIAtom* nameAtom = NS_NewAtom(upper);
mContent->GetAttribute(kNameSpaceID_HTML, nameAtom, value);
NS_RELEASE(nameAtom);
*aAttribute = (nsIDOMNode *) new nsDOMAttribute(aAttrName, value);
return NS_OK;
}
@ -387,7 +392,12 @@ nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
attribute->GetValue(value);
NS_RELEASE(attribute);
mContent->SetAttribute(name, value, PR_TRUE);
// XXX need to parse namespace from attribute name
// XXX also need to uppercase name only if HTML namespace
name.ToUpperCase();
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->SetAttribute(kNameSpaceID_HTML, nameAtom, value, PR_TRUE);
NS_RELEASE(nameAtom);
return NS_OK;
}
@ -396,10 +406,12 @@ nsDOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
{
nsresult res = GetNamedItem(aName, aReturn);
if (NS_OK == res) {
// XXX need to parse namespace from attribute name
// XXX need to uppercase only if HTML namespace
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr, PR_TRUE);
mContent->UnsetAttribute(kNameSpaceID_HTML, attr, PR_TRUE);
}
return res;
@ -409,27 +421,19 @@ nsresult
nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{
nsresult res = NS_ERROR_FAILURE;
nsAutoString name, value;
nsISupportsArray *attributes = nsnull;
if (NS_OK == NS_NewISupportsArray(&attributes)) {
PRInt32 count;
mContent->GetAllAttributeNames(attributes, count);
if (count > 0) {
if ((PRInt32)aIndex < count) {
nsISupports *att = attributes->ElementAt(aIndex);
static NS_DEFINE_IID(kIAtom, NS_IATOM_IID);
nsIAtom *atName = nsnull;
if (nsnull != att && NS_OK == att->QueryInterface(kIAtom, (void**)&atName)) {
atName->ToString(name);
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(name, value)) {
*aReturn = (nsIDOMNode *)new nsDOMAttribute(name, value);
res = NS_OK;
}
NS_RELEASE(atName);
}
}
PRInt32 nameSpaceID;
nsIAtom* nameAtom = nsnull;
if (NS_SUCCEEDED(mContent->GetAttributeNameAt(aIndex, nameSpaceID, nameAtom))) {
nsAutoString value;
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(nameSpaceID, nameAtom, value)) {
// XXX need to prefix namespace if present
nsAutoString name;
nameAtom->ToString(name);
*aReturn = (nsIDOMNode *)new nsDOMAttribute(name, value);
res = NS_OK;
}
NS_RELEASE(attributes);
NS_RELEASE(nameAtom);
}
return res;
@ -745,6 +749,8 @@ nsGenericElement::GetTagName(nsString& aTagName)
{
aTagName.Truncate();
if (nsnull != mTag) {
// note that we assume no namespace here, subclasses that support
// namespaces must override
mTag->ToString(aTagName);
}
return NS_OK;
@ -753,37 +759,52 @@ nsGenericElement::GetTagName(nsString& aTagName)
nsresult
nsGenericElement::GetDOMAttribute(const nsString& aName, nsString& aReturn)
{
mContent->GetAttribute(aName, aReturn);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
mContent->GetAttribute(kNameSpaceID_None, nameAtom, aReturn);
NS_RELEASE(nameAtom);
return NS_OK;
}
nsresult
nsGenericElement::SetDOMAttribute(const nsString& aName,
const nsString& aValue)
const nsString& aValue)
{
mContent->SetAttribute(aName, aValue, PR_TRUE);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
mContent->SetAttribute(kNameSpaceID_None, nameAtom, aValue, PR_TRUE);
NS_RELEASE(nameAtom);
return NS_OK;
}
nsresult
nsGenericElement::RemoveAttribute(const nsString& aName)
{
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr, PR_TRUE);
NS_RELEASE(attr);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
mContent->UnsetAttribute(kNameSpaceID_None, nameAtom, PR_TRUE);
NS_RELEASE(nameAtom);
return NS_OK;
}
nsresult
nsGenericElement::GetAttributeNode(const nsString& aName,
nsIDOMAttr** aReturn)
nsIDOMAttr** aReturn)
{
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(aName);
nsAutoString value;
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(aName, value)) {
if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(kNameSpaceID_None, nameAtom, value)) {
*aReturn = new nsDOMAttribute(aName, value);
}
else {
*aReturn = nsnull;
}
NS_RELEASE(nameAtom);
return NS_OK;
}
@ -801,7 +822,11 @@ nsGenericElement::SetAttributeNode(nsIDOMAttr* aAttribute,
if (NS_OK == res) {
res = aAttribute->GetValue(value);
if (NS_OK == res) {
mContent->SetAttribute(name, value, PR_TRUE);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->SetAttribute(kNameSpaceID_None, nameAtom, value, PR_TRUE);
NS_RELEASE(nameAtom);
}
}
}
@ -820,10 +845,11 @@ nsGenericElement::RemoveAttributeNode(nsIDOMAttr* aAttribute,
nsAutoString name;
res = aAttribute->GetName(name);
if (NS_OK == res) {
nsAutoString upper;
name.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr, PR_TRUE);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
nsIAtom* nameAtom = NS_NewAtom(name);
mContent->UnsetAttribute(kNameSpaceID_None, nameAtom, PR_TRUE);
NS_RELEASE(nameAtom);
}
}
@ -1454,57 +1480,25 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute,
//----------------------------------------------------------------------
// Nothing for now, though XMLContent might want to define this
// to deal with certain types of attributes with the HTML namespace
static void
MapAttributesInto(nsIHTMLAttributes* aAttributes,
nsIStyleContext* aContext,
nsIPresContext* aPresContext)
struct nsGenericAttribute
{
}
// XXX This routine was copied from EnsureWriteableAttributes and
// modified slightly. Could be shared code.
static nsresult EnsureWritableAttributes(nsIContent* aContent,
nsIHTMLAttributes*& aAttributes,
PRBool aCreate)
{
nsresult result = NS_OK;
if (nsnull == aAttributes) {
if (PR_TRUE == aCreate) {
if (NS_OK == result) {
result = NS_NewHTMLAttributes(&aAttributes, nsnull, &MapAttributesInto);
if (NS_OK == result) {
aAttributes->AddContentRef();
}
}
}
nsGenericAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue)
: mNameSpaceID(aNameSpaceID),
mName(aName),
mValue(aValue)
{
NS_IF_ADDREF(mName);
}
else {
// To allow for the case where the attribute set is shared
// between content.
PRInt32 contentRefCount;
aAttributes->GetContentRefCount(contentRefCount);
if (1 < contentRefCount) {
nsIHTMLAttributes* attrs;
result = aAttributes->Clone(&attrs);
if (NS_OK == result) {
aAttributes->ReleaseContentRef();
NS_RELEASE(aAttributes);
aAttributes = attrs;
aAttributes->AddContentRef();
}
}
}
return result;
}
static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes)
{
aAttributes->ReleaseContentRef();
NS_RELEASE(aAttributes);
}
~nsGenericAttribute(void)
{
NS_IF_RELEASE(mName);
}
PRInt32 mNameSpaceID;
nsIAtom* mName;
nsString mValue;
};
nsGenericContainerElement::nsGenericContainerElement()
{
@ -1513,13 +1507,19 @@ nsGenericContainerElement::nsGenericContainerElement()
nsGenericContainerElement::~nsGenericContainerElement()
{
PRInt32 n = mChildren.Count();
for (PRInt32 i = 0; i < n; i++) {
nsIContent* kid = (nsIContent *)mChildren.ElementAt(i);
PRInt32 count = mChildren.Count();
PRInt32 index;
for (index = 0; index < count; index++) {
nsIContent* kid = (nsIContent *)mChildren.ElementAt(index);
NS_RELEASE(kid);
}
if (nsnull != mAttributes) {
ReleaseAttributes(mAttributes);
count = mAttributes->Count();
for (index = 0; index < count; index++) {
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
delete attr;
}
delete mAttributes;
}
}
@ -1823,162 +1823,173 @@ nsGenericContainerElement::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aRetu
nsresult
nsGenericContainerElement::SetAttribute(const nsString& aName,
nsGenericContainerElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue,
PRBool aNotify)
{
nsresult rv = NS_OK;;
nsIAtom* attr = NS_NewAtom(aName);
rv = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
PRInt32 count;
rv = mAttributes->SetAttribute(attr, aValue, count);
if (0 == count) {
ReleaseAttributes(mAttributes);
}
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, attr, NS_STYLE_HINT_UNKNOWN);
}
NS_ASSERTION(kNameSpaceID_Unknown != aNameSpaceID, "must have name space ID");
if (kNameSpaceID_Unknown == aNameSpaceID) {
return NS_ERROR_ILLEGAL_VALUE;
}
NS_ASSERTION(nsnull != aName, "must have attribute name");
if (nsnull == aName) {
return NS_ERROR_NULL_POINTER;
}
NS_RELEASE(attr);
return rv;
}
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
nsresult
nsGenericContainerElement::GetAttribute(const nsString& aName,
nsString& aResult) const
{
nsresult rv = NS_OK;;
nsIAtom* attr = NS_NewAtom(aName);
nsHTMLValue value;
char cbuf[20];
nscolor color;
if (nsnull == mAttributes) {
mAttributes = new nsVoidArray();
}
if (nsnull != mAttributes) {
rv = mAttributes->GetAttribute(attr, value);
if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
// XXX Again this is code that is copied from nsGenericHTMLElement
// and could potentially be shared. In any case, we don't expect
// anything that's not a string.
// Provide default conversions for most everything
switch (value.GetUnit()) {
case eHTMLUnit_Empty:
aResult.Truncate();
break;
case eHTMLUnit_String:
case eHTMLUnit_Null:
value.GetStringValue(aResult);
break;
case eHTMLUnit_Integer:
aResult.Truncate();
aResult.Append(value.GetIntValue(), 10);
break;
case eHTMLUnit_Pixel:
aResult.Truncate();
aResult.Append(value.GetPixelValue(), 10);
break;
case eHTMLUnit_Percent:
aResult.Truncate(0);
aResult.Append(PRInt32(value.GetPercentValue() * 100.0f), 10);
aResult.Append('%');
break;
case eHTMLUnit_Color:
color = nscolor(value.GetColorValue());
PR_snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
NS_GET_R(color), NS_GET_G(color), NS_GET_B(color));
aResult.Truncate(0);
aResult.Append(cbuf);
break;
default:
case eHTMLUnit_Enumerated:
NS_NOTREACHED("no default enumerated value to string conversion");
rv = NS_CONTENT_ATTR_NOT_THERE;
break;
nsGenericAttribute* attr;
PRInt32 index;
PRInt32 count = mAttributes->Count();
for (index = 0; index < count; index++) {
attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
if ((aNameSpaceID == attr->mNameSpaceID) && (aName == attr->mName)) {
attr->mValue = aValue;
rv = NS_OK;
break;
}
}
if (index >= count) { // didn't find it
attr = new nsGenericAttribute(aNameSpaceID, aName, aValue);
if (nsnull != attr) {
mAttributes->AppendElement(attr);
rv = NS_OK;
}
}
}
else {
rv = NS_CONTENT_ATTR_NOT_THERE;
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aName, NS_STYLE_HINT_UNKNOWN);
}
NS_RELEASE(attr);
return rv;
}
nsresult
nsGenericContainerElement::UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify)
nsGenericContainerElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const
{
nsresult rv = NS_OK;;
NS_ASSERTION(nsnull != aName, "must have attribute name");
if (nsnull == aName) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv = NS_CONTENT_ATTR_NOT_THERE;
rv = EnsureWritableAttributes(mContent, mAttributes, PR_FALSE);
if (nsnull != mAttributes) {
PRInt32 count;
rv = mAttributes->UnsetAttribute(aAttribute, count);
if (0 == count) {
ReleaseAttributes(mAttributes);
PRInt32 count = mAttributes->Count();
PRInt32 index;
for (index = 0; index < count; index++) {
const nsGenericAttribute* attr = (const nsGenericAttribute*)mAttributes->ElementAt(index);
if ((attr->mNameSpaceID == aNameSpaceID) && (attr->mName == aName)) {
aResult = attr->mValue;
if (0 < aResult.Length()) {
rv = NS_CONTENT_ATTR_HAS_VALUE;
}
else {
rv = NS_CONTENT_ATTR_NO_VALUE;
}
break;
}
}
}
return rv;
}
nsresult
nsGenericContainerElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify)
{
NS_ASSERTION(nsnull != aName, "must have attribute name");
if (nsnull == aName) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv = NS_OK;
if (nsnull != mAttributes) {
PRInt32 count = mAttributes->Count();
PRInt32 index;
for (index = 0; index < count; index++) {
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
if ((attr->mNameSpaceID == aNameSpaceID) && (attr->mName == aName)) {
mAttributes->RemoveElementAt(index);
delete attr;
break;
}
}
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aAttribute, NS_STYLE_HINT_UNKNOWN);
mDocument->AttributeChanged(mContent, aName, NS_STYLE_HINT_UNKNOWN);
}
}
return rv;
}
nsresult
nsGenericContainerElement::GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const
nsresult
nsGenericContainerElement::GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
{
if (nsnull != mAttributes) {
return mAttributes->GetAllAttributeNames(aArray, aCount);
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(aIndex);
if (nsnull != attr) {
aNameSpaceID = attr->mNameSpaceID;
aName = attr->mName;
NS_IF_ADDREF(aName);
return NS_OK;
}
}
aCount = 0;
return NS_OK;
aNameSpaceID = kNameSpaceID_None;
aName = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
}
nsresult
nsGenericContainerElement::GetAttributeCount(PRInt32& aResult) const
{
if (nsnull != mAttributes) {
return mAttributes->Count(aResult);
aResult = mAttributes->Count();
}
else {
aResult = 0;
}
aResult = 0;
return NS_OK;
}
void
nsGenericContainerElement::ListAttributes(FILE* out) const
{
nsISupportsArray* attrs;
if (NS_OK == NS_NewISupportsArray(&attrs)) {
PRInt32 index, count;
GetAllAttributeNames(attrs, count);
for (index = 0; index < count; index++) {
// name
nsIAtom* attr = (nsIAtom*)attrs->ElementAt(index);
nsAutoString buffer;
attr->ToString(buffer);
PRInt32 index, count;
GetAttributeCount(count);
// value
nsAutoString value;
GetAttribute(buffer, value);
buffer.Append("=");
buffer.Append(value);
for (index = 0; index < count; index++) {
const nsGenericAttribute* attr = (const nsGenericAttribute*)mAttributes->ElementAt(index);
nsAutoString buffer;
fputs(" ", out);
fputs(buffer, out);
NS_RELEASE(attr);
if (kNameSpaceID_None != attr->mNameSpaceID) { // prefix namespace
buffer.Append(attr->mNameSpaceID, 10);
buffer.Append(':');
}
NS_RELEASE(attrs);
// name
nsAutoString name;
attr->mName->ToString(name);
buffer.Append(name);
// value
buffer.Append("=");
buffer.Append(attr->mValue);
fputs(" ", out);
fputs(buffer, out);
}
}

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

@ -45,7 +45,6 @@ class nsISupportsArray;
class nsIDOMScriptObjectFactory;
class nsDOMCSSDeclaration;
class nsIDOMCSSStyleDeclaration;
class nsIHTMLAttributes;
// Attribute helper class used to wrap up an attribute with a dom
// object that implements nsIDOMAttr and nsIDOMNode and
@ -297,12 +296,16 @@ public:
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
// Remainder of nsIContent
nsresult SetAttribute(const nsString& aName, const nsString& aValue,
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue,
PRBool aNotify);
nsresult GetAttribute(const nsString& aName, nsString& aResult) const;
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const;
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const;
nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify);
nsresult GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const;
nsresult GetAttributeCount(PRInt32& aResult) const;
nsresult List(FILE* out, PRInt32 aIndent) const;
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
@ -320,7 +323,7 @@ public:
void ListAttributes(FILE* out) const;
nsIHTMLAttributes* mAttributes;
nsVoidArray* mAttributes;
nsVoidArray mChildren;
};
@ -495,20 +498,22 @@ public:
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
return _g.GetTag(aResult); \
} \
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, \
PRBool aNotify) { \
return _g.SetAttribute(aName, aValue, aNotify); \
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
const nsString& aValue, PRBool aNotify) { \
return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \
} \
NS_IMETHOD GetAttribute(const nsString& aName, \
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
nsString& aResult) const { \
return _g.GetAttribute(aName, aResult); \
return _g.GetAttribute(aNameSpaceID, aName, aResult); \
} \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
return _g.UnsetAttribute(aAttribute, aNotify); \
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
PRBool aNotify) { \
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
} \
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
PRInt32& aResult) const { \
return _g.GetAllAttributeNames(aArray, aResult); \
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
PRInt32& aNameSpaceID, \
nsIAtom*& aName) const { \
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
} \
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
return _g.GetAttributeCount(aResult); \

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

@ -34,8 +34,8 @@
#include "nsIView.h"
#include "nsHTMLParts.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsHTMLParts.h"
#include "nsIFormControl.h"
#include "nsINameSpaceManager.h"
// XXX make this pixels
#define CONTROL_SPACING 40
@ -176,16 +176,6 @@ void nsFileControlFrame::MouseClicked(nsIPresContext* aPresContext)
}
void SetType(nsIHTMLContent* aElement, nsString& aValue)
{
nsIHTMLContent* iContent = nsnull;
nsresult result = aElement->QueryInterface(kIHTMLContentIID, (void**)&iContent);
if ((NS_OK == result) && iContent) {
iContent->SetAttribute("type", aValue, PR_FALSE);
NS_RELEASE(iContent);
}
}
NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -201,9 +191,9 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext,
nsIHTMLContent* text = nsnull;
nsIAtom* tag = NS_NewAtom("text");
NS_NewHTMLInputElement(&text, tag);
text->SetAttribute("type", "text", PR_FALSE);
text->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, nsAutoString("text"), PR_FALSE);
if (disabled) {
text->SetAttribute("disabled", "1", PR_FALSE);
text->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, nsAutoString("1"), PR_FALSE); // XXX this should use an "empty" bool value
}
NS_NewTextControlFrame(childFrame);
childFrame->Init(aPresContext, text, this, mStyleContext);
@ -213,9 +203,9 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext,
nsIHTMLContent* browse = nsnull;
tag = NS_NewAtom("browse");
NS_NewHTMLInputElement(&browse, tag);
browse->SetAttribute("type", "browse", PR_FALSE);
browse->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, nsAutoString("browse"), PR_FALSE);
if (disabled) {
browse->SetAttribute("disabled", "1", PR_FALSE);
browse->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, nsAutoString("1"), PR_FALSE); // XXX should be "empty"
}
NS_NewButtonControlFrame(childFrame);
((nsButtonControlFrame*)childFrame)->SetFileControlFrame(this);
@ -282,7 +272,7 @@ nsFileControlFrame::GetName(nsString* aResult)
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
if ((NS_OK == result) && formControl) {
nsHTMLValue value;
result = formControl->GetAttribute(nsHTMLAtoms::name, value);
result = formControl->GetHTMLAttribute(nsHTMLAtoms::name, value);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(*aResult);

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

@ -49,6 +49,7 @@
#include "nsIContent.h"
#include "nsGlobalVariables.h"
#include "nsStyleUtil.h"
#include "nsINameSpaceManager.h"
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
@ -524,7 +525,7 @@ nsFormControlFrame::GetMaxLength(PRInt32* aSize)
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
if (nsnull != content) {
nsHTMLValue value;
result = content->GetAttribute(nsHTMLAtoms::maxlength, value);
result = content->GetHTMLAttribute(nsHTMLAtoms::maxlength, value);
if (eHTMLUnit_Integer == value.GetUnit()) {
*aSize = value.GetIntValue();
}
@ -542,7 +543,7 @@ nsFormControlFrame::GetSize(PRInt32* aSize) const
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
if (nsnull != content) {
nsHTMLValue value;
result = content->GetAttribute(nsHTMLAtoms::size, value);
result = content->GetHTMLAttribute(nsHTMLAtoms::size, value);
if (eHTMLUnit_Integer == value.GetUnit()) {
*aSize = value.GetIntValue();
}
@ -575,7 +576,7 @@ nsFormControlFrame::GetName(nsString* aResult)
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
if ((NS_OK == result) && formControl) {
nsHTMLValue value;
result = formControl->GetAttribute(nsHTMLAtoms::name, value);
result = formControl->GetHTMLAttribute(nsHTMLAtoms::name, value);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(*aResult);
@ -596,7 +597,7 @@ nsFormControlFrame::GetValue(nsString* aResult)
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
if ((NS_OK == result) && formControl) {
nsHTMLValue value;
result = formControl->GetAttribute(nsHTMLAtoms::value, value);
result = formControl->GetHTMLAttribute(nsHTMLAtoms::value, value);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(*aResult);
@ -788,12 +789,12 @@ nsFormControlFrame::CalculateSize (nsIPresContext* aPresContext, nsFormControlFr
nsAutoString valAttr;
nsresult valStatus = NS_CONTENT_ATTR_NOT_THERE;
if (nsnull != aSpec.mColValueAttr) {
valStatus = hContent->GetAttribute(aSpec.mColValueAttr, valAttr);
valStatus = hContent->GetAttribute(kNameSpaceID_HTML, aSpec.mColValueAttr, valAttr);
}
nsHTMLValue colAttr;
nsresult colStatus = NS_CONTENT_ATTR_NOT_THERE;
if (nsnull != aSpec.mColSizeAttr) {
colStatus = hContent->GetAttribute(aSpec.mColSizeAttr, colAttr);
colStatus = hContent->GetHTMLAttribute(aSpec.mColSizeAttr, colAttr);
}
float p2t;
aPresContext->GetScaledPixelsToTwips(p2t);
@ -842,7 +843,7 @@ nsFormControlFrame::CalculateSize (nsIPresContext* aPresContext, nsFormControlFr
nsHTMLValue rowAttr;
nsresult rowStatus = NS_CONTENT_ATTR_NOT_THERE;
if (nsnull != aSpec.mRowSizeAttr) {
rowStatus = hContent->GetAttribute(aSpec.mRowSizeAttr, rowAttr);
rowStatus = hContent->GetHTMLAttribute(aSpec.mRowSizeAttr, rowAttr);
}
if (NS_CONTENT_ATTR_HAS_VALUE == rowStatus) { // row attr will provide height
PRInt32 rowAttrInt = ((rowAttr.GetUnit() == eHTMLUnit_Pixel) ? rowAttr.GetPixelValue() : rowAttr.GetIntValue());

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

@ -246,7 +246,7 @@ nsHTMLButtonControlFrame::GetName(nsString* aResult)
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
if ((NS_OK == result) && formControl) {
nsHTMLValue value;
result = formControl->GetAttribute(nsHTMLAtoms::name, value);
result = formControl->GetHTMLAttribute(nsHTMLAtoms::name, value);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(*aResult);
@ -267,7 +267,7 @@ nsHTMLButtonControlFrame::GetValue(nsString* aResult)
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
if ((NS_OK == result) && formControl) {
nsHTMLValue value;
result = formControl->GetAttribute(nsHTMLAtoms::value, value);
result = formControl->GetHTMLAttribute(nsHTMLAtoms::value, value);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(*aResult);

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

@ -169,7 +169,7 @@ PRInt32 nsLegendFrame::GetAlign()
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
if (nsnull != content) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::align, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::align, value))) {
if (eHTMLUnit_Enumerated == value.GetUnit()) {
intValue = value.GetIntValue();
}

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

@ -4408,7 +4408,7 @@ nsBlockFrame::RenumberLists(nsBlockReflowState& aState)
if (mContent && (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc))) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::start, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::start, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
ordinal = value.GetIntValue();
if (ordinal <= 0) {

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

@ -4408,7 +4408,7 @@ nsBlockFrame::RenumberLists(nsBlockReflowState& aState)
if (mContent && (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc))) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::start, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::start, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
ordinal = value.GetIntValue();
if (ordinal <= 0) {

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

@ -4408,7 +4408,7 @@ nsBlockFrame::RenumberLists(nsBlockReflowState& aState)
if (mContent && (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc))) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::start, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::start, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
ordinal = value.GetIntValue();
if (ordinal <= 0) {

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

@ -171,7 +171,7 @@ nsBulletFrame::SetListItemOrdinal(PRInt32 aNextOrdinal)
nsIHTMLContent* hc;
if (NS_OK == parentContent->QueryInterface(kIHTMLContentIID, (void**) &hc)) {
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::value, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::value, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
// Use ordinal specified by the value attribute
mOrdinal = value.GetIntValue();

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

@ -422,7 +422,7 @@ PRBool nsHTMLFrameInnerFrame::GetURL(nsIContent* aContent, nsString& aResult)
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
if (nsnull != content) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::src, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::src, value))) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(aResult);
if (aResult.Length() > 0) {
@ -445,7 +445,7 @@ PRBool nsHTMLFrameInnerFrame::GetName(nsIContent* aContent, nsString& aResult)
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
if (nsnull != content) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::name, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::name, value))) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(aResult);
result = PR_TRUE;
@ -465,7 +465,7 @@ PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent, PRBool aStanda
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
if (nsnull != content) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::scrolling, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::scrolling, value))) {
if (eHTMLUnit_Enumerated == value.GetUnit()) {
PRInt32 returnValue;
PRInt32 intValue;
@ -499,7 +499,7 @@ nsFrameborder nsHTMLFrameInnerFrame::GetFrameBorder(PRBool aStandardMode)
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
if (nsnull != content) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::frameborder, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::frameborder, value))) {
if (eHTMLUnit_Enumerated == value.GetUnit()) {
PRInt32 intValue;
intValue = value.GetIntValue();
@ -536,7 +536,7 @@ PRInt32 nsHTMLFrameInnerFrame::GetMarginWidth(nsIPresContext* aPresContext, nsIC
float p2t;
aPresContext->GetScaledPixelsToTwips(p2t);
nsHTMLValue value;
content->GetAttribute(nsHTMLAtoms::marginwidth, value);
content->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
marginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
if (marginWidth < 0) {
@ -556,7 +556,7 @@ PRInt32 nsHTMLFrameInnerFrame::GetMarginHeight(nsIPresContext* aPresContext, nsI
float p2t;
aPresContext->GetScaledPixelsToTwips(p2t);
nsHTMLValue value;
content->GetAttribute(nsHTMLAtoms::marginheight, value);
content->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
marginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
if (marginHeight < 0) {
@ -615,8 +615,8 @@ void TempMakeAbsURL(nsIContent* aContent, nsString& aRelURL, nsString& aAbsURL)
}
nsAutoString base;
if (NS_CONTENT_ATTR_HAS_VALUE != aContent->GetAttribute(NS_HTML_BASE_HREF, base)) {
base = "";
if (NS_CONTENT_ATTR_HAS_VALUE != aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base)) {
base.Truncate();
}
nsresult rv = NS_MakeAbsoluteURL(docURL, base, aRelURL, aAbsURL);
NS_IF_RELEASE(docURL);

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

@ -312,7 +312,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext)
nsIHTMLContent* content = nsnull;
mContent->QueryInterface(kIHTMLContentIID, (void**)&content);
if (nsnull != content) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::border, htmlVal))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::border, htmlVal))) {
nsHTMLUnit unit = htmlVal.GetUnit();
PRInt32 intVal = 0;
if (eHTMLUnit_Pixel == unit) {
@ -493,7 +493,7 @@ void nsHTMLFramesetFrame::ParseRowCol(nsIAtom* aAttrType, PRInt32& aNumSpecs, ns
nsIHTMLContent* content = nsnull;
nsresult result = mContent->QueryInterface(kIHTMLContentIID, (void**)&content);
if (nsnull != content) {
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(aAttrType, value)) {
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetHTMLAttribute(aAttrType, value)) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(rowsCols);
nsFramesetSpec* specs = new nsFramesetSpec[gMaxNumRowColSpecs];
@ -688,7 +688,7 @@ nsFrameborder GetFrameBorderHelper(nsIHTMLContent* aContent, PRBool aStandardMod
{
if (nsnull != aContent) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetAttribute(nsHTMLAtoms::frameborder, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetHTMLAttribute(nsHTMLAtoms::frameborder, value))) {
if (eHTMLUnit_Enumerated == value.GetUnit()) {
PRInt32 intValue;
intValue = value.GetIntValue();
@ -751,7 +751,7 @@ nscolor nsHTMLFramesetFrame::GetBorderColor()
mContent->QueryInterface(kIHTMLContentIID, (void**)&content);
if (nsnull != content) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::bordercolor, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
if (value.GetUnit() == eHTMLUnit_Color) {
result = value.GetColorValue();
} else if (value.GetUnit() == eHTMLUnit_String) {
@ -777,7 +777,7 @@ nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent)
aContent->QueryInterface(kIHTMLContentIID, (void**)&content);
if (nsnull != content) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetAttribute(nsHTMLAtoms::bordercolor, value))) {
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
if (value.GetUnit() == eHTMLUnit_Color) {
result = value.GetColorValue();
} else if (value.GetUnit() == eHTMLUnit_String) {
@ -1240,7 +1240,7 @@ nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame)
content->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
if (nsnull != htmlContent) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetAttribute(nsHTMLAtoms::noresize, value)) {
if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetHTMLAttribute(nsHTMLAtoms::noresize, value)) {
result = PR_TRUE;
}
NS_RELEASE(htmlContent);

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

@ -25,6 +25,7 @@
#include "nsIURL.h"
#include "nsIInputStream.h"
#include "nsHTMLEntities.h"
#include "nsINameSpaceManager.h"
#include "stdlib.h"
static NS_DEFINE_IID(kIFrameUtilIID, NS_IFRAME_UTIL_IID);
@ -164,22 +165,24 @@ static nsresult
AddAttributes(const nsIParserNode& aNode, nsIContent* aContent)
{
// Add tag attributes to the content attributes
nsAutoString k, v;
nsAutoString name, value;
PRInt32 ac = aNode.GetAttributeCount();
for (PRInt32 i = 0; i < ac; i++) {
// Get upper-cased key
const nsString& key = aNode.GetKeyAt(i);
k.Truncate();
k.Append(key);
// XXX need to parse namespace from name
// XXX need to uppercase name if HTML namespace
key.ToUpperCase(name);
nsAutoString value;
if (NS_CONTENT_ATTR_NOT_THERE == aContent->GetAttribute(k, value)) {
nsIAtom* nameAtom = NS_NewAtom(name);
if (NS_CONTENT_ATTR_NOT_THERE == aContent->GetAttribute(kNameSpaceID_None, nameAtom, value)) {
// Get value and remove mandatory quotes
GetAttributeValueAt(aNode, i, v);
GetAttributeValueAt(aNode, i, value);
// Add attribute to content
aContent->SetAttribute(k, v, PR_FALSE);
aContent->SetAttribute(kNameSpaceID_None, nameAtom, value, PR_FALSE);
}
NS_RELEASE(nameAtom);
}
return NS_OK;
}

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

@ -44,6 +44,7 @@
#include "nsCSSRendering.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsIDeviceContext.h"
#include "nsINameSpaceManager.h"
#ifndef _WIN32
#define BROKEN_IMAGE_URL "resource:/res/html/broken-image.gif"
@ -423,11 +424,11 @@ nsImageFrame::Reflow(nsIPresContext& aPresContext,
// source URL and base URL
if (eReflowReason_Initial == aReflowState.reason) {
nsAutoString src, base;
if ((NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", src)) &&
if ((NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, src)) &&
(src.Length() > 0)) {
mImageLoader.SetURL(src);
if (NS_CONTENT_ATTR_HAS_VALUE ==
mContent->GetAttribute(NS_HTML_BASE_HREF, base)) {
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base)) {
mImageLoader.SetBaseHREF(base);
}
}
@ -637,7 +638,7 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext& aPresContext,
// If there's still room, display the alt-text
if (!inner.IsEmpty()) {
nsAutoString altText;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ALT", altText)) {
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::alt, altText)) {
DisplayAltText(aPresContext, aRenderingContext, altText, inner);
}
}
@ -715,7 +716,7 @@ nsImageFrame::GetImageMap()
{
if (nsnull == mImageMap) {
nsAutoString usemap;
mContent->GetAttribute("usemap", usemap);
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::usemap, usemap);
if (0 == usemap.Length()) {
return nsnull;
}
@ -767,14 +768,14 @@ PRBool
nsImageFrame::IsServerImageMap()
{
nsAutoString ismap;
return NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ismap", ismap);
return NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::ismap, ismap);
}
PRIntn
nsImageFrame::GetSuppress()
{
nsAutoString s;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("suppress", s)) {
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::suppress, s)) {
if (s.EqualsIgnoreCase("true")) {
return SUPPRESS;
} else if (s.EqualsIgnoreCase("false")) {
@ -848,9 +849,9 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
else {
suppress = GetSuppress();
nsAutoString baseURL;
mContent->GetAttribute(NS_HTML_BASE_HREF, baseURL);
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, baseURL);
nsAutoString src;
mContent->GetAttribute("src", src);
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, src);
NS_MakeAbsoluteURL(docURL, baseURL, src, absURL);
// Note: We don't subtract out the border/padding here to remain
@ -938,7 +939,7 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext,
mImageLoader.GetURL(oldSRC);
nsAutoString newSRC;
aChild->GetAttribute("src", newSRC);
aChild->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, newSRC);
if (!oldSRC.Equals(newSRC)) {
mSizeFrozen = PR_TRUE;

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

@ -40,6 +40,7 @@
#include "nsIJVMPluginTagInfo.h"
#include "nsIWebShell.h"
#include "nsIBrowserWindow.h"
#include "nsINameSpaceManager.h"
// XXX For temporary paint code
#include "nsIStyleContext.h"
@ -389,10 +390,10 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
buf = (char *)PR_Malloc(PL_strlen("application/x-java-vm") + 1);
PL_strcpy(buf, "application/x-java-vm");
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("CODE", src)) {
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::code, src)) {
SetURL(src);
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("CODEBASE", base))
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::codebase, base))
SetBaseHREF(base);
nsIPresShell *shell = aPresContext.GetShell();
@ -410,7 +411,7 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
}
}
else {
mContent->GetAttribute(nsString("type"), type);
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, type);
buflen = type.Length();
@ -423,10 +424,10 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
//stream in the object source if there is one...
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", src)) {
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, src)) {
SetURL(src);
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(NS_HTML_BASE_HREF, base))
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base))
SetBaseHREF(base);
nsIPresShell *shell = aPresContext.GetShell();
@ -818,90 +819,77 @@ NS_IMETHODIMP nsPluginInstanceOwner :: GetAttributes(PRUint16& n,
const char*const*& names,
const char*const*& values)
{
nsresult rv;
nsIHTMLContent *content;
nsIContent *icontent;
nsresult rv;
nsIContent* iContent;
if ((nsnull == mAttrNames) && (nsnull != mOwner))
{
rv = mOwner->GetContent(icontent);
if ((nsnull == mAttrNames) && (nsnull != mOwner)) {
rv = mOwner->GetContent(iContent);
if (rv == NS_OK)
{
rv = icontent->QueryInterface(kIHTMLContentIID, (void **)&content);
if (NS_SUCCEEDED(rv)) {
PRInt32 count;
if (NS_OK == rv)
{
nsISupportsArray *array;
if (NS_SUCCEEDED(iContent->GetAttributeCount(count))) {
PRInt32 index;
mAttrNames = (char **)PR_Calloc(sizeof(char *) * count, 1);
mAttrVals = (char **)PR_Calloc(sizeof(char *) * count, 1);
mNumAttrs = 0;
rv = NS_NewISupportsArray(&array);
if ((nsnull != mAttrNames) && (nsnull != mAttrVals)) {
for (index = 0; index < count; index++) {
PRInt32 nameSpaceID;
nsIAtom* atom;
iContent->GetAttributeNameAt(index, nameSpaceID, atom);
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == iContent->GetAttribute(nameSpaceID, atom, value)) {
nsAutoString name;
atom->ToString(name);
if (NS_OK == rv)
{
PRInt32 cnt, numattrs;
mAttrNames[mNumAttrs] = (char *)PR_Malloc(name.Length() + 1);
mAttrVals[mNumAttrs] = (char *)PR_Malloc(value.Length() + 1);
if ((NS_OK == content->GetAllAttributeNames(array, numattrs)) && (numattrs > 0))
{
mAttrNames = (char **)PR_Calloc(sizeof(char *) * numattrs, 1);
mAttrVals = (char **)PR_Calloc(sizeof(char *) * numattrs, 1);
if ((nsnull != mAttrNames) && (nsnull != mAttrVals))
{
for (cnt = 0; cnt < numattrs; cnt++)
if ((nsnull != mAttrNames[mNumAttrs]) &&
(nsnull != mAttrVals[mNumAttrs]))
{
nsIAtom *atom = (nsIAtom *)array->ElementAt(cnt);
nsAutoString name, val;
name.ToCString(mAttrNames[mNumAttrs], name.Length() + 1);
value.ToCString(mAttrVals[mNumAttrs], value.Length() + 1);
if (nsnull != atom)
mNumAttrs++;
}
else
{
if (nsnull != mAttrNames[mNumAttrs])
{
atom->ToString(name);
if (NS_CONTENT_ATTR_HAS_VALUE == icontent->GetAttribute(name, val))
{
mAttrNames[mNumAttrs] = (char *)PR_Malloc(name.Length() + 1);
mAttrVals[mNumAttrs] = (char *)PR_Malloc(val.Length() + 1);
if ((nsnull != mAttrNames[mNumAttrs]) &&
(nsnull != mAttrVals[mNumAttrs]))
{
name.ToCString(mAttrNames[mNumAttrs], name.Length() + 1);
val.ToCString(mAttrVals[mNumAttrs], val.Length() + 1);
mNumAttrs++;
}
else
{
if (nsnull != mAttrNames[mNumAttrs])
{
PR_Free(mAttrNames[mNumAttrs]);
mAttrNames[mNumAttrs] = nsnull;
}
if (nsnull != mAttrVals[mNumAttrs])
{
PR_Free(mAttrVals[mNumAttrs]);
mAttrVals[mNumAttrs] = nsnull;
}
}
}
NS_RELEASE(atom);
PR_Free(mAttrNames[mNumAttrs]);
mAttrNames[mNumAttrs] = nsnull;
}
if (nsnull != mAttrVals[mNumAttrs])
{
PR_Free(mAttrVals[mNumAttrs]);
mAttrVals[mNumAttrs] = nsnull;
}
}
}
NS_RELEASE(atom);
}
}
else {
rv = NS_ERROR_OUT_OF_MEMORY;
if (nsnull != mAttrVals) {
PR_Free(mAttrVals);
mAttrVals = nsnull;
}
if (nsnull != mAttrNames) {
PR_Free(mAttrNames);
mAttrNames = nsnull;
}
NS_RELEASE(array);
}
NS_RELEASE(content);
}
NS_RELEASE(icontent);
NS_RELEASE(iContent);
}
}
else
else {
rv = NS_OK;
}
n = mNumAttrs;
names = (const char **)mAttrNames;
@ -1187,8 +1175,8 @@ NS_IMETHODIMP nsPluginInstanceOwner :: GetParameters(PRUint16& n, const char*con
//add param to list...
if ((NS_CONTENT_ATTR_HAS_VALUE == kid->GetAttribute("NAME", name)) &&
(NS_CONTENT_ATTR_HAS_VALUE == kid->GetAttribute("VALUE", val)))
if ((NS_CONTENT_ATTR_HAS_VALUE == kid->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, name)) &&
(NS_CONTENT_ATTR_HAS_VALUE == kid->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, val)))
{
mParamNames[mNumParams] = (char *)PR_Malloc(name.Length() + 1);
mParamVals[mNumParams] = (char *)PR_Malloc(val.Length() + 1);

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

@ -26,6 +26,7 @@
#include "nsUnitConversion.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsINameSpaceManager.h"
// Spacer type's
#define TYPE_WORD 0 // horizontal space
@ -84,19 +85,19 @@ SpacerFrame::Reflow(nsIPresContext& aPresContext,
if (nsnull != hc) {
if (type != TYPE_IMAGE) {
nsHTMLValue val;
ca = hc->GetAttribute(nsHTMLAtoms::size, val);
ca = hc->GetHTMLAttribute(nsHTMLAtoms::size, val);
if (NS_CONTENT_ATTR_HAS_VALUE == ca) {
width = val.GetPixelValue();
}
} else {
nsHTMLValue val;
ca = hc->GetAttribute(nsHTMLAtoms::width, val);
ca = hc->GetHTMLAttribute(nsHTMLAtoms::width, val);
if (NS_CONTENT_ATTR_HAS_VALUE == ca) {
if (eHTMLUnit_Pixel == val.GetUnit()) {
width = val.GetPixelValue();
}
}
ca = hc->GetAttribute(nsHTMLAtoms::height, val);
ca = hc->GetHTMLAttribute(nsHTMLAtoms::height, val);
if (NS_CONTENT_ATTR_HAS_VALUE == ca) {
if (eHTMLUnit_Pixel == val.GetUnit()) {
height = val.GetPixelValue();
@ -143,7 +144,8 @@ SpacerFrame::GetType()
{
PRUint8 type = TYPE_WORD;
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("type", value)) {
// XXX this would be better served by storing as an enumerated value
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, value)) {
if (value.EqualsIgnoreCase("line") ||
value.EqualsIgnoreCase("vert") ||
value.EqualsIgnoreCase("vertical")) {

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

@ -4408,7 +4408,7 @@ nsBlockFrame::RenumberLists(nsBlockReflowState& aState)
if (mContent && (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc))) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::start, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::start, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
ordinal = value.GetIntValue();
if (ordinal <= 0) {

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

@ -4408,7 +4408,7 @@ nsBlockFrame::RenumberLists(nsBlockReflowState& aState)
if (mContent && (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc))) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::start, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::start, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
ordinal = value.GetIntValue();
if (ordinal <= 0) {

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

@ -4408,7 +4408,7 @@ nsBlockFrame::RenumberLists(nsBlockReflowState& aState)
if (mContent && (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc))) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::start, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::start, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
ordinal = value.GetIntValue();
if (ordinal <= 0) {

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

@ -443,14 +443,14 @@ nsBodyFrame::DidSetStyleContext(nsIPresContext* aPresContext)
aPresContext->GetScaledPixelsToTwips(p2t);
nsIHTMLContent* hc;
if (NS_OK == mContent->QueryInterface(kIHTMLContentIID, (void**) &hc)) {
hc->GetAttribute(nsHTMLAtoms::marginwidth, value);
hc->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
if (eHTMLUnit_Pixel == value.GetUnit()) { // marginwidth is set in body
marginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
if (marginWidth < 0) {
marginWidth = 0;
}
}
hc->GetAttribute(nsHTMLAtoms::marginheight, value);
hc->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
if (eHTMLUnit_Pixel == value.GetUnit()) { // marginheight is set in body
marginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
if (marginHeight < 0) {

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

@ -171,7 +171,7 @@ nsBulletFrame::SetListItemOrdinal(PRInt32 aNextOrdinal)
nsIHTMLContent* hc;
if (NS_OK == parentContent->QueryInterface(kIHTMLContentIID, (void**) &hc)) {
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::value, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::value, value)) {
if (eHTMLUnit_Integer == value.GetUnit()) {
// Use ordinal specified by the value attribute
mOrdinal = value.GetIntValue();

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

@ -324,7 +324,7 @@ HRuleFrame::GetThickness()
// should be.
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
hc->GetAttribute(nsHTMLAtoms::size, value)) {
hc->GetHTMLAttribute(nsHTMLAtoms::size, value)) {
if (value.GetUnit() == eHTMLUnit_Pixel) {
PRInt32 pixels = value.GetPixelValue();
switch (pixels) {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше