Chromium Code Reviews
DescriptionFix bug causing TextIterator to duplicate leading spaces
I ran into a TextIterator bug causing spaces at the beginning of a line occuring
immediately after another element to be duplicated. If you're iterating over
ranges, you get a range containing just the space, and then a range containing
the space together with the rest of the line, and if you call plainText() on a
range to get the text, the space occurs twice in the output.
The bug occurs because the line break gets output as one space, and then the
actual space at the beginning of the line is supposed to be skipped over. The
method restoreCollapsedLeadingSpace() is called, which incorrectly causes
TextIterator to output the real space in addition to the space from the line
break.
It appears this method was originally added to fix a text copying bug. Text
copying does use the plainText() function, but does not exhibit the bug because
it sets the emitsImageAltText behavior, and this method immediately returns if
that flag is set.
It appears that the correct fix is to remove this method. It may have been
necessary at some point but now it just appears to be introducing this bug. I
took out this method and re-ran all the webkit_unit_tests and blink layout
tests, and the only test that failed was one with a TODO saying to fix the
behavior. So my change actually fixes another bug there.
Additionally, I think the change in https://codereview.chromium.org/2723913002
is just a workaround for this bug and is no longer necessary, so I'm reverting
it. I don't understand it super well though so I could be wrong.
BUG=697654
Review-Url: https://codereview.chromium.org/2746153008
Cr-Commit-Position: refs/heads/master@{#458365}
Committed: https://chromium.googlesource.com/chromium/src/+/477e319330d3ad4eccfb32fbd5c7d28a75c6d7e3
Patch Set 1 #Patch Set 2 : also remove method definition from header #
Total comments: 2
Patch Set 3 : Remove obsolete comment #
Dependent Patchsets: Messages
Total messages: 25 (19 generated)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||