Skip to content

Commit

Permalink
[embedlite] Guard PreRender with visibility and active state. Fixes J…
Browse files Browse the repository at this point in the history
…B#32879

In case pupper widget is invisible or inactive there is
no need to check rendering status from the owner window. If
the pupper widget is invisible or inactive, LayerManagerComposite
should not render.

When a embedlite view is created set the widget of the window
as active. Similarly active state of the view's widget is updated
when active state changes even thou that doesn't do anything meaningful
at the moment.

Reason for adding active for puppet widget is that visibility
of the puppet widget is overloaded. Furthermore, this makes
controlling of rendering easier.
  • Loading branch information
rainemak committed Nov 4, 2015
1 parent 3404573 commit 8ccfa0b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.cpp
Expand Up @@ -86,6 +86,7 @@ EmbedLitePuppetWidget::EmbedLitePuppetWidget(EmbedLiteWindowBaseChild* window,
, mView(view)
, mVisible(false)
, mEnabled(false)
, mActive(false)
, mHasCompositor(false)
, mIMEComposing(false)
, mParent(nullptr)
Expand Down Expand Up @@ -187,6 +188,11 @@ EmbedLitePuppetWidget::UpdateSize()
#endif
}

void EmbedLitePuppetWidget::SetActive(bool active)
{
mActive = active;
}

NS_IMETHODIMP
EmbedLitePuppetWidget::Create(nsIWidget* aParent,
nsNativeWidget aNativeParent,
Expand Down Expand Up @@ -769,6 +775,10 @@ bool
EmbedLitePuppetWidget::PreRender(LayerManagerComposite *aManager)
{
MOZ_ASSERT(mWindow);
if (!IsVisible() || !mActive) {
return false;
}

EmbedLiteWindow* window = EmbedLiteApp::GetInstance()->GetWindowByID(mWindow->GetUniqueID());
if (window) {
return window->GetListener()->PreRender();
Expand Down
2 changes: 2 additions & 0 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.h
Expand Up @@ -179,6 +179,7 @@ class EmbedLitePuppetWidget : public nsBaseWidget
void SetRotation(mozilla::ScreenRotation);
void SetMargins(const nsIntMargin& marins);
void UpdateSize();
void SetActive(bool active);

void AddObserver(EmbedLitePuppetWidgetObserver*);
void RemoveObserver(EmbedLitePuppetWidgetObserver*);
Expand Down Expand Up @@ -208,6 +209,7 @@ class EmbedLitePuppetWidget : public nsBaseWidget

bool mVisible;
bool mEnabled;
bool mActive;
bool mHasCompositor;
InputContext mInputContext;
bool mIMEComposing;
Expand Down
13 changes: 13 additions & 0 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseChild.cpp
Expand Up @@ -277,6 +277,13 @@ EmbedLiteViewBaseChild::InitGeckoWindow(const uint32_t& parentId, const bool& is
widget->UpdateSize();
}

static bool firstViewCreated = false;
EmbedLiteWindowBaseChild *windowBase = static_cast<EmbedLiteWindowBaseChild*>(mWindow);
if (!firstViewCreated && windowBase && windowBase->GetWidget()) {
windowBase->GetWidget()->SetActive(true);
firstViewCreated = true;
}

OnGeckoWindowInitialized();

unused << SendInitialized();
Expand Down Expand Up @@ -507,6 +514,12 @@ EmbedLiteViewBaseChild::RecvSetIsActive(const bool& aIsActive)
fm->WindowLowered(mDOMWindow);
LOGT("Deactivate browser");
}

EmbedLitePuppetWidget* widget = static_cast<EmbedLitePuppetWidget*>(mWidget.get());
if (widget) {
widget->SetActive(aIsActive);
}

mWebBrowser->SetIsActive(aIsActive);
mWidget->Show(aIsActive);

Expand Down

0 comments on commit 8ccfa0b

Please sign in to comment.