зеркало из https://github.com/mozilla/gecko-dev.git
Don't apply user stylesheets to native anonymous content. Bug 286895, r+sr=dbaron
This commit is contained in:
Родитель
b2ab6a6008
Коммит
3fffd1fdc3
|
@ -567,6 +567,9 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||||
(!aBindingParent && aParent &&
|
(!aBindingParent && aParent &&
|
||||||
aParent->GetBindingParent() == GetBindingParent()),
|
aParent->GetBindingParent() == GetBindingParent()),
|
||||||
"Already have a binding parent. Unbind first!");
|
"Already have a binding parent. Unbind first!");
|
||||||
|
NS_PRECONDITION(aBindingParent != this || IsNativeAnonymous(),
|
||||||
|
"Only native anonymous content should have itself as its "
|
||||||
|
"own binding parent");
|
||||||
|
|
||||||
if (!aBindingParent && aParent) {
|
if (!aBindingParent && aParent) {
|
||||||
aBindingParent = aParent->GetBindingParent();
|
aBindingParent = aParent->GetBindingParent();
|
||||||
|
|
|
@ -1756,6 +1756,9 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||||
(!aBindingParent && aParent &&
|
(!aBindingParent && aParent &&
|
||||||
aParent->GetBindingParent() == GetBindingParent()),
|
aParent->GetBindingParent() == GetBindingParent()),
|
||||||
"Already have a binding parent. Unbind first!");
|
"Already have a binding parent. Unbind first!");
|
||||||
|
NS_PRECONDITION(aBindingParent != this || IsNativeAnonymous(),
|
||||||
|
"Only native anonymous content should have itself as its "
|
||||||
|
"own binding parent");
|
||||||
|
|
||||||
if (!aBindingParent && aParent) {
|
if (!aBindingParent && aParent) {
|
||||||
aBindingParent = aParent->GetBindingParent();
|
aBindingParent = aParent->GetBindingParent();
|
||||||
|
|
|
@ -1090,11 +1090,14 @@ nsBindingManager::WalkRules(nsStyleSet* aStyleSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIContent* parent = content->GetBindingParent();
|
nsIContent* parent = content->GetBindingParent();
|
||||||
if (parent == content)
|
if (parent == content) {
|
||||||
break; // The scrollbar case only is deliberately hacked to return itself
|
NS_ASSERTION(content->IsNativeAnonymous() ||
|
||||||
// (see GetBindingParent in nsXULElement.cpp). Actually, all
|
content->IsNodeOfType(nsINode::eXUL),
|
||||||
// native anonymous content is thus hacked. Cut off inheritance
|
"Unexpected binding parent");
|
||||||
// here.
|
|
||||||
|
break; // The anonymous content case is often deliberately hacked to
|
||||||
|
// return itself to cut off style inheritance here. Do that.
|
||||||
|
}
|
||||||
|
|
||||||
content = parent;
|
content = parent;
|
||||||
} while (content);
|
} while (content);
|
||||||
|
|
|
@ -1905,6 +1905,8 @@ nsCSSFrameConstructor::CreateAttributeContent(nsIContent* aParentContent,
|
||||||
getter_AddRefs(content));
|
getter_AddRefs(content));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
content->SetNativeAnonymous(PR_TRUE);
|
||||||
|
|
||||||
// Set aContent as the parent content so that event handling works.
|
// Set aContent as the parent content so that event handling works.
|
||||||
rv = content->BindToTree(mDocument, aParentContent, content, PR_TRUE);
|
rv = content->BindToTree(mDocument, aParentContent, content, PR_TRUE);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -1912,8 +1914,6 @@ nsCSSFrameConstructor::CreateAttributeContent(nsIContent* aParentContent,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
content->SetNativeAnonymous(PR_TRUE);
|
|
||||||
|
|
||||||
// Create a text frame and initialize it
|
// Create a text frame and initialize it
|
||||||
nsIFrame* textFrame = NS_NewTextFrame(mPresShell, aStyleContext);
|
nsIFrame* textFrame = NS_NewTextFrame(mPresShell, aStyleContext);
|
||||||
rv = textFrame->Init(content, aParentFrame, nsnull);
|
rv = textFrame->Init(content, aParentFrame, nsnull);
|
||||||
|
@ -1967,6 +1967,8 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram
|
||||||
data.mContent.mImage);
|
data.mContent.mImage);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
content->SetNativeAnonymous(PR_TRUE);
|
||||||
|
|
||||||
// Set aContent as the parent content and set the document object. This
|
// Set aContent as the parent content and set the document object. This
|
||||||
// way event handling works
|
// way event handling works
|
||||||
// Hack the binding parent to make document rules not match (not
|
// Hack the binding parent to make document rules not match (not
|
||||||
|
@ -1978,8 +1980,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
content->SetNativeAnonymous(PR_TRUE);
|
|
||||||
|
|
||||||
// Create an image frame and initialize it
|
// Create an image frame and initialize it
|
||||||
nsIFrame* imageFrame = NS_NewImageFrame(mPresShell, aStyleContext);
|
nsIFrame* imageFrame = NS_NewImageFrame(mPresShell, aStyleContext);
|
||||||
if (NS_UNLIKELY(!imageFrame)) {
|
if (NS_UNLIKELY(!imageFrame)) {
|
||||||
|
@ -2149,6 +2149,8 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram
|
||||||
NS_ASSERTION(*textPtr, "must implement nsIDOMCharacterData");
|
NS_ASSERTION(*textPtr, "must implement nsIDOMCharacterData");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textContent->SetNativeAnonymous(PR_TRUE);
|
||||||
|
|
||||||
// Set aContent as the parent content so that event handling works.
|
// Set aContent as the parent content so that event handling works.
|
||||||
nsresult rv = textContent->BindToTree(mDocument, aContent, textContent,
|
nsresult rv = textContent->BindToTree(mDocument, aContent, textContent,
|
||||||
PR_TRUE);
|
PR_TRUE);
|
||||||
|
@ -2157,8 +2159,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
textContent->SetNativeAnonymous(PR_TRUE);
|
|
||||||
|
|
||||||
// Create a text frame and initialize it
|
// Create a text frame and initialize it
|
||||||
textFrame = NS_NewTextFrame(mPresShell, aStyleContext);
|
textFrame = NS_NewTextFrame(mPresShell, aStyleContext);
|
||||||
if (!textFrame) {
|
if (!textFrame) {
|
||||||
|
|
|
@ -462,7 +462,12 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
||||||
(*aCollectorFunc)(mRuleProcessors[ePresHintSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[ePresHintSheet], aData);
|
||||||
nsRuleNode* lastPresHintRN = mRuleWalker->GetCurrentNode();
|
nsRuleNode* lastPresHintRN = mRuleWalker->GetCurrentNode();
|
||||||
|
|
||||||
if (mRuleProcessors[eUserSheet])
|
PRBool skipUserStyles = aData->mContent &&
|
||||||
|
aData->mContent == aData->mContent->GetBindingParent();
|
||||||
|
NS_ASSERTION(!skipUserStyles || aData->mContent->IsNativeAnonymous() ||
|
||||||
|
aData->mContent->IsNodeOfType(nsINode::eXUL),
|
||||||
|
"Content with bogus binding parent");
|
||||||
|
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
|
||||||
(*aCollectorFunc)(mRuleProcessors[eUserSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[eUserSheet], aData);
|
||||||
nsRuleNode* lastUserRN = mRuleWalker->GetCurrentNode();
|
nsRuleNode* lastUserRN = mRuleWalker->GetCurrentNode();
|
||||||
|
|
||||||
|
@ -476,7 +481,8 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
||||||
mBindingManager->WalkRules(this, aCollectorFunc, aData,
|
mBindingManager->WalkRules(this, aCollectorFunc, aData,
|
||||||
&cutOffInheritance);
|
&cutOffInheritance);
|
||||||
}
|
}
|
||||||
if (!cutOffInheritance && mRuleProcessors[eDocSheet]) // NOTE: different
|
if (!skipUserStyles && !cutOffInheritance &&
|
||||||
|
mRuleProcessors[eDocSheet]) // NOTE: different
|
||||||
(*aCollectorFunc)(mRuleProcessors[eDocSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[eDocSheet], aData);
|
||||||
if (mRuleProcessors[eStyleAttrSheet])
|
if (mRuleProcessors[eStyleAttrSheet])
|
||||||
(*aCollectorFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
||||||
|
@ -514,8 +520,15 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
|
||||||
(*aFunc)(mRuleProcessors[eAgentSheet], aData);
|
(*aFunc)(mRuleProcessors[eAgentSheet], aData);
|
||||||
if (mRuleProcessors[ePresHintSheet])
|
if (mRuleProcessors[ePresHintSheet])
|
||||||
(*aFunc)(mRuleProcessors[ePresHintSheet], aData);
|
(*aFunc)(mRuleProcessors[ePresHintSheet], aData);
|
||||||
if (mRuleProcessors[eUserSheet])
|
|
||||||
|
PRBool skipUserStyles = aData->mContent &&
|
||||||
|
aData->mContent == aData->mContent->GetBindingParent();
|
||||||
|
NS_ASSERTION(!skipUserStyles || aData->mContent->IsNativeAnonymous() ||
|
||||||
|
aData->mContent->IsNodeOfType(nsINode::eXUL),
|
||||||
|
"Content with bogus binding parent");
|
||||||
|
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
|
||||||
(*aFunc)(mRuleProcessors[eUserSheet], aData);
|
(*aFunc)(mRuleProcessors[eUserSheet], aData);
|
||||||
|
|
||||||
if (mRuleProcessors[eHTMLPresHintSheet])
|
if (mRuleProcessors[eHTMLPresHintSheet])
|
||||||
(*aFunc)(mRuleProcessors[eHTMLPresHintSheet], aData);
|
(*aFunc)(mRuleProcessors[eHTMLPresHintSheet], aData);
|
||||||
|
|
||||||
|
@ -524,7 +537,8 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
|
||||||
// We can supply additional document-level sheets that should be walked.
|
// We can supply additional document-level sheets that should be walked.
|
||||||
mBindingManager->WalkRules(this, aFunc, aData, &cutOffInheritance);
|
mBindingManager->WalkRules(this, aFunc, aData, &cutOffInheritance);
|
||||||
}
|
}
|
||||||
if (!cutOffInheritance && mRuleProcessors[eDocSheet]) // NOTE: different
|
if (!skipUserStyles && !cutOffInheritance &&
|
||||||
|
mRuleProcessors[eDocSheet]) // NOTE: different
|
||||||
(*aFunc)(mRuleProcessors[eDocSheet], aData);
|
(*aFunc)(mRuleProcessors[eDocSheet], aData);
|
||||||
if (mRuleProcessors[eStyleAttrSheet])
|
if (mRuleProcessors[eStyleAttrSheet])
|
||||||
(*aFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
(*aFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче