RESOLVED FIXED Bug 96264
Reuse floating point formatting of TextStream in RenderTreeAsText.cpp
https://bugs.webkit.org/show_bug.cgi?id=96264
Summary Reuse floating point formatting of TextStream in RenderTreeAsText.cpp
Patrick R. Gansterer
Reported 2012-09-10 05:26:09 PDT
Reuse floating point formatting of TextStream in RenderTreeAsText.cpp
Attachments
Patch (2.34 KB, patch)
2012-09-10 05:44 PDT, Patrick R. Gansterer
gyuyoung.kim: commit-queue-
Patch (4.38 KB, patch)
2012-09-10 06:06 PDT, Patrick R. Gansterer
no flags
Patch (6.26 KB, patch)
2012-09-11 09:51 PDT, Patrick R. Gansterer
no flags
Patch (6.26 KB, patch)
2012-09-11 09:57 PDT, Patrick R. Gansterer
gyuyoung.kim: commit-queue-
Patch (6.41 KB, patch)
2012-09-11 10:04 PDT, Patrick R. Gansterer
no flags
Patch (7.12 KB, patch)
2012-09-13 04:03 PDT, Patrick R. Gansterer
no flags
Patrick R. Gansterer
Comment 1 2012-09-10 05:44:53 PDT
Gyuyoung Kim
Comment 2 2012-09-10 05:57:23 PDT
Peter Beverloo (cr-android ews)
Comment 3 2012-09-10 05:59:09 PDT
Comment on attachment 163100 [details] Patch Attachment 163100 [details] did not pass cr-android-ews (chromium-android): Output: http://queues.webkit.org/results/13796869
Build Bot
Comment 4 2012-09-10 06:01:03 PDT
Early Warning System Bot
Comment 5 2012-09-10 06:01:16 PDT
Patrick R. Gansterer
Comment 6 2012-09-10 06:06:27 PDT
Benjamin Poulain
Comment 7 2012-09-10 15:23:27 PDT
Comment on attachment 163107 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=163107&action=review > Source/WebCore/rendering/RenderTreeAsText.cpp:90 > -String formatNumberRespectingIntegers(double value) > +void writeNumberRespectingIntegers(TextStream& ts, float value) The change double->float must be justified. > Source/WebCore/rendering/RenderTreeAsText.cpp:121 > - ts << "(" << formatNumberRespectingIntegers(p.x()); > - ts << "," << formatNumberRespectingIntegers(p.y()); > + ts << "("; > + writeNumberRespectingIntegers(ts, p.x()); > + ts << ","; > + writeNumberRespectingIntegers(ts, p.y()); > ts << ")"; > return ts; I haven't looked at this code in detail yet so that is just an early comment. To make the code more readable, could't you add an operator<< to TextStream taking an wrapper returned by formatNumberRespectingIntegers? Something like this: struct TextStreamFormatNumberRespectingIntegers { double value; } TextStream::operator<<(TextStreamFormatNumberRespectingIntegers value) { if (hasFractions(value)) { ... }
Patrick R. Gansterer
Comment 8 2012-09-11 09:51:08 PDT
WebKit Review Bot
Comment 9 2012-09-11 09:55:56 PDT
Attachment 163387 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/platform/text/TextStream.h:38: This { should be at the end of the previous line [whitespace/braces] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Patrick R. Gansterer
Comment 10 2012-09-11 09:57:24 PDT
Gyuyoung Kim
Comment 11 2012-09-11 10:01:19 PDT
WebKit Review Bot
Comment 12 2012-09-11 10:02:47 PDT
Comment on attachment 163390 [details] Patch Attachment 163390 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/13806825
Early Warning System Bot
Comment 13 2012-09-11 10:04:11 PDT
Early Warning System Bot
Comment 14 2012-09-11 10:04:11 PDT
Patrick R. Gansterer
Comment 15 2012-09-11 10:04:42 PDT
Benjamin Poulain
Comment 16 2012-09-12 14:37:21 PDT
Comment on attachment 163394 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=163394&action=review I like this, it is a better encapsulation. > Source/WebCore/ChangeLog:10 > + RenderTreeAsText uses the same format for streaming out floats as > + TextStream does. Replace formatNumberRespectingIntegers() with > + a new overload to the operator<< to avoid code duplications. I would like a bit more explanation. 1) What code duplication is saved. 2) Mention it takes advantage of StringBuilder::appendNumber() to avoid a temporary StringImpl. > Source/WebCore/platform/text/TextStream.cpp:29 > +#include <math.h> MathExtras.h for future proofing it? > Source/WebCore/platform/text/TextStream.cpp:119 > +TextStream& TextStream::operator<<(const FormatNumberRespectingIntegers& value) value -> formattedValue or something like that? The following "value.value" is a little unfortunate for readability. > Source/WebCore/rendering/RenderTreeAsText.h:-102 > -String formatNumberRespectingIntegers(double); > - Can you remove #include <wtf/MathExtras.h> ?
Patrick R. Gansterer
Comment 17 2012-09-13 04:03:53 PDT
Patrick R. Gansterer
Comment 18 2012-09-14 00:09:30 PDT
Note You need to log in before you can comment on or make changes to this bug.