Closed Bug 270708 Opened 20 years ago Closed 20 years ago

Invalid comment in nsIFrame.h

Categories

(Core :: Layout, defect)

defect
Not set
trivial

Tracking

()

RESOLVED FIXED

People

(Reporter: pkwarren, Assigned: vhaarr+bmo)

Details

(Whiteboard: [good first bug])

Attachments

(2 files, 3 obsolete files)

From nsIFrame.h:

819   /**
820    * This call is invoked when the value of a content objects's attribute
821    * is changed. 
822    * The first frame that maps that content is asked to deal
823    * with the change by doing whatever is appropriate.
824    *
825    * @param aChild the content object
826    * @param aAttribute the attribute whose value changed
827    * @param aHint the level of change that has already been dealt with
828    */
829   NS_IMETHOD  AttributeChanged(nsPresContext* aPresContext,
830                                nsIContent*     aChild,
831                                PRInt32         aNameSpaceID,
832                                nsIAtom*        aAttribute,
833                                PRInt32         aModType) = 0;

There is no aHint param, and several of the parameters are not documented.
According to bz, this function should be documented similarly to the
AttributeChanged function in nsIDocumentObserver.h.
And as long as we're here we should remove aPresContext, since frames can get
their prescontext just fine via GetPresContext().
Whiteboard: [good first bug]
How does this look?

bz: Did you mean to remove aPresContext wherever it is not really needed? I see
lots of methods taking nsPresContext* as parameter where they could just use
GetPresContext(). If so, I can search/replace more :)
Attachment #169334 - Flags: review?(pkwarren)
> bz: Did you mean to remove aPresContext wherever it is not really needed? 

In general, yes.  As part of this bug, probably not.  ;)

If you have time to clean up nsIFrame methods that take an nsIPresShell/nsIPresContext 
but don't really need it, that would be great!  File a bug on that, cc rbs, roc, dbaron, 
myself, bryner?
Comment on attachment 169334 [details] [diff] [review]
removes nsPresContext from AttributeChanged and fixes comment in nsIFrame.h

>Index: generic/nsIFrame.h
>===================================================================
...
>+   * @param aModType Whether or not the attribute was added, changed, or removed.

Can you add the additional comment from nsIDocumentObserver.h in here? ("The
constants are defined in nsIDOMMutationEvent.h.")

>Index: svg/base/src/nsSVGTextFrame.cpp
>===================================================================
>RCS file: /cvsroot/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp,v
>retrieving revision 1.9
>diff -w -u -p -7 -r1.9 nsSVGTextFrame.cpp
>--- svg/base/src/nsSVGTextFrame.cpp	5 Dec 2004 22:12:43 -0000	1.9
>+++ svg/base/src/nsSVGTextFrame.cpp	22 Dec 2004 00:36:16 -0000
>@@ -110,16 +110,15 @@ public:
>   
>   NS_IMETHOD Init(nsPresContext*  aPresContext,
>                   nsIContent*      aContent,
>                   nsIFrame*        aParent,
>                   nsStyleContext*  aContext,
>                   nsIFrame*        aPrevInFlow);
>@@ -273,32 +272,30 @@ NS_INTERFACE_MAP_BEGIN(nsSVGTextFrame)
> //----------------------------------------------------------------------
> // nsIFrame methods
> NS_IMETHODIMP
>-nsSVGTextFrame::Init(nsPresContext*  aPresContext,
>-                     nsIContent*      aContent,
>+nsSVGTextFrame::Init(nsIContent*      aContent,
>                      nsIFrame*        aParent,
>                      nsStyleContext*  aContext,
>                      nsIFrame*        aPrevInFlow)
> {
>   nsresult rv;
>-  rv = nsSVGTextFrameBase::Init(aPresContext, aContent, aParent,
>+  rv = nsSVGTextFrameBase::Init(GetPresContext(), aContent, aParent,
>                                 aContext, aPrevInFlow);
> 
>   Init();
>   
>   return rv;
> }

Did you mean to include this change in with the changes for AttributeChanged?
If so, you need to change the declaration in the header file above.

Everything else looks ok, but you should probably get someone else with more
layout experience to look it over.

r=pkw with those two changes (backing out change to Init and adding additional
comment in nsIFrame.h).
Attachment #169334 - Flags: review?(pkwarren) → review+
Comment on attachment 169334 [details] [diff] [review]
removes nsPresContext from AttributeChanged and fixes comment in nsIFrame.h

I've added the comment to nsIFrame.h and reverted my changes to
nsSVGTextFrame.cpp. I'll attach an updated patch after sr comments. Thanks for
the review, PKW!

Why did this build? I haven't enabled SVG - is that why?

bz: I'll open a new bug once this is checked in :)
Attachment #169334 - Flags: superreview?(bzbarsky)
Actually, is there a reason to keep the aContent argument?  It'll always be the mContent 
of the frame, I would hope....
I guess that if it isn't the mContent, something is wrong, or someone is
invoking methods out of context. I see lots of methods that check if (mContent)
{}, so I presume it has been/is null at some point.
In any case, I believe that should be a seperate bug - lets take a look at it
after aPresContext is gone.

bz: it seems bug 244581 covers some of the remaining aPresContexts. I'll do that
after this bug, and then open a new one if there are even more of them remaining.
> I guess that if it isn't the mContent, something is wrong,

Yes.

>  I see lots of methods that check if (mContent) {}, so I presume it has been/is null at
> some point.

It's null in very rare cases (viewport and page frames).  It's non-null otherwise.

> In any case, I believe that should be a seperate bug - lets take a look at it
> after aPresContext is gone.

OK.  I'll treview this patch with that in mind.  Probably not happening till at least Tues 
night, though....
Status: NEW → ASSIGNED
Assignee: nobody → bugmail
Status: ASSIGNED → NEW
Comment on attachment 169334 [details] [diff] [review]
removes nsPresContext from AttributeChanged and fixes comment in nsIFrame.h

>Index: forms/nsFileControlFrame.cpp
>+nsFileControlFrame::AttributeChanged(nsIContent*     aChild,
>                                        PRInt32         aNameSpaceID,

I assume you fixed the indents in your tree, here and elsewhere?  It helps to
post a real patch in addition to the -w one....

>Index: generic/nsBlockFrame.cpp

>   if (nsHTMLAtoms::start == aAttribute) {

On this codepath you will end up calling GetPresContext() twice.  Call it once
and store the return value in a local nsIPresContext pointer here?

>       // Tell the enclosing block frame to renumber list items within
>       // itself

Same here.

>Index: mathml/base/src/nsMathMLmfracFrame.cpp

>+          mSlashChar->SetData(GetPresContext(), slashChar);
>+          ResolveMathMLCharStyle(GetPresContext(), mContent, mStyleContext, mSlashChar, PR_TRUE);

Same here.

>Index: svg/base/src/nsSVGTextFrame.cpp

>-nsSVGTextFrame::Init(nsPresContext*  aPresContext,
>-                     nsIContent*      aContent,
>+nsSVGTextFrame::Init(nsIContent*      aContent,

This won't compile, because you didn't change the prototype (why're you
changing Init() anyway?).

Please do build with all optional layout stuff enabled for treewide patches
like this...

>Index: xul/base/src/nsListBoxBodyFrame.cpp
>-      t2p = aPresContext->TwipsToPixels();
>+      t2p = GetPresContext()->TwipsToPixels();

Again, please cache the prescontext pointer here?

>Index: xul/base/src/nsTextBoxFrame.cpp
>+    UpdateAttributes(GetPresContext(), aAttribute, aResize, aRedraw);

And here.

The rest looks good.... please fix those issues, though.
Attachment #169334 - Flags: superreview?(bzbarsky) → superreview-
"real patch" without -w will be attached shortly.

bz: I changed nsSVGTextFrame::Init because it was search/replace, and I didn't
catch it when I ran through manually or when I compiled (since I hadn't enabled
svg).
Attachment #169334 - Attachment is obsolete: true
Attachment #169892 - Flags: superreview?(bzbarsky)
Attachment #169892 - Flags: review+
Attached patch patch without -w (obsolete) — Splinter Review
without -w, for your pleasure
Names starting with "a" are used for function arguments in Mozilla.... please
just name the locals "presContext".

I wouldn't bother with attaching the -w patch in this case -- it's not any
easier to review, and the without -w one is needed anyway for checkin.
Yes, I realized too late that adding both patches was just silly :)

If this passes sr, someone can just check it in at their leisure; I don't have
CVS access. You can credit me by full name and e-mail if you want to.
Attachment #169892 - Attachment is obsolete: true
Attachment #169893 - Attachment is obsolete: true
Attachment #169914 - Flags: superreview?(bzbarsky)
Attachment #169914 - Flags: review+
Comment on attachment 169914 [details] [diff] [review]
aPresContext -> presContext

sr=bzbarsky
Attachment #169914 - Flags: superreview?(bzbarsky) → superreview+
Comment on attachment 169914 [details] [diff] [review]
aPresContext -> presContext

Checked in
Ian: Thanks!

bz: Care to file a new bug about aContent/mContent with some details? Feel free
to CC me, and I'll look into providing a patch!

I'll continue with bug 244581 now, and look into removing more nsPresContext
references after that one.

Checked in by Ian -> FIXED.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
I didn't compile mathml earlier, even though bz told me to - I just forgot
about it, sorry.
Attachment #169955 - Attachment description: bustage fix for mathml → bustage fix for mathml (checked in)
Attachment #169892 - Flags: superreview?(bzbarsky)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: