Bug 108633 - No caret on empty contenteditable element with negative text-indent
Summary: No caret on empty contenteditable element with negative text-indent
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Robert Hogan
URL: http://jsbin.com/etatey/1/quiet
Keywords: HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2013-02-01 06:57 PST by Jake Archibald
Modified: 2013-09-11 13:05 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.62 KB, patch)
2013-02-18 14:16 PST, Robert Hogan
no flags Details | Formatted Diff | Diff
Patch (5.49 KB, patch)
2013-02-19 11:47 PST, Robert Hogan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jake Archibald 2013-02-01 06:57:42 PST
Click on the green box, the caret may flash once in the correct place, but doesn't appear after that.

Once you start typing, the text appears, as does the caret.

Firefox & Opera show a caret, although in the wrong place.
Comment 1 Alexey Proskuryakov 2013-02-01 10:47:19 PST
See also: bug 20242, bug 58975, bug 108053. We probably have a few duplicates between these, and other bugs that I didn't find now.
Comment 2 Radar WebKit Bug Importer 2013-02-01 10:51:41 PST
<rdar://problem/13134969>
Comment 3 Robert Hogan 2013-02-18 14:16:15 PST
Created attachment 188942 [details]
Patch
Comment 4 WebKit Review Bot 2013-02-18 14:19:02 PST
Attachment 188942 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent-expected.png', u'LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent-expected.txt', u'LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent.html', u'Source/WebCore/ChangeLog', u'Source/WebCore/rendering/RenderBlock.cpp']" exit_code: 1
LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent-expected.png:0:  Have to enable auto props in the subversion config file (/home/alancutter/.subversion/config "enable-auto-props = yes"). Have to set the svn:mime-type in the subversion config file (/home/alancutter/.subversion/config "*.png = svn:mime-type=image/png").  [image/png] [5]
Total errors found: 1 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Ryosuke Niwa 2013-02-18 14:57:57 PST
Comment on attachment 188942 [details]
Patch

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

> Source/WebCore/rendering/RenderBlock.cpp:1685
> +    bool caretBrowsing = frame()->settings() && frame()->settings()->caretBrowsingEnabled();
> +    if (textIndentOffset() < 0 && (caretBrowsing || (node() && node()->rendererIsEditable()))) {

Why do we want to check node()->rendererIsEditable() when caret browsing is disabled? rendererIsEditable() is a very expensive function, I'd rather not call it here.
Comment 6 Robert Hogan 2013-02-19 11:26:07 PST
(In reply to comment #5)
> (From update of attachment 188942 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=188942&action=review
> 
> > Source/WebCore/rendering/RenderBlock.cpp:1685
> > +    bool caretBrowsing = frame()->settings() && frame()->settings()->caretBrowsingEnabled();
> > +    if (textIndentOffset() < 0 && (caretBrowsing || (node() && node()->rendererIsEditable()))) {
> 
> Why do we want to check node()->rendererIsEditable() when caret browsing is disabled? rendererIsEditable() is a very expensive function, I'd rather not call it here.

rendererIsEditable() only gets expensive if you need to climb the tree looking for a HTML element. I don't think that will happen very often here, especially where a negative text indent has been defined. Does that sound reasonable?

It might be cheaper overall to just add the overflow for any element that has the text indent rather than ones that will want to display a caret at some point. But I don't think rendererIsEditable() ever gets expensive here.

I need to remove the multiple calls to textIndentOffset().
Comment 7 Robert Hogan 2013-02-19 11:47:23 PST
Created attachment 189126 [details]
Patch
Comment 8 WebKit Review Bot 2013-02-19 11:51:01 PST
Attachment 189126 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent-expected.png', u'LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent-expected.txt', u'LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent.html', u'Source/WebCore/ChangeLog', u'Source/WebCore/rendering/RenderBlock.cpp']" exit_code: 1
LayoutTests/fast/repaint/paint-caret-in-div-with-negative-indent-expected.png:0:  Have to enable auto props in the subversion config file (/home/alancutter/.subversion/config "enable-auto-props = yes"). Have to set the svn:mime-type in the subversion config file (/home/alancutter/.subversion/config "*.png = svn:mime-type=image/png").  [image/png] [5]
Total errors found: 1 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 WebKit Review Bot 2013-02-20 11:52:45 PST
Comment on attachment 189126 [details]
Patch

Clearing flags on attachment: 189126

Committed r143483: <http://trac.webkit.org/changeset/143483>
Comment 10 WebKit Review Bot 2013-02-20 11:52:49 PST
All reviewed patches have been landed.  Closing bug.
Comment 11 Simon Fraser (smfr) 2013-09-10 17:58:00 PDT
This caused a bad repaint regression, when authors combine negative text-indent with overflow:hidden (which is what we recommend they do): bug 121137.
Comment 12 Alexey Proskuryakov 2013-09-11 13:05:40 PDT
This bug still appears fixed after rollout (maybe <http://trac.webkit.org/changeset/143313> also took care of the same?)

Please comment and possibly open a new bug if the next nightly doesn't quite work for you in this regard.