`nsIFormControl` has utility methods to avoid QI from `nsINode*` or `EventTarget*`

78 views
Skip to first unread message

Masayuki Nakano

unread,
Jul 11, 2024, 12:30:19 AMJul 11
to dev-pl...@mozilla.org

Hello,

The fix of bug 1906015 introduced `nsIFormControl::FromNode`, `nsIFormControl::FromNodeOrNull`, `nsIFormControl::FromEventTarget` and `nsIFormControl::FromEventTargetOrNull`.  Therefore, you don't need to do like this:

const nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aNode->GetFirstChild());

Instead, you can do:

nsIFormControl* const formControl = nsIFormControl::FromNodeOrNull(aNode->GetFirstChild());

The utilities are faster and make you free from using strong pointer.

-- 
Masayuki Nakano <masa...@d-toybox.com>
Working on DOM, Events, editor and IME handling for Gecko
Reply all
Reply to author
Forward
0 new messages