Closed Bug 1459034 Opened 7 years ago Closed 5 years ago

devirtualize some functions in nsIFrame

Categories

(Core :: Layout, enhancement, P3)

enhancement

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: froydnj, Assigned: froydnj)

Details

Attachments

(4 files)

This saves a small amount of vtable space and a decent-ish amount of text size, because subclasses no longer need forwarding thunks.
nsPluginFrame is the lone overrider of this method, but its implementation duplicates work done by the primary implementation, and calls through to the primary implementation anyway. There's no need for this method to be virtual.
Attachment #8973024 - Flags: review?(dholbert)
The default implementation of this function just forwards to GetContentOffsetsFromPoint, and there are no subclasses that override this function. I believe the "External" prefix hearkens back to a day when bits of layout lived in a separate library from everything else, but that day is long gone. Both reasons are sufficient motivation to devirtualize this function.
Attachment #8973025 - Flags: review?(dholbert)
nsFrame provides the lone implementation of this method, and there are no other overrides. We might as well move its implementation to nsIFrame and devirtualize it.
Attachment #8973026 - Flags: review?(dholbert)
Nothing overrides these default implementations, and the underlying GetUsed* methods they call are already virtual. So a subclass needing to override the GetLogicalUsed* variants seems rather unlikely.
Attachment #8973027 - Flags: review?(dholbert)
Comment on attachment 8973024 [details] [diff] [review] part 1 - devirtualize nsIFrame::IsFocusable I think the commit message should be clearer that you're *removing* the nsPluginFrame override because the override is no longer needed. The code looks good, though. (dholbert's away, and since I looked, I may as well review this)
Attachment #8973024 - Flags: review?(dholbert) → review+
Comment on attachment 8973025 [details] [diff] [review] part 2 - devirtualize nsIFrame::GetContentOffsetsFromPointExternal Yeah, this probably dated back to when accessibility was in a different library from layout.
Attachment #8973025 - Flags: review?(dholbert) → review+
(In reply to Nathan Froyd [:froydnj] from comment #4) > Nothing overrides these default implementations, and the underlying > GetUsed* methods they call are already virtual. So a subclass needing > to override the GetLogicalUsed* variants seems rather unlikely. IIRC, the idea was that the classes that override the GetUsed* methods would be changed to instead override GetLogicalUsed* so that we could minimize the use of, or remove, the physical variants eventually. I suspect that these days the logical variants are used more than the physical ones. There are also some cases where we first compute the result in logical coordinates, then convert it to physical, and then back to logical in GetLogicalUsed*. e.g. https://searchfox.org/mozilla-central/rev/c0d81882c7941c4ff13a50603e37095cdab0d1ea/layout/tables/nsTableFrame.cpp#2866
(In reply to Mats Palmgren (:mats) from comment #7) > (In reply to Nathan Froyd [:froydnj] from comment #4) > > Nothing overrides these default implementations, and the underlying > > GetUsed* methods they call are already virtual. So a subclass needing > > to override the GetLogicalUsed* variants seems rather unlikely. > > IIRC, the idea was that the classes that override the GetUsed* > methods would be changed to instead override GetLogicalUsed* > so that we could minimize the use of, or remove, the physical > variants eventually. I suspect that these days the logical > variants are used more than the physical ones. > > There are also some cases where we first compute the result in > logical coordinates, then convert it to physical, and then back to > logical in GetLogicalUsed*. e.g. > https://searchfox.org/mozilla-central/rev/ > c0d81882c7941c4ff13a50603e37095cdab0d1ea/layout/tables/nsTableFrame.cpp#2866 Thanks for the explanation here; I am woefully unfamiliar with layout code, and the history here is helpful. For avoidance of doubt, are you saying: a) The patch should not be landed; b) The patch can be landed, but somebody will probably undo its effects later as part of a (step-wise) refactoring; or c) The patch is a good idea, but should really be accomplished by removing the physical variants and making the overrides work with logical coordinates instead, and should not be landed in its current state. ?
Flags: needinfo?(mats)
Sorry for the confusion, please land it. I suspect somebody will probably switch the roles of GetLogicalUsed*/GetUsed* eventually though, in terms of which should be virtual and overridable.
Flags: needinfo?(mats)
Priority: -- → P3

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:froydnj, could you have a look please?

Flags: needinfo?(nfroyd)
Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(nfroyd)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: