зеркало из https://github.com/mozilla/gecko-dev.git
Bug 41983: Make (x)html-elements support namespaced attributes.
r=heikki sr=jst a=roc+moz
This commit is contained in:
Родитель
b599af5b77
Коммит
058a33eded
|
@ -223,6 +223,12 @@ public:
|
|||
mInner.mNamespaceID);
|
||||
}
|
||||
|
||||
PRBool NameAndNamespaceEquals(nsINodeInfo *aNodeInfo) const
|
||||
{
|
||||
return aNodeInfo == this || aNodeInfo->Equals(mInner.mName,
|
||||
mInner.mNamespaceID);
|
||||
}
|
||||
|
||||
PRBool Equals(nsIAtom *aNameAtom) const
|
||||
{
|
||||
return mInner.mName == aNameAtom;
|
||||
|
|
|
@ -421,10 +421,7 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
aElement->GetLocalName(tagLocalName);
|
||||
aElement->GetNamespaceURI(tagNamespaceURI);
|
||||
|
||||
PRInt32 namespaceID, elementNamespaceID;
|
||||
content->GetNameSpaceID(elementNamespaceID);
|
||||
if (elementNamespaceID == kNameSpaceID_HTML)
|
||||
ToLowerCase(tagLocalName); // XXX We shouldn't need this hack
|
||||
PRInt32 namespaceID;
|
||||
|
||||
PRInt32 index, count;
|
||||
nsAutoString nameStr, prefixStr, uriStr, valueStr;
|
||||
|
@ -440,26 +437,15 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
*getter_AddRefs(attrName),
|
||||
*getter_AddRefs(attrPrefix));
|
||||
|
||||
if (namespaceID == kNameSpaceID_XMLNS ||
|
||||
elementNamespaceID == kNameSpaceID_HTML /*XXX Hack*/) {
|
||||
if (namespaceID == kNameSpaceID_XMLNS) {
|
||||
PRBool hasPrefix = attrPrefix ? PR_TRUE : PR_FALSE;
|
||||
content->GetAttr(namespaceID, attrName, uriStr);
|
||||
|
||||
attrName->ToString(nameStr);
|
||||
// XXX We shouldn't need this hack
|
||||
if (elementNamespaceID == kNameSpaceID_HTML) {
|
||||
if (Substring(nameStr, 0, 6).Equals(NS_LITERAL_STRING("xmlns:"))) {
|
||||
nameStr.Cut(0,6);
|
||||
hasPrefix = PR_TRUE;
|
||||
} else if (!nameStr.Equals(kXMLNS)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasPrefix) {
|
||||
if (!attrPrefix) {
|
||||
// Default NS attribute does not have prefix (and the name is "xmlns")
|
||||
PushNameSpaceDecl(nsString(), uriStr, aElement);
|
||||
} else {
|
||||
attrName->ToString(nameStr);
|
||||
PushNameSpaceDecl(nameStr, uriStr, aElement);
|
||||
}
|
||||
}
|
||||
|
@ -470,8 +456,7 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
addNSAttr = ConfirmPrefix(tagPrefix, tagNamespaceURI);
|
||||
// Serialize the qualified name of the element
|
||||
AppendToString(NS_LITERAL_STRING("<"), aStr);
|
||||
if (!tagPrefix.IsEmpty() &&
|
||||
!(elementNamespaceID == kNameSpaceID_HTML && tagPrefix.Equals(kXMLNS) /*XXX Hack*/)) {
|
||||
if (!tagPrefix.IsEmpty()) {
|
||||
AppendToString(tagPrefix, aStr);
|
||||
AppendToString(NS_LITERAL_STRING(":"), aStr);
|
||||
}
|
||||
|
@ -515,8 +500,6 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
content->GetAttr(namespaceID, attrName, valueStr);
|
||||
attrName->ToString(nameStr);
|
||||
|
||||
if (elementNamespaceID == kNameSpaceID_HTML && nameStr.Equals(NS_LITERAL_STRING("xmlns:xmlns")))
|
||||
nameStr.Assign(kXMLNS); // XXX Shouldn't need this hack, breaks case where there really is xmlns:xmlns
|
||||
SerializeAttr(prefixStr, nameStr, valueStr, aStr, PR_TRUE);
|
||||
|
||||
if (addNSAttr) {
|
||||
|
@ -559,16 +542,10 @@ nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
|||
aElement->GetLocalName(tagLocalName);
|
||||
aElement->GetNamespaceURI(tagNamespaceURI);
|
||||
|
||||
PRInt32 namespaceID;
|
||||
content->GetNameSpaceID(namespaceID);
|
||||
if (namespaceID == kNameSpaceID_HTML)
|
||||
ToLowerCase(tagLocalName); // XXX We shouldn't need this hack
|
||||
|
||||
ConfirmPrefix(tagPrefix, tagNamespaceURI);
|
||||
|
||||
AppendToString(NS_LITERAL_STRING("</"), aStr);
|
||||
if (!tagPrefix.IsEmpty() &&
|
||||
!(namespaceID == kNameSpaceID_HTML && tagPrefix.Equals(kXMLNS) /*XXX Hack*/)) {
|
||||
if (!tagPrefix.IsEmpty()) {
|
||||
AppendToString(tagPrefix, aStr);
|
||||
AppendToString(NS_LITERAL_STRING(":"), aStr);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
#include "nsIFrameSelection.h"
|
||||
#include "nsIFrameUtil.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
#include "nsIDOMNSHTMLElement.h"
|
||||
#include "nsIDOMElementCSSInlineStyle.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
|
@ -189,27 +189,6 @@ nsGenericHTMLElement::Init(nsINodeInfo *aNodeInfo)
|
|||
#endif
|
||||
|
||||
|
||||
// this function is a holdover from when attributes were shared
|
||||
// leaving it in place in case we need to go back to that model
|
||||
static nsresult EnsureWritableAttributes(nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes, PRBool aCreate)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (nsnull == aAttributes) {
|
||||
if (PR_TRUE == aCreate) {
|
||||
result = NS_NewHTMLAttributes(&aAttributes);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
// aAttributes->ReleaseContentRef();
|
||||
NS_RELEASE(aAttributes);
|
||||
}
|
||||
|
||||
class nsGenericHTMLElementTearoff : public nsIDOMNSHTMLElement,
|
||||
public nsIDOMElementCSSInlineStyle
|
||||
{
|
||||
|
@ -270,9 +249,7 @@ nsGenericHTMLElement::nsGenericHTMLElement()
|
|||
|
||||
nsGenericHTMLElement::~nsGenericHTMLElement()
|
||||
{
|
||||
if (nsnull != mAttributes) {
|
||||
ReleaseAttributes(mAttributes);
|
||||
}
|
||||
delete mAttributes;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1601,7 +1578,16 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID,
|
|||
if ((kNameSpaceID_HTML != aNameSpaceID) &&
|
||||
(kNameSpaceID_None != aNameSpaceID) &&
|
||||
(kNameSpaceID_Unknown != aNameSpaceID)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
result = mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
result = nimgr->GetNodeInfo(aAttribute, nsnull, kNameSpaceID_None,
|
||||
*getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
return SetAttr(ni, aValue, aNotify);
|
||||
}
|
||||
|
||||
if (nsHTMLAtoms::style == aAttribute) {
|
||||
|
@ -1664,23 +1650,13 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID,
|
|||
GetMappedAttributeImpact(aAttribute, modHint, impact);
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet(dont_AddRef(GetAttrStyleSheet(mDocument)));
|
||||
if (sheet) { // set attr via style sheet
|
||||
result = sheet->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, mAttributes);
|
||||
}
|
||||
else { // manage this ourselves and re-sync when we connect to doc
|
||||
result = EnsureWritableAttributes(this, mAttributes, PR_TRUE);
|
||||
if (mAttributes) {
|
||||
PRInt32 count;
|
||||
result = mAttributes->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, nsnull, count);
|
||||
if (0 == count) {
|
||||
ReleaseAttributes(mAttributes);
|
||||
}
|
||||
}
|
||||
if (!mAttributes) {
|
||||
result = NS_NewHTMLAttributes(&mAttributes);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
result = mAttributes->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, sheet);
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
|
@ -1737,15 +1713,89 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo,
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aNodeInfo);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
PRInt32 nsid;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
PRInt32 namespaceID;
|
||||
|
||||
aNodeInfo->GetNameAtom(*getter_AddRefs(atom));
|
||||
aNodeInfo->GetNamespaceID(nsid);
|
||||
aNodeInfo->GetNameAtom(*getter_AddRefs(localName));
|
||||
aNodeInfo->GetNamespaceID(namespaceID);
|
||||
|
||||
// We still rely on the old way of setting the attribute.
|
||||
if (namespaceID == kNameSpaceID_HTML ||
|
||||
namespaceID == kNameSpaceID_None ||
|
||||
namespaceID == kNameSpaceID_Unknown)
|
||||
return SetAttr(namespaceID, localName, aValue, aNotify);
|
||||
|
||||
// This code is copied from SetAttr(PRInt32, nsIAtom* ,...
|
||||
// It sux that we have it duplicated, but we'll have to live with it
|
||||
// until we have better SetAttr signatures in nsIContent
|
||||
|
||||
return SetAttr(nsid, atom, aValue, aNotify);
|
||||
nsAutoString strValue;
|
||||
|
||||
// don't do any update if old == new
|
||||
rv = GetAttr(namespaceID, localName, strValue);
|
||||
if (rv != NS_CONTENT_ATTR_NOT_THERE && aValue.Equals(strValue))
|
||||
return NS_OK;
|
||||
|
||||
PRBool modification = (rv != NS_CONTENT_ATTR_NOT_THERE);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->BeginUpdate();
|
||||
mDocument->AttributeWillChange(this, namespaceID, localName);
|
||||
}
|
||||
|
||||
if (!mAttributes) {
|
||||
rv = NS_NewHTMLAttributes(&mAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = mAttributes->SetAttributeFor(aNodeInfo, aValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(this, getter_AddRefs(binding));
|
||||
if (binding)
|
||||
binding->AttributeChanged(localName, namespaceID, PR_FALSE);
|
||||
|
||||
if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
|
||||
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
nsMutationEvent mutation;
|
||||
mutation.eventStructType = NS_MUTATION_EVENT;
|
||||
mutation.message = NS_MUTATION_ATTRMODIFIED;
|
||||
mutation.mTarget = node;
|
||||
|
||||
nsAutoString attrLocalName, attrNamespace;
|
||||
localName->ToString(attrLocalName);
|
||||
aNodeInfo->GetNamespaceURI(attrNamespace);
|
||||
nsCOMPtr<nsIDOMAttr> attrNode;
|
||||
GetAttributeNodeNS(attrNamespace, attrLocalName, getter_AddRefs(attrNode));
|
||||
mutation.mRelatedNode = attrNode;
|
||||
|
||||
mutation.mAttrName = localName;
|
||||
if (!strValue.IsEmpty())
|
||||
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(strValue));
|
||||
if (!aValue.IsEmpty())
|
||||
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(aValue));
|
||||
if (modification)
|
||||
mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION;
|
||||
else
|
||||
mutation.mAttrChange = nsIDOMMutationEvent::ADDITION;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
HandleDOMEvent(nsnull, &mutation, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
|
||||
if (aNotify) {
|
||||
PRInt32 modHint = modification ? PRInt32(nsIDOMMutationEvent::MODIFICATION)
|
||||
: PRInt32(nsIDOMMutationEvent::ADDITION);
|
||||
mDocument->AttributeChanged(this, namespaceID, localName, modHint,
|
||||
NS_STYLE_HINT_UNKNOWN);
|
||||
mDocument->EndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsGenericHTMLElement::IsEventName(nsIAtom* aName)
|
||||
|
@ -1861,10 +1911,19 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute,
|
|||
}
|
||||
}
|
||||
sheet = dont_AddRef(GetAttrStyleSheet(mDocument));
|
||||
if (sheet) { // set attr via style sheet
|
||||
result = sheet->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, mAttributes);
|
||||
if (sheet) {
|
||||
if (!mAttributes) {
|
||||
nsresult rv = NS_NewHTMLAttributes(&mAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
PRInt32 count;
|
||||
result = mAttributes->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, sheet, count);
|
||||
if (0 == count) {
|
||||
delete mAttributes;
|
||||
mAttributes = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
|
@ -1909,15 +1968,17 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute,
|
|||
}
|
||||
}
|
||||
if (!sheet) { // manage this ourselves and re-sync when we connect to doc
|
||||
result = EnsureWritableAttributes(this, mAttributes, PR_TRUE);
|
||||
if (mAttributes) {
|
||||
PRInt32 count;
|
||||
result = mAttributes->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, nsnull, count);
|
||||
if (0 == count) {
|
||||
ReleaseAttributes(mAttributes);
|
||||
}
|
||||
if (!mAttributes) {
|
||||
nsresult rv = NS_NewHTMLAttributes(&mAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
PRInt32 count;
|
||||
result = mAttributes->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, sheet, count);
|
||||
if (0 == count) {
|
||||
delete mAttributes;
|
||||
mAttributes = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1929,19 +1990,15 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBoo
|
|||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
NS_ASSERTION((kNameSpaceID_HTML == aNameSpaceID) ||
|
||||
(kNameSpaceID_None == aNameSpaceID) ||
|
||||
(kNameSpaceID_Unknown == aNameSpaceID),
|
||||
"html content only holds HTML attributes");
|
||||
|
||||
if ((kNameSpaceID_HTML != aNameSpaceID) &&
|
||||
(kNameSpaceID_None != aNameSpaceID) &&
|
||||
(kNameSpaceID_Unknown != aNameSpaceID)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
if (aNameSpaceID == kNameSpaceID_HTML ||
|
||||
aNameSpaceID == kNameSpaceID_Unknown) {
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
}
|
||||
|
||||
|
||||
// Check for event handlers
|
||||
if (IsEventName(aAttribute)) {
|
||||
if (aNameSpaceID == kNameSpaceID_None &&
|
||||
IsEventName(aAttribute)) {
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
GetListenerManager(getter_AddRefs(manager));
|
||||
|
||||
|
@ -1951,14 +2008,15 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBoo
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet;
|
||||
PRInt32 impact = NS_STYLE_HINT_UNKNOWN;
|
||||
if (mDocument) {
|
||||
PRInt32 impact = NS_STYLE_HINT_UNKNOWN;
|
||||
if (aNotify) {
|
||||
mDocument->BeginUpdate();
|
||||
|
||||
mDocument->AttributeWillChange(this, aNameSpaceID, aAttribute);
|
||||
|
||||
if (nsHTMLAtoms::style == aAttribute) {
|
||||
if (aNameSpaceID == kNameSpaceID_None &&
|
||||
aAttribute == nsHTMLAtoms::style) {
|
||||
nsHTMLValue oldValue;
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != GetHTMLAttribute(aAttribute,
|
||||
oldValue)) {
|
||||
|
@ -1995,12 +2053,20 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBoo
|
|||
HandleDOMEvent(nsnull, &mutation, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
|
||||
sheet = dont_AddRef(GetAttrStyleSheet(mDocument));
|
||||
if (sheet) { // set attr via style sheet
|
||||
result = sheet->UnsetAttributeFor(aAttribute, this, mAttributes);
|
||||
sheet = dont_AddRef(GetAttrStyleSheet(mDocument));
|
||||
if (sheet && mAttributes) {
|
||||
PRInt32 count;
|
||||
result = mAttributes->UnsetAttributeFor(aAttribute, aNameSpaceID, this,
|
||||
sheet, count);
|
||||
if (0 == count) {
|
||||
delete mAttributes;
|
||||
mAttributes = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
|
@ -2013,57 +2079,48 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBoo
|
|||
mDocument->EndUpdate();
|
||||
}
|
||||
}
|
||||
if (!sheet) { // manage this ourselves and re-sync when we connect to doc
|
||||
result = EnsureWritableAttributes(this, mAttributes, PR_FALSE);
|
||||
if (mAttributes) {
|
||||
PRInt32 count;
|
||||
result = mAttributes->UnsetAttributeFor(aAttribute, this, nsnull, count);
|
||||
if (0 == count) {
|
||||
ReleaseAttributes(mAttributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||
nsIAtom*& aPrefix, nsAString& aResult) const
|
||||
nsAString& aResult) const
|
||||
{
|
||||
aPrefix = nsnull;
|
||||
|
||||
return GetAttr(aNameSpaceID, aAttribute, aResult);
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
return GetAttr(aNameSpaceID, aAttribute, *getter_AddRefs(prefix), aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||
nsAString& aResult) const
|
||||
nsIAtom*& aPrefix, nsAString& aResult) const
|
||||
{
|
||||
aResult.SetLength(0);
|
||||
|
||||
#if 0
|
||||
NS_ASSERTION((kNameSpaceID_HTML == aNameSpaceID) ||
|
||||
(kNameSpaceID_None == aNameSpaceID) ||
|
||||
(kNameSpaceID_Unknown == aNameSpaceID),
|
||||
"html content only holds HTML attributes");
|
||||
#endif
|
||||
nsresult rv;
|
||||
aResult.Truncate();
|
||||
|
||||
aPrefix = nsnull;
|
||||
const nsHTMLValue* value;
|
||||
if ((kNameSpaceID_HTML != aNameSpaceID) &&
|
||||
(kNameSpaceID_None != aNameSpaceID) &&
|
||||
(kNameSpaceID_Unknown != aNameSpaceID)) {
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
rv = mAttributes ? mAttributes->GetAttribute(aAttribute, aNameSpaceID,
|
||||
aPrefix,
|
||||
&value) :
|
||||
NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
else {
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
rv = mAttributes ? mAttributes->GetAttribute(aAttribute, &value) :
|
||||
NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
const nsHTMLValue* value;
|
||||
nsresult result = mAttributes ? mAttributes->GetAttribute(aAttribute, &value) :
|
||||
NS_CONTENT_ATTR_NOT_THERE;
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
aResult.Truncate();
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
// Try subclass conversion routine first
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
AttributeToString(aAttribute, *value, aResult)) {
|
||||
return result;
|
||||
if (aNameSpaceID == kNameSpaceID_None &&
|
||||
AttributeToString(aAttribute, *value, aResult) ==
|
||||
NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nscolor color;
|
||||
|
@ -2119,18 +2176,21 @@ nsGenericHTMLElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
|||
default:
|
||||
case eHTMLUnit_Enumerated:
|
||||
NS_NOTREACHED("no default enumerated value to string conversion");
|
||||
result = NS_CONTENT_ATTR_NOT_THERE;
|
||||
rv = NS_CONTENT_ATTR_NOT_THERE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsGenericHTMLElement::HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const
|
||||
{
|
||||
return mAttributes ? mAttributes->HasAttribute(aName) : PR_FALSE;
|
||||
if (aNameSpaceID == kNameSpaceID_HTML ||
|
||||
aNameSpaceID == kNameSpaceID_Unknown)
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
return mAttributes && mAttributes->HasAttribute(aName, aNameSpaceID);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -2150,12 +2210,13 @@ nsGenericHTMLElement::GetAttrNameAt(PRInt32 aIndex,
|
|||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix) const
|
||||
{
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
aPrefix = nsnull;
|
||||
if (nsnull != mAttributes) {
|
||||
return mAttributes->GetAttributeNameAt(aIndex, aName);
|
||||
return mAttributes->GetAttributeNameAt(aIndex, aNameSpaceID, aName,
|
||||
aPrefix);
|
||||
}
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
aName = nsnull;
|
||||
aPrefix = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class nsIDOMEventListener;
|
|||
class nsIDOMNodeList;
|
||||
class nsIEventListenerManager;
|
||||
class nsIFrame;
|
||||
class nsIHTMLAttributes;
|
||||
class nsHTMLAttributes;
|
||||
class nsIHTMLMappedAttributes;
|
||||
class nsIHTMLContent;
|
||||
class nsIStyleRule;
|
||||
|
@ -380,7 +380,7 @@ public:
|
|||
const nsAString& aValue,
|
||||
PRBool aNotify);
|
||||
|
||||
nsIHTMLAttributes* mAttributes;
|
||||
nsHTMLAttributes* mAttributes;
|
||||
|
||||
// Helper functions for <a> and <area>
|
||||
static nsresult SetProtocolInHrefString(const nsAString &aHref,
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
#include "nsIFrameManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
|
||||
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
class nsHTMLBRElement : public nsGenericHTMLLeafElement,
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "nsIWebShell.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIFrame.h"
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
|
||||
|
||||
class nsHTMLDListElement : public nsGenericHTMLContainerElement,
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
// XXX nav4 has type= start= (same as OL/UL)
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
// XXX support missing nav attributes? gutter, cols, width
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsCSSDeclaration.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
class nsHTMLHRElement : public nsGenericHTMLLeafElement,
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
class nsHTMLHeadingElement : public nsGenericHTMLContainerElement,
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIJSNativeInitializer.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsIDocument.h"
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFormSubmission.h"
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
class nsHTMLLIElement : public nsGenericHTMLContainerElement,
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
// XXX nav4 has type= start= (same as OL/UL)
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
class nsHTMLOListElement : public nsGenericHTMLContainerElement,
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
// XXX missing nav attributes
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsCSSDeclaration.h"
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFormSubmission.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
|
||||
|
||||
class nsHTMLSharedLeafElement : public nsGenericHTMLLeafElement,
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
|
||||
|
||||
class nsHTMLSharedLeafElement : public nsGenericHTMLLeafElement,
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
class nsHTMLTableCaptionElement : public nsGenericHTMLContainerElement,
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "nsIHTMLTableColElement.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "nsDOMError.h"
|
||||
#include "GenericElementCollection.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "GenericElementCollection.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "nsIDOMHTMLTableSectionElem.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIGfxTextControlFrame.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
extern nsGenericHTMLElement::EnumTable kListTypeTable[];
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
|
||||
class nsHTMLUnknownElement : public nsGenericHTMLContainerElement,
|
||||
|
@ -167,27 +167,6 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
|
|||
return sheet;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
EnsureWritableAttributes(nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes, PRBool aCreate)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (!aAttributes) {
|
||||
if (PR_TRUE == aCreate) {
|
||||
result = NS_NewHTMLAttributes(&aAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
// aAttributes->ReleaseContentRef();
|
||||
NS_RELEASE(aAttributes);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID,
|
||||
|
@ -276,24 +255,13 @@ nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID,
|
|||
GetMappedAttributeImpact(aAttribute, nsIDOMMutationEvent::MODIFICATION, impact);
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet(dont_AddRef(GetAttrStyleSheet(mDocument)));
|
||||
if (sheet) { // set attr via style sheet
|
||||
result = sheet->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, mAttributes);
|
||||
}
|
||||
else { // manage this ourselves and re-sync when we connect to doc
|
||||
result = EnsureWritableAttributes(this, mAttributes, PR_TRUE);
|
||||
|
||||
if (mAttributes) {
|
||||
PRInt32 count;
|
||||
result = mAttributes->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, nsnull, count);
|
||||
if (0 == count) {
|
||||
ReleaseAttributes(mAttributes);
|
||||
}
|
||||
}
|
||||
if (!mAttributes) {
|
||||
result = NS_NewHTMLAttributes(&mAttributes);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
result = mAttributes->SetAttributeFor(aAttribute, aValue,
|
||||
(NS_STYLE_HINT_CONTENT < impact),
|
||||
this, sheet);
|
||||
}
|
||||
|
||||
if (aNotify && (mDocument)) {
|
||||
|
|
|
@ -14,5 +14,4 @@ nsICSSRule.h
|
|||
nsICSSStyleRule.h
|
||||
nsICSSStyleRuleProcessor.h
|
||||
nsIHTMLCSSStyleSheet.h
|
||||
nsIHTMLAttributes.h
|
||||
nsIInspectorCSSUtils.h
|
||||
|
|
|
@ -85,7 +85,6 @@ EXPORTS = \
|
|||
nsCSSDeclaration.h \
|
||||
nsICSSOMFactory.h \
|
||||
nsIHTMLCSSStyleSheet.h \
|
||||
nsIHTMLAttributes.h \
|
||||
nsIInspectorCSSUtils.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ EXPORTS = \
|
|||
nsICSSOMFactory.h \
|
||||
nsIHTMLCSSStyleSheet.h \
|
||||
nsDOMCSSDeclaration.h \
|
||||
nsIHTMLAttributes.h \
|
||||
nsIInspectorCSSUtils.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,285 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIHTMLAttributes_h___
|
||||
#define nsIHTMLAttributes_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsINodeInfo.h"
|
||||
class nsIAtom;
|
||||
class nsISupportsArray;
|
||||
class nsIHTMLStyleSheet;
|
||||
class nsRuleWalker;
|
||||
struct HTMLAttribute;
|
||||
class nsHTMLMappedAttributes;
|
||||
|
||||
// IID for the nsIHTMLMappedAttributes interface {0fdd27a0-2e7b-11d3-8060-006008159b5a}
|
||||
#define NS_IHTML_MAPPED_ATTRIBUTES_IID \
|
||||
{0x0fdd27a0, 0x2e7b, 0x11d3, \
|
||||
{0x80, 0x60, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
|
||||
|
||||
class nsIHTMLMappedAttributes : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_MAPPED_ATTRIBUTES_IID);
|
||||
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttrName, nsHTMLValue& aValue) const = 0;
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttrName, const nsHTMLValue** aValue) const = 0;
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCount) const = 0;
|
||||
|
||||
NS_IMETHOD Equals(const nsIHTMLMappedAttributes* aAttributes, PRBool& aResult) const = 0;
|
||||
NS_IMETHOD HashValue(PRUint32& aValue) const = 0;
|
||||
|
||||
// Sheet accessors for unique table management
|
||||
NS_IMETHOD SetUniqued(PRBool aUniqued) = 0;
|
||||
NS_IMETHOD GetUniqued(PRBool& aUniqued) = 0;
|
||||
NS_IMETHOD DropStyleSheetReference(void) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void SizeOf(nsISizeOfHandler* aSizer, PRUint32 &aResult) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
const PRInt32 kHTMLAttrNameBufferSize = 4;
|
||||
|
||||
struct nsHTMLClassList {
|
||||
nsHTMLClassList(nsIAtom* aAtom)
|
||||
: mAtom(aAtom), // take ref
|
||||
mNext(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsHTMLClassList);
|
||||
}
|
||||
|
||||
nsHTMLClassList(const nsHTMLClassList& aCopy)
|
||||
: mAtom(aCopy.mAtom),
|
||||
mNext(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsHTMLClassList);
|
||||
NS_IF_ADDREF(mAtom);
|
||||
if (aCopy.mNext) {
|
||||
mNext = new nsHTMLClassList(*(aCopy.mNext));
|
||||
}
|
||||
}
|
||||
|
||||
~nsHTMLClassList(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsHTMLClassList);
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset(void)
|
||||
{
|
||||
NS_IF_RELEASE(mAtom);
|
||||
if (mNext) {
|
||||
delete mNext;
|
||||
mNext = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom* mAtom;
|
||||
nsHTMLClassList* mNext;
|
||||
};
|
||||
|
||||
/*
|
||||
* union that represents an atom or a nsINodeInfo. It is used to save cycles
|
||||
* for the common case when an attribute is not in a namespace, and therefore
|
||||
* can't have a prefix. In that case we only store the attribute name and
|
||||
* don't spend cycles looking up the right nsINodeInfo in the nodeinfo-hash.
|
||||
* The union handles NO refcounting automatically, the client has to call
|
||||
* Addref and Release manually.
|
||||
*/
|
||||
#define NS_ATTRNAME_NODEINFO_BIT 0x01
|
||||
union nsHTMLAttrName {
|
||||
nsHTMLAttrName()
|
||||
{
|
||||
}
|
||||
|
||||
nsHTMLAttrName(nsIAtom* aAtom) : mAtom(aAtom)
|
||||
{
|
||||
NS_ASSERTION(aAtom, "null atom-name in nsHTMLAttrName");
|
||||
}
|
||||
|
||||
nsHTMLAttrName(nsINodeInfo* aNodeInfo) : mNodeInfo(aNodeInfo)
|
||||
{
|
||||
NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsHTMLAttrName");
|
||||
mBits |= NS_ATTRNAME_NODEINFO_BIT;
|
||||
}
|
||||
|
||||
PRBool IsAtom() const
|
||||
{
|
||||
return !(mBits & NS_ATTRNAME_NODEINFO_BIT);
|
||||
}
|
||||
|
||||
nsINodeInfo* GetNodeInfo() const
|
||||
{
|
||||
NS_ASSERTION(!IsAtom(), "getting NodeInfo-value of atom-name");
|
||||
return (nsINodeInfo*)(mBits & ~NS_ATTRNAME_NODEINFO_BIT);
|
||||
}
|
||||
|
||||
void SetNodeInfo(nsINodeInfo* aNodeInfo)
|
||||
{
|
||||
NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsHTMLAttrName");
|
||||
mNodeInfo = aNodeInfo;
|
||||
mBits |= NS_ATTRNAME_NODEINFO_BIT;
|
||||
}
|
||||
|
||||
void Addref()
|
||||
{
|
||||
// Since both nsINodeInfo and nsIAtom inherits nsISupports as it's first
|
||||
// interface we can safly assume that it's first in the vtable
|
||||
nsISupports* name = NS_REINTERPRET_CAST(nsISupports *,
|
||||
mBits & ~NS_ATTRNAME_NODEINFO_BIT);
|
||||
|
||||
NS_IF_ADDREF(name);
|
||||
}
|
||||
|
||||
void Release()
|
||||
{
|
||||
// Since both nsINodeInfo and nsIAtom inherits nsISupports as it's first
|
||||
// interface we can safly assume that it's first in the vtable
|
||||
nsISupports* name = NS_REINTERPRET_CAST(nsISupports *,
|
||||
mBits & ~NS_ATTRNAME_NODEINFO_BIT);
|
||||
|
||||
NS_IF_RELEASE(name);
|
||||
mBits = 0;
|
||||
}
|
||||
nsIAtom* mAtom; // Used if !(mBits & NS_ATTRNAME_NODEINFO_BIT)
|
||||
nsINodeInfo* mNodeInfo; // Used if (mBits & NS_ATTRNAME_NODEINFO_BIT)
|
||||
PRWord mBits;
|
||||
};
|
||||
|
||||
class nsHTMLAttributes {
|
||||
public:
|
||||
nsHTMLAttributes(void);
|
||||
nsHTMLAttributes(const nsHTMLAttributes& aCopy);
|
||||
~nsHTMLAttributes(void);
|
||||
|
||||
NS_METHOD SetAttributeFor(nsIAtom* aAttrName, const nsHTMLValue& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLStyleSheet* aSheet,
|
||||
PRInt32& aAttrCount);
|
||||
NS_METHOD SetAttributeFor(nsIAtom* aAttrName, const nsAString& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLStyleSheet* aSheet);
|
||||
NS_METHOD UnsetAttributeFor(nsIAtom* aAttrName,
|
||||
PRInt32 aNamespaceID,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLStyleSheet* aSheet,
|
||||
PRInt32& aAttrCount);
|
||||
|
||||
NS_METHOD GetAttribute(nsIAtom* aAttrName,
|
||||
nsHTMLValue& aValue) const;
|
||||
NS_METHOD GetAttribute(nsIAtom* aAttribute,
|
||||
const nsHTMLValue** aValue) const;
|
||||
|
||||
NS_METHOD_(PRBool) HasAttribute(nsIAtom* aAttrName,
|
||||
PRInt32 aNamespaceID) const;
|
||||
|
||||
// Namespace-able methods. The namespace must NOT be null
|
||||
NS_METHOD SetAttributeFor(nsINodeInfo* aAttrName,
|
||||
const nsAString& aValue);
|
||||
NS_METHOD GetAttribute(nsIAtom* aAttrName, PRInt32 aNamespaceID,
|
||||
nsIAtom*& aPrefix,
|
||||
const nsHTMLValue** aValue) const;
|
||||
|
||||
|
||||
NS_METHOD GetAttributeNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNamespaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix) const;
|
||||
|
||||
NS_METHOD GetAttributeCount(PRInt32& aCount) const;
|
||||
|
||||
NS_METHOD GetID(nsIAtom*& aResult) const;
|
||||
NS_METHOD GetClasses(nsVoidArray& aArray) const;
|
||||
NS_METHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
|
||||
|
||||
NS_METHOD Clone(nsHTMLAttributes** aInstancePtrResult) const;
|
||||
|
||||
NS_METHOD SetStyleSheet(nsIHTMLStyleSheet* aSheet);
|
||||
|
||||
NS_METHOD WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker) const;
|
||||
|
||||
#ifdef UNIQUE_ATTR_SUPPORT
|
||||
NS_METHOD AddContentRef(void);
|
||||
NS_METHOD ReleaseContentRef(void);
|
||||
NS_METHOD GetContentRefCount(PRInt32& aCount) const;
|
||||
#endif
|
||||
NS_METHOD Reset(void);
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_METHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
|
||||
void SizeOf(nsISizeOfHandler* aSizer, PRUint32 &aResult);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nsresult SetAttributeName(nsHTMLAttrName aAttrName, PRBool& aFound);
|
||||
nsresult UnsetAttributeName(nsIAtom* aAttrName, PRBool& aFound);
|
||||
nsresult UnsetAttributeName(nsIAtom* aAttrName, PRInt32 aNamespaceID,
|
||||
PRBool& aFound);
|
||||
nsresult EnsureSingleMappedFor(nsIHTMLContent* aContent,
|
||||
nsIHTMLStyleSheet* aSheet,
|
||||
PRBool aCreate);
|
||||
nsresult UniqueMapped(nsIHTMLStyleSheet* aSheet);
|
||||
|
||||
private:
|
||||
nsHTMLAttributes& operator=(const nsHTMLAttributes& aCopy);
|
||||
PRBool operator==(const nsHTMLAttributes& aCopy) const;
|
||||
|
||||
protected:
|
||||
|
||||
nsHTMLAttrName* mAttrNames;
|
||||
PRInt32 mAttrCount;
|
||||
PRInt32 mAttrSize;
|
||||
HTMLAttribute* mFirstUnmapped;
|
||||
nsHTMLMappedAttributes* mMapped;
|
||||
nsIAtom* mID;
|
||||
nsHTMLClassList mFirstClass;
|
||||
|
||||
nsHTMLAttrName mNameBuffer[kHTMLAttrNameBufferSize];
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLAttributes(nsHTMLAttributes** aInstancePtrResult);
|
||||
|
||||
#endif /* nsIHTMLAttributes_h___ */
|
|
@ -37,7 +37,7 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
@ -852,21 +852,6 @@ public:
|
|||
NS_IMETHOD SetActiveLinkColor(nscolor aColor);
|
||||
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
|
||||
|
||||
// Attribute management methods, aAttributes is an in/out param
|
||||
NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
|
||||
// Mapped Attribute management methods
|
||||
NS_IMETHOD UniqueMappedAttributes(nsIHTMLMappedAttributes* aMapped,
|
||||
nsIHTMLMappedAttributes*& aUniqueMapped);
|
||||
|
@ -1406,75 +1391,6 @@ HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetAttributesFor(nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
if (aAttributes) {
|
||||
aAttributes->SetStyleSheet(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
if (!aAttributes) {
|
||||
nsresult rv = NS_NewHTMLAttributes(&aAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return aAttributes->SetAttributeFor(aAttribute, aValue, aMappedToStyle,
|
||||
aContent, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if ((!aAttributes) && (eHTMLUnit_Null != aValue.GetUnit())) {
|
||||
rv = NS_NewHTMLAttributes(&aAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
PRInt32 count;
|
||||
rv = aAttributes->SetAttributeFor(aAttribute, aValue, aMappedToStyle,
|
||||
aContent, this, count);
|
||||
if (count == 0) {
|
||||
NS_RELEASE(aAttributes);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::UnsetAttributeFor(nsIAtom* aAttribute,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (aAttributes) {
|
||||
PRInt32 count;
|
||||
result = aAttributes->UnsetAttributeFor(aAttribute, aContent, this, count);
|
||||
if (0 == count) {
|
||||
NS_RELEASE(aAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::UniqueMappedAttributes(nsIHTMLMappedAttributes* aMapped,
|
||||
nsIHTMLMappedAttributes*& aUniqueMapped)
|
||||
|
|
|
@ -1,146 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIHTMLAttributes_h___
|
||||
#define nsIHTMLAttributes_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
class nsIAtom;
|
||||
class nsISupportsArray;
|
||||
class nsIHTMLStyleSheet;
|
||||
class nsRuleWalker;
|
||||
|
||||
// IID for the nsIHTMLAttributes interface {a18f85f0-c058-11d1-8031-006008159b5a}
|
||||
#define NS_IHTML_ATTRIBUTES_IID \
|
||||
{0xa18f85f0, 0xc058, 0x11d1, \
|
||||
{0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
|
||||
|
||||
// IID for the nsIHTMLMappedAttributes interface {0fdd27a0-2e7b-11d3-8060-006008159b5a}
|
||||
#define NS_IHTML_MAPPED_ATTRIBUTES_IID \
|
||||
{0x0fdd27a0, 0x2e7b, 0x11d3, \
|
||||
{0x80, 0x60, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
|
||||
|
||||
class nsIHTMLAttributes : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_ATTRIBUTES_IID);
|
||||
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLStyleSheet* aSheet,
|
||||
PRInt32& aAttrCount) = 0;
|
||||
// this string value version lets you avoid an extra string copy,
|
||||
// the value is still stored in a nsHTMLValue
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsAString& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLStyleSheet* aSheet) = 0;
|
||||
NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLStyleSheet* aSheet,
|
||||
PRInt32& aAttrCount) = 0;
|
||||
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const = 0;
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttribute,
|
||||
const nsHTMLValue** aValue) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) HasAttribute(nsIAtom* aAttrName) const = 0;
|
||||
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
|
||||
nsIAtom*& aName) const = 0;
|
||||
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aAttrCount) const = 0;
|
||||
|
||||
NS_IMETHOD GetID(nsIAtom*& aResult) const = 0;
|
||||
NS_IMETHOD GetClasses(nsVoidArray& aArray) const = 0;
|
||||
NS_IMETHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const = 0;
|
||||
|
||||
NS_IMETHOD Clone(nsIHTMLAttributes** aInstancePtrResult) const = 0;
|
||||
|
||||
NS_IMETHOD SetStyleSheet(nsIHTMLStyleSheet* aSheet) = 0;
|
||||
|
||||
NS_IMETHOD WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker) const = 0;
|
||||
|
||||
#ifdef UNIQUE_ATTR_SUPPORT
|
||||
NS_IMETHOD Equals(const nsIHTMLAttributes* aAttributes, PRBool& aResult) const = 0;
|
||||
NS_IMETHOD HashValue(PRUint32& aValue) const = 0;
|
||||
|
||||
NS_IMETHOD AddContentRef(void) = 0;
|
||||
NS_IMETHOD ReleaseContentRef(void) = 0;
|
||||
NS_IMETHOD GetContentRefCount(PRInt32& aCount) const = 0;
|
||||
|
||||
NS_IMETHOD Reset(void) = 0;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
|
||||
virtual void SizeOf(nsISizeOfHandler* aSizer, PRUint32 &aResult) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
class nsIHTMLMappedAttributes : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_MAPPED_ATTRIBUTES_IID);
|
||||
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttrName, nsHTMLValue& aValue) const = 0;
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttrName, const nsHTMLValue** aValue) const = 0;
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCount) const = 0;
|
||||
|
||||
NS_IMETHOD Equals(const nsIHTMLMappedAttributes* aAttributes, PRBool& aResult) const = 0;
|
||||
NS_IMETHOD HashValue(PRUint32& aValue) const = 0;
|
||||
|
||||
// Sheet accessors for unique table management
|
||||
NS_IMETHOD SetUniqued(PRBool aUniqued) = 0;
|
||||
NS_IMETHOD GetUniqued(PRBool& aUniqued) = 0;
|
||||
NS_IMETHOD DropStyleSheetReference(void) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void SizeOf(nsISizeOfHandler* aSizer, PRUint32 &aResult) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult);
|
||||
|
||||
#endif /* nsIHTMLAttributes_h___ */
|
||||
|
|
@ -48,7 +48,6 @@
|
|||
#include "nsIStyledContent.h"
|
||||
|
||||
class nsIEventListenerManager;
|
||||
class nsIHTMLAttributes;
|
||||
class nsIURI;
|
||||
class nsIWebShell;
|
||||
|
||||
|
|
|
@ -1762,12 +1762,6 @@ nsXMLContentSink::AddAttributes(const PRUnichar** aAtts,
|
|||
nameSpaceID = kNameSpaceID_None;
|
||||
nameAtom = dont_AddRef(NS_NewAtom(key));
|
||||
nameSpacePrefix = nsnull;
|
||||
} else if ((kNameSpaceID_XMLNS == nameSpaceID) && aIsHTML) {
|
||||
// Ooh, what a nice little hack we have here :-)
|
||||
nsAutoString name;
|
||||
nameAtom->ToString(name);
|
||||
nameAtom = dont_AddRef(NS_NewAtom(NS_LITERAL_STRING("xmlns:") + name));
|
||||
nameSpaceID = kNameSpaceID_HTML; // XXX this is wrong, but necessary until HTML can store other namespaces for attrs
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "nsIImage.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIView.h"
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "nsIImage.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIView.h"
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsHTMLValue;
|
||||
class nsIHTMLAttributes;
|
||||
class nsIHTMLMappedAttributes;
|
||||
class nsIHTMLContent;
|
||||
class nsIDocument;
|
||||
|
@ -65,21 +64,6 @@ public:
|
|||
NS_IMETHOD GetVisitedLinkColor(nscolor& aColor) = 0;
|
||||
NS_IMETHOD SetVisitedLinkColor(nscolor aColor) = 0;
|
||||
|
||||
// Attribute management methods
|
||||
NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes) = 0;
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes) = 0;
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes) = 0;
|
||||
NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes) = 0;
|
||||
|
||||
// Mapped Attribute management methods
|
||||
NS_IMETHOD UniqueMappedAttributes(nsIHTMLMappedAttributes* aMapped,
|
||||
nsIHTMLMappedAttributes*& aUniqueMapped) = 0;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsIPresContext.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsTableFrame.h"
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "nsCRT.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDocument.h"
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
@ -852,21 +852,6 @@ public:
|
|||
NS_IMETHOD SetActiveLinkColor(nscolor aColor);
|
||||
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
|
||||
|
||||
// Attribute management methods, aAttributes is an in/out param
|
||||
NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes);
|
||||
|
||||
// Mapped Attribute management methods
|
||||
NS_IMETHOD UniqueMappedAttributes(nsIHTMLMappedAttributes* aMapped,
|
||||
nsIHTMLMappedAttributes*& aUniqueMapped);
|
||||
|
@ -1406,75 +1391,6 @@ HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetAttributesFor(nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
if (aAttributes) {
|
||||
aAttributes->SetStyleSheet(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
if (!aAttributes) {
|
||||
nsresult rv = NS_NewHTMLAttributes(&aAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return aAttributes->SetAttributeFor(aAttribute, aValue, aMappedToStyle,
|
||||
aContent, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
PRBool aMappedToStyle,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if ((!aAttributes) && (eHTMLUnit_Null != aValue.GetUnit())) {
|
||||
rv = NS_NewHTMLAttributes(&aAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
PRInt32 count;
|
||||
rv = aAttributes->SetAttributeFor(aAttribute, aValue, aMappedToStyle,
|
||||
aContent, this, count);
|
||||
if (count == 0) {
|
||||
NS_RELEASE(aAttributes);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::UnsetAttributeFor(nsIAtom* aAttribute,
|
||||
nsIHTMLContent* aContent,
|
||||
nsIHTMLAttributes*& aAttributes)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (aAttributes) {
|
||||
PRInt32 count;
|
||||
result = aAttributes->UnsetAttributeFor(aAttribute, aContent, this, count);
|
||||
if (0 == count) {
|
||||
NS_RELEASE(aAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::UniqueMappedAttributes(nsIHTMLMappedAttributes* aMapped,
|
||||
nsIHTMLMappedAttributes*& aUniqueMapped)
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsIPresContext.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsTableFrame.h"
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
#include "nsIImage.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIStyleContext.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче