Closed Bug 1355595 Opened 5 years ago Closed 5 years ago

Simplify the default font size calculation for the spellchecker underline


(Core :: Layout, enhancement, P1)

50 Branch



Tracking Status
firefox55 --- fixed


(Reporter: jj.evelyn, Assigned: jj.evelyn)


(Blocks 2 open bugs)


(Keywords: perf, Whiteboard: [qf:p1])


(1 file)

+++ This bug was initially created as a clone of Bug #1354641 +++

From profile [1] and code [2] it shows we spend some time to calculate the thickness of the spellchecker underline when every time selectedframes is called. We might be able to calculate this value directly from PresContext instead of creating a temporary nsStyleFont object to do a bunch of expensive work.

Whiteboard: [e10s-multi:-][qf:p1] → [qf]
Blocks: 1355600
No longer blocks: 1355600
David, I saw you reviewed bug 486735 so set review request to you. Feel free to point to someone else if you are busy. Thanks!
profile after applying this patch:
Comment on attachment 8857223 [details]
Bug 1355595 - Simplify the default font size calculation;

r=dbaron with these three comments:

::: layout/generic/nsTextFrame.cpp:5805
(Diff revision 1)
> -      gfxFloat fontSize = std::min(gfxFloat(defaultFontSize),
> +      int32_t scaledFontSize = aPresContext->AppUnitsToDevPixels(
> +          defaultFontSize * aPresContext->EffectiveTextZoom());

I think it's clearer to continue using the nsStyleFont::ZoomText function here, i.e., by replacing the manual multiplication of "defaultFontSize * aPresContext->EffectiveTextZoom()" with nsStyleFont::ZoomText(aPresContext, defaultFontSize)".  (I think the rounding is different, maybe, depending on what NSToCoordTruncClamped does.  It's also clearer.)

I'd also call the resulting variable zoomedFontSize rather than scaledFontSize, since scaled could mean so many other things.

::: layout/generic/nsTextFrame.cpp:5807
(Diff revision 1)
> +      gfxFloat fontSize = std::min(gfxFloat(scaledFontSize),
>                                   aFontMetrics.emHeight);

While you're here, please line up the indentation of the two arguments to std::min(), or just fit them one one line if they fit within 80 characters.  They were probably misaligned after some previous mass-edit.
Attachment #8857223 - Flags: review?(dbaron) → review+
Pushed by
Simplify the default font size calculation; r=dbaron
Thanks for the review! David.
commend addressed and trigger auto-land on mozreview.
Assignee: nobody → ehung
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Duplicate of this bug: 1355600
Whiteboard: [qf] → [qf:p1]
You need to log in before you can comment on or make changes to this bug.