Bug 1200303 - Support meta-viewport changes in ZoomConstraintsClient as well. r=miketaylr
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 01 Sep 2015 14:04:56 -0400
changeset 260331 bccb519d4c080f00d38ebdf7e5f547ba007d7201
parent 260330 68a1e024ad6a069cad5243335a012e46d26ac6f1
child 260332 40194ca337859b8979559b85cf5fcf9815a25e22
push id64473
push userkgupta@mozilla.com
push dateTue, 01 Sep 2015 18:05:15 +0000
treeherdermozilla-inbound@40194ca33785 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiketaylr
bugs1200303
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1200303 - Support meta-viewport changes in ZoomConstraintsClient as well. r=miketaylr
layout/base/ZoomConstraintsClient.cpp
--- a/layout/base/ZoomConstraintsClient.cpp
+++ b/layout/base/ZoomConstraintsClient.cpp
@@ -20,16 +20,17 @@
 #include "UnitTransforms.h"
 
 #define ZCC_LOG(...)
 // #define ZCC_LOG(...) printf_stderr("ZCC: " __VA_ARGS__)
 
 NS_IMPL_ISUPPORTS(ZoomConstraintsClient, nsIDOMEventListener, nsIObserver)
 
 static const nsLiteralString DOM_META_ADDED = NS_LITERAL_STRING("DOMMetaAdded");
+static const nsLiteralString DOM_META_CHANGED = NS_LITERAL_STRING("DOMMetaChanged");
 static const nsLiteralCString BEFORE_FIRST_PAINT = NS_LITERAL_CSTRING("before-first-paint");
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
 ZoomConstraintsClient::ZoomConstraintsClient() :
   mDocument(nullptr),
   mPresShell(nullptr)
@@ -61,16 +62,17 @@ ZoomConstraintsClient::Destroy()
   if (!(mPresShell && mDocument)) {
     return;
   }
 
   ZCC_LOG("Destroying %p\n", this);
 
   if (mEventTarget) {
     mEventTarget->RemoveEventListener(DOM_META_ADDED, this, false);
+    mEventTarget->RemoveEventListener(DOM_META_CHANGED, this, false);
     mEventTarget = nullptr;
   }
 
   nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
   if (observerService) {
     observerService->RemoveObserver(this, BEFORE_FIRST_PAINT.Data());
   }
 
@@ -97,16 +99,17 @@ ZoomConstraintsClient::Init(nsIPresShell
   mPresShell = aPresShell;
   mDocument = aDocument;
 
   if (nsCOMPtr<nsPIDOMWindow> window = mDocument->GetWindow()) {
     mEventTarget = window->GetChromeEventHandler();
   }
   if (mEventTarget) {
     mEventTarget->AddEventListener(DOM_META_ADDED, this, false);
+    mEventTarget->AddEventListener(DOM_META_CHANGED, this, false);
   }
 
   nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
   if (observerService) {
     observerService->AddObserver(this, BEFORE_FIRST_PAINT.Data(), false);
   }
 }
 
@@ -114,17 +117,21 @@ NS_IMETHODIMP
 ZoomConstraintsClient::HandleEvent(nsIDOMEvent* event)
 {
   nsAutoString type;
   event->GetType(type);
 
   if (type.Equals(DOM_META_ADDED)) {
     ZCC_LOG("Got a dom-meta-added event in %p\n", this);
     RefreshZoomConstraints();
+  } else if (type.Equals(DOM_META_CHANGED)) {
+    ZCC_LOG("Got a dom-meta-changed event in %p\n", this);
+    RefreshZoomConstraints();
   }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ZoomConstraintsClient::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
 {
   if (SameCOMIdentity(aSubject, mDocument) && BEFORE_FIRST_PAINT.EqualsASCII(aTopic)) {
     ZCC_LOG("Got a before-first-paint event in %p\n", this);