mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 525608 part 6. Remove null-checks on RuleProcessorData::mContent. r=dbaron
This commit is contained in:
parent
6b4f1d994c
commit
5ea79b4acb
@ -1272,8 +1272,7 @@ nsBindingManager::WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc,
|
||||
{
|
||||
*aCutOffInheritance = PR_FALSE;
|
||||
|
||||
if (!aData->mContent)
|
||||
return NS_OK;
|
||||
NS_ASSERTION(aData->mContent, "How did that happen?");
|
||||
|
||||
// Walk the binding scope chain, starting with the binding attached to our
|
||||
// content, up till we run out of scopes or we get cut off.
|
||||
|
@ -925,7 +925,7 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
|
||||
{
|
||||
MOZ_COUNT_CTOR(RuleProcessorData);
|
||||
|
||||
NS_ASSERTION(!aContent || aContent->IsNodeOfType(nsINode::eELEMENT),
|
||||
NS_ASSERTION(aContent && aContent->IsNodeOfType(nsINode::eELEMENT),
|
||||
"non-element leaked into SelectorMatches");
|
||||
|
||||
mNthIndices[0][0] = -2;
|
||||
@ -945,41 +945,30 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
|
||||
mCompatMode = aContent->GetOwnerDoc()->GetCompatibilityMode();
|
||||
}
|
||||
|
||||
if (NS_LIKELY(aContent)) {
|
||||
NS_ASSERTION(aContent->GetOwnerDoc(), "Document-less node here?");
|
||||
NS_ASSERTION(aContent->GetOwnerDoc(), "Document-less node here?");
|
||||
|
||||
// get the tag and parent
|
||||
mContentTag = aContent->Tag();
|
||||
mParentContent = aContent->GetParent();
|
||||
// get the tag and parent
|
||||
mContentTag = aContent->Tag();
|
||||
mParentContent = aContent->GetParent();
|
||||
|
||||
// see if there are attributes for the content
|
||||
mHasAttributes = aContent->GetAttrCount() > 0;
|
||||
if (mHasAttributes) {
|
||||
// get the ID and classes for the content
|
||||
mContentID = aContent->GetID();
|
||||
mClasses = aContent->GetClasses();
|
||||
} else {
|
||||
mContentID = nsnull;
|
||||
mClasses = nsnull;
|
||||
}
|
||||
|
||||
// get the namespace
|
||||
mNameSpaceID = aContent->GetNameSpaceID();
|
||||
|
||||
// check for HTMLContent status
|
||||
mIsHTMLContent = (mNameSpaceID == kNameSpaceID_XHTML);
|
||||
mIsHTML = mIsHTMLContent && aContent->IsInHTMLDocument();
|
||||
// see if there are attributes for the content
|
||||
mHasAttributes = aContent->GetAttrCount() > 0;
|
||||
if (mHasAttributes) {
|
||||
// get the ID and classes for the content
|
||||
mContentID = aContent->GetID();
|
||||
mClasses = aContent->GetClasses();
|
||||
} else {
|
||||
mContentTag = nsnull;
|
||||
mParentContent = nsnull;
|
||||
mContentID = nsnull;
|
||||
mClasses = nsnull;
|
||||
mHasAttributes = PR_FALSE;
|
||||
mNameSpaceID = kNameSpaceID_Unknown;
|
||||
mIsHTMLContent = PR_FALSE;
|
||||
mIsHTML = PR_FALSE;
|
||||
}
|
||||
|
||||
// get the namespace
|
||||
mNameSpaceID = aContent->GetNameSpaceID();
|
||||
|
||||
// check for HTMLContent status
|
||||
mIsHTMLContent = (mNameSpaceID == kNameSpaceID_XHTML);
|
||||
mIsHTML = mIsHTMLContent && aContent->IsInHTMLDocument();
|
||||
|
||||
// No need to initialize mIsLink or mLinkState; the IsLink() accessor will
|
||||
// handle that.
|
||||
|
||||
@ -1053,13 +1042,11 @@ RuleProcessorData::ContentState()
|
||||
if (!mGotContentState) {
|
||||
mGotContentState = PR_TRUE;
|
||||
mContentState = 0;
|
||||
if (mContent) {
|
||||
if (mPresContext) {
|
||||
mPresContext->EventStateManager()->GetContentState(mContent,
|
||||
mContentState);
|
||||
} else {
|
||||
mContentState = mContent->IntrinsicState();
|
||||
}
|
||||
if (mPresContext) {
|
||||
mPresContext->EventStateManager()->GetContentState(mContent,
|
||||
mContentState);
|
||||
} else {
|
||||
mContentState = mContent->IntrinsicState();
|
||||
}
|
||||
}
|
||||
return mContentState;
|
||||
@ -1072,32 +1059,30 @@ RuleProcessorData::IsLink()
|
||||
mGotLinkInfo = PR_TRUE;
|
||||
mLinkState = eLinkState_Unknown;
|
||||
mIsLink = PR_FALSE;
|
||||
if (mContent) {
|
||||
// if HTML content and it has some attributes, check for an HTML link
|
||||
// NOTE: optimization: cannot be a link if no attributes (since it needs
|
||||
// an href)
|
||||
nsILinkHandler* linkHandler =
|
||||
mPresContext ? mPresContext->GetLinkHandler() : nsnull;
|
||||
if (mIsHTMLContent && mHasAttributes) {
|
||||
// check if it is an HTML Link
|
||||
if (nsStyleUtil::IsHTMLLink(mContent, linkHandler, &mLinkState)) {
|
||||
mIsLink = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// if not an HTML link, check for a simple xlink (cannot be both HTML
|
||||
// link and xlink) NOTE: optimization: cannot be an XLink if no
|
||||
// attributes (since it needs an href)
|
||||
if(!mIsLink &&
|
||||
mHasAttributes &&
|
||||
!(mIsHTMLContent || mContent->IsXUL()) &&
|
||||
nsStyleUtil::IsLink(mContent, linkHandler, &mLinkState)) {
|
||||
// if HTML content and it has some attributes, check for an HTML link
|
||||
// NOTE: optimization: cannot be a link if no attributes (since it needs
|
||||
// an href)
|
||||
nsILinkHandler* linkHandler =
|
||||
mPresContext ? mPresContext->GetLinkHandler() : nsnull;
|
||||
if (mIsHTMLContent && mHasAttributes) {
|
||||
// check if it is an HTML Link
|
||||
if (nsStyleUtil::IsHTMLLink(mContent, linkHandler, &mLinkState)) {
|
||||
mIsLink = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (mLinkState == eLinkState_Visited && !gSupportVisitedPseudo) {
|
||||
mLinkState = eLinkState_Unvisited;
|
||||
}
|
||||
// if not an HTML link, check for a simple xlink (cannot be both HTML
|
||||
// link and xlink) NOTE: optimization: cannot be an XLink if no
|
||||
// attributes (since it needs an href)
|
||||
if(!mIsLink &&
|
||||
mHasAttributes &&
|
||||
!(mIsHTMLContent || mContent->IsXUL()) &&
|
||||
nsStyleUtil::IsLink(mContent, linkHandler, &mLinkState)) {
|
||||
mIsLink = PR_TRUE;
|
||||
}
|
||||
|
||||
if (mLinkState == eLinkState_Visited && !gSupportVisitedPseudo) {
|
||||
mLinkState = eLinkState_Unvisited;
|
||||
}
|
||||
}
|
||||
return mIsLink;
|
||||
@ -1569,7 +1554,6 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
}
|
||||
else if (nsCSSPseudoClasses::root == pseudoClass->mAtom) {
|
||||
result = (data.mParentContent == nsnull &&
|
||||
data.mContent &&
|
||||
data.mContent ==
|
||||
data.mContent->GetOwnerDoc()->GetRootContent());
|
||||
}
|
||||
@ -1577,7 +1561,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
// XXXldb How do we know where the selector came from? And what
|
||||
// if there are multiple bindings, and we should be matching the
|
||||
// outer one?
|
||||
result = (data.mScopedRoot && data.mScopedRoot == data.mContent);
|
||||
result = (data.mScopedRoot == data.mContent);
|
||||
}
|
||||
else if (nsCSSPseudoClasses::lang == pseudoClass->mAtom) {
|
||||
NS_ASSERTION(nsnull != pseudoClass->u.mString, "null lang parameter");
|
||||
@ -1593,7 +1577,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
nsDependentString(pseudoClass->u.mString),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
else if (data.mContent) {
|
||||
else {
|
||||
nsIDocument* doc = data.mContent->GetDocument();
|
||||
if (doc) {
|
||||
// Try to get the language from the HTTP header or if this
|
||||
@ -1732,8 +1716,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
result = data.mIsHTML;
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozLocaleDir == pseudoClass->mAtom) {
|
||||
nsIDocument* doc = data.mContent ? data.mContent->GetDocument() :
|
||||
data.mPresContext->Document();
|
||||
nsIDocument* doc = data.mContent->GetDocument();
|
||||
|
||||
if (doc) {
|
||||
PRBool docIsRTL = doc && doc->IsDocumentRightToLeft();
|
||||
@ -1753,7 +1736,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
}
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozLWTheme == pseudoClass->mAtom) {
|
||||
nsIDocument* doc = data.mContent ? data.mContent->GetOwnerDoc() : nsnull;
|
||||
nsIDocument* doc = data.mContent->GetOwnerDoc();
|
||||
|
||||
if (doc) {
|
||||
result = doc->GetDocumentLWTheme() > nsIDocument::Doc_Theme_None;
|
||||
@ -1763,7 +1746,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
}
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozLWThemeBrightText == pseudoClass->mAtom) {
|
||||
nsIDocument* doc = data.mContent ? data.mContent->GetOwnerDoc() : nsnull;
|
||||
nsIDocument* doc = data.mContent->GetOwnerDoc();
|
||||
|
||||
if (doc) {
|
||||
result = doc->GetDocumentLWTheme() == nsIDocument::Doc_Theme_Bright;
|
||||
@ -1773,7 +1756,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
}
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozLWThemeDarkText == pseudoClass->mAtom) {
|
||||
nsIDocument* doc = data.mContent ? data.mContent->GetOwnerDoc() : nsnull;
|
||||
nsIDocument* doc = data.mContent->GetOwnerDoc();
|
||||
|
||||
if (doc) {
|
||||
result = doc->GetDocumentLWTheme() == nsIDocument::Doc_Theme_Dark;
|
||||
@ -1827,8 +1810,6 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
// if no attributes on the content, no match
|
||||
return PR_FALSE;
|
||||
} else {
|
||||
NS_ASSERTION(data.mContent,
|
||||
"Must have content if data.mHasAttributes is true!");
|
||||
result = PR_TRUE;
|
||||
nsAttrSelector* attr = aSelector->mAttrList;
|
||||
nsIAtom* matchAttribute;
|
||||
@ -2160,9 +2141,8 @@ static void PseudoEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector,
|
||||
NS_IMETHODIMP
|
||||
nsCSSRuleProcessor::RulesMatching(PseudoRuleProcessorData* aData)
|
||||
{
|
||||
NS_PRECONDITION(!aData->mContent ||
|
||||
aData->mContent->IsNodeOfType(nsINode::eELEMENT),
|
||||
"content (if present) must be element");
|
||||
NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
|
||||
"content must be element");
|
||||
|
||||
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
|
||||
|
||||
|
@ -144,18 +144,16 @@ HTMLCSSStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData)
|
||||
{
|
||||
nsIContent* content = aData->mContent;
|
||||
|
||||
if (content) {
|
||||
// just get the one and only style rule from the content's STYLE attribute
|
||||
nsICSSStyleRule* rule = content->GetInlineStyleRule();
|
||||
if (rule)
|
||||
aData->mRuleWalker->Forward(rule);
|
||||
// just get the one and only style rule from the content's STYLE attribute
|
||||
nsICSSStyleRule* rule = content->GetInlineStyleRule();
|
||||
if (rule)
|
||||
aData->mRuleWalker->Forward(rule);
|
||||
|
||||
#ifdef MOZ_SMIL
|
||||
rule = content->GetSMILOverrideStyleRule();
|
||||
if (rule)
|
||||
aData->mRuleWalker->Forward(rule);
|
||||
rule = content->GetSMILOverrideStyleRule();
|
||||
if (rule)
|
||||
aData->mRuleWalker->Forward(rule);
|
||||
#endif // MOZ_SMIL
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -124,19 +124,19 @@ public:
|
||||
PRBool aCheckEdgeOnly);
|
||||
|
||||
nsPresContext* mPresContext;
|
||||
nsIContent* mContent; // weak ref
|
||||
nsIContent* mParentContent; // if content, content->GetParent(); weak ref
|
||||
nsIContent* mContent; // weak ref, must not be null
|
||||
nsIContent* mParentContent; // mContent->GetParent(); weak ref
|
||||
nsRuleWalker* mRuleWalker; // Used to add rules to our results.
|
||||
nsIContent* mScopedRoot; // Root of scoped stylesheet (set and unset by the supplier of the scoped stylesheet
|
||||
|
||||
nsIAtom* mContentTag; // if content, then content->GetTag()
|
||||
nsIAtom* mContentID; // if styled content, then weak reference to styledcontent->GetID()
|
||||
PRPackedBool mIsHTMLContent; // if content, then whether it's IsHTML()
|
||||
PRPackedBool mIsHTML; // if content then mIsHTMLContent && IsInHTMLDocument()
|
||||
PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0
|
||||
nsIAtom* mContentTag; // mContent->GetTag()
|
||||
nsIAtom* mContentID; // mContent->GetID()
|
||||
PRPackedBool mIsHTMLContent; // whether mContent it's IsHTML()
|
||||
PRPackedBool mIsHTML; // mIsHTMLContent && IsInHTMLDocument()
|
||||
PRPackedBool mHasAttributes; // mContent->GetAttrCount() > 0
|
||||
nsCompatibility mCompatMode; // Possibly remove use of this in SelectorMatches?
|
||||
PRInt32 mNameSpaceID; // if content, content->GetNameSapce()
|
||||
const nsAttrValue* mClasses; // if styled content, styledcontent->GetClasses()
|
||||
PRInt32 mNameSpaceID; // mContent->GetNameSapce()
|
||||
const nsAttrValue* mClasses; // mContent->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.
|
||||
@ -154,10 +154,11 @@ private:
|
||||
// subscript is 0 for nth- and 1 for nth-last-.
|
||||
PRInt32 mNthIndices[2][2];
|
||||
|
||||
PRInt32 mContentState; // if content, eventStateMgr->GetContentState()
|
||||
// mContentState, mLinkState, mIsLink are initialized lazily.
|
||||
PRInt32 mContentState; // eventStateMgr->GetContentState() or
|
||||
// mContent->IntrinsicState() if we have no ESM
|
||||
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
|
||||
PRPackedBool mIsLink; // if content, calls nsStyleUtil::IsHTMLLink
|
||||
// or nsStyleUtil::IsLink
|
||||
PRPackedBool mIsLink; // nsStyleUtil::IsHTMLLink or nsStyleUtil::IsLink
|
||||
PRPackedBool mGotContentState;
|
||||
PRPackedBool mGotLinkInfo; // Whether we've gotten the right values
|
||||
// for mLinkState and mIsLink.
|
||||
@ -170,7 +171,6 @@ struct ElementRuleProcessorData : public RuleProcessorData {
|
||||
: RuleProcessorData(aPresContext,aContent,aRuleWalker)
|
||||
{
|
||||
NS_PRECONDITION(aPresContext, "null pointer");
|
||||
NS_PRECONDITION(aContent, "null pointer");
|
||||
NS_PRECONDITION(aRuleWalker, "null pointer");
|
||||
}
|
||||
};
|
||||
@ -238,7 +238,6 @@ struct StateRuleProcessorData : public RuleProcessorData {
|
||||
mStateMask(aStateMask)
|
||||
{
|
||||
NS_PRECONDITION(aPresContext, "null pointer");
|
||||
NS_PRECONDITION(aContent, "null pointer");
|
||||
}
|
||||
const PRInt32 mStateMask; // |HasStateDependentStyle| for which state(s)?
|
||||
// Constants defined in nsIEventStateManager.h .
|
||||
@ -256,7 +255,6 @@ struct AttributeRuleProcessorData : public RuleProcessorData {
|
||||
mAttrHasChanged(aAttrHasChanged)
|
||||
{
|
||||
NS_PRECONDITION(aPresContext, "null pointer");
|
||||
NS_PRECONDITION(aContent, "null pointer");
|
||||
}
|
||||
nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
|
||||
PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent).
|
||||
|
@ -677,8 +677,7 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
|
||||
if (mRuleProcessors[ePresHintSheet])
|
||||
(*aFunc)(mRuleProcessors[ePresHintSheet], aData);
|
||||
|
||||
PRBool skipUserStyles =
|
||||
aData->mContent && aData->mContent->IsInNativeAnonymousSubtree();
|
||||
PRBool skipUserStyles = aData->mContent->IsInNativeAnonymousSubtree();
|
||||
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
|
||||
(*aFunc)(mRuleProcessors[eUserSheet], aData);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user