RESOLVED FIXED Bug 83848
Support size_t multiplication and division operators on LayoutUnit
https://bugs.webkit.org/show_bug.cgi?id=83848
Summary Support size_t multiplication and division operators on LayoutUnit
Emil A Eklund
Reported 2012-04-12 18:41:05 PDT
Add size_t versions of operator* and operator/
Attachments
Patch (3.90 KB, patch)
2012-04-12 18:46 PDT, Emil A Eklund
no flags
Patch (3.88 KB, patch)
2012-04-13 11:43 PDT, Emil A Eklund
no flags
Patch (4.00 KB, patch)
2012-04-13 13:11 PDT, Emil A Eklund
no flags
Patch (4.11 KB, patch)
2012-04-14 18:37 PDT, Emil A Eklund
no flags
Updated patch: add overloaded operators for most unsigned types, per Darin's suggestion. (8.07 KB, patch)
2012-12-18 15:07 PST, Julien Chaffraix
no flags
Updated patch without the bad multipliciation test and with an overflowing test. (8.63 KB, patch)
2012-12-18 15:50 PST, Julien Chaffraix
no flags
Updated patch 3: Forgot to update the ChangeLog after the bug rename. (8.60 KB, patch)
2012-12-18 15:53 PST, Julien Chaffraix
no flags
Updated patch 4: fixed signed / unsigned comparison in the tests. (8.57 KB, patch)
2012-12-19 08:29 PST, Julien Chaffraix
no flags
Updated patch 5: sigh, fix the EWS. (8.56 KB, patch)
2012-12-19 10:00 PST, Julien Chaffraix
no flags
Proposed fix 6: This time passing on mac FOR REAL. (8.48 KB, patch)
2012-12-19 14:18 PST, Julien Chaffraix
no flags
Emil A Eklund
Comment 1 2012-04-12 18:46:13 PDT
Build Bot
Comment 2 2012-04-12 19:12:57 PDT
Early Warning System Bot
Comment 3 2012-04-12 19:19:36 PDT
Early Warning System Bot
Comment 4 2012-04-12 19:30:42 PDT
Emil A Eklund
Comment 5 2012-04-13 11:43:43 PDT
Emil A Eklund
Comment 6 2012-04-13 13:11:09 PDT
Emil A Eklund
Comment 7 2012-04-13 13:13:20 PDT
The only difference between patch2 and 3 is the ChangeLog entry.
Julien Chaffraix
Comment 8 2012-04-13 15:49:29 PDT
Comment on attachment 137132 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=137132&action=review > Source/WebCore/platform/FractionalLayoutUnit.h:40 > +#define LAYOUT_UNIT_SIZE_T Not a huge fan of the naming. First it should be an HAVE() macro as it is about the underlying platform. Then the name doesn't speak to me, how about HAVE_SEPARATE_SIZE_T_UNIT? (it really should be ARE_SIZE_T_UNSIGNED_DIFFERENT_UNIT but we don't have a general ARE() macro). I wonder if we shouldn't put that in Platform.h as we do with the other macros, which would force rebuilding everything. Maybe someone else has some ideas on the matter.
Emil A Eklund
Comment 9 2012-04-13 16:17:37 PDT
(In reply to comment #8) > (From update of attachment 137132 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=137132&action=review > > > Source/WebCore/platform/FractionalLayoutUnit.h:40 > > +#define LAYOUT_UNIT_SIZE_T > > Not a huge fan of the naming. First it should be an HAVE() macro as it is about the underlying platform. Then the name doesn't speak to me, how about HAVE_SEPARATE_SIZE_T_UNIT? (it really should be ARE_SIZE_T_UNSIGNED_DIFFERENT_UNIT but we don't have a general ARE() macro). > > I wonder if we shouldn't put that in Platform.h as we do with the other macros, which would force rebuilding everything. Maybe someone else has some ideas on the matter. Seems fair. Do you think we should have a separate macro or just repeat the or clause for each function?
Julien Chaffraix
Comment 10 2012-04-13 16:48:10 PDT
Comment on attachment 137132 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=137132&action=review >>> Source/WebCore/platform/FractionalLayoutUnit.h:40 >>> +#define LAYOUT_UNIT_SIZE_T >> >> Not a huge fan of the naming. First it should be an HAVE() macro as it is about the underlying platform. Then the name doesn't speak to me, how about HAVE_SEPARATE_SIZE_T_UNIT? (it really should be ARE_SIZE_T_UNSIGNED_DIFFERENT_UNIT but we don't have a general ARE() macro). >> >> I wonder if we shouldn't put that in Platform.h as we do with the other macros, which would force rebuilding everything. Maybe someone else has some ideas on the matter. > > Seems fair. Do you think we should have a separate macro or just repeat the or clause for each function? If nobody objects to an inline definition, I would rather use the ARE_SIZE_T_UNSIGNED_DIFFERENT_UNIT (or equivalent), repeated each time.
Emil A Eklund
Comment 11 2012-04-14 18:37:51 PDT
Eric Seidel (no email)
Comment 12 2012-04-14 20:16:29 PDT
Comment on attachment 137222 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=137222&action=review > Source/WebCore/platform/FractionalLayoutUnit.h:41 > +#if PLATFORM(CHROMIUM) || PLATFORM(MAC) > +#define ARE_SIZE_T_UNSIGNED_DIFFERENT_UNIT > +#endif This feels like something which belongs in a more central place. I'm not sure. MathExtras? Maybe there is some other header in wtf in which thsi would make sense? Is this really the only place we have this trouble?
Emil A Eklund
Comment 13 2012-04-16 09:26:16 PDT
(In reply to comment #12) > (From update of attachment 137222 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=137222&action=review > > > Source/WebCore/platform/FractionalLayoutUnit.h:41 > > +#if PLATFORM(CHROMIUM) || PLATFORM(MAC) > > +#define ARE_SIZE_T_UNSIGNED_DIFFERENT_UNIT > > +#endif > > This feels like something which belongs in a more central place. I'm not sure. MathExtras? Maybe there is some other header in wtf in which thsi would make sense? Is this really the only place we have this trouble? I haven't found any other places where we have a function that can either take an unsigned int or a size_t, generally we tend to use one or the other.
Emil A Eklund
Comment 14 2012-04-17 10:07:14 PDT
I'm happy to move the definition elsewhere if you think that makes sense. Another option would be to keep it where it is for now and move it once we start using it elsewhere.
Julien Chaffraix
Comment 15 2012-04-17 10:24:51 PDT
Comment on attachment 137222 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=137222&action=review >>> Source/WebCore/platform/FractionalLayoutUnit.h:41 >>> +#endif >> >> This feels like something which belongs in a more central place. I'm not sure. MathExtras? Maybe there is some other header in wtf in which thsi would make sense? Is this really the only place we have this trouble? > > I haven't found any other places where we have a function that can either take an unsigned int or a size_t, generally we tend to use one or the other. I haven't heard any strong objections to keeping the #define here. The only people who commented felt like it may belong somewhere else but nothing substantial (Eric thought of MathExtras.h, I thought about Platform.h but it felt clunky). Based on your assessment, I feel like it's fine to keep it here for now. If someone objects, it can moved appropriately.
WebKit Review Bot
Comment 16 2012-04-17 11:52:08 PDT
Comment on attachment 137222 [details] Patch Clearing flags on attachment: 137222 Committed r114404: <http://trac.webkit.org/changeset/114404>
WebKit Review Bot
Comment 17 2012-04-17 11:52:14 PDT
All reviewed patches have been landed. Closing bug.
Emil A Eklund
Comment 18 2012-04-17 13:59:25 PDT
Reverted as it broke a couple of the chromium bots. I'm not convinced this approach is going to work as the chromium linux release and valgrind bots seems to have conflicting ideas of whether or not size_t and unisgned are interchangeable, despite having the same architecture.
Darin Adler
Comment 19 2012-05-12 08:53:17 PDT
We should not add size_t versions, since our current overloading is based on basic C types. Instead we should add all the basic C types (except maybe the char ones), short, int, long, long long, unsigned short, unsigned, unsigned long, unsigned long long. Once we have all those covered, that takes care of size_t automatically because it’s one of those types.
Julien Chaffraix
Comment 20 2012-12-18 15:07:51 PST
Created attachment 180037 [details] Updated patch: add overloaded operators for most unsigned types, per Darin's suggestion.
Levi Weintraub
Comment 21 2012-12-18 15:20:14 PST
Comment on attachment 180037 [details] Updated patch: add overloaded operators for most unsigned types, per Darin's suggestion. View in context: https://bugs.webkit.org/attachment.cgi?id=180037&action=review > Tools/TestWebKitAPI/Tests/WebCore/LayoutUnit.cpp:194 > + ASSERT_EQ((LayoutUnit(400) / aHundredSizeT).toInt(), aHundredSizeT); This appears to say 400/100 = 100?
Emil A Eklund
Comment 22 2012-12-18 15:20:43 PST
Comment on attachment 180037 [details] Updated patch: add overloaded operators for most unsigned types, per Darin's suggestion. View in context: https://bugs.webkit.org/attachment.cgi?id=180037&action=review > Source/WebCore/ChangeLog:3 > + Add size_t versions of multiplication and division operators to FractionalLayoutUnit You should update the bug description as you are in fact not adding size_t versions of the operators. > Tools/TestWebKitAPI/Tests/WebCore/LayoutUnit.cpp:150 > + size_t aHundredSizeT = 100; I'd like to see a test for cases where the value is larger than MAX_INT. Something like the quarterMax code below but with std::numeric_limits<size_t>::max.
Julien Chaffraix
Comment 23 2012-12-18 15:50:40 PST
Created attachment 180045 [details] Updated patch without the bad multipliciation test and with an overflowing test.
Julien Chaffraix
Comment 24 2012-12-18 15:53:40 PST
Created attachment 180046 [details] Updated patch 3: Forgot to update the ChangeLog after the bug rename.
Build Bot
Comment 25 2012-12-18 19:32:26 PST
Comment on attachment 180046 [details] Updated patch 3: Forgot to update the ChangeLog after the bug rename. Attachment 180046 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/15404492
Julien Chaffraix
Comment 26 2012-12-19 08:29:45 PST
Created attachment 180172 [details] Updated patch 4: fixed signed / unsigned comparison in the tests.
Build Bot
Comment 27 2012-12-19 09:09:39 PST
Comment on attachment 180172 [details] Updated patch 4: fixed signed / unsigned comparison in the tests. Attachment 180172 [details] did not pass win-ews (win): Output: http://queues.webkit.org/results/15401700
WebKit Review Bot
Comment 28 2012-12-19 09:26:03 PST
Comment on attachment 180172 [details] Updated patch 4: fixed signed / unsigned comparison in the tests. Attachment 180172 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/15410707
EFL EWS Bot
Comment 29 2012-12-19 09:28:28 PST
Comment on attachment 180172 [details] Updated patch 4: fixed signed / unsigned comparison in the tests. Attachment 180172 [details] did not pass efl-ews (efl): Output: http://queues.webkit.org/results/15413652
Peter Beverloo (cr-android ews)
Comment 30 2012-12-19 09:57:08 PST
Comment on attachment 180172 [details] Updated patch 4: fixed signed / unsigned comparison in the tests. Attachment 180172 [details] did not pass cr-android-ews (chromium-android): Output: http://queues.webkit.org/results/15405716
Julien Chaffraix
Comment 31 2012-12-19 10:00:33 PST
Created attachment 180187 [details] Updated patch 5: sigh, fix the EWS.
Build Bot
Comment 32 2012-12-19 13:04:34 PST
Comment on attachment 180187 [details] Updated patch 5: sigh, fix the EWS. Attachment 180187 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/15401746
Build Bot
Comment 33 2012-12-19 14:08:56 PST
Comment on attachment 180187 [details] Updated patch 5: sigh, fix the EWS. Attachment 180187 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/15413711
Julien Chaffraix
Comment 34 2012-12-19 14:18:05 PST
Created attachment 180225 [details] Proposed fix 6: This time passing on mac FOR REAL.
Levi Weintraub
Comment 35 2012-12-20 09:47:30 PST
(In reply to comment #34) > Created an attachment (id=180225) [details] > Proposed fix 6: This time passing on mac FOR REAL. Woo!
WebKit Review Bot
Comment 36 2013-01-07 09:26:58 PST
Comment on attachment 180225 [details] Proposed fix 6: This time passing on mac FOR REAL. Clearing flags on attachment: 180225 Committed r138952: <http://trac.webkit.org/changeset/138952>
WebKit Review Bot
Comment 37 2013-01-07 09:27:04 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.