Closed Bug 208548 Opened 21 years ago Closed 21 years ago

Inconsistency in link determination in HTMLStyleSheetImpl

Categories

(Core :: CSS Parsing and Computation, defect, P4)

defect

Tracking

()

RESOLVED FIXED
mozilla1.5alpha

People

(Reporter: ian, Assigned: dbaron)

Details

(Whiteboard: [patch])

Attachments

(1 file)

In content/html/style/src/nsHTMLStyleSheet.cpp :

HTMLStyleSheetImpl::RulesMatching(...):
814       if (tag == nsHTMLAtoms::a) {
815         if (mLinkRule || mVisitedRule || mActiveRule) {
816           if (aData->mIsHTMLLink) {
...
HTMLStyleSheetImpl::HasStateDependentStyle(...):
871   *aResult = mActiveRule &&
872              (aData->mStateMask & NS_EVENT_STATE_ACTIVE) &&
873              aData->mStyledContent &&
874              aData->mIsHTMLContent &&
875              aData->mContentTag == nsHTMLAtoms::a &&
876              aData->mStyledContent->HasAttr(kNameSpaceID_None,
877                                             nsHTMLAtoms::href);

It seems that the two pieces of code should use the same algorithm to work out
if the element is a link or not. In fact, it seems that they could both be
simplified:

       if (aData->mIsHTMLLink && (mLinkRule || mVisitedRule || mActiveRule)) {

...and:

   *aResult = mActiveRule &&
              (aData->mStateMask & NS_EVENT_STATE_ACTIVE) &&
              aData->mStyledContent &&
              aData->mIsHTMLContent &&
              aData->mIsHTMLLink;

That would have the side effect of also applying the attributes to <area> and
<link> elements which might even be a good idea.

Anyway. Just something I spotted while browsing the code. It could be
intentional of course.
Actually this would also require changes to
HTMLStyleSheetImpl::HasAttributeDependentStyle() so maybe it's not such a good idea.
I think |HasStateDependentStyle| could be fixed (although it's not dangerous if
it returns true more often than needed -- just slower).
Status: UNCONFIRMED → NEW
Ever confirmed: true
Status: NEW → ASSIGNED
OS: Windows 2000 → All
Priority: -- → P4
Hardware: PC → All
Whiteboard: [patch]
Target Milestone: --- → mozilla1.5alpha
Attachment #125102 - Flags: superreview?(bz-bugspam)
Attachment #125102 - Flags: review?(bz-bugspam)
Comment on attachment 125102 [details] [diff] [review]
patch

r+sr=me
Attachment #125102 - Flags: superreview?(bz-bugspam)
Attachment #125102 - Flags: superreview+
Attachment #125102 - Flags: review?(bz-bugspam)
Attachment #125102 - Flags: review+
Fix checked in to trunk, 2003-06-10 15:10 -0700.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: