зеркало из https://github.com/mozilla/gecko-dev.git
Bug 598832 part 10. Stop caching information about the element's attributes; just get it from the DOM as needed. r=dbaron
This commit is contained in:
Родитель
2e4df29640
Коммит
22bd1cff27
|
@ -1138,20 +1138,6 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
|
|||
|
||||
// get the parent
|
||||
mParentContent = aElement->GetParent();
|
||||
|
||||
// see if there are attributes for the content
|
||||
mHasAttributes = aElement->GetAttrCount() > 0;
|
||||
if (mHasAttributes) {
|
||||
// get the ID and classes for the content
|
||||
mContentID = aElement->GetID();
|
||||
mClasses = aElement->GetClasses();
|
||||
} else {
|
||||
mContentID = nsnull;
|
||||
mClasses = nsnull;
|
||||
}
|
||||
|
||||
// get the namespace
|
||||
mNameSpaceID = aElement->GetNameSpaceID();
|
||||
}
|
||||
|
||||
RuleProcessorData::~RuleProcessorData()
|
||||
|
@ -1560,7 +1546,7 @@ static PRBool SelectorMatches(Element* aElement,
|
|||
// namespace/tag match
|
||||
// optimization : bail out early if we can
|
||||
if ((kNameSpaceID_Unknown != aSelector->mNameSpace &&
|
||||
data.mNameSpaceID != aSelector->mNameSpace))
|
||||
aElement->GetNameSpaceID() != aSelector->mNameSpace))
|
||||
return PR_FALSE;
|
||||
|
||||
if (aSelector->mLowercaseTag) {
|
||||
|
@ -1574,14 +1560,15 @@ static PRBool SelectorMatches(Element* aElement,
|
|||
|
||||
nsAtomList* IDList = aSelector->mIDList;
|
||||
if (IDList) {
|
||||
if (data.mContentID) {
|
||||
nsIAtom* id = aElement->GetID();
|
||||
if (id) {
|
||||
// case sensitivity: bug 93371
|
||||
const PRBool isCaseSensitive =
|
||||
aTreeMatchContext.mCompatMode != eCompatibility_NavQuirks;
|
||||
|
||||
if (isCaseSensitive) {
|
||||
do {
|
||||
if (IDList->mAtom != data.mContentID) {
|
||||
if (IDList->mAtom != id) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
IDList = IDList->mNext;
|
||||
|
@ -1590,7 +1577,7 @@ static PRBool SelectorMatches(Element* aElement,
|
|||
// Use EqualsIgnoreASCIICase instead of full on unicode case conversion
|
||||
// in order to save on performance. This is only used in quirks mode
|
||||
// anyway.
|
||||
nsDependentAtomString id1Str(data.mContentID);
|
||||
nsDependentAtomString id1Str(id);
|
||||
do {
|
||||
if (!nsContentUtils::EqualsIgnoreASCIICase(id1Str,
|
||||
nsDependentAtomString(IDList->mAtom))) {
|
||||
|
@ -1608,7 +1595,7 @@ static PRBool SelectorMatches(Element* aElement,
|
|||
nsAtomList* classList = aSelector->mClassList;
|
||||
if (classList) {
|
||||
// test for class match
|
||||
const nsAttrValue *elementClasses = data.mClasses;
|
||||
const nsAttrValue *elementClasses = aElement->GetClasses();
|
||||
if (!elementClasses) {
|
||||
// Element has no classes but we have a class selector
|
||||
return PR_FALSE;
|
||||
|
@ -2026,7 +2013,8 @@ static PRBool SelectorMatches(Element* aElement,
|
|||
PRBool result = PR_TRUE;
|
||||
if (aSelector->mAttrList) {
|
||||
// test for attribute match
|
||||
if (!data.mHasAttributes) {
|
||||
PRUint32 attrCount = aElement->GetAttrCount();
|
||||
if (attrCount == 0) {
|
||||
// if no attributes on the content, no match
|
||||
return PR_FALSE;
|
||||
} else {
|
||||
|
@ -2046,7 +2034,6 @@ static PRBool SelectorMatches(Element* aElement,
|
|||
// matches, evaluate for each namespace (the only namespaces that
|
||||
// have a chance at matching, of course, are ones that the element
|
||||
// actually has attributes in), short-circuiting if we ever match.
|
||||
PRUint32 attrCount = data.mElement->GetAttrCount();
|
||||
result = PR_FALSE;
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
const nsAttrName* attrName =
|
||||
|
@ -2443,7 +2430,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
|
|||
// check for the lwtheme and lwthemetextcolor attribute on root XUL elements
|
||||
if ((aData->mAttribute == nsGkAtoms::lwtheme ||
|
||||
aData->mAttribute == nsGkAtoms::lwthemetextcolor) &&
|
||||
aData->mNameSpaceID == kNameSpaceID_XUL &&
|
||||
aData->mElement->GetNameSpaceID() == kNameSpaceID_XUL &&
|
||||
aData->mElement == aData->mElement->GetOwnerDoc()->GetRootElement())
|
||||
{
|
||||
data.change = nsRestyleHint(data.change | eRestyle_Subtree);
|
||||
|
@ -2476,7 +2463,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
|
|||
}
|
||||
|
||||
if (aData->mAttribute == aData->mElement->GetClassAttributeName()) {
|
||||
const nsAttrValue* elementClasses = aData->mClasses;
|
||||
const nsAttrValue* elementClasses = aData->mElement->GetClasses();
|
||||
if (elementClasses) {
|
||||
PRInt32 atomCount = elementClasses->GetAtomCount();
|
||||
for (PRInt32 i = 0; i < atomCount; ++i) {
|
||||
|
|
|
@ -179,10 +179,6 @@ public:
|
|||
nsIContent* mParentContent; // mElement->GetParent(); weak ref
|
||||
nsRuleWalker* mRuleWalker; // Used to add rules to our results.
|
||||
|
||||
nsIAtom* mContentID; // mElement->GetID()
|
||||
PRPackedBool mHasAttributes; // mElement->GetAttrCount() > 0
|
||||
PRInt32 mNameSpaceID; // mElement->GetNameSapce()
|
||||
const nsAttrValue* mClasses; // mElement->GetClasses()
|
||||
// mPreviousSiblingData and mParentData are always RuleProcessorData
|
||||
// and never a derived class. They are allocated lazily, when
|
||||
// selectors require matching of prior siblings or ancestors.
|
||||
|
|
Загрузка…
Ссылка в новой задаче