Skip to content

Commit

Permalink
Fixed some crashes in embedlite multiple view management. make test w…
Browse files Browse the repository at this point in the history
…ith VIEW_COUNT=40 reproduce 100% bug 935846
  • Loading branch information
tmeshkova committed Oct 22, 2014
1 parent 6fd383b commit 9288146
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
21 changes: 13 additions & 8 deletions dom/events/EventStateManager.cpp
Expand Up @@ -5461,15 +5461,23 @@ bool EventStateManager::Prefs::sClickHoldContextMenu = false;
int32_t EventStateManager::Prefs::sGenericAccessModifierKey = -1;
int32_t EventStateManager::Prefs::sChromeAccessModifierMask = 0;
int32_t EventStateManager::Prefs::sContentAccessModifierMask = 0;
bool EventStateManager::Prefs::sPrefsAlreadyCached = false;

// static
void
EventStateManager::Prefs::Init()
{
DebugOnly<nsresult> rv =
Preferences::AddBoolVarCache(&sKeyCausesActivation,
"accessibility.accesskeycausesactivation",
sKeyCausesActivation);
DebugOnly<nsresult> rv = Preferences::RegisterCallback(OnChange, "dom.popup_allowed_events");
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"dom.popup_allowed_events\"");

if (sPrefsAlreadyCached) {
return;
}

rv = Preferences::AddBoolVarCache(&sKeyCausesActivation,
"accessibility.accesskeycausesactivation",
sKeyCausesActivation);
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"accessibility.accesskeycausesactivation\"");
rv = Preferences::AddBoolVarCache(&sClickHoldContextMenu,
Expand All @@ -5492,10 +5500,7 @@ EventStateManager::Prefs::Init()
sContentAccessModifierMask);
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"ui.key.contentAccess\"");

rv = Preferences::RegisterCallback(OnChange, "dom.popup_allowed_events");
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"dom.popup_allowed_events\"");
sPrefsAlreadyCached = true;
}

// static
Expand Down
1 change: 1 addition & 0 deletions dom/events/EventStateManager.h
Expand Up @@ -265,6 +265,7 @@ class EventStateManager : public nsSupportsWeakReference,
static int32_t sContentAccessModifierMask;

static int32_t GetAccessModifierMask(int32_t aItemType);
static bool sPrefsAlreadyCached;
};

/**
Expand Down
Expand Up @@ -143,7 +143,7 @@ EmbedLiteCompositorParent::Invalidate()

UpdateTransformState();

if (!view->GetListener()->Invalidate()) {
if (view->GetListener() && !view->GetListener()->Invalidate()) {
mCurrentCompositeTask = NewRunnableMethod(this, &EmbedLiteCompositorParent::RenderGL);
MessageLoop::current()->PostDelayedTask(FROM_HERE, mCurrentCompositeTask, 16);
return true;
Expand Down
13 changes: 11 additions & 2 deletions embedding/embedlite/tests/embedLiteViewInitTest.cpp
Expand Up @@ -37,6 +37,8 @@ class MyListener : public EmbedLiteAppListener
printf("DoDestroyApp\n");
self->mApp->Stop();
}
static void CreateView(void* aData);

EmbedLiteApp* App() { return mApp; }

private:
Expand Down Expand Up @@ -117,16 +119,23 @@ class MyViewListener : public EmbedLiteViewListener
EmbedLiteView* mView;
};

void MyListener::CreateView(void* aData)
{
MyListener* self = static_cast<MyListener*>(aData);
self->viewListeners.push_back(new MyViewListener(self));
}

void MyListener::Initialized()
{
printf("Embedding initialized, let's make view");

int defaultViewCount = 2;
const char* viewsCount = getenv("VIEW_COUNT");
static const char* viewsCount = getenv("VIEW_COUNT");
if (viewsCount != nullptr) {
defaultViewCount = atoi(viewsCount);
}
for (int i = 0; i < defaultViewCount; ++i) {
viewListeners.push_back(new MyViewListener(this));
mApp->PostTask(&MyListener::CreateView, this, 500);
}
}

Expand Down

0 comments on commit 9288146

Please sign in to comment.