Closed
Bug 1087982
Opened 11 years ago
Closed 11 years ago
Get rid of the ASCII variants of nsRenderingContext::DrawString/GetWidth
Categories
(Core :: Layout, defect)
Core
Layout
Tracking
()
RESOLVED
FIXED
mozilla36
People
(Reporter: jwatt, Assigned: jwatt)
References
Details
Attachments
(3 files)
|
939 bytes,
patch
|
jfkthame
:
review+
jwatt
:
checkin+
|
Details | Diff | Splinter Review |
|
2.52 KB,
patch
|
jfkthame
:
review+
jwatt
:
checkin+
|
Details | Diff | Splinter Review |
|
6.20 KB,
patch
|
jfkthame
:
review+
jwatt
:
checkin+
|
Details | Diff | Splinter Review |
No description provided.
| Assignee | ||
Comment 1•11 years ago
|
||
In the case of GetMaxChunkLength, after all calls we go on to deref mFontMetrics anyway. In the case of GetWidth the other GetWidth instance that it calls if mFontMetrics is null goes on to reref without checking it for null. So the null checks in this file are bogus.
Attachment #8510265 -
Flags: review?(jfkthame)
| Assignee | ||
Comment 2•11 years ago
|
||
Attachment #8510269 -
Flags: review?(jfkthame)
| Assignee | ||
Comment 3•11 years ago
|
||
We know that the single caller of these functions has a maximum string length of 16. Therefore all the length checks inherent to these nsRenderingContext methods are redundant. We can just use the nsFontMetrics object directly.
Attachment #8510270 -
Flags: review?(jfkthame)
Updated•11 years ago
|
Attachment #8510265 -
Flags: review?(jfkthame) → review+
Comment 4•11 years ago
|
||
Comment on attachment 8510269 [details] [diff] [review]
part 2 - Get rid of the pass-char-by-value variant of nsRenderingContext::GetWidth
Review of attachment 8510269 [details] [diff] [review]:
-----------------------------------------------------------------
You're on a code-removal spree, aren't you? :)
Attachment #8510269 -
Flags: review?(jfkthame) → review+
Comment 5•11 years ago
|
||
Comment on attachment 8510270 [details] [diff] [review]
part 3 - Get rid of the ASCII variants of nsRenderingContext::DrawString/GetWidth
Review of attachment 8510270 [details] [diff] [review]:
-----------------------------------------------------------------
::: layout/base/nsPresShell.cpp
@@ +10110,5 @@
> sprintf(buf, "%d", counter->mCount);
> nscoord x = 0, y = fm->MaxAscent();
> nscoord width, height = fm->MaxHeight();
> + fm->SetTextRunRTL(false);
> + width = fm->GetWidth(buf, strlen(buf), aRenderingContext);;
While you're here, how about assigning the return value of sprintf() just above to a local |len| variable, and avoiding the need to call strlen() here?
@@ +10143,2 @@
> aRenderingContext->ThebesContext()->SetColor(color);
> + fm->DrawString(buf, strlen(buf), x, y, aRenderingContext);
Then these two strlen()s will also be unnecessary.
Attachment #8510270 -
Flags: review?(jfkthame) → review+
| Assignee | ||
Comment 6•11 years ago
|
||
Comment on attachment 8510265 [details] [diff] [review]
part 1 - Get rid of the useless null checks in nsRenderingContext::GetMaxChunkLength/GetWidth
https://hg.mozilla.org/integration/mozilla-inbound/rev/5e7b73241e03
Attachment #8510265 -
Flags: checkin+
| Assignee | ||
Comment 7•11 years ago
|
||
Comment on attachment 8510269 [details] [diff] [review]
part 2 - Get rid of the pass-char-by-value variant of nsRenderingContext::GetWidth
https://hg.mozilla.org/integration/mozilla-inbound/rev/0085911c35b4
Attachment #8510269 -
Flags: checkin+
| Assignee | ||
Comment 8•11 years ago
|
||
Comment on attachment 8510270 [details] [diff] [review]
part 3 - Get rid of the ASCII variants of nsRenderingContext::DrawString/GetWidth
https://hg.mozilla.org/integration/mozilla-inbound/rev/2b6b6c03d82b
Attachment #8510270 -
Flags: checkin+
Comment 9•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/5e7b73241e03
https://hg.mozilla.org/mozilla-central/rev/0085911c35b4
https://hg.mozilla.org/mozilla-central/rev/2b6b6c03d82b
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in
before you can comment on or make changes to this bug.
Description
•