WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
54244
Convert the line box tree to floating point and eliminate font rounding hacks
https://bugs.webkit.org/show_bug.cgi?id=54244
Summary
Convert the line box tree to floating point and eliminate font rounding hacks
Dave Hyatt
Reported
2011-02-10 14:01:59 PST
Convert the line box tree to floating point and eliminate font rounding hacks. This fixes numerous issues in environments that don't return integral values for widths of glyphs.
Attachments
Patch (don't really review, just catching build errors)
(125.88 KB, patch)
2011-02-10 14:02 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(125.93 KB, patch)
2011-02-10 15:06 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(128.80 KB, patch)
2011-02-10 15:34 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(146.52 KB, patch)
2011-02-11 11:30 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(151.88 KB, patch)
2011-02-11 12:40 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(158.91 KB, patch)
2011-02-11 14:40 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(160.99 KB, patch)
2011-02-11 15:05 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(161.67 KB, patch)
2011-02-11 15:29 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(162.15 KB, patch)
2011-02-13 17:14 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(172.53 KB, patch)
2011-02-14 10:53 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Patch that applies (ignore for review, just testing builds)
(177.08 KB, patch)
2011-02-14 11:52 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Ready for review!
(195.50 KB, patch)
2011-02-14 13:19 PST
,
Dave Hyatt
mitz: review-
Details
Formatted Diff
Diff
Sample of layout tests changes
(1.93 MB, patch)
2011-02-14 13:20 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Address Dan's comments.
(198.16 KB, patch)
2011-02-15 11:01 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Update Windows since someone added new uses of string truncation.
(201.02 KB, patch)
2011-02-15 12:20 PST
,
Dave Hyatt
no flags
Details
Formatted Diff
Diff
Update for Windows again since code got added to WebKit2
(201.05 KB, patch)
2011-02-15 15:16 PST
,
Dave Hyatt
mitz: review+
Details
Formatted Diff
Diff
Show Obsolete
(13)
View All
Add attachment
proposed patch, testcase, etc.
Dave Hyatt
Comment 1
2011-02-10 14:02:53 PST
Created
attachment 82044
[details]
Patch (don't really review, just catching build errors)
Dave Hyatt
Comment 2
2011-02-10 15:06:05 PST
Created
attachment 82058
[details]
Patch that applies (ignore for review, just testing builds)
WebKit Review Bot
Comment 3
2011-02-10 15:09:31 PST
Attachment 82058
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/WebCore.exp.in', u'Source/W..." exit_code: 1 Source/WebCore/rendering/InlineTextBox.cpp:938: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/InlineTextBox.cpp:939: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/InlineTextBox.cpp:1109: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/InlineTextBox.cpp:1110: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/HitTestResult.h:114: The parameter name "rect" adds no information, so it should be removed. [readability/parameter_name] [5] Source/WebCore/platform/graphics/Font.h:97: The parameter name "glyphOverflow" adds no information, so it should be removed. [readability/parameter_name] [5] Source/WebCore/platform/graphics/Font.h:98: The parameter name "run" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 7 in 44 files If any of these errors are false positives, please file a bug against check-webkit-style.
Dave Hyatt
Comment 4
2011-02-10 15:34:05 PST
Created
attachment 82062
[details]
Patch that applies (ignore for review, just testing builds)
WebKit Review Bot
Comment 5
2011-02-10 15:36:58 PST
Attachment 82062
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/WebCore.exp.in', u'Source/W..." exit_code: 1 Source/WebCore/rendering/InlineTextBox.cpp:938: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/InlineTextBox.cpp:939: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/InlineTextBox.cpp:1109: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/InlineTextBox.cpp:1110: One space before end of line comments [whitespace/comments] [5] Source/WebCore/rendering/HitTestResult.h:114: The parameter name "rect" adds no information, so it should be removed. [readability/parameter_name] [5] Source/WebCore/platform/graphics/Font.h:97: The parameter name "glyphOverflow" adds no information, so it should be removed. [readability/parameter_name] [5] Source/WebCore/platform/graphics/Font.h:98: The parameter name "run" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 7 in 45 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 6
2011-02-10 15:37:15 PST
Attachment 82058
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/7884413
WebKit Review Bot
Comment 7
2011-02-10 15:54:04 PST
Attachment 82062
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/7869499
Build Bot
Comment 8
2011-02-10 16:10:28 PST
Attachment 82058
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7869503
Build Bot
Comment 9
2011-02-10 16:31:55 PST
Attachment 82062
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7869507
Early Warning System Bot
Comment 10
2011-02-10 19:07:39 PST
Attachment 82062
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/7884461
WebKit Review Bot
Comment 11
2011-02-10 21:57:11 PST
Attachment 82062
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/7870574
mitz
Comment 12
2011-02-10 22:07:34 PST
<
rdar://problem/8891123
>
Collabora GTK+ EWS bot
Comment 13
2011-02-10 22:51:04 PST
Attachment 82062
[details]
did not build on gtk: Build output:
http://queues.webkit.org/results/7869566
Dave Hyatt
Comment 14
2011-02-11 11:30:01 PST
Created
attachment 82153
[details]
Patch that applies (ignore for review, just testing builds)
WebKit Review Bot
Comment 15
2011-02-11 11:44:14 PST
Attachment 82153
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/7900003
Dave Hyatt
Comment 16
2011-02-11 12:40:19 PST
Created
attachment 82161
[details]
Patch that applies (ignore for review, just testing builds)
Build Bot
Comment 17
2011-02-11 12:44:54 PST
Attachment 82153
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7893014
Early Warning System Bot
Comment 18
2011-02-11 12:47:10 PST
Attachment 82153
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/7870746
WebKit Review Bot
Comment 19
2011-02-11 12:52:51 PST
Attachment 82161
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/7870748
Collabora GTK+ EWS bot
Comment 20
2011-02-11 13:08:21 PST
Attachment 82161
[details]
did not build on gtk: Build output:
http://queues.webkit.org/results/7870754
Build Bot
Comment 21
2011-02-11 13:23:10 PST
Attachment 82161
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7869739
Early Warning System Bot
Comment 22
2011-02-11 13:37:14 PST
Attachment 82161
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/7867750
Dave Hyatt
Comment 23
2011-02-11 14:40:50 PST
Created
attachment 82181
[details]
Patch that applies (ignore for review, just testing builds)
WebKit Review Bot
Comment 24
2011-02-11 14:55:35 PST
Attachment 82181
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/7867766
Dave Hyatt
Comment 25
2011-02-11 15:05:13 PST
Created
attachment 82187
[details]
Patch that applies (ignore for review, just testing builds)
Collabora GTK+ EWS bot
Comment 26
2011-02-11 15:23:49 PST
Attachment 82187
[details]
did not build on gtk: Build output:
http://queues.webkit.org/results/7867771
Dave Hyatt
Comment 27
2011-02-11 15:29:27 PST
Created
attachment 82194
[details]
Patch that applies (ignore for review, just testing builds)
Build Bot
Comment 28
2011-02-11 16:38:50 PST
Attachment 82194
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7884715
Dave Hyatt
Comment 29
2011-02-13 17:14:06 PST
Created
attachment 82282
[details]
Patch that applies (ignore for review, just testing builds)
Dave Hyatt
Comment 30
2011-02-14 10:53:06 PST
Created
attachment 82339
[details]
Patch that applies (ignore for review, just testing builds) In pretty good shape now I think. Fixed SVG dumping in this patch to not dump floats and also fixed a bug with vertical alignment created by some issues using the dumb PositionTop and PositionBottom constants. I just yanked those since they aren't necessary.
Dave Hyatt
Comment 31
2011-02-14 11:52:49 PST
Created
attachment 82347
[details]
Patch that applies (ignore for review, just testing builds) Fix offsetForPosition, positionForOffset to be float-based to avoid rounding errors. Patch localCaretRect to operate on floats to avoid truncation mistakes.
Dave Hyatt
Comment 32
2011-02-14 13:19:19 PST
Created
attachment 82356
[details]
Ready for review! Layout test changes too massive to include in the patch. I'll post a followup attachment that provides a sample of how they're changing.
Dave Hyatt
Comment 33
2011-02-14 13:20:18 PST
Created
attachment 82357
[details]
Sample of layout tests changes
Build Bot
Comment 34
2011-02-14 13:51:36 PST
Attachment 82347
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7909694
Build Bot
Comment 35
2011-02-14 14:54:54 PST
Attachment 82356
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7908713
mitz
Comment 36
2011-02-14 15:23:12 PST
Comment on
attachment 82356
[details]
Ready for review! View in context:
https://bugs.webkit.org/attachment.cgi?id=82356&action=review
r- because of EWS build failures. Some minor comments inside.
> Source/WebCore/ChangeLog:8 > + hacks from the Font code and makes sure all Font APIS involving width measurement and width offsets use floats.
Typo: APIS
> Source/WebCore/platform/graphics/WidthIterator.cpp:173 > + float expansion = previousExpansion - m_expansion;
Don’t need this anymore, can just use m_expansionPerOpportunity. You don’t need previousExpansion at all I think.
> Source/WebCore/platform/graphics/mac/ComplexTextController.cpp:480 > + float expansion = previousExpansion - m_expansion;
Here too you can get rid of expansion and previousExpansion.
> Source/WebCore/platform/graphics/win/UniscribeController.cpp:-323 > - // Match AppKit's rules for the integer vs. non-integer rendering modes. > - float roundedAdvance = roundf(advance); > - if (!m_font.isPrinterFont() && !fontData->isSystemFont()) { > - advance = roundedAdvance; > - offsetX = roundf(offsetX); > - offsetY = roundf(offsetY); > - }
Don’t we need this still?
> Source/WebCore/platform/graphics/win/UniscribeController.cpp:319 > float previousPadding = m_padding; > m_padding -= m_padPerSpace; > - advance += roundf(previousPadding) - roundf(m_padding); > + advance += previousPadding - m_padding;
Again, no need for previousPadding anymore. Just add m_padPerSpace to advance and subtract m_padPerSpace from m_padding.
> Source/WebCore/rendering/InlineBox.cpp:109 > +
Space!
> Source/WebCore/rendering/InlineBox.h:312 > +
Spaces!
> Source/WebCore/rendering/RenderBlockLineLayout.cpp:397 > + trailingSpaceRun->m_box->setLogicalWidth(max(0.f, trailingSpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth));
Another way to write this is max<float>(0, …)
> Source/WebCore/rendering/RenderText.cpp:509 > + // Go ahead and round left to snap it to the nearest pixel.
:)
> Source/WebCore/rendering/RenderText.cpp:705 > + const_cast<RenderText*>(this)->computePreferredLogicalWidths(0.f);
Is this .f needed?
> Source/WebCore/rendering/RenderText.cpp:713 > + const_cast<RenderText*>(this)->computePreferredLogicalWidths(0.f);
Ditto.
> Source/WebCore/rendering/RenderTreeAsText.cpp:474 > + // to detect any changes caused by the conversion to floating point. :(
The best thing you can do is generate pixel results for all tests on your machine w/o the patch, then apply the patch and run-webkit-tests --pixel and see if there are any significant differences.
Dominic Cooney
Comment 37
2011-02-14 21:55:27 PST
This patch will also fix
bug 14956
, at least for LTR content.
Dave Hyatt
Comment 38
2011-02-15 11:00:23 PST
(In reply to
comment #37
)
> This patch will also fix
bug 14956
, at least for LTR content.
Not sure it will. I'm rounding to pixels when painting borders and backgrounds, so you'll probably have to test it to see if it really fixes that issue.
Dave Hyatt
Comment 39
2011-02-15 11:01:32 PST
Created
attachment 82488
[details]
Address Dan's comments.
Nikolas Zimmermann
Comment 40
2011-02-15 11:51:07 PST
Comment on
attachment 82488
[details]
Address Dan's comments. View in context:
https://bugs.webkit.org/attachment.cgi?id=82488&action=review
Great, looking forward to this patch! I have another patch in the works, eliminating SVG pixel test diffs between 10.6.6 32bit/64bit machines, that will probably change enclosingIntRect, we might want to discuss that, to avoid several rebaselines...
> Source/WebCore/rendering/InlineBox.h:244 > + int pixelSnappedLogicalLeft() const { return logicalLeft(); } > + int pixelSnappedLogicalRight() const { return ceilf(logicalRight()); }
Hm, you want to cast to int, no? and isn't a ceilf missing in the pixelSnappedLogicalLeft() function?
Build Bot
Comment 41
2011-02-15 11:58:53 PST
Attachment 82488
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7912899
Nikolas Zimmermann
Comment 42
2011-02-15 12:03:04 PST
(In reply to
comment #40
)
> (From update of
attachment 82488
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=82488&action=review
> > Great, looking forward to this patch! I have another patch in the works, eliminating SVG pixel test diffs between 10.6.6 32bit/64bit machines, that will probably change enclosingIntRect, we might want to discuss that, to avoid several rebaselines... > > > Source/WebCore/rendering/InlineBox.h:244 > > + int pixelSnappedLogicalLeft() const { return logicalLeft(); } > > + int pixelSnappedLogicalRight() const { return ceilf(logicalRight()); }
I wonder wheter we want to expose FloatRect's safeFloatToInt method here?
Dave Hyatt
Comment 43
2011-02-15 12:15:05 PST
(In reply to
comment #40
)
> (From update of
attachment 82488
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=82488&action=review
> > Great, looking forward to this patch! I have another patch in the works, eliminating SVG pixel test diffs between 10.6.6 32bit/64bit machines, that will probably change enclosingIntRect, we might want to discuss that, to avoid several rebaselines... > > > Source/WebCore/rendering/InlineBox.h:244 > > + int pixelSnappedLogicalLeft() const { return logicalLeft(); } > > + int pixelSnappedLogicalRight() const { return ceilf(logicalRight()); } > > Hm, you want to cast to int, no? and isn't a ceilf missing in the pixelSnappedLogicalLeft() function?
I should perhaps rename these methods. They're about returning the enclosing left and right (same as what enclosingIntRect would do to a rectangle that included these as the left and right sides). "enclosingLogicalLeft" sounded dumb though when I tried it. :) Basically the left side is floored and the right side is ceilinged so that a bounding box or overflow will enclose the whole run.
Dave Hyatt
Comment 44
2011-02-15 12:20:39 PST
Created
attachment 82502
[details]
Update Windows since someone added new uses of string truncation.
Eric Seidel (no email)
Comment 45
2011-02-15 13:02:54 PST
Curious. do you expect this to be a noticeable effect on memory usage for memory-constrained ports?
Dave Hyatt
Comment 46
2011-02-15 13:08:31 PST
(In reply to
comment #45
)
> Curious. do you expect this to be a noticeable effect on memory usage for memory-constrained ports?
Shouldn't be... it's just int -> float not int -> double.
Build Bot
Comment 47
2011-02-15 14:40:11 PST
Attachment 82502
[details]
did not build on win: Build output:
http://queues.webkit.org/results/7919033
Eric Seidel (no email)
Comment 48
2011-02-15 14:56:51 PST
(In reply to
comment #46
)
> (In reply to
comment #45
) > > Curious. do you expect this to be a noticeable effect on memory usage for memory-constrained ports? > > Shouldn't be... it's just int -> float not int -> double.
Ah yes, my mistake.
Dave Hyatt
Comment 49
2011-02-15 15:16:32 PST
Created
attachment 82533
[details]
Update for Windows again since code got added to WebKit2
mitz
Comment 50
2011-02-15 15:16:32 PST
Comment on
attachment 82502
[details]
Update Windows since someone added new uses of string truncation. r+ if you resolve the Windows build issue (or if there is no issue)
Dave Hyatt
Comment 51
2011-02-17 11:22:41 PST
Landed in
r78846
.
WebKit Review Bot
Comment 52
2011-02-17 11:32:21 PST
http://trac.webkit.org/changeset/78846
might have broken EFL Linux Release (Build)
Marc-Antoine Ruel
Comment 53
2011-04-26 13:07:12 PDT
Comment on
attachment 82533
[details]
Update for Windows again since code got added to WebKit2 View in context:
https://bugs.webkit.org/attachment.cgi?id=82533&action=review
> Source/WebCore/rendering/InlineBox.h:243 > + int pixelSnappedLogicalLeft() const { return logicalLeft(); }
This code generates: warning C4244: 'return' : conversion from 'float' to 'int', possible loss of data It'd be better to do return static_cast<int>(logicalLeft()); to be clear about the intent. There are warnings at line 245, 246, 249, 254, 256 and 266 (line numbers are slightly offset, I'm at
r84935
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug