Closed Bug 1506439 Opened 7 years ago Closed 7 years ago

Cannot set ref-countable argument to nullptr if the method is marked as MOZ_CAN_RUN_SCRIPT

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(firefox67 fixed)

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: masayuki, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

If there is like this method in nsContentUtils: MOZ_CAN_RUN_SCRIPT static void DoSomething(TextEditor* aTextEditor = nullptr); Then, nsContentUtils::DoSomething(); becomes bustage due to: > error: arguments must all be strong refs or parent parameters when calling a function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object argument) Here is an example: https://treeherder.mozilla.org/#/jobs?repo=try&selectedJob=210861923&revision=d07307d5ff5be5d35dfd3b2df9d80bde47c36a71 > [task 2018-11-09T17:43:11.531Z] 17:43:11 INFO - /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:259:19: error: arguments must all be strong refs or parent parameters when calling a function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object argument) > [task 2018-11-09T17:43:11.531Z] 17:43:11 INFO - nsresult rv = nsContentUtils::DispatchInputEvent(inputElement); > [task 2018-11-09T17:43:11.531Z] 17:43:11 INFO - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ And this is fixed by doing: RefPtr<TextEditor> textEditor; nsContentUtils::DoSomething(textEditor); https://treeherder.mozilla.org/#/jobs?repo=try&selectedJob=210861923&revision=13feb0dd4081f578f811ca9a99e43081ffc6940b
Summary: Cannot set nullptr to ref-countable argument if the method is marked as MOZ_CAN_RUN_SCRIPT → Cannot set ref-countable argument to nullptr if the method is marked as MOZ_CAN_RUN_SCRIPT

Masayuki, how did you intend to write nsContentUtils::DispatchInputEvent once this is fixed? Is the idea to do:

  MOZ_CAN_RUN_SCRIPT
  static nsresult DispatchInputEvent(Element* aEventTarget) {
    return DispatchInputEvent(aEventTarget, mozilla::EditorInputType::eUnknown,
                              nullptr, InputEventOptions());
  }

(which I think can be done without this fix too)? Or to actually use a default arg? Back when this bug was filed we didn't have the EditorInputType and InputEventOptions args, looks like...

Flags: needinfo?(masayuki)

I think that the overload should be used when there is no TextEditor instance. So, your code example looks fine to me.

Flags: needinfo?(masayuki)
Attachment #9050169 - Attachment description: Bug 1506439. Fix CanRunScript analysis handling of arguments that default to null. r=andi → Bug 1506439 part 1. Fix CanRunScript analysis handling of arguments that default to null. r=andi
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9b6190dc000d part 1. Fix CanRunScript analysis handling of arguments that default to null. r=andi https://hg.mozilla.org/integration/autoland/rev/fcaf6f3d0497 part 2. Stop creating a useless nsCOMPtr in DispatchInputEvent. r=masayuki
Assignee: nobody → bzbarsky
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: