Backing out bug 275196, xml:id, to fix tp regression

This commit is contained in:
Olli.Pettay%helsinki.fi 2007-07-26 14:16:21 +00:00
Родитель 1a45754cb1
Коммит 3255dc745d
28 изменённых файлов: 114 добавлений и 248 удалений

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

@ -63,8 +63,8 @@ class nsIDocShell;
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0x609baee8, 0x3c0a, 0x4122, \
{ 0x9c, 0xc6, 0xe4, 0xc9, 0x83, 0x53, 0xff, 0x9c } }
{ 0x36b375cb, 0xf01e, 0x4c18, \
{ 0xbf, 0x9e, 0xba, 0xad, 0x77, 0x1d, 0xce, 0x22 } }
// hack to make egcs / gcc 2.95.2 happy
class nsIContent_base : public nsINode {
@ -211,21 +211,10 @@ public:
/**
* Returns an atom holding the name of the attribute of type ID on
* this content node (if applicable).
* Language specific ID attribute has the highest priority, then
* ID attribute defined in DTD, and finally xml:id.
* Returns null for non-element content nodes.
* this content node (if applicable). Returns null for non-element
* content nodes.
*/
virtual nsIAtom* GetIDAttributeName(PRInt32& aNameSpaceID) const = 0;
/**
* Returns true if the attribute can be
* used as an ID attribute of the element.
* Note this may return true with many attributes, but only one
* is used as an ID at a time.
*/
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const = 0;
virtual nsIAtom *GetIDAttributeName() const = 0;
/**
* Normalizes an attribute name and returns it as a nodeinfo if an attribute
@ -742,8 +731,8 @@ public:
/**
* Get the ID of this content node (the atom corresponding to the
* value of the attribute whose name is given by GetIDAttributeName().
* This may be null if there is no ID.
* value of the null-namespace attribute whose name is given by
* GetIDAttributeName(). This may be null if there is no ID.
*/
virtual nsIAtom* GetID() const = 0;

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

@ -600,15 +600,14 @@ nsDOMAttribute::GetIsId(PRBool* aReturn)
return NS_OK;
}
PRInt32 namespaceID;
nsIAtom* idAtom = content->GetIDAttributeName(namespaceID);
nsIAtom* idAtom = content->GetIDAttributeName();
if (!idAtom)
{
*aReturn = PR_FALSE;
return NS_OK;
}
*aReturn = mNodeInfo->Equals(idAtom, namespaceID);
*aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None);
return NS_OK;
}

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

@ -631,19 +631,11 @@ nsGenericDOMDataNode::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
}
nsIAtom *
nsGenericDOMDataNode::GetIDAttributeName(PRInt32& aNameSpaceID) const
nsGenericDOMDataNode::GetIDAttributeName() const
{
aNameSpaceID = kNameSpaceID_Unknown;
return nsnull;
}
PRBool
nsGenericDOMDataNode::IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const
{
return PR_FALSE;
}
already_AddRefed<nsINodeInfo>
nsGenericDOMDataNode::GetExistingAttrNameFromQName(const nsAString& aStr) const
{

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

@ -195,9 +195,7 @@ public:
virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
PRBool aNullParent = PR_TRUE);
virtual nsIAtom *GetIDAttributeName(PRInt32& aNamespaceId) const;
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const;
virtual nsIAtom *GetIDAttributeName() const;
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, PRBool aNotify)

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

@ -2260,10 +2260,9 @@ nsGenericElement::DispatchDOMEvent(nsEvent* aEvent,
nsIAtom*
nsGenericElement::GetID() const
{
PRInt32 namespaceID;
nsIAtom* IDName = GetIDAttributeName(namespaceID);
nsIAtom* IDName = GetIDAttributeName();
if (IDName) {
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName, namespaceID);
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName);
if (attrVal){
if (attrVal->Type() == nsAttrValue::eAtom) {
return attrVal->GetAtomValue();
@ -2326,26 +2325,9 @@ nsGenericElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
}
nsIAtom *
nsGenericElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
nsGenericElement::GetIDAttributeName() const
{
aNameSpaceID = kNameSpaceID_None;
nsIAtom* idAtom = mNodeInfo->GetIDAttributeAtom();
if (idAtom && HasAttr(aNameSpaceID, idAtom)) {
return idAtom;
}
aNameSpaceID = kNameSpaceID_XML;
return nsGkAtoms::id;
}
PRBool
nsGenericElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const
{
return (aNameSpaceID == kNameSpaceID_None &&
aAtom == mNodeInfo->GetIDAttributeAtom()) ||
(aNameSpaceID == kNameSpaceID_XML &&
aAtom == nsGkAtoms::id);
return mNodeInfo->GetIDAttributeAtom();
}
nsIAtom *
@ -3670,8 +3652,8 @@ nsGenericElement::ParseAttribute(PRInt32 aNamespaceID,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (IsPotentialIDAttributeName(aNamespaceID, aAttribute) &&
!aValue.IsEmpty()) {
if (aNamespaceID == kNameSpaceID_None &&
aAttribute == GetIDAttributeName() && !aValue.IsEmpty()) {
// Store id as an atom. id="" means that the element has no id,
// not that it has an emptystring as the id.
aResult.ParseAtom(aValue);

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

@ -383,9 +383,7 @@ public:
PRBool aCompileEventHandlers);
virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
PRBool aNullParent = PR_TRUE);
virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const;
virtual nsIAtom *GetIDAttributeName() const;
virtual nsIAtom *GetClassAttributeName() const;
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,

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

@ -46,9 +46,7 @@ public:
virtual ~nsXMLEventsElement();
NS_FORWARD_NSIDOMNODE(nsXMLElement::)
virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const;
virtual nsIAtom *GetIDAttributeName() const;
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify);
@ -65,21 +63,11 @@ nsXMLEventsElement::~nsXMLEventsElement()
}
nsIAtom *
nsXMLEventsElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
nsXMLEventsElement::GetIDAttributeName() const
{
if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) {
aNameSpaceID = kNameSpaceID_None;
if (mNodeInfo->Equals(nsGkAtoms::listener))
return nsGkAtoms::id;
}
return nsGenericElement::GetIDAttributeName(aNameSpaceID);
}
PRBool
nsXMLEventsElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const
{
return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom);
return nsXMLElement::GetIDAttributeName();
}
nsresult

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

@ -377,11 +377,20 @@ nsXMLEventsManager::AttributeChanged(nsIDocument* aDocument,
AddXMLEventsContent(aContent);
nsXMLEventsListener::InitXMLEventsListener(aDocument, this, aContent);
}
else if (aContent->IsPotentialIDAttributeName(aNameSpaceID, aAttribute)) {
//Remove possible listener
mListeners.Enumerate(EnumAndSetIncomplete, aContent);
//Add new listeners
AddListeners(aDocument);
else if (aContent->GetIDAttributeName() == aAttribute) {
if (aModType == nsIDOMMutationEvent::REMOVAL)
mListeners.Enumerate(EnumAndSetIncomplete, aContent);
else if (aModType == nsIDOMMutationEvent::MODIFICATION) {
//Remove possible listener
mListeners.Enumerate(EnumAndSetIncomplete, aContent);
//Add new listeners
AddListeners(aDocument);
}
else {
//If we are adding the ID attribute, we must check whether we can
//add new listeners
AddListeners(aDocument);
}
}
}
}

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

@ -1493,21 +1493,9 @@ nsGenericHTMLElement::GetClasses() const
}
nsIAtom *
nsGenericHTMLElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
nsGenericHTMLElement::GetIDAttributeName() const
{
if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) {
aNameSpaceID = kNameSpaceID_None;
return nsGkAtoms::id;
}
return nsGenericElement::GetIDAttributeName(aNameSpaceID);
}
PRBool
nsGenericHTMLElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const
{
return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom);
return nsGkAtoms::id;
}
nsIAtom *

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

@ -241,9 +241,7 @@ public:
virtual void UpdateEditableState();
virtual const nsAttrValue* GetClasses() const;
virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const;
virtual nsIAtom *GetIDAttributeName() const;
virtual nsIAtom *GetClassAttributeName() const;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
virtual nsICSSStyleRule* GetInlineStyleRule();

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

@ -1376,7 +1376,8 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID,
return;
}
}
} else if (aContent->IsPotentialIDAttributeName(aNameSpaceID, aAttribute)) {
} else if (aAttribute == aContent->GetIDAttributeName() &&
aNameSpaceID == kNameSpaceID_None) {
nsresult rv = RemoveFromIdTable(aContent);
if (NS_FAILED(rv)) {
@ -1405,7 +1406,8 @@ nsHTMLDocument::AttributeChanged(nsIDocument* aDocument,
if (name) {
UpdateNameTableEntry(name, aContent);
}
} else if (aContent->IsPotentialIDAttributeName(aNameSpaceID, aAttribute)) {
} else if (aAttribute == aContent->GetIDAttributeName() &&
aNameSpaceID == kNameSpaceID_None) {
nsIAtom* id = aContent->GetID();
if (id) {
UpdateIdTableEntry(id, aContent);

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

@ -126,22 +126,10 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericElement)
//----------------------------------------------------------------------
// nsIContent methods
nsIAtom*
nsSVGElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
nsIAtom *
nsSVGElement::GetIDAttributeName() const
{
if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) {
aNameSpaceID = kNameSpaceID_None;
return nsGkAtoms::id;
}
return nsGenericElement::GetIDAttributeName(aNameSpaceID);
}
PRBool
nsSVGElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const
{
return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom);
return nsGkAtoms::id;
}
nsIAtom *

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

@ -71,9 +71,7 @@ public:
// nsIContent interface methods
virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const;
virtual nsIAtom *GetIDAttributeName() const;
virtual nsIAtom *GetClassAttributeName() const;
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify);

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

@ -265,21 +265,10 @@ nsXTFElementWrapper::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
}
nsIAtom *
nsXTFElementWrapper::GetIDAttributeName(PRInt32& aNameSpaceID) const
nsXTFElementWrapper::GetIDAttributeName() const
{
if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) {
aNameSpaceID = kNameSpaceID_None;
return nsGkAtoms::id;
}
return nsXTFElementWrapperBase::GetIDAttributeName(aNameSpaceID);
}
PRBool
nsXTFElementWrapper::IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const
{
return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
nsXTFElementWrapperBase::IsPotentialIDAttributeName(aNameSpaceID, aAtom);
// XXX:
return nsGkAtoms::id;
}
nsresult

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

@ -78,9 +78,7 @@ public:
nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify);
nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const;
nsIAtom *GetIDAttributeName() const;
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify);

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

@ -1633,9 +1633,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify)
nsIAtom*
nsXULElement::GetID() const
{
PRInt32 namespaceID;
nsIAtom* IDName = GetIDAttributeName(namespaceID);
const nsAttrValue* attrVal = FindLocalOrProtoAttr(namespaceID, IDName);
const nsAttrValue* attrVal = FindLocalOrProtoAttr(kNameSpaceID_None, nsGkAtoms::id);
NS_ASSERTION(!attrVal ||
attrVal->Type() == nsAttrValue::eAtom ||
@ -1741,21 +1739,9 @@ nsXULElement::IsAttributeMapped(const nsIAtom* aAttribute) const
}
nsIAtom *
nsXULElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
nsXULElement::GetIDAttributeName() const
{
if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) {
aNameSpaceID = kNameSpaceID_None;
return nsGkAtoms::id;
}
return nsGenericElement::GetIDAttributeName(aNameSpaceID);
}
PRBool
nsXULElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const
{
return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom);
}
nsIAtom *

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

@ -505,9 +505,7 @@ public:
virtual void UnbindFromTree(PRBool aDeep, PRBool aNullParent);
virtual void SetNativeAnonymous(PRBool aAnonymous);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID,
nsIAtom* aAtom) const;
virtual nsIAtom *GetIDAttributeName() const;
virtual nsIAtom *GetClassAttributeName() const;
virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const;

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

@ -929,8 +929,7 @@ nsXULDocument::AttributeChanged(nsIDocument* aDocument,
// XXXbz check aNameSpaceID, dammit!
// First see if we need to update our element map.
if (aElement->IsPotentialIDAttributeName(aNameSpaceID, aAttribute) ||
(aAttribute == nsGkAtoms::ref && aNameSpaceID == kNameSpaceID_None)) {
if ((aAttribute == nsGkAtoms::id) || (aAttribute == nsGkAtoms::ref)) {
rv = mElementMap.Enumerate(RemoveElementsFromMapByContent, aElement);
if (NS_FAILED(rv)) return;
@ -1758,27 +1757,29 @@ nsXULDocument::GetTemplateBuilderFor(nsIContent* aContent,
return NS_OK;
}
// Attributes that are used with getElementById() and the
// resource-to-element map.
nsIAtom** nsXULDocument::kIdentityAttrs[] =
{
&nsGkAtoms::id,
&nsGkAtoms::ref,
nsnull
};
nsresult
nsXULDocument::AddElementToMap(nsIContent* aElement)
{
// Look at the element's ID and 'ref' attributes, and if set,
// Look at the element's 'id' and 'ref' attributes, and if set,
// add pointers in the resource-to-element map to the element.
nsresult rv;
nsIAtom* idAtom = aElement->GetID();
if (idAtom) {
nsAutoString idStr;
idAtom->ToString(idStr);
if (!idStr.IsEmpty()) {
rv = mElementMap.Add(idStr, aElement);
NS_ENSURE_SUCCESS(rv, rv);
}
}
nsAutoString refvalue;
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, refvalue);
if (!refvalue.IsEmpty()) {
rv = mElementMap.Add(refvalue, aElement);
NS_ENSURE_SUCCESS(rv, rv);
for (PRInt32 i = 0; kIdentityAttrs[i] != nsnull; ++i) {
nsAutoString value;
aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value);
if (!value.IsEmpty()) {
rv = mElementMap.Add(value, aElement);
if (NS_FAILED(rv)) return rv;
}
}
return NS_OK;
@ -1790,21 +1791,14 @@ nsXULDocument::RemoveElementFromMap(nsIContent* aElement)
{
// Remove the element from the resource-to-element map.
nsresult rv;
nsIAtom* idAtom = aElement->GetID();
if (idAtom) {
nsAutoString idStr;
idAtom->ToString(idStr);
if (!idStr.IsEmpty()) {
rv = mElementMap.Remove(idStr, aElement);
NS_ENSURE_SUCCESS(rv, rv);
}
}
nsAutoString refvalue;
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, refvalue);
if (!refvalue.IsEmpty()) {
rv = mElementMap.Remove(refvalue, aElement);
NS_ENSURE_SUCCESS(rv, rv);
for (PRInt32 i = 0; kIdentityAttrs[i] != nsnull; ++i) {
nsAutoString value;
aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value);
if (!value.IsEmpty()) {
rv = mElementMap.Remove(value, aElement);
if (NS_FAILED(rv)) return rv;
}
}
return NS_OK;

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

@ -1962,10 +1962,8 @@ nsXFormsUtils::GetElementById(const nsAString &aId,
if (type == nsIDOMNode::ELEMENT_NODE) {
nsCOMPtr<nsIContent> content(do_QueryInterface(childNode));
NS_ASSERTION(content, "An ELEMENT_NODE not implementing nsIContent?!");
PRInt32 namespaceID;
nsIAtom* idAtom = content->GetIDAttributeName(namespaceID);
if (idAtom &&
content->AttrValueIs(namespaceID, idAtom, aId, eCaseMatters)) {
if (content->AttrValueIs(kNameSpaceID_None, content->GetIDAttributeName(),
aId, eCaseMatters)) {
element = do_QueryInterface(childNode);
break;
}

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

@ -10128,8 +10128,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent,
#endif
// the style tag has its own interpretation based on aHint
nsChangeHint hint = (aNameSpaceID == kNameSpaceID_None)
? aContent->GetAttributeChangeHint(aAttribute, aModType) : nsChangeHint(0);
nsChangeHint hint = aContent->GetAttributeChangeHint(aAttribute, aModType);
PRBool reframe = (hint & nsChangeHint_ReconstructFrame) != 0;
@ -10164,19 +10163,15 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent,
if (primaryFrame) {
// See if we have appearance information for a theme.
if (aNameSpaceID == kNameSpaceID_None) {
const nsStyleDisplay* disp = primaryFrame->GetStyleDisplay();
if (disp->mAppearance) {
nsPresContext* presContext = mPresShell->GetPresContext();
nsITheme *theme = presContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(presContext, primaryFrame,
disp->mAppearance)) {
PRBool repaint = PR_FALSE;
theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute,
&repaint);
if (repaint)
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
}
const nsStyleDisplay* disp = primaryFrame->GetStyleDisplay();
if (disp->mAppearance) {
nsPresContext* presContext = mPresShell->GetPresContext();
nsITheme *theme = presContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(presContext, primaryFrame, disp->mAppearance)) {
PRBool repaint = PR_FALSE;
theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint);
if (repaint)
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
}
}
@ -10193,7 +10188,6 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent,
// the frame's AttributeChanged() in case it does something that affects the style
nsFrameManager *frameManager = shell->FrameManager();
nsReStyleHint rshint = frameManager->HasAttributeDependentStyle(aContent,
aNameSpaceID,
aAttribute,
aModType,
aStateMask);

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

@ -1445,14 +1445,12 @@ nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame,
nsReStyleHint
nsFrameManager::HasAttributeDependentStyle(nsIContent *aContent,
PRInt32 aNameSpaceID,
nsIAtom *aAttribute,
PRInt32 aModType,
PRUint32 aStateMask)
{
nsReStyleHint hint = mStyleSet->HasAttributeDependentStyle(GetPresContext(),
aContent,
aNameSpaceID,
aAttribute,
aModType,
aStateMask);

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

@ -191,7 +191,6 @@ public:
// Determine whether an attribute affects style
NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent,
PRInt32 aNameSpaceID,
nsIAtom *aAttribute,
PRInt32 aModType,
PRUint32 aStateMask);

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

@ -1001,8 +1001,6 @@ static PRBool AttrMatchesValue(const nsAttrSelector* aAttrSelector,
static PRBool SelectorMatches(RuleProcessorData &data,
nsCSSSelector* aSelector,
PRInt32 aStateMask, // states NOT to test
PRInt32 aNameSpaceID, // the namespace of the
// attribute NOT to test
nsIAtom* aAttribute, // attribute NOT to test
PRBool* const aDependence = nsnull)
@ -1324,9 +1322,9 @@ static PRBool SelectorMatches(RuleProcessorData &data,
result = PR_TRUE;
nsAttrSelector* attr = aSelector->mAttrList;
do {
if (attr->mAttr == aAttribute &&
(attr->mNameSpace == aNameSpaceID ||
attr->mNameSpace == kNameSpaceID_Unknown)) {
if (attr->mAttr == aAttribute) {
// XXX we should really have a namespace, not just an attr
// name, in HasAttributeDependentStyle!
result = PR_TRUE;
if (aDependence)
*aDependence = PR_TRUE;
@ -1398,9 +1396,8 @@ static PRBool SelectorMatches(RuleProcessorData &data,
if (result && IDList) {
// test for ID match
result = PR_FALSE;
PRInt32 namespaceID;
if (aAttribute &&
data.mContent->IsPotentialIDAttributeName(namespaceID, aAttribute)) {
if (aAttribute && aAttribute == data.mContent->GetIDAttributeName()) {
result = PR_TRUE;
if (aDependence)
*aDependence = PR_TRUE;
@ -1438,8 +1435,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
if (result && aSelector->mClassList) {
// test for class match
if (aAttribute && aAttribute == data.mContent->GetClassAttributeName() &&
aNameSpaceID == kNameSpaceID_None) {
if (aAttribute && aAttribute == data.mContent->GetClassAttributeName()) {
result = PR_TRUE;
if (aDependence)
*aDependence = PR_TRUE;
@ -1466,7 +1462,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
for (nsCSSSelector *negation = aSelector->mNegations;
result && negation; negation = negation->mNegations) {
PRBool dependence = PR_FALSE;
result = !SelectorMatches(data, negation, aStateMask, aNameSpaceID,
result = !SelectorMatches(data, negation, aStateMask,
aAttribute, &dependence);
// If the selector does match due to the dependence on aStateMask
// or aAttribute, then we want to keep result true so that the
@ -1540,7 +1536,7 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
if (! data) {
return PR_FALSE;
}
if (SelectorMatches(*data, selector, 0, kNameSpaceID_Unknown, nsnull)) {
if (SelectorMatches(*data, selector, 0, nsnull)) {
// to avoid greedy matching, we need to recur if this is a
// descendant combinator and the next combinator is not
if ((NS_IS_GREEDY_OPERATOR(selector->mOperator)) &&
@ -1577,7 +1573,7 @@ static void ContentEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector,
{
ElementRuleProcessorData* data = (ElementRuleProcessorData*)aData;
if (SelectorMatches(*data, aSelector, 0, kNameSpaceID_Unknown, nsnull)) {
if (SelectorMatches(*data, aSelector, 0, nsnull)) {
nsCSSSelector *next = aSelector->mNext;
if (!next || SelectorMatchesTree(*data, next)) {
// for performance, require that every implementation of
@ -1630,7 +1626,7 @@ static void PseudoEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector,
if (PRUnichar('+') == selector->mOperator) {
return; // not valid here, can't match
}
if (SelectorMatches(*data, selector, 0, kNameSpaceID_Unknown, nsnull)) {
if (SelectorMatches(*data, selector, 0, nsnull)) {
selector = selector->mNext;
}
else {
@ -1701,8 +1697,7 @@ PR_STATIC_CALLBACK(PRBool) StateEnumFunc(void* aSelector, void* aData)
// bother calling SelectorMatches, since even if it returns false
// enumData->change won't change.
if ((possibleChange & ~(enumData->change)) &&
SelectorMatches(*data, selector, data->mStateMask, kNameSpaceID_Unknown,
nsnull) &&
SelectorMatches(*data, selector, data->mStateMask, nsnull) &&
SelectorMatchesTree(*data, selector->mNext)) {
enumData->change = nsReStyleHint(enumData->change | possibleChange);
}
@ -1756,8 +1751,7 @@ PR_STATIC_CALLBACK(PRBool) AttributeEnumFunc(void* aSelector, void* aData)
// bother calling SelectorMatches, since even if it returns false
// enumData->change won't change.
if ((possibleChange & ~(enumData->change)) &&
SelectorMatches(*data, selector, data->mStateMask, data->mNameSpaceID,
data->mAttribute) &&
SelectorMatches(*data, selector, data->mStateMask, data->mAttribute) &&
SelectorMatchesTree(*data, selector->mNext)) {
enumData->change = nsReStyleHint(enumData->change | possibleChange);
}
@ -1778,7 +1772,6 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
// and :visited rules from prefs), rather than hacking AddRule below
// to add |href| to the hash, we'll just handle it here.
if (aData->mAttribute == nsGkAtoms::href &&
aData->mNameSpaceID == kNameSpaceID_None &&
aData->mIsHTMLContent &&
(aData->mContentTag == nsGkAtoms::a ||
aData->mContentTag == nsGkAtoms::area ||
@ -1796,13 +1789,11 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
// we have a hashtable with a per-attribute list.
if (cascade) {
if (aData->mContent->IsPotentialIDAttributeName(aData->mNameSpaceID,
aData->mAttribute)) {
if (aData->mAttribute == aData->mContent->GetIDAttributeName()) {
cascade->mIDSelectors.EnumerateForwards(AttributeEnumFunc, &data);
}
if (aData->mNameSpaceID == kNameSpaceID_None &&
aData->mAttribute == aData->mContent->GetClassAttributeName()) {
if (aData->mAttribute == aData->mContent->GetClassAttributeName()) {
cascade->mClassSelectors.EnumerateForwards(AttributeEnumFunc, &data);
}

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

@ -153,24 +153,19 @@ struct StateRuleProcessorData : public RuleProcessorData {
struct AttributeRuleProcessorData : public RuleProcessorData {
AttributeRuleProcessorData(nsPresContext* aPresContext,
nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType,
PRUint32 aStateMask)
: RuleProcessorData(aPresContext, aContent, nsnull),
mNameSpaceID(aNameSpaceID),
mAttribute(aAttribute),
mModType(aModType),
mStateMask(aStateMask)
{
NS_PRECONDITION(aContent, "null pointer");
}
// |HasAttributeDependentStyle| for which attribute?
PRInt32 mNameSpaceID;
nsIAtom* mAttribute;
PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent).
PRUint32 mStateMask; // The states that changed with the attr change.
nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent).
PRUint32 mStateMask; // The states that changed with the attr change.
};

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

@ -959,10 +959,10 @@ nsStyleSet::HasStateDependentStyle(nsPresContext* aPresContext,
struct AttributeData : public AttributeRuleProcessorData {
AttributeData(nsPresContext* aPresContext,
nsIContent* aContent, PRInt32 aNameSpaceID,
nsIAtom* aAttribute, PRInt32 aModType, PRUint32 aStateMask)
: AttributeRuleProcessorData(aPresContext, aContent, aNameSpaceID,
aAttribute, aModType, aStateMask),
nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType,
PRUint32 aStateMask)
: AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType,
aStateMask),
mHint(nsReStyleHint(0))
{}
nsReStyleHint mHint;
@ -982,7 +982,6 @@ SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData)
nsReStyleHint
nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext,
nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType,
PRUint32 aStateMask)
@ -997,8 +996,8 @@ nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext,
mRuleProcessors[eDocSheet] ||
mRuleProcessors[eStyleAttrSheet] ||
mRuleProcessors[eOverrideSheet])) {
AttributeData data(aPresContext, aContent, aNameSpaceID, aAttribute,
aModType, aStateMask);
AttributeData data(aPresContext, aContent, aAttribute, aModType,
aStateMask);
WalkRuleProcessors(SheetHasAttributeStyle, &data);
result = data.mHint;
}

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

@ -139,7 +139,6 @@ class nsStyleSet
// Test if style is dependent on the presence of an attribute.
nsReStyleHint HasAttributeDependentStyle(nsPresContext* aPresContext,
nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType,
PRUint32 aStateMask);

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

@ -68,7 +68,6 @@ css_properties.js: host_ListCSSProperties$(HOST_BIN_SUFFIX) css_properties_like_
_TEST_FILES = test_bug74880.html \
test_bug221428.html \
test_bug275196.xhtml \
test_bug302186.html \
test_bug319381.html \
test_bug357614.html \

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