WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
137728
Have offsetFromContainer() / offsetFromAncestorContainer() take a RenderElement&
https://bugs.webkit.org/show_bug.cgi?id=137728
Summary
Have offsetFromContainer() / offsetFromAncestorContainer() take a RenderElement&
Chris Dumez
Reported
2014-10-14 19:25:10 PDT
Have offsetFromContainer() / offsetFromAncestorContainer() take a RenderElement& instead of a RenderObject*. The argument passed is never null and the type should be a RenderElement as the argument is a container.
Attachments
Patch
(33.50 KB, patch)
2014-10-14 19:35 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(33.79 KB, patch)
2014-10-14 20:12 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(33.83 KB, patch)
2014-10-14 21:17 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2014-10-14 19:35:59 PDT
Created
attachment 239840
[details]
Patch
Chris Dumez
Comment 2
2014-10-14 20:12:33 PDT
Created
attachment 239843
[details]
Patch
Benjamin Poulain
Comment 3
2014-10-14 21:10:42 PDT
Comment on
attachment 239843
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=239843&action=review
rs=me
> Source/WebCore/rendering/RenderBox.cpp:1915 > + auto* container = this->container(repaintContainer, &containerSkipped);
IMHO, "auto" is bad here, the type is 100% non obvious.
> Source/WebCore/rendering/RenderBox.cpp:1964 > + auto* container = this->container(ancestorToStopAt, &ancestorSkipped);
ditto
> Source/WebCore/rendering/RenderBoxModelObject.cpp:2640 > + auto* container = this->container();
ditto
> Source/WebCore/rendering/RenderObject.cpp:1874 > - auto nextContainer = currContainer->container(); > + auto* nextContainer = currContainer->container();
gosh I hate auto sometimes... It is just making code hard to follow :(
Chris Dumez
Comment 4
2014-10-14 21:14:47 PDT
Comment on
attachment 239843
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=239843&action=review
>> Source/WebCore/rendering/RenderBox.cpp:1915 >> + auto* container = this->container(repaintContainer, &containerSkipped); > > IMHO, "auto" is bad here, the type is 100% non obvious.
I think Darin prefers auto* in this case because this way it always uses the same type returned by container(). For e.g., it is quite common for people to assign to a RenderObject* even though the function returns a RenderElement* nowadays. That said, I don't feel strongly either way. In this case, I do agree the type is not obvious.
Chris Dumez
Comment 5
2014-10-14 21:17:36 PDT
Created
attachment 239846
[details]
Patch
WebKit Commit Bot
Comment 6
2014-10-14 22:01:38 PDT
Comment on
attachment 239846
[details]
Patch Clearing flags on attachment: 239846 Committed
r174722
: <
http://trac.webkit.org/changeset/174722
>
WebKit Commit Bot
Comment 7
2014-10-14 22:01:44 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 8
2014-10-15 09:22:17 PDT
At some point we should talk this style point. I agree that the type is non-obvious, but I don’t agree that is a problem. Why does the type need to be obvious?
Benjamin Poulain
Comment 9
2014-10-15 13:59:51 PDT
(In reply to
comment #8
)
> At some point we should talk this style point. I agree that the type is non-obvious, but I don’t agree that is a problem. Why does the type need to be obvious?
For me it is all about reading/reviewing/understanding code. I would rather spend 5 minutes making the code explicit when writing it than creating cognitive load for anyone reading the code. I like that "auto" always get the right type even after refactoring of disconnected parts of the code but the code readability suffers so much that the cost far outweigh the gains.
Darin Adler
Comment 10
2014-10-15 16:21:39 PDT
(In reply to
comment #9
)
> (In reply to
comment #8
) > > At some point we should talk this style point. I agree that the type is non-obvious, but I don’t agree that is a problem. Why does the type need to be obvious? > > For me it is all about reading/reviewing/understanding code. I would rather spend 5 minutes making the code explicit when writing it than creating cognitive load for anyone reading the code.
What I’m not clear on is whether this cognitive load is an intrinsic result of this coding style, or a result of the fact that we are accustomed to the other style. I often don’t need to know the types of things; the names of the functions we are calling on them seem sufficient. Every time I see an explicit type name such as RenderObject I wonder if the type is correct. We do not see the type names of function results or data members each time we use them. Is there some reason we need these type names urgently for local variables, but not those other things?
Benjamin Poulain
Comment 11
2014-10-15 20:18:07 PDT
(In reply to
comment #10
)
> (In reply to
comment #9
) > > (In reply to
comment #8
) > > > At some point we should talk this style point. I agree that the type is non-obvious, but I don’t agree that is a problem. Why does the type need to be obvious? > > > > For me it is all about reading/reviewing/understanding code. I would rather spend 5 minutes making the code explicit when writing it than creating cognitive load for anyone reading the code. > > What I’m not clear on is whether this cognitive load is an intrinsic result of this coding style, or a result of the fact that we are accustomed to the other style. I often don’t need to know the types of things; the names of the functions we are calling on them seem sufficient. Every time I see an explicit type name such as RenderObject I wonder if the type is correct. > > We do not see the type names of function results or data members each time we use them. Is there some reason we need these type names urgently for local variables, but not those other things?
Funny you mention that, you always have me remove my local variables :) I do use local variables to make types explicit whenever I feel that it clarifies the flow. Let's talk about this face to face when you have 5 minutes, this is not the best forum.
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