Last Comment Bug 685154 - Cleanup nsIFrame::GetParentStyleContextFrame and related code
: Cleanup nsIFrame::GetParentStyleContextFrame and related code
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Layout (show other bugs)
: unspecified
: All All
: -- trivial (vote)
: mozilla9
Assigned To: Mats Palmgren (:mats)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-07 07:42 PDT by Mats Palmgren (:mats)
Modified: 2011-09-13 06:46 PDT (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix (28.73 KB, patch)
2011-09-07 07:45 PDT, Mats Palmgren (:mats)
no flags Details | Diff | Splinter Review
part 1, outparamdel nsIFrame::GetParentStyleContextFrame (28.90 KB, patch)
2011-09-08 07:18 PDT, Mats Palmgren (:mats)
no flags Details | Diff | Splinter Review
part 2, Make nsCSSFrameConstructor::ConstructTable return a null frame if creating the inner table frame fails (10.61 KB, patch)
2011-09-08 07:21 PDT, Mats Palmgren (:mats)
roc: review+
Details | Diff | Splinter Review
part1+2 (37.06 KB, patch)
2011-09-08 07:23 PDT, Mats Palmgren (:mats)
no flags Details | Diff | Splinter Review
part 1, outparamdel nsIFrame::GetParentStyleContextFrame (28.77 KB, patch)
2011-09-09 10:06 PDT, Mats Palmgren (:mats)
roc: review+
Details | Diff | Splinter Review
(part 1b before foding it into part1) (18.38 KB, patch)
2011-09-09 10:08 PDT, Mats Palmgren (:mats)
no flags Details | Diff | Splinter Review
full patch (36.94 KB, patch)
2011-09-09 10:10 PDT, Mats Palmgren (:mats)
no flags Details | Diff | Splinter Review

Description Mats Palmgren (:mats) 2011-09-07 07:42:49 PDT

    
Comment 1 Mats Palmgren (:mats) 2011-09-07 07:45:58 PDT
Created attachment 558804 [details] [diff] [review]
fix

Essentially this change:

-  NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,
-                                        nsIFrame**      aProviderFrame,
-                                        PRBool*         aIsChild) = 0;
+  virtual nsIFrame* GetParentStyleContextFrame(PRBool* aIsChild) = 0;
Comment 2 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-09-07 09:44:38 PDT
Shouldn't the failure nsresults at least be converted to assertions?
Comment 3 Mats Palmgren (:mats) 2011-09-07 10:33:16 PDT
nsFrame::DoGetParentStyleContextFrame already has a NS_NOTREACHED.

I can add one in nsTableOuterFrame::GetParentStyleContextFrame if you like,
in this block:

  if (!mInnerTableFrame) {
    *aIsChild = PR_FALSE;
    return this;
  }

OTOH, I think it would be better to remove all null checks of
mInnerTableFrame and instead make nsCSSFrameConstructor::ConstructTable
return a null (outer) table frame if its inner couldn't be created for
some reason.  nsCSSFrameConstructor::CreateContinuingOuterTableFrame
already does that.
Comment 4 Boris Zbarsky [:bz] 2011-09-07 10:41:26 PDT
I would be fine with that.
Comment 5 Robert O'Callahan (:roc) (email my personal email if necessary) 2011-09-07 14:35:41 PDT
Comment on attachment 558804 [details] [diff] [review]
fix

Review of attachment 558804 [details] [diff] [review]:
-----------------------------------------------------------------

I guess we'll have a new patch here
Comment 6 Mats Palmgren (:mats) 2011-09-08 07:18:40 PDT
Created attachment 559141 [details] [diff] [review]
part 1, outparamdel nsIFrame::GetParentStyleContextFrame
Comment 7 Mats Palmgren (:mats) 2011-09-08 07:21:14 PDT
Created attachment 559142 [details] [diff] [review]
part 2, Make nsCSSFrameConstructor::ConstructTable return a null frame if creating the inner table frame fails

Make nsCSSFrameConstructor::ConstructTable return a null frame if
creating the inner table frame fails.  Simplify some code since we can
now depend on the invariant that a properly created outer table frame
always has a non-null inner table frame.
Comment 8 Mats Palmgren (:mats) 2011-09-08 07:23:34 PDT
Created attachment 559143 [details] [diff] [review]
part1+2

Here's the full patch in case you prefer it for review.
Comment 9 Mats Palmgren (:mats) 2011-09-08 14:19:37 PDT
BTW, is the nsTableOuterFrame::mInnerTableFrame really worth the space?
Wouldn't an accessor to mFrames.FirstChild() just as fast?
Comment 10 Boris Zbarsky [:bz] 2011-09-08 14:20:58 PDT
Do we guarantee that the first child is the inner?

We didn't use to, but maybe we do now.
Comment 11 Mats Palmgren (:mats) 2011-09-08 14:28:31 PDT
We assert that it is:
http://mxr.mozilla.org/mozilla-central/source/layout/tables/nsTableOuterFrame.cpp#242
except for when the given child list is empty, which is the case I'm removing
in part 2.
Comment 12 Boris Zbarsky [:bz] 2011-09-08 14:44:38 PDT
In that case, just nuke the member.
Comment 13 Robert O'Callahan (:roc) (email my personal email if necessary) 2011-09-08 18:56:19 PDT
Comment on attachment 559141 [details] [diff] [review]
part 1, outparamdel nsIFrame::GetParentStyleContextFrame

Review of attachment 559141 [details] [diff] [review]:
-----------------------------------------------------------------

Why even bother with the aIsChild parameter? Callers can easily check whether the returned frame's GetParent() is equal to the frame we asked about.
Comment 14 Robert O'Callahan (:roc) (email my personal email if necessary) 2011-09-08 18:58:06 PDT
Comment on attachment 559142 [details] [diff] [review]
part 2, Make nsCSSFrameConstructor::ConstructTable return a null frame if creating the inner table frame fails

Review of attachment 559142 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/base/nsCSSFrameConstructor.cpp
@@ +1911,5 @@
>      innerFrame = NS_NewTableFrame(mPresShell, styleContext);
> +
> +  if (!innerFrame) {
> +    newFrame->Destroy();
> +    return NS_ERROR_OUT_OF_MEMORY;

Shouldn't frame allocation just be infallible?
Comment 15 Boris Zbarsky [:bz] 2011-09-08 19:19:11 PDT
> Shouldn't frame allocation just be infallible?

Ideally, yes.  But we're not there yet.  I'd love for that to happen; if allocation from presshell arenas were infallible we could simplify a lot of code...
Comment 16 Mats Palmgren (:mats) 2011-09-09 09:52:04 PDT
(In reply to Boris Zbarsky (:bz) from comment #12)
> In that case, just nuke the member.

Filed as bug 685901.
Comment 17 Mats Palmgren (:mats) 2011-09-09 10:06:04 PDT
Created attachment 559496 [details] [diff] [review]
part 1, outparamdel nsIFrame::GetParentStyleContextFrame

Remove the aIsChild parameter too.
Comment 18 Mats Palmgren (:mats) 2011-09-09 10:08:37 PDT
Created attachment 559497 [details] [diff] [review]
(part 1b before foding it into part1)

Here's the addendum for removing aIsChild before folding it into part 1 -
in case you want to review just that bit.
Comment 19 Mats Palmgren (:mats) 2011-09-09 10:10:03 PDT
Created attachment 559498 [details] [diff] [review]
full patch
Comment 20 Mats Palmgren (:mats) 2011-09-09 10:12:26 PDT
> Shouldn't frame allocation just be infallible?

As Boris said, let's attack OOM handling in the frame constructor systematically
in a specific bug for that purpose.

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