Closed
Bug 438517
Opened 17 years ago
Closed 16 years ago
CSS text-shadow not working for XUL elements using nsTextBoxFrame
Categories
(Core :: Layout: Text and Fonts, defect)
Core
Layout: Text and Fonts
Tracking
()
RESOLVED
FIXED
People
(Reporter: dao, Assigned: robarnold)
References
Details
Attachments
(4 files, 1 obsolete file)
14.38 KB,
patch
|
roc
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
5.30 KB,
application/octet-stream
|
Details | |
9.09 KB,
patch
|
roc
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
590 bytes,
patch
|
roc
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
From bug 10713 comment 159:
> XUL support is not in this patch, I was thinking of doing it as a followup; or
> even better, this motivates someone else with a lot more layout experience to
> port XUL to nsTextFrameThebes.
Comment 1•17 years ago
|
||
What does this mean? That text-shadow isn't implemented for any xul elements, or just not for text using nsTextBoxFrame.cpp? I suspect you mean the latter.
> port XUL to nsTextFrameThebes.
huh? <label>Blah</label> already does so.
Reporter | ||
Comment 2•17 years ago
|
||
I suspect that too. Michael, can you confirm?
xul:text, xul:label with a value attribute, and xul:description with a value attribute use nsTextBoxFrame. That's what this bug is about.
xul:label without a value attribute and xul:description without a value attribute use a block wrapping a regular text frame.
Reporter | ||
Updated•17 years ago
|
Summary: Implement CSS text-shadow for XUL → Implement CSS text-shadow for nsTextBoxFrame
Comment 4•17 years ago
|
||
Is there any current work to remove nsTextBoxFrame and make XUL use nsTextFrameThebes?
Comment 5•17 years ago
|
||
(In reply to comment #4)
> Is there any current work to remove nsTextBoxFrame and make XUL use
> nsTextFrameThebes?
That doesn't sound like it would be compatible. nsTextBoxFrame doesn't lay out the same way. It would be good to share text rendering functionality though.
Comment 6•17 years ago
|
||
Is this needed? nsTextBoxFrame doesn't support other CSS properties too. E.g., word-spacing, letter-spacing and text-align: justify;
i think yes ^^ i think that's one of the only things that could be improved in the ui
I would like to get rid of nsTextBoxFrame and use nsTextFrame(Thebes) instead. It would save code, make things more consistent, and add considerable power, like the ability to use text-shadow.
The functionality that's currently only in nsTextBoxFrame is, as far as I know:
-- Ellipsization
-- Access-key underlining
Let me know if I missed something.
Access-key underlining would be fairly easy to add to nsTextFrame.
Ellipsization could be handled by text-overflow, which is somewhat hard but we should implement anyway --- except for the feature where we can put ellipses in the centre of the text. That's rarely used but we might be able to hack it in somehow or another.
Reporter | ||
Comment 9•17 years ago
|
||
(In reply to comment #8)
> except for the feature where we can put ellipses in
> the centre of the text. That's rarely used but we might be able to hack it in
> somehow or another.
As far as I know it's mostly used for URLs, like in the tab labels.
Reporter | ||
Updated•17 years ago
|
Summary: Implement CSS text-shadow for nsTextBoxFrame → CSS text-shadow not working for XUL elements using nsTextBoxFrame
Comment 10•17 years ago
|
||
Confirmed with Minefield Trunk Build 2008072211 (Win32). Setting text-shadow on something like a <menu> doesn't show any kind of shadow (As you would expect).
Adding myself to the CC list on this one, as I'm interested in getting this in.
Updated•16 years ago
|
Assignee: nobody → tellrob
Assignee | ||
Comment 11•16 years ago
|
||
I'm not entirely sure that this patch handles invalidation of the paint region correctly, but it draws text shadow and doesn't seem to have broken non-shadow text rendering.
Attachment #340870 -
Flags: review?
Whom did you mean to request review from?
Assignee | ||
Comment 13•16 years ago
|
||
Comment on attachment 340870 [details] [diff] [review]
v1.0
I meant to ask review from roc...not sure why bugzilla didn't prompt me to correct it.
Attachment #340870 -
Flags: review? → review?(roc)
+ if(textStyle->mTextShadow) {
if (
But I think that computing an exact paint rect here is a waste of time. If there's an mTextShadow, just assume that the text needs to be drawn and go ahead. In fact I think probably you should just remove the check that's already here; display list construction should do just fine at skipping painting of anything that doesn't intersect the dirty rect.
However, you *do* need to compute the exact paint rect so you can add it to the overflow area of this frame during layout.
+ DrawText(aRenderingContext, textRect, 0);
The last param should be NS_RGBA(0,0,0,0) I guess. But then it looks like if the shadow color is specified as rgba(0,0,0,0) that will magically change to some other color. I think you need an extra param to say whether there is a color override. Or else you could make the param nscolor* aOverrideColor and let it be nsnull if there is no override.
+ // Conjure an nsIRenderingContext from a gfxContext for DrawText
+ nsCOMPtr<nsIRenderingContext> renderingContext = nsnull;
+ nsIDeviceContext* devCtx = PresContext()->DeviceContext();
+ devCtx->CreateRenderingContextInstance(*getter_AddRefs(renderingContext));
+ if(!renderingContext) return;
if (
But this should all happen before aCtx->Save(), so we don't have unbalanced Save/Restore if this fails.
Need tests.
Comment 15•16 years ago
|
||
Comment on attachment 340870 [details] [diff] [review]
v1.0
>+ if(textStyle->mTextShadow) {
Nit: would be nice if you could be consistent with space between if and (
>+ // ie. it is painted first.
i.e. ?
>+ for (PRUint32 i = textStyle->mTextShadow->Length(); i > 0; --i) {
>+ PaintOneShadow(aRenderingContext.ThebesContext(),
>+ textRect,
>+ textStyle->mTextShadow->ShadowAt(i - 1),
>+ GetStyleColor()->mColor);
>+ }
>+ }
>+
>+ DrawText(aRenderingContext, textRect, 0);
Why not just pass GetStyleColor()->mColor here (i.e. make the third parameter aColor instead of aOverrideColor)?
Comment 16•16 years ago
|
||
Comment on attachment 340870 [details] [diff] [review]
v1.0
>+ nscoord blurRadius = shadow->mRadius;
>+
>+ tmpRect.MoveBy(nsPoint(xOffset, yOffset));
>+ tmpRect.Inflate(blurRadius, blurRadius);
>+
>+ paintRect.UnionRect(paintRect, tmpRect);
Nit: "Blank" lines containing spaces
Assignee | ||
Comment 17•16 years ago
|
||
Fixes style nits. Adds overflow computations to nsTextBoxFrame::DoLayout. Tests to follow in another patch.
Attachment #340870 -
Attachment is obsolete: true
Attachment #341186 -
Flags: review?(roc)
Attachment #340870 -
Flags: review?(roc)
Comment on attachment 341186 [details] [diff] [review]
v1.1
Looks good, but you have to promise to fix the RGBA(0,0,0,0) issue in a separate patch.
Attachment #341186 -
Flags: superreview+
Attachment #341186 -
Flags: review?(roc)
Attachment #341186 -
Flags: review+
Assignee | ||
Comment 19•16 years ago
|
||
These are just some of the existing text-shadow tests translated to xul labels
Assignee | ||
Comment 20•16 years ago
|
||
Pushed to mozilla-central:
(patch) http://hg.mozilla.org/mozilla-central/rev/fe9ee813563d
(tests) http://hg.mozilla.org/mozilla-central/rev/3605e1c34f25
rgba(0,0,0,0) issue still unaddressed.
Assignee | ||
Comment 21•16 years ago
|
||
Doesn't seem to have broken anything.
Attachment #341198 -
Flags: review?(roc)
Attachment #341198 -
Flags: superreview+
Attachment #341198 -
Flags: review?(roc)
Attachment #341198 -
Flags: review+
Assignee | ||
Comment 22•16 years ago
|
||
Pushed to mozilla-central:
http://hg.mozilla.org/mozilla-central/rev/6e39da3e3e20
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment 23•16 years ago
|
||
(In reply to comment #15)
> Why not just pass GetStyleColor()->mColor here (i.e. make the third parameter
> aColor instead of aOverrideColor)?
I see now, the text, underline and strikeout may have different colours.
Comment 24•16 years ago
|
||
Comment on attachment 341186 [details] [diff] [review]
v1.1
I see a lot of assertions with this patch, but unfortunately they've scrolled off my console.
Assignee | ||
Comment 25•16 years ago
|
||
I noticed the assertions too, but roc seemed to think that they were safe to ignore. Still, it is very annoying and I wonder if there's a way to remove them.
Comment 26•16 years ago
|
||
Comment on attachment 341186 [details] [diff] [review]
v1.1
>+ nsPoint origin(0,0);
>+ nsRect textRect = CalcTextRect(*aBoxLayoutState.GetRenderingContext(), origin);
>+ nsRect overflowRect(nsLayoutUtils::GetTextShadowRectsUnion(textRect, this));
>+ FinishAndStoreOverflow(&overflowRect, GetSize());
This seems to be what's causing the assertion - the overflowRect doesn't necessarily include the frame's size.
That's a good point, but it wasn't the source of the assertions Rob mentioned on IRC.
Anyway, we should fix that up, I goofed in my review. We just need to union overflowRect with nsRect(nsPoint(0,0), GetSize()).
Comment 28•16 years ago
|
||
I was already testing with this patch when you commented to the same effect.
Attachment #341363 -
Flags: superreview?(roc)
Attachment #341363 -
Flags: review?(roc)
Comment 29•16 years ago
|
||
By the way, on a slightly related topic I notice that many of the callers to GetTextShadowRectsUnion erroneously(?) union the parameter with the result because they want to update the parameter to include the union of the shadows. (I say erroneously because maybe they want to assign the result or possibly they would prefer their parameter to be inflated to include the shadow area.)
Attachment #341363 -
Flags: superreview?(roc)
Attachment #341363 -
Flags: superreview+
Attachment #341363 -
Flags: review?(roc)
Attachment #341363 -
Flags: review+
Comment 30•16 years ago
|
||
Comment on attachment 341363 [details] [diff] [review]
Union
Pushed changeset 6a0437ba9680 to mozilla-central.
Comment 31•16 years ago
|
||
I filed bug 459086 on the assertions this introduces.
You need to log in
before you can comment on or make changes to this bug.
Description
•