Closed Bug 290377 Opened 19 years ago Closed 19 years ago

[FIXr]computed value of 'border-width' is incorrect

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: dbaron, Assigned: bzbarsky)

References

Details

(Keywords: css2)

Attachments

(4 files, 3 obsolete files)

This is the bug that makes the rule tree a pain to deal with (again).

The computed value of 'border-width' is supposed to be zero when 'border-style'
is 'none' or 'hidden', which means it should be inherited that way.  But we
can't really store that in the rule tree because it would break some cascading
cases.  But we also really don't want to disable the rule tree optimizations (as
we did for the section 9.7 fixups) because this is the default case.
Attached patch Quick hack (obsolete) — Splinter Review
I think this actually fully fixes the bug...

That said, I'd still like to expose this better on nsStyleBorder.  As things
stand, we have a lot of weird code in various places because nsStyleBorder
can't answer the simple question of "is there a border on this side, and how
wide should it be?"

I'm also still trying to decide whether the cached border stuff is really worth
it...
Attached patch Proposed patch (obsolete) — Splinter Review
This fixes this bug and bug 273500...  I'm not quite sure whether to add the
side constants to gfxCore or nsMargin; in the latter case I'd have to make
nsStyleConsts include nsMargin (which might be ok).

Note that if we find that the "live" width/style updating is too slow we can go
back to having a RecalcData() function like we used to have.  But I suspect
this won't be an issue.
Assignee: dbaron → bzbarsky
Attachment #180819 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #180963 - Flags: superreview?(dbaron)
Attachment #180963 - Flags: review?(dbaron)
Priority: -- → P1
Summary: computed value of 'border-width' is incorrect → [FIX]computed value of 'border-width' is incorrect
Target Milestone: --- → mozilla1.8beta2
Note: I should also change the comment at
http://lxr.mozilla.org/seamonkey/source/layout/base/nsStyleConsts.h#233 to
something more like:

  "Possible enumerated specified values of border-*-width, used by nsCSSMargin."

Comment on attachment 180963 [details] [diff] [review]
Proposed patch

>Index: gfx/public/nsMargin.h
>+  nscoord& side(PRUint8 aSide) {
>+    NS_PRECONDITION(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
>+                    NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
>+                    "Unexpected side constants");
>+    NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
>+    return *(&top + aSide);
>+  }    
>+
>+#if (NS_SIDE_TOP == 0) && (NS_SIDE_RIGHT == 1) && (NS_SIDE_BOTTOM == 2) && (NS_SIDE_LEFT == 3)
>+  nscoord side(PRUint8 aSide) const {
>+    NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
>+    return *(&top + aSide);
>+  }    
>+#else
>+#error "Somebody changed the side constants."
>+#endif

Just put both inside the #if and skip the first NS_PRECONDITION.
Comment on attachment 180963 [details] [diff] [review]
Proposed patch

>Index: layout/style/nsStyleStruct.h
>+  void SetBorderWidth(PRUint8 aSide, nscoord aBorderWidth)
>   {
>+    NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");

>+  nscoord GetBorderWidth(PRUint8 aSide) const
>+  {
>+    NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");

Probably better to drop these assertions, and just assume that nsMargin::side
has them.


Can you eliminate the fourth and fifth parameters to CalcSidesFor and fifth and
sixth of CalcSideFor?

>Index: layout/generic/nsInlineFrame.cpp

You can remove IsBorderZero.
Attachment #180963 - Flags: superreview?(dbaron)
Attachment #180963 - Flags: superreview+
Attachment #180963 - Flags: review?(dbaron)
Attachment #180963 - Flags: review+
> Can you eliminate the fourth and fifth parameters to CalcSidesFor and fifth and
> sixth of CalcSideFor?

Yes.  Will do that and make the other changes you asked for.
Attached patch Updated to comments (obsolete) — Splinter Review
This should be pretty safe and simplifies the border code quite a bit, in
addition to making us inherit border widths correctly...
Attachment #182136 - Flags: approval1.8b2?
Summary: [FIX]computed value of 'border-width' is incorrect → [FIXr]computed value of 'border-width' is incorrect
Comment on attachment 182136 [details] [diff] [review]
Updated to comments

a=asa
Attachment #182136 - Flags: approval1.8b2? → approval1.8b2+
Attachment #182136 - Attachment is obsolete: true
Fixed.  Even seemed to help out Tp a tad....  Still waiting on luna's Tdhtml to
settle from what I think is a temporary spike.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Well, looks like luna's spike is not quite temporary.  Trying to figure out
what's going on there.
I don't know what was going on this morning, but I think I got confused between
windows on two different machines.... :(  That'll teach me to check in before
I'm really awake.

This diff, applied on top of the previous one, addresses the comments.	I just
checked it in.
Attachment #180963 - Attachment is obsolete: true
And looks like the times on luna are just being very jumpy... it's been back and
forth from 2030 to 2080 ever since roc's scrollframe changes.  :(
Depends on: 299723
No longer depends on: 299723
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: