Closed Bug 197205 Opened 22 years ago Closed 21 years ago

remove null checks from GetStyleData callers

Categories

(Core :: CSS Parsing and Computation, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.5alpha

People

(Reporter: dbaron, Assigned: dbaron)

References

Details

(Whiteboard: [patch])

Attachments

(2 files, 1 obsolete file)

Now that bug 154751 has landed, we should remove all the null-checks after calls
to GetStyleData.

(It also might be worth converting to the templatized form, although I should
probably double-check that that doesn't change codesize.)
Depends on: 154751
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.4beta
I think whoever does this should get r+sr-in-advance and then just go do it.
Target Milestone: mozilla1.4beta → mozilla1.5beta
Attached file patch (obsolete) (deleted) —
This patch removes the null checks and also converts all callers to use the
typesafe template.  It modifies the template so that it works with nsRefPtr. 
It also changes the return type of nsIFrame::GetStyleData so that the result is
returned instead of being an out parameter.
Attachment #122808 - Flags: superreview?(roc+moz)
Attachment #122808 - Flags: review?(roc+moz)
Target Milestone: mozilla1.5beta → mozilla1.4final
Comment on attachment 122808 [details]
patch

In this patch, there are nontrivial changes in nsStyleContext.h,
nsIFrame.h, and nsFrame.{h,cpp}.

I also cleaned up the SVG stuff in nsRuleNode.{h,cpp} -- I commented the
struct in nsRuleNode.h in the style of other structs, and I applied the
fix to bug 111815 to ComputeSVGData in nsRuleNode.cpp.

Pretty much everything else was conversion to the templatized forms and
removal of null checks.
Oh, there were also some places where I removed |.get()| from the end of the
first parameter to the function template |GetStyleData| (no longer needed with
this patch) or added |::| to the beginning of the call (good style everywhere,
since it's needed within nsIFrame implementations).
I should have said this before you did all this work, but ...

Since we're trying to get away from unnecessary out parameters, why not have a
family of methods
template <class Source> const nsStyleBorder* GetBorderStyle(const Source& source);
template <class Source> const nsStylePadding* GetPaddingStyle(const Source& source);
etc?
If we went that way, I'd rather they were just methods on nsIFrame and
nsStyleContext (since there's no need for template type deduction).  I might
rather they be:

  const nsStyleBorder* StyleBorder() { return [...]; }

etc.

It's a little less general, but I guess I do prefer it.  Maybe I'll do another
pass over the tree.  But first, what do others think of the idea?
Target Milestone: mozilla1.4final → mozilla1.5alpha
(It's worth noting that with the current code at least some compilers will
optimize away the performance cost of having an out parameter rather than a
return value.  However, I think I like the syntax I propose in my previous
comment better.)
Yes, it's only a syntactic issue, not a performance issue.

I would slightly prefer the "GetBorderStyle()" naming scheme.
And generate the function signatures using preprocessing?  Sure, that
could work....  We could also template GetStyleData on the return type,
no?  (That will mean simpler changes to callers, I guess; not sure whether
I prefer it to having names like GetBorderStyle or whatever).
> We could also template GetStyleData on the return type

No, you can't do that.

> And generate the function signatures using preprocessing?

We could, although we're not talking about much code.
Attached file patch (deleted) —
This implements what is described above -- inline methods on nsIFrame and
nsStyleContext called GetStyleBorder, GetStyleColor, etc.  Otherwise it's
pretty similar to the previous patch, although there was an additional spot or
two where I couldn't resist a little cleanup.
Attachment #122808 - Attachment is obsolete: true
Whiteboard: [patch]
Comment on attachment 122808 [details]
patch

wonderful. r+sr=roc+moz
Attachment #122808 - Flags: superreview?(roc+moz)
Attachment #122808 - Flags: superreview+
Attachment #122808 - Flags: review?(roc+moz)
Attachment #122808 - Flags: review+
Comment on attachment 123099 [details]
patch

This is relatively low-risk (and I'll double-check it again before I land), and
I think it's worth landing before we branch to make it easier to move things
back and forth between branch and trunk after we branch.

(I assume roc noted r+sr on the wrong attachment.)
Attachment #123099 - Flags: approval1.4?
woops, yeah, I meant to r+sr the latest patch
Comment on attachment 123099 [details]
patch

a=brendan@mozilla.org for 1.4final.

/be
Attachment #123099 - Flags: approval1.4? → approval1.4+
Fix checked in to trunk, 2003-05-14 20:42 PDT.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Attachment #167802 - Flags: superreview?(roc)
Attachment #167802 - Flags: review?(roc)
Attachment #167802 - Flags: superreview?(roc)
Attachment #167802 - Flags: superreview+
Attachment #167802 - Flags: review?(roc)
Attachment #167802 - Flags: review+
Attachment #167802 - Attachment description: clean up callers of old api that have crept back in → clean up callers of old api that have crept back in (checked in 2004-12-03 22:31 -0800)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: