Bug 1210057. Schedule a paint when an apz aware event listener is added so that event regions on the layer tree get updated. r=smaug

This commit is contained in:
Timothy Nikkel 2016-02-10 17:47:59 -06:00
parent 7f52ab42ea
commit 144bb37d6e
2 changed files with 42 additions and 4 deletions

View File

@ -48,6 +48,7 @@
#include "nsPIDOMWindow.h"
#include "nsSandboxFlags.h"
#include "xpcpublic.h"
#include "nsIFrame.h"
namespace mozilla {
@ -416,10 +417,7 @@ EventListenerManager::AddEventListenerInternal(
}
if (IsApzAwareEvent(aTypeAtom)) {
nsCOMPtr<nsINode> node = do_QueryInterface(mTarget);
if (node) {
node->SetMayHaveApzAwareListeners();
}
ProcessApzAwareEventListenerAdd();
}
if (aTypeAtom && mTarget) {
@ -432,6 +430,44 @@ EventListenerManager::AddEventListenerInternal(
}
}
void
EventListenerManager::ProcessApzAwareEventListenerAdd()
{
// Mark the node as having apz aware listeners
nsCOMPtr<nsINode> node = do_QueryInterface(mTarget);
if (node) {
node->SetMayHaveApzAwareListeners();
}
// Schedule a paint so event regions on the layer tree gets updated
nsIDocument* doc = nullptr;
if (node) {
doc = node->OwnerDoc();
}
if (!doc) {
if (nsCOMPtr<nsPIDOMWindowInner> window = GetTargetAsInnerWindow()) {
doc = window->GetExtantDoc();
}
}
if (!doc) {
if (nsCOMPtr<DOMEventTargetHelper> helper = do_QueryInterface(mTarget)) {
if (nsPIDOMWindowInner* window = helper->GetOwner()) {
doc = window->GetExtantDoc();
}
}
}
if (doc) {
nsIPresShell* ps = doc->GetShell();
if (ps) {
nsIFrame* f = ps->GetRootFrame();
if (f) {
f->SchedulePaint();
}
}
}
}
bool
EventListenerManager::IsDeviceType(EventMessage aEventMessage)
{

View File

@ -467,6 +467,8 @@ protected:
nsIDocShell* GetDocShellForTarget();
void ProcessApzAwareEventListenerAdd();
/**
* Compile the "inline" event listener for aListener. The
* body of the listener can be provided in aBody; if this is null we