- if (tooltipNode->GetComposedDoc() &&
- nsContentUtils::IsChromeDoc(tooltipNode->GetComposedDoc())) {
+ // Make sure the document still has focus.
+ auto* doc = tooltipNode->GetComposedDoc();
+ if (!doc || !nsContentUtils::IsChromeDoc(doc) ||
+ !doc->HasFocus(IgnoreErrors())) {
+ return NS_OK;
+ }
...
- }
}
return NS_OK;
If I see correctly, all the changes are:1) remembering result of tooltipNode->GetComposedDoc() and adding the test of doc->HasFocus(IgnoreErrors()). Note that writing this one now is maybe easier than it was at the time the initial code was written, it could be the "auto" in this current semantic didn't exist in C++ (or the used compilers/platforms) at that time.
2) Explicit return. Instead of:
if (b)
X;
return OK;
now it's: if (!b)
return OK;
X;
return OK;
which in this case increases readability as X is in many lines and b is a more complex condition.