Open Bug 1323794 Opened 7 years ago Updated 2 years ago

rename nsPresContext::Document() to nsPresContext::GetDocument() since it may return null

Categories

(Core :: Layout, defect, P3)

50 Branch
defect

Tracking

()

People

(Reporter: smaug, Unassigned)

Details

Attachments

(3 files)

In Gecko methods which may possibly return null have traditionally had Get* prefix.
For some reason nsPresContext::Document() doesn't have.
Priority: -- → P3
HEY!!! I am a newbie. Can I work on this bug.
Feel free to. I can review the patch.
Attachment #8941846 - Flags: review?(bugs)
(In reply to dvabhinav31@gmail.com from comment #3)
> Created attachment 8941846 [details] [diff] [review]
> bug-1323794-v1.patch

That only contains the changes to one file? I'm pretty sure there are many more callers.

Given this can only return null during disconnect, which I think most of the code doesn't care about, I'd prefer a function that asserted when called instead, but not sure...
(Renaming to GetDocument() is fine I guess. I'm just saying that given it's ok for most of the code to not null-check it, feels weird). Anyway, not a huge deal.
IIRC, long ago we had some crashes because the method did in fact return null but callers didn't expect that (since the name hints that it doesn't return null).
Comment on attachment 8941846 [details] [diff] [review]
bug-1323794-v1.patch

Yeah, the method is called everywhere
https://searchfox.org/mozilla-central/search?q=symbol:_ZNK13nsPresContext8DocumentEv&redirect=false

Please compile the patch before uploading.
Attachment #8941846 - Flags: review?(bugs) → review-
Attachment #8942423 - Flags: review?(bugs)
Comment on attachment 8942423 [details] [diff] [review]
bug-1323794-v2.patch

You need to change all the callers in the tree too, and ensure the patch compiles.
Attachment #8942423 - Flags: review?(bugs) → review-
I have searched for files and was able to find a few.
Is there a way I can find all the files at once?
Attachment #8947437 - Flags: review?(bugs)
Comment on attachment 8947437 [details] [diff] [review]
bug-1323794.patch

>@@ -2225,7 +2225,7 @@ nsStyleImageRequest::Resolve(nsPresConte
>   }
> 
>   if (mModeFlags & Mode::Track) {
>-    mImageTracker = aPresContext->Document()->ImageTracker();
>+    mImageTracker = aPresContext-GetDocument()->ImageTracker();

This for example doesn't compile. Please provide patches which do compile.
Attachment #8947437 - Flags: review?(bugs) → review-
sorry. I will take care.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: