Bug 101879 - text-overflow:ellipsis is not applied when the block contains nested blocks
Summary: text-overflow:ellipsis is not applied when the block contains nested blocks
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Bem Jones-Bey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-11 18:35 PST by Philippe Wittenbergh
Modified: 2013-03-13 02:09 PDT (History)
8 users (show)

See Also:


Attachments
test case from the spec (332 bytes, text/html)
2012-11-11 18:38 PST, Philippe Wittenbergh
no flags Details
Patch (5.56 KB, patch)
2013-02-13 18:03 PST, Bem Jones-Bey
no flags Details | Formatted Diff | Diff
Patch (5.70 KB, patch)
2013-02-21 09:40 PST, Bem Jones-Bey
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Wittenbergh 2012-11-11 18:35:46 PST
WebKit falls back to text-overflow: clip (the default). Firefox and Opera handle this correctly.

Example: 4th example in the spec;
http://www.w3.org/TR/css3-ui/#text-overflow
http://dev.w3.org/csswg/css3-ui/#text-overflow

Sample markup
<div style="text-overflow:ellipsis; overflow:hidden"> NESTED <p>PARAGRAPH</p> WON'T ELLIPSE. </div>
Comment 1 Philippe Wittenbergh 2012-11-11 18:38:04 PST
Created attachment 173534 [details]
test case from the spec

Expected results: an ellipsis after the words:'nested', 'won't and 'ellipse'.
Actual results: no ellipsis is shown.
Comment 2 Bem Jones-Bey 2013-02-13 18:03:35 PST
Created attachment 188244 [details]
Patch

Fix for bug
Comment 3 Eric Seidel (no email) 2013-02-14 09:41:04 PST
Comment on attachment 188244 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=188244&action=review

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:1828
>      // FIXME: CSS3 says that descendants that are clipped must also know how to truncate.  This is insanely
>      // difficult to figure out (especially in the middle of doing layout), and is really an esoteric pile of nonsense
>      // anyway, so we won't worry about following the draft here.

It looks like you're partially implementing this FIXME.  Do we care about the multiple-nested anonymous block case?

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:1830
> +    bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip())
> +        || (isAnonymousBlock() && parent() && parent()->isRenderBlock() && parent()->style()->textOverflow() && parent()->hasOverflowClip());

Since textOverflow is the uncommon case, this will always hit the second part of the branch, but will exit quickly with the isAnonymousBlock check.  I dno't think this code is super-hot, but it's on a common path.
Comment 4 Bem Jones-Bey 2013-02-14 09:49:36 PST
(In reply to comment #3)
> (From update of attachment 188244 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=188244&action=review
> 
> > Source/WebCore/rendering/RenderBlockLineLayout.cpp:1828
> >      // FIXME: CSS3 says that descendants that are clipped must also know how to truncate.  This is insanely
> >      // difficult to figure out (especially in the middle of doing layout), and is really an esoteric pile of nonsense
> >      // anyway, so we won't worry about following the draft here.
> 
> It looks like you're partially implementing this FIXME.  Do we care about the multiple-nested anonymous block case?

Can you explain to me when this case happens (or link to the spec that describes this behavior)?

It is possible that it makes the most sense to just update the FIXME saying that it doesn't work in the multiple nested anonymous block case and file a bug for that.

> > Source/WebCore/rendering/RenderBlockLineLayout.cpp:1830
> > +    bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip())
> > +        || (isAnonymousBlock() && parent() && parent()->isRenderBlock() && parent()->style()->textOverflow() && parent()->hasOverflowClip());
> 
> Since textOverflow is the uncommon case, this will always hit the second part of the branch, but will exit quickly with the isAnonymousBlock check.  I dno't think this code is super-hot, but it's on a common path.

I'm not sure I understand what needs to be changed here. Are you suggesting that I flip around the order of the conditions in the or expression?
Comment 5 Bem Jones-Bey 2013-02-21 09:40:38 PST
Created attachment 189547 [details]
Patch

Updated FIXME comment to reflect that this change fixes part of what it is referring to.
Comment 6 Eric Seidel (no email) 2013-02-22 10:47:38 PST
Comment on attachment 189547 [details]
Patch

This seems reasonable to me.  Mitz and Hyatt are CC'd and can scream if they disagree.
Comment 7 WebKit Review Bot 2013-02-22 11:00:05 PST
Comment on attachment 189547 [details]
Patch

Clearing flags on attachment: 189547

Committed r143754: <http://trac.webkit.org/changeset/143754>
Comment 8 WebKit Review Bot 2013-02-22 11:00:09 PST
All reviewed patches have been landed.  Closing bug.