Closed Bug 1349462 Opened 7 years ago Closed 7 years ago

Rename nsIFrame::IsSVGText() to nsSVGUtils::IsInSVGTextSubtree()

Categories

(Core :: SVG, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: u459114, Assigned: u459114)

Details

Attachments

(2 files)

nsIFrame::IsSVGText() return true if this object is an SVG text object or a descendant of an SVG test object. Function name is kind of misleading.
Seems fine as is is to me FWIW, have you checked with cam?
(In reply to Robert Longson from comment #1)
> Seems fine as is is to me FWIW, have you checked with cam?

Yes, I discussed with him several weeks ago.
I think the current name does kind of sound like "is this an SVGTextFrame", rather than "is this a frame that implements SVG text", which would include the descendant nsBlockFrames/nsInlineFrames.

Since the SVGTextFrame itself also has this bit set, I don't think "IsDescendantOfSVGText" is quite right.  (If anything, it would need to be "IsSVGTextOrDescendant".)

Maybe "IsInSVGTextSubtree" (to mirror things like IsInNativeAnonymousSubtree)?
An alternative would be just to document the IsSVGText method in nsIFrame.h.  (Also it looks like the comment above the NS_FRAME_IS_SVG_TEXT definition in nsFrameStateBits.h is wrong, since it also says "descendant" when it should include the SVGTextFrame itself, too.)
How about we move this util function to nsSVGUtil? Define an SVG specific function in nsIFrame is a little bit weird.
For example:
bool nsSVGUtil::IsInSVGTextSubtree(nsIFrame* aFrame)
{
  return aFrame->GetStateBits() & NS_FRAME_IS_SVG_TEXT;
}
bool nsSVGUtil::HasSVGLayout(nsIFrame* aFrame)
{
  return aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT;
}
(In reply to Cameron McCormack (:heycam) from comment #3)
> Maybe "IsInSVGTextSubtree"

Gets my vote.

I'd also have a slight preference for putting these on nsSVGUtils.
Assignee: nobody → cku
FWIW there are other access methods on nsIFrame that just check state bits (e.g. IsGeneratedContentFrame, IsXULHorizontal, IsAbsoluteContainer), so it seems fine to me to stay there.  But I don't mind if it's on nsSVGUtils either.
IsGeneratedContentFrame and IsAbsoluteContainer is ok for me. If we have nsXULUtil, I would like to move IsXULHorizontal there.
Attachment #8850409 - Flags: review?(mstange)
Attachment #8850409 - Flags: review?(mstange) → review?(cam)
Comment on attachment 8850409 [details]
Bug 1349462 - Part 1. Rename IsSVGText as IsInSVGTextSubtree.

https://reviewboard.mozilla.org/r/123006/#review125270

::: layout/svg/nsSVGUtils.h:613
(Diff revision 1)
> +  static bool
> +  IsInSVGTextSubtree(const nsIFrame* aFrame) {
> +    return aFrame->GetStateBits() & NS_FRAME_IS_SVG_TEXT;
> +  }

Nit: one line for |static bool IsInSVGTextSubtree(...) {|.  (The few functions above here have the wrong style, for declarations inside a class.)

Also, please add a comment describing what this does (i.e., returns true if the frame is an SVGTextFrame or one of its descendants).
Attachment #8850409 - Flags: review?(cam) → review+
Attachment #8850445 - Flags: review?(cku)
Comment on attachment 8850445 [details]
Bug 1349462 - Part 2. one line for static function.

https://reviewboard.mozilla.org/r/123038/#review125298
Attachment #8850445 - Flags: review?(cku) → review+
Comment on attachment 8850445 [details]
Bug 1349462 - Part 2. one line for static function.

https://reviewboard.mozilla.org/r/123038/#review125294

::: layout/svg/nsSVGUtils.h:367
(Diff revision 1)
> -  GetClipRectForFrame(nsIFrame *aFrame,
> -                      float aX, float aY, float aWidth, float aHeight);
> +                                     float aX, float aY, float aWidth,
> +                                     float aHeight);

Since you're having to wrap aHeight here, I'd put aWidth on the same line, but maybe that's just me. ;)
Attachment #8850445 - Flags: review+
Summary: Rename nsIFrame::IsSVGText() to IsDescendantOfSVGText() → Rename nsIFrame::IsSVGText() to nsSVGUtils::IsInSVGTextSubtree()
Attachment #8850445 - Flags: review?(cam)
Attachment #8850445 - Flags: review?(cam)
Pushed by cku@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f9222bab527d
Part 1. Rename IsSVGText as IsInSVGTextSubtree. r=heycam
https://hg.mozilla.org/integration/autoland/rev/821005b8d9fa
Part 2. one line for static function. r=jwatt
(In reply to Pulsebot from comment #15)
> https://hg.mozilla.org/integration/autoland/rev/821005b8d9fa
> Part 2. one line for static function. r=jwatt

Hmm, I forgot to review the commit message. It's useful to think of commit messages from the point of view of someone looking at *all* commits landing in the tree and asking yourself if this message is useful for them. Something like "Reformat nsSVGUtils' methods to conform to the style guidelines" would have been much more useful I think. :) Sorry for not catching that.
https://hg.mozilla.org/mozilla-central/rev/f9222bab527d
https://hg.mozilla.org/mozilla-central/rev/821005b8d9fa
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: