Skip to content

Commit

Permalink
Back out 204665ad4a24 (bug 764240) for Android M4 failures
Browse files Browse the repository at this point in the history
  • Loading branch information
philor committed Nov 19, 2012
1 parent 4f3af44 commit 9cc19a4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 116 deletions.
10 changes: 5 additions & 5 deletions docshell/base/nsIMarkupDocumentViewer.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface nsIMarkupDocumentViewer;

[ref] native nsIMarkupDocumentViewerTArray(nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> >);

[scriptable, uuid(02d37b31-e654-4b74-9bc3-14dfe0020bb3)]
[scriptable, uuid(1016d5e8-690f-4d97-8ac5-d50ffa341c46)]
interface nsIMarkupDocumentViewer : nsISupports
{

Expand Down Expand Up @@ -68,10 +68,10 @@ interface nsIMarkupDocumentViewer : nsISupports

//void GetCharacterSetHint(in wstring hintCharset, in int32_t charsetSource);

/**
* Requests the size of the content to the container.
*/
void getContentSize(out long width, out long height);
/**
* Tell the container to shrink-to-fit or grow-to-fit its contents
*/
void sizeToContent();

/**
* Options for Bidi presentation.
Expand Down
24 changes: 2 additions & 22 deletions dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5474,32 +5474,12 @@ nsGlobalWindow::SizeToContent()

// The content viewer does a check to make sure that it's a content
// viewer for a toplevel docshell.

nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIMarkupDocumentViewer> markupViewer(do_QueryInterface(cv));
NS_ENSURE_TRUE(markupViewer, NS_ERROR_FAILURE);

int32_t width, height;
NS_ENSURE_SUCCESS(markupViewer->GetContentSize(&width, &height),
NS_ERROR_FAILURE);

// Make sure the new size is following the CheckSecurityWidthAndHeight
// rules.
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);

nsIntSize cssSize(DevToCSSIntPixels(nsIntSize(width, height)));
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&cssSize.width,
&cssSize.height),
NS_ERROR_FAILURE);

nsIntSize newDevSize(CSSToDevIntPixels(cssSize));

nsCOMPtr<nsIDocShellTreeItem> docShellAsItem = do_QueryInterface(mDocShell);
NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem,
newDevSize.width, newDevSize.height),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(markupViewer->SizeToContent(), NS_ERROR_FAILURE);

return NS_OK;
}
Expand Down
1 change: 0 additions & 1 deletion dom/tests/mochitest/bugs/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ MOCHITEST_FILES = \
file_bug809290_b2.html \
file_bug809290_c.html \
file_empty.html \
test_sizetocontent_clamp.html \
$(NULL)

ifneq (Linux,$(OS_ARCH))
Expand Down
73 changes: 0 additions & 73 deletions dom/tests/mochitest/bugs/test_sizetocontent_clamp.html

This file was deleted.

15 changes: 11 additions & 4 deletions layout/base/nsDocumentViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3260,8 +3260,7 @@ NS_IMETHODIMP DocumentViewerImpl::ChangeMaxLineBoxWidth(int32_t aMaxLineBoxWidth
return NS_OK;
}

NS_IMETHODIMP
DocumentViewerImpl::GetContentSize(int32_t* aWidth, int32_t* aHeight)
NS_IMETHODIMP DocumentViewerImpl::SizeToContent()
{
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);

Expand Down Expand Up @@ -3302,15 +3301,23 @@ DocumentViewerImpl::GetContentSize(int32_t* aWidth, int32_t* aHeight)
GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);

int32_t width, height;

// so how big is it?
nsRect shellArea = presContext->GetVisibleArea();
// Protect against bogus returns here
NS_ENSURE_TRUE(shellArea.width != NS_UNCONSTRAINEDSIZE &&
shellArea.height != NS_UNCONSTRAINEDSIZE,
NS_ERROR_FAILURE);
width = presContext->AppUnitsToDevPixels(shellArea.width);
height = presContext->AppUnitsToDevPixels(shellArea.height);

nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);

*aWidth = presContext->AppUnitsToDevPixels(shellArea.width);
*aHeight = presContext->AppUnitsToDevPixels(shellArea.height);
NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width, height),
NS_ERROR_FAILURE);

return NS_OK;
}
Expand Down
14 changes: 3 additions & 11 deletions xpfe/appshell/src/nsXULWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,17 +975,9 @@ void nsXULWindow::OnChromeLoaded()
// (if LoadSizeFromXUL set the size, mIntrinsicallySized will be false)
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIMarkupDocumentViewer> markupViewer = do_QueryInterface(cv);
if (markupViewer) {
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
if (treeOwner) {
int32_t width, height;
markupViewer->GetContentSize(&width, &height);
treeOwner->SizeShellTo(docShellAsItem, width, height);
}
}
nsCOMPtr<nsIMarkupDocumentViewer> markupViewer(do_QueryInterface(cv));
if (markupViewer)
markupViewer->SizeToContent();
}

bool positionSet = !mIgnoreXULPosition;
Expand Down

0 comments on commit 9cc19a4

Please sign in to comment.