Bug 1455514 - part 1: Add accessors and static helper methods to retrieve nsINode or its concrete classes from EventTarget r=smaug
Currently, checking whether an `EventTarget` is `nsINode` (or its concrete classes) or not requires a QI, but it's expensive and used a lot while we handle each event. Therefore, it'd be nicer for creating a virtual method, `EventTarget::IsNode()` and use it for the check. If trying to convert `EventTarget` to a concrete class, it may require two virtual method calls. I'm not sure whether it's cheaper than a QI, but at least, it won't depend on the UUID check order of `QueryInterface()` when multiple interfaces are implemented. Differential Revision: https://phabricator.services.mozilla.com/D129781
This commit is contained in:
@@ -4625,9 +4625,6 @@ void HTMLMediaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
return;
|
||||
}
|
||||
|
||||
HTMLInputElement* el = nullptr;
|
||||
nsCOMPtr<nsINode> node;
|
||||
|
||||
// We will need to trap pointer, touch, and mouse events within the media
|
||||
// element, allowing media control exclusive consumption on these events,
|
||||
// and preventing the content from handling them.
|
||||
@@ -4649,12 +4646,17 @@ void HTMLMediaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
// The *move events however are only comsumed when the range input is being
|
||||
// dragged.
|
||||
case ePointerMove:
|
||||
case eMouseMove:
|
||||
node = do_QueryInterface(aVisitor.mEvent->mOriginalTarget);
|
||||
case eMouseMove: {
|
||||
nsINode* node =
|
||||
nsINode::FromEventTargetOrNull(aVisitor.mEvent->mOriginalTarget);
|
||||
if (MOZ_UNLIKELY(!node)) {
|
||||
return;
|
||||
}
|
||||
HTMLInputElement* el = nullptr;
|
||||
if (node->IsInNativeAnonymousSubtree() || node->IsInUAWidget()) {
|
||||
if (node->IsHTMLElement(nsGkAtoms::input)) {
|
||||
// The node is a <input type="range">
|
||||
el = static_cast<HTMLInputElement*>(node.get());
|
||||
el = static_cast<HTMLInputElement*>(node);
|
||||
} else if (node->GetParentNode() &&
|
||||
node->GetParentNode()->IsHTMLElement(nsGkAtoms::input)) {
|
||||
// The node is a child of <input type="range">
|
||||
@@ -4667,7 +4669,7 @@ void HTMLMediaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
}
|
||||
nsGenericHTMLElement::GetEventTargetParent(aVisitor);
|
||||
return;
|
||||
|
||||
}
|
||||
default:
|
||||
nsGenericHTMLElement::GetEventTargetParent(aVisitor);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user