New issue
Advanced search Search tips

Issue 789508 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Paint selection on newlines of contenteditable elements

Project Member Reported by r...@igalia.com, Nov 29 2017

Issue description


There's currently some inconsistency between how newlines selection
is painted in textareas vs contenteditable as you can see
in the attached example and image.

In textareas the newline has an extra whitespace selected,
so you know that you've selected the new line.
Also when yo

The primary use case for this is to be able to remove a bunch of empty lines
in a contenteditable element by selecting them.
Right now you cannot see how many you've selected in order to remove them,
however that's possible in a textarea.

I've been checking the code and actually the newlines are already adding
that extra whitespace for selection.
But the following condition in InlineFlowBoxPainter::Paint():
    if (!paint_info.GetCullRect().IntersectsCullRect(overflow_rect))
      return;
Is always true, so the painting code for the newline in InlineTextBoxPainter::Paint()
isn't called, thus the extra whitespace for selection isn't painted.

I've a experimental patch that modifies that method, so the VisualOverflowRect
of the newline is extended to include the extra whitespace.
This cause that the condition above isn't always true for newlines
and then the extra whitespace for selection is actually painted.
You can check it in the following CL:
https://chromium-review.googlesource.com/c/chromium/src/+/793036

 
selection-newlines-textarea-vs-contenteditable.html
595 bytes View Download
selection-newlines-textarea-vs-contenteditable.png
16.0 KB View Download

Comment 1 by r...@igalia.com, Dec 4 2017

Owner: r...@igalia.com
Status: Started (was: Untriaged)

I've just discovered that this is working already for vertical writing modes.

I believe this works just by chance, as the overflow_rect
in InlineFlowBoxPainter::Paint() is not empty for vertical newlines (17x1),
while for horizontal newlines it's empty (0x18).

selection-rtl-writing-modes.html
1.7 KB View Download
selection-rtl-writing-modes.html.png
28.4 KB View Download
Project Member

Comment 2 by bugdroid1@chromium.org, Dec 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/488172cd66cee9c0b9f4931011d9b9a0a2fc8128

commit 488172cd66cee9c0b9f4931011d9b9a0a2fc8128
Author: Manuel Rego Casasnovas <rego@igalia.com>
Date: Tue Dec 05 22:33:59 2017

Paint selection on newlines of contenteditable elements

This patch makes that when you select empty lines
on a contenteditable element, the selection is painted
similar to what happens on a textarea.

There are 2 changes to make this happen.
On one side, newlines are no longer marked as
InlineBox::KnownToHaveNoOverflow().
On the other side, InlineFlowBox::ComputeOverflow() has been modified
in order to extend the overflow rect for newlines.

With this the behavior of selection in contenteditable elements
and textareas is more consistent.

BUG= 789508 

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I55f33e8c688a92e760e3d359c2cf54deacd005af
Reviewed-on: https://chromium-review.googlesource.com/793036
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: yosin (OOO Dec 11 to Jan 8) <yosin@chromium.org>
Commit-Queue: Manuel Rego Casasnovas <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#521863}
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/editing/selection/selection-linebreaks-rtl-writing-modes.html
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/linux/editing/selection/selection-linebreaks-rtl-writing-modes-expected.png
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/linux/editing/selection/selection-linebreaks-rtl-writing-modes-expected.txt
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/linux/editing/style/5228141-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/linux/fast/text/selection/selection-hard-linebreak-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/text/selection/selection-hard-linebreak-expected.png
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/mac/editing/selection/selection-linebreaks-rtl-writing-modes-expected.png
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/mac/editing/selection/selection-linebreaks-rtl-writing-modes-expected.txt
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/mac/editing/style/5228141-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/mac/fast/text/selection/selection-hard-linebreak-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/mac/paint/invalidation/selection/selection-change-in-iframe-with-relative-parent-expected.png
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/win/editing/selection/selection-linebreaks-rtl-writing-modes-expected.png
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/win/editing/selection/selection-linebreaks-rtl-writing-modes-expected.txt
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/win/editing/style/5228141-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/win/fast/text/selection/selection-hard-linebreak-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/win/paint/invalidation/selection/selection-change-in-iframe-with-relative-parent-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/platform/win7/fast/text/selection/selection-hard-linebreak-expected.png
[add] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/selection/selection-change-in-iframe-with-relative-parent-expected.png
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/selection/selection-change-in-iframe-with-relative-parent-expected.txt
[modify] https://crrev.com/488172cd66cee9c0b9f4931011d9b9a0a2fc8128/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp

Comment 3 by r...@igalia.com, Dec 5 2017

Status: Fixed (was: Started)

Sign in to add a comment