New issue
Advanced search Search tips

Issue 650120 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocking:
issue 248597
issue 630365
issue 671055



Sign in to add a comment

Add multiline text selection support to gfx::RenderTextHarfBuzz

Project Member Reported by karandeepb@chromium.org, Sep 26 2016

Issue description

RenderText methods FindCursorPosition and GetCursorBounds don't currently support multiline. These should be updated to support multiline. 

 
Blocking: 630365
Status: Available (was: Assigned)
Owner: ellyjo...@chromium.org
Status: Assigned (was: Available)
Cc: ellyjo...@chromium.org
Owner: karandeepb@chromium.org
karandeepb@: I'm giving this to you, as part of  issue 630365 ; if you don't want to work on that, please hand it back to me.
Summary: Add multiline text selection support to gfx::RenderTextHarfBuzz (was: Add multiline text selection support to gfx::RenderText)
Blocking: 248597
Blocking: 671055
Project Member

Comment 8 by bugdroid1@chromium.org, Jan 4 2017

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

commit 4e4ca175171eb6c46603799904a624e6797773e4
Author: karandeepb <karandeepb@chromium.org>
Date: Wed Jan 04 02:12:24 2017

RenderTextHarfBuzz: Add support for multi line text selection.

This CL-
  - Adds support for multi-line text selection to RenderTextHarfBuzz. To do this
    RenderTextHarfBuzz::FindCursorPosition and
    RenderTextHarfBuzz::GetSubstringBounds are reimplemented.
  - RenderTextHarfBuzz::FindCursorPosition now returns valid grapheme boundaries
    hence fixing  issue 673986 .
  - RenderTextHarfBuzz::GetSubstringBounds did already support multiline but the
    implementation was flawed. It relied on the text space bounds intersection
    computed from LineSegment's x_range paramater and from TextRunHarfBuzz.
    However these were not in sync if some newline segments were popped or if
    some text was truncated.
  - Enables multi-line text selection for views::Labels.
  - Corrects the behavior for RTL when mouse is dragged above/below the text
    bounds on MacViews.
  - Adds lots of tests.

BUG= 650120 ,  630365 ,  600166 ,  673986 
TEST= Open views_examples_with_content_exe. Select Labels from the dropdown.
Enter a large string in the "Content" textfield. Enable the Multiline and Text
Selection checkboxes. Ensure text selection works correctly on the Label.

Review-Url: https://codereview.chromium.org/2541313002
Cr-Commit-Position: refs/heads/master@{#441290}

[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/gfx/render_text.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/gfx/render_text.h
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/gfx/render_text_harfbuzz.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/gfx/render_text_harfbuzz.h
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/gfx/render_text_unittest.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/controls/label.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/controls/label.h
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/controls/label_unittest.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/controls/textfield/textfield_unittest.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/examples/label_example.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/examples/label_example.h
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/selection_controller.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/style/platform_style.cc
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/style/platform_style.h
[modify] https://crrev.com/4e4ca175171eb6c46603799904a624e6797773e4/ui/views/style/platform_style_mac.mm

Status: Fixed (was: Assigned)
FindCursorPosition and GetSubstringBounds do support multiline now. GetCursorBounds still doesn't support multiline, but there's no use-case for it currently.
Test RenderTextHarfBuzzTest.GetSubstringBoundsMultiline/HarfBuzz is failing on Ubuntu 16.04

Value of: GetSelectionBoundsUnion()
  Actual: 0,491 3x17
Expected: expected_line_bounds
Which is: 0,491 3x18


I think this is caused by the following:

- for calculating expected_line_bounds in test, std::ceil is used for both, width and height

https://cs.chromium.org/chromium/src/ui/gfx/render_text_unittest.cc?l=4253

const Size line_size(std::ceil(line.size.width()),
                         std::ceil(line.size.height()));

dbg info:
line.size.height(): 17,760000, ceil(line.size.height()): 18,000000


- but in RenderTextHarfBuzz::GetSubstringBounds() function, std::ceil is used only for width

https://cs.chromium.org/chromium/src/ui/gfx/render_text_harfbuzz.cc?l=1111

int end_x = std::ceil(x + width);
int start_x = std::ceil(x);
gfx::Rect rect(start_x, 0, end_x - start_x, line.size.height());

dbg info:
line.size.height() : 17,760000
rect.height(): 17



Seems the bots din't catch it. Thanks for the info, I'll file a bug and fix it.

Sign in to add a comment