Skip to content

Commit

Permalink
Applied embedlite part for orientation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Feb 2, 2014
1 parent b26a541 commit 9be263f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
14 changes: 12 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.cpp
Expand Up @@ -76,6 +76,7 @@ EmbedLiteViewThreadChild::EmbedLiteViewThreadChild(const uint32_t& aId, const ui
: mId(aId)
, mOuterId(0)
, mViewSize(0, 0)
, mViewResized(false)
, mDispatchSynthMouseEvents(true)
, mIMEComposing(false)
{
Expand Down Expand Up @@ -489,6 +490,7 @@ EmbedLiteViewThreadChild::RecvRemoveMessageListeners(const InfallibleTArray<nsSt
bool
EmbedLiteViewThreadChild::RecvSetViewSize(const gfxSize& aSize)
{
mViewResized = aSize != mViewSize;
mViewSize = aSize;
LOGT("sz[%g,%g]", mViewSize.width, mViewSize.height);

Expand Down Expand Up @@ -571,13 +573,21 @@ EmbedLiteViewThreadChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
return true;
}


FrameMetrics metrics(aFrameMetrics);
if (mViewResized && mHelper->HandlePossibleViewportChange()) {
metrics = mHelper->mFrameMetrics;
mViewResized = false;
}


for (unsigned int i = 0; i < mControllerListeners.Length(); i++) {
mControllerListeners[i]->RequestContentRepaint(aFrameMetrics);
mControllerListeners[i]->RequestContentRepaint(metrics);
}

bool ret = true;
if (sHandleDefaultAZPC.viewport) {
ret = mHelper->RecvUpdateFrame(aFrameMetrics);
ret = mHelper->RecvUpdateFrame(metrics);
}

return ret;
Expand Down
1 change: 1 addition & 0 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.h
Expand Up @@ -127,6 +127,7 @@ class EmbedLiteViewThreadChild : public PEmbedLiteViewChild,
nsCOMPtr<nsIWebNavigation> mWebNavigation;
WebBrowserChrome* mBChrome;
gfxSize mViewSize;
bool mViewResized;
gfxSize mGLViewSize;

nsRefPtr<TabChildHelper> mHelper;
Expand Down
13 changes: 8 additions & 5 deletions embedding/embedlite/utils/TabChildHelper.cpp
Expand Up @@ -268,6 +268,7 @@ TabChildHelper::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
// Should this also handle "MozScrolledAreaChanged".
if (eventType.EqualsLiteral("DOMMetaAdded")) {
// This meta data may or may not have been a meta viewport tag. If it was,
// we should handle it immediately.
Expand Down Expand Up @@ -765,11 +766,11 @@ GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewport)
std::max(htmlHeight, bodyHeight));
}

void
bool
TabChildHelper::HandlePossibleViewportChange()
{
if (sDisableViewportHandler) {
return;
return false;
}
nsCOMPtr<nsIDOMDocument> domDoc;
mView->mWebNavigation->GetDocument(getter_AddRefs(domDoc));
Expand All @@ -796,7 +797,7 @@ TabChildHelper::HandlePossibleViewportChange()
// We're not being displayed in any way; don't bother doing anything because
// that will just confuse future adjustments.
if (!screenW || !screenH) {
return;
return false;
}

float oldBrowserWidth = mOldViewportWidth;
Expand All @@ -816,7 +817,7 @@ TabChildHelper::HandlePossibleViewportChange()
// window.innerWidth before they are painted have a correct value (bug
// 771575).
if (!mContentDocumentIsDisplayed) {
return;
return false;
}

float oldScreenWidth = mLastRootMetrics.mCompositionBounds.width;
Expand Down Expand Up @@ -885,11 +886,13 @@ TabChildHelper::HandlePossibleViewportChange()
CSSSize pageSize = GetPageSize(document, viewport);
if (!pageSize.width) {
// Return early rather than divide by 0.
return;
return false;
}
metrics.mScrollableRect = CSSRect(CSSPoint(), pageSize);

// Force a repaint with these metrics. This, among other things, sets the
// displayport, so we start with async painting.
ProcessUpdateFrame(metrics);
mFrameMetrics = metrics;
return true;
}
3 changes: 2 additions & 1 deletion embedding/embedlite/utils/TabChildHelper.h
Expand Up @@ -95,7 +95,7 @@ class TabChildHelper : public nsIDOMEventListener,
// viewport data on a document may have changed. If it didn't
// change, this function doesn't do anything. However, it should
// not be called all the time as it is fairly expensive.
void HandlePossibleViewportChange();
bool HandlePossibleViewportChange();

friend class EmbedLiteViewThreadChild;
EmbedLiteViewThreadChild* mView;
Expand All @@ -105,6 +105,7 @@ class TabChildHelper : public nsIDOMEventListener,
nsRefPtr<EmbedTabChildGlobal> mTabChildGlobal;
mozilla::layers::FrameMetrics mLastRootMetrics;
mozilla::layers::FrameMetrics mLastSubFrameMetrics;
mozilla::layers::FrameMetrics mFrameMetrics;
};

}
Expand Down

0 comments on commit 9be263f

Please sign in to comment.