Skip to content

Commit

Permalink
Bug 986359 part 2 - Factor out GetTransaction in DOMWindowUtils; r=ma…
Browse files Browse the repository at this point in the history
…ttwoodrow
  • Loading branch information
birtles committed Mar 21, 2014
1 parent 89108ce commit 277ad86
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
42 changes: 23 additions & 19 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ nsDOMWindowUtils::GetDocument()
return window->GetExtantDoc();
}

LayerTransactionChild*
nsDOMWindowUtils::GetLayerTransaction()
{
nsIWidget* widget = GetWidget();
if (!widget)
return nullptr;

LayerManager* manager = widget->GetLayerManager();
if (!manager)
return nullptr;

ShadowLayerForwarder* forwarder = manager->AsShadowForwarder();
return forwarder && forwarder->HasShadowManager() ?
forwarder->GetShadowManager() :
nullptr;
}

NS_IMETHODIMP
nsDOMWindowUtils::GetImageAnimationMode(uint16_t *aMode)
{
Expand Down Expand Up @@ -2552,16 +2569,9 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(int64_t aMilliseconds)
nsRefreshDriver* driver = GetPresContext()->RefreshDriver();
driver->AdvanceTimeAndRefresh(aMilliseconds);

nsIWidget* widget = GetWidget();
if (widget) {
LayerManager* manager = widget->GetLayerManager();
if (manager) {
ShadowLayerForwarder* forwarder = manager->AsShadowForwarder();
if (forwarder && forwarder->HasShadowManager()) {
forwarder->GetShadowManager()->SendSetTestSampleTime(
driver->MostRecentRefresh());
}
}
LayerTransactionChild* transaction = GetLayerTransaction();
if (transaction) {
transaction->SendSetTestSampleTime(driver->MostRecentRefresh());
}

return NS_OK;
Expand All @@ -2577,15 +2587,9 @@ nsDOMWindowUtils::RestoreNormalRefresh()
// Kick the compositor out of test mode before the refresh driver, so that
// the refresh driver doesn't send an update that gets ignored by the
// compositor.
nsIWidget* widget = GetWidget();
if (widget) {
LayerManager* manager = widget->GetLayerManager();
if (manager) {
ShadowLayerForwarder* forwarder = manager->AsShadowForwarder();
if (forwarder && forwarder->HasShadowManager()) {
forwarder->GetShadowManager()->SendLeaveTestMode();
}
}
LayerTransactionChild* transaction = GetLayerTransaction();
if (transaction) {
transaction->SendLeaveTestMode();
}

nsRefreshDriver* driver = GetPresContext()->RefreshDriver();
Expand Down
7 changes: 7 additions & 0 deletions dom/base/nsDOMWindowUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class nsPresContext;
class nsPoint;
class nsIDocument;

namespace mozilla {
namespace layers {
class LayerTransactionChild;
}
}

class nsDOMWindowUtils MOZ_FINAL : public nsIDOMWindowUtils,
public nsSupportsWeakReference
{
Expand All @@ -41,6 +47,7 @@ class nsDOMWindowUtils MOZ_FINAL : public nsIDOMWindowUtils,
nsIPresShell* GetPresShell();
nsPresContext* GetPresContext();
nsIDocument* GetDocument();
mozilla::layers::LayerTransactionChild* GetLayerTransaction();

NS_IMETHOD SendMouseEventCommon(const nsAString& aType,
float aX,
Expand Down

0 comments on commit 277ad86

Please sign in to comment.