RESOLVED FIXED 51566
TextMetrics::width is an integer, but the member is a float
https://bugs.webkit.org/show_bug.cgi?id=51566
Summary TextMetrics::width is an integer, but the member is a float
Evan Martin
Reported 2010-12-23 15:20:43 PST
In WebCore/html/TextMetrics.idl it says: readonly attribute float width; in .../TextMetrics.h: float m_width; But there's a getter with this confusing comment: // FIXME: Is coercing to an integer value intentional? If so, there should be a static_cast<unsigned>() here. unsigned width() const { return m_width; } From my greps around, it appears this getter is unused, but I unsure how the idl interacts with this (perhaps the idl generates code that calls width().)
Attachments
Patch (1.45 KB, patch)
2010-12-23 16:43 PST, Evan Martin
no flags
Evan Martin
Comment 1 2010-12-23 15:26:15 PST
CC hyatt, original author of the code (correct bug this time)
Evan Martin
Comment 2 2010-12-23 15:28:41 PST
in LayoutTests/fast/canvas/canvas-text-baseline.html if I dump out all the widths found by ctx.measureText(text).width they are always integers. Not sure if it's intentional (or perhaps in Chrome we always have integer width fonts for other reasons)
Evan Martin
Comment 3 2010-12-23 16:26:23 PST
I tried changing it to a float and still got integers out. Spec says the width should be "CSS pixels", which I think can be floating point. I'll upload a patch and see what y'all think. http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-measuretext
Evan Martin
Comment 4 2010-12-23 16:43:13 PST
Evan Martin
Comment 5 2010-12-23 16:44:34 PST
I tried modifying the test to use text of width 32.1 pixels, but even after this change the "width" field came out as an integer. Again, this could be due to some other code in Chrome rounding text widths.
WebKit Commit Bot
Comment 6 2010-12-24 03:49:32 PST
The commit-queue encountered the following flaky tests while processing attachment 77385 [details]: inspector/elements-panel-styles.html bug 50987 (author: pfeldman@chromium.org) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 7 2010-12-24 03:50:48 PST
Comment on attachment 77385 [details] Patch Clearing flags on attachment: 77385 Committed r74628: <http://trac.webkit.org/changeset/74628>
WebKit Commit Bot
Comment 8 2010-12-24 03:50:55 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.