WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
131606
Replace width*height with calls to area
https://bugs.webkit.org/show_bug.cgi?id=131606
Summary
Replace width*height with calls to area
Dean Jackson
Reported
2014-04-13 23:17:32 PDT
Darin mentioned in 131553 that we should use area() helper functions for the cases where we are calculating width * height. It turns out there are a lot of places where we do this. Add some helpers for IntSize, IntRect, LayoutRect, FloatSize and FloatRect.
Attachments
Patch
(34.19 KB, patch)
2014-04-13 23:23 PDT
,
Dean Jackson
no flags
Details
Formatted Diff
Diff
Patch
(34.18 KB, patch)
2014-04-13 23:27 PDT
,
Dean Jackson
no flags
Details
Formatted Diff
Diff
Patch
(34.18 KB, patch)
2014-04-14 00:58 PDT
,
Dean Jackson
no flags
Details
Formatted Diff
Diff
Patch
(34.21 KB, patch)
2014-04-14 10:19 PDT
,
Dean Jackson
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2014-04-13 23:22:14 PDT
I just meant a local area helper in that file, but it would OK to put some in a header instead.
Darin Adler
Comment 2
2014-04-13 23:22:41 PDT
The problem in a header is that we’d have to chose a type for the area result and it’s not 100% clear what the best type would be for all the cases.
Dean Jackson
Comment 3
2014-04-13 23:23:20 PDT
Created
attachment 229263
[details]
Patch
Dean Jackson
Comment 4
2014-04-13 23:27:47 PDT
Created
attachment 229264
[details]
Patch
Dean Jackson
Comment 5
2014-04-14 00:58:04 PDT
Created
attachment 229269
[details]
Patch
Dean Jackson
Comment 6
2014-04-14 08:03:42 PDT
Comment on
attachment 229269
[details]
Patch Failing some tests.
Dean Jackson
Comment 7
2014-04-14 10:15:13 PDT
Actually it doesn't fail any more tests than without the change. The EFL build failure doesn't give enough info in the log, so I'll upload another patch.
Dean Jackson
Comment 8
2014-04-14 10:19:09 PDT
Created
attachment 229287
[details]
Patch
Simon Fraser (smfr)
Comment 9
2014-04-14 17:32:23 PDT
Comment on
attachment 229287
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=229287&action=review
> Source/WebCore/platform/graphics/IntRect.h:253 > +inline int area(const IntRect& rect) > +{ > + return rect.width() * rect.height(); > +}
Why isn't this a member function? Do we care about overflow?
> Source/WebCore/platform/graphics/IntSize.h:196 > +inline int area(const IntSize& size) > +{ > + return size.area(); > +}
Ditto.
Darin Adler
Comment 10
2014-04-16 10:45:28 PDT
Comment on
attachment 229287
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=229287&action=review
I worry that these different area functions have different overflow behaviors. They all have the same name, but different behavior. The only ones I am really comfortable with are the ones that return floating point, because there I know what to expect from overflow. The integer ones worry me. Otherwise this patch seems fantastic!
> Source/WebCore/platform/graphics/LayoutRect.h:252 > + return rect.width() * rect.height();
Seems a shame to convert to a float only after a possible overflow.
> Source/WebCore/platform/graphics/LayoutSize.h:207 > + return size.width() * size.height();
Seems a shame to convert to a float only after a possible overflow.
> Source/WebCore/platform/graphics/Region.cpp:119 > + for (size_t i = 0; i < size; ++i) > + totalArea += area(rects[i]);
Should use C++11 for loop instead of size and such.
> Source/WebCore/platform/graphics/ShadowBlur.cpp:532 > if (templateSize.width() > rect.width() || templateSize.height() > rect.height() > - || (templateSize.width() * templateSize.height() > m_sourceRect.width() * m_sourceRect.height())) { > + || area(templateSize) > area(m_sourceRect)) {
Should combine onto a single line now that it’s short enough.
> Source/WebCore/platform/graphics/ShadowBlur.cpp:560 > if (templateSize.width() > hRect.width() || templateSize.height() > hRect.height() > - || (templateSize.width() * templateSize.height() > hRect.width() * hRect.height())) { > + || area(templateSize) > area(hRect)) {
Should combine onto a single line now that it’s short enough.
Ahmad Saleem
Comment 11
2022-10-25 15:30:34 PDT
Checking via BugID on Webkit GitHub, it seems this r+ patch didn't landed. Is anything needed from this patch? Thanks!
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