Last Comment Bug 693801 - nsHTMLReflowState's second constructor has redundant initialization for mFlags.mIsTopOfPage from parent reflow state
: nsHTMLReflowState's second constructor has redundant initialization for mFlag...
Status: RESOLVED FIXED
[inbound]
:
Product: Core
Classification: Components
Component: Layout (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla10
Assigned To: Daniel Holbert [:dholbert]
:
Mentors:
Depends on: 113424
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-11 13:58 PDT by Daniel Holbert [:dholbert]
Modified: 2011-10-22 06:06 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix (3.08 KB, patch)
2011-10-11 14:02 PDT, Daniel Holbert [:dholbert]
dbaron: review+
Details | Diff | Splinter Review

Description Daniel Holbert [:dholbert] 2011-10-11 13:58:39 PDT
nsHTMLReflowState's second constructor looks like this:
> 126 nsHTMLReflowState::nsHTMLReflowState(nsPresContext*           aPresContext,
[...]
> 132                                      bool                     aInit)
> 133   : nsCSSOffsetState(aFrame, aParentReflowState.rendContext)
[...]
> 136   , mFlags(aParentReflowState.mFlags)
> 137 {
[...]
> 166   mFlags.mIsTopOfPage = aParentReflowState.mFlags.mIsTopOfPage;
http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsHTMLReflowState.cpp#126

The mFlags.mIsTopOfPage assignment on line 166 is redundant, since mFlags is already initialized off of aParentReflowState's mFlags.

This line was last modified in the patch[1] for bug 113424, which tweaked the boolean member-variable "nsHTMLReflowState::isTopOfPage" to be part of mFlags.

Before that patch, this line looked like:
> isTopOfPage = aParentReflowState.isTopOfPage;
...and it was necessary because isTopOfPage wasn't initialized elsewhere.  But now it gets initialized as part of mFlags, so this line is redundant.

[1] http://bonsai.mozilla.org/cvsview2.cgi?diff_mode=context&whitespace_mode=show&root=/cvsroot&subdir=mozilla/layout/generic&command=DIFF_FRAMESET&file=nsHTMLReflowState.cpp&rev2=1.129&rev1=1.128
Comment 1 Daniel Holbert [:dholbert] 2011-10-11 14:02:42 PDT
Created attachment 566333 [details] [diff] [review]
fix

Patch attached.  Including 30 lines of context (back to the mFlags initialization), to demonstrate the redundancy.
Comment 2 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-10-21 11:45:52 PDT
Comment on attachment 566333 [details] [diff] [review]
fix

r=dbaron, but maybe add a comment near the other flag initializations pointing out that mFlags is initialized above by copy-construction so that we only need to initialize those flags that need a value other than what we get by copying the parent.
Comment 3 Daniel Holbert [:dholbert] 2011-10-21 13:43:37 PDT
Added a message as suggested (and added a blank line to set apart the mFlags.* assignments from the other member-variable initializations), and pushed:
https://hg.mozilla.org/integration/mozilla-inbound/rev/c09b6f933f76
Comment 4 Ed Morley [:emorley] 2011-10-22 06:06:40 PDT
https://hg.mozilla.org/mozilla-central/rev/c09b6f933f76

Note You need to log in before you can comment on or make changes to this bug.