Bug 1042959 - Ensure that we always use the actual old screen size in HandlePossibleViewportChange. r=botond

This commit is contained in:
Kartikaya Gupta 2014-08-06 12:41:05 -04:00
Родитель aaced0d806
Коммит ff97ac7749
2 изменённых файлов: 20 добавлений и 8 удалений

Просмотреть файл

@ -78,6 +78,7 @@
#include "mozilla/gfx/Matrix.h" #include "mozilla/gfx/Matrix.h"
#include "UnitTransforms.h" #include "UnitTransforms.h"
#include "ClientLayerManager.h" #include "ClientLayerManager.h"
#include "LayersLogging.h"
#include "nsColorPickerProxy.h" #include "nsColorPickerProxy.h"
@ -88,6 +89,9 @@
#define BROWSER_ELEMENT_CHILD_SCRIPT \ #define BROWSER_ELEMENT_CHILD_SCRIPT \
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
#define TABC_LOG(...)
// #define TABC_LOG(...) printf_stderr("TABC: " __VA_ARGS__)
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::dom::ipc; using namespace mozilla::dom::ipc;
@ -174,12 +178,16 @@ TabChildBase::InitializeRootMetrics()
// as the resolution. // as the resolution.
mLastRootMetrics.mResolution = mLastRootMetrics.mCumulativeResolution / LayoutDeviceToParentLayerScale(1); mLastRootMetrics.mResolution = mLastRootMetrics.mCumulativeResolution / LayoutDeviceToParentLayerScale(1);
mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0)); mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0));
TABC_LOG("After InitializeRootMetrics, mLastRootMetrics is %s\n",
Stringify(mLastRootMetrics).c_str());
} }
void void
TabChildBase::SetCSSViewport(const CSSSize& aSize) TabChildBase::SetCSSViewport(const CSSSize& aSize)
{ {
mOldViewportSize = aSize; mOldViewportSize = aSize;
TABC_LOG("Setting CSS viewport to %s\n", Stringify(aSize).c_str());
if (mContentDocumentIsDisplayed) { if (mContentDocumentIsDisplayed) {
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils()); nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
@ -213,12 +221,15 @@ TabChildBase::GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewp
} }
bool bool
TabChildBase::HandlePossibleViewportChange() TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize)
{ {
if (!IsAsyncPanZoomEnabled()) { if (!IsAsyncPanZoomEnabled()) {
return false; return false;
} }
TABC_LOG("HandlePossibleViewportChange aOldScreenSize=%s mInnerSize=%s\n",
Stringify(aOldScreenSize).c_str(), Stringify(mInnerSize).c_str());
nsCOMPtr<nsIDocument> document(GetDocument()); nsCOMPtr<nsIDocument> document(GetDocument());
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils()); nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
@ -249,6 +260,8 @@ TabChildBase::HandlePossibleViewportChange()
return false; return false;
} }
TABC_LOG("HandlePossibleViewportChange mOldViewportSize=%s viewport=%s\n",
Stringify(mOldViewportSize).c_str(), Stringify(viewport).c_str());
CSSSize oldBrowserSize = mOldViewportSize; CSSSize oldBrowserSize = mOldViewportSize;
mLastRootMetrics.mViewport.SizeTo(viewport); mLastRootMetrics.mViewport.SizeTo(viewport);
if (oldBrowserSize == CSSSize()) { if (oldBrowserSize == CSSSize()) {
@ -269,9 +282,7 @@ TabChildBase::HandlePossibleViewportChange()
return false; return false;
} }
ScreenIntSize oldScreenSize = ViewAs<ScreenPixel>( ScreenIntSize oldScreenSize = aOldScreenSize;
RoundedToInt(mLastRootMetrics.mCompositionBounds).Size(),
PixelCastJustification::ScreenToParentLayerForRoot);
if (oldScreenSize == ScreenIntSize()) { if (oldScreenSize == ScreenIntSize()) {
oldScreenSize = mInnerSize; oldScreenSize = mInnerSize;
} }
@ -748,7 +759,7 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent)
if (eventType.EqualsLiteral("DOMMetaAdded")) { if (eventType.EqualsLiteral("DOMMetaAdded")) {
// This meta data may or may not have been a meta viewport tag. If it was, // This meta data may or may not have been a meta viewport tag. If it was,
// we should handle it immediately. // we should handle it immediately.
HandlePossibleViewportChange(); HandlePossibleViewportChange(mInnerSize);
} }
return NS_OK; return NS_OK;
@ -799,7 +810,7 @@ TabChild::Observe(nsISupports *aSubject,
InitializeRootMetrics(); InitializeRootMetrics();
utils->SetResolution(mLastRootMetrics.mResolution.scale, utils->SetResolution(mLastRootMetrics.mResolution.scale,
mLastRootMetrics.mResolution.scale); mLastRootMetrics.mResolution.scale);
HandlePossibleViewportChange(); HandlePossibleViewportChange(mInnerSize);
} }
} }
} }
@ -1750,6 +1761,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const
} }
mOrientation = orientation; mOrientation = orientation;
ScreenIntSize oldScreenSize = mInnerSize;
mInnerSize = ScreenIntSize::FromUnknownSize( mInnerSize = ScreenIntSize::FromUnknownSize(
gfx::IntSize(size.width, size.height)); gfx::IntSize(size.width, size.height));
mWidget->Resize(0, 0, size.width, size.height, mWidget->Resize(0, 0, size.width, size.height,
@ -1767,7 +1779,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const
InitializeRootMetrics(); InitializeRootMetrics();
} }
HandlePossibleViewportChange(); HandlePossibleViewportChange(oldScreenSize);
return true; return true;
} }

Просмотреть файл

@ -178,7 +178,7 @@ public:
// viewport data on a document may have changed. If it didn't // viewport data on a document may have changed. If it didn't
// change, this function doesn't do anything. However, it should // change, this function doesn't do anything. However, it should
// not be called all the time as it is fairly expensive. // not be called all the time as it is fairly expensive.
bool HandlePossibleViewportChange(); bool HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize);
virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId, virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,
const mozilla::layers::FrameMetrics::ViewID& aViewId, const mozilla::layers::FrameMetrics::ViewID& aViewId,
const bool& aIsRoot, const bool& aIsRoot,