mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1927967 - Use typed units for nsDocumentViewer bounds. r=hiro,dholbert
SVG is fine because it always uses an effective DPI of 1. The rest already use and assume layout pixels. Differential Revision: https://phabricator.services.mozilla.com/D228120
This commit is contained in:
parent
b0d352c18b
commit
73ba109df2
@ -6884,9 +6884,9 @@ nsresult nsDocShell::CaptureState() {
|
||||
|
||||
// Capture the current content viewer bounds.
|
||||
if (mDocumentViewer) {
|
||||
nsIntRect bounds;
|
||||
LayoutDeviceIntRect bounds;
|
||||
mDocumentViewer->GetBounds(bounds);
|
||||
mOSHE->SetViewerBounds(bounds);
|
||||
mOSHE->SetViewerBounds(bounds.ToUnknownRect());
|
||||
}
|
||||
|
||||
// Capture the docshell hierarchy.
|
||||
@ -7234,7 +7234,7 @@ nsresult nsDocShell::RestoreFromHistory() {
|
||||
|
||||
nsView* rootViewSibling = nullptr;
|
||||
nsView* rootViewParent = nullptr;
|
||||
nsIntRect newBounds(0, 0, 0, 0);
|
||||
LayoutDeviceIntRect newBounds(0, 0, 0, 0);
|
||||
|
||||
PresShell* oldPresShell = GetPresShell();
|
||||
if (oldPresShell) {
|
||||
@ -7541,7 +7541,8 @@ nsresult nsDocShell::RestoreFromHistory() {
|
||||
// cached viewer size (skipping the resize if they are equal).
|
||||
|
||||
if (newRootView) {
|
||||
if (!newBounds.IsEmpty() && !newBounds.IsEqualEdges(oldBounds)) {
|
||||
if (!newBounds.IsEmpty() &&
|
||||
!newBounds.ToUnknownRect().IsEqualEdges(oldBounds)) {
|
||||
MOZ_LOG(gPageCacheLog, LogLevel::Debug,
|
||||
("resize widget(%d, %d, %d, %d)", newBounds.x, newBounds.y,
|
||||
newBounds.width, newBounds.height));
|
||||
@ -7938,7 +7939,7 @@ nsresult nsDocShell::SetupNewViewer(nsIDocumentViewer* aNewViewer,
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE);
|
||||
|
||||
nsIntRect bounds(x, y, cx, cy);
|
||||
LayoutDeviceIntRect bounds(x, y, cx, cy);
|
||||
|
||||
mDocumentViewer->SetNavigationTiming(mTiming);
|
||||
|
||||
|
@ -1163,7 +1163,7 @@ class nsDocShell final : public nsDocLoader,
|
||||
nsWeakPtr mBrowserChild;
|
||||
|
||||
// Dimensions of the docshell
|
||||
nsIntRect mBounds;
|
||||
mozilla::LayoutDeviceIntRect mBounds;
|
||||
|
||||
/**
|
||||
* Content-Type Hint of the most-recently initiated load. Used for
|
||||
|
@ -33,7 +33,7 @@ class RemotePrintJobChild;
|
||||
%}
|
||||
|
||||
[ptr] native nsIWidgetPtr(nsIWidget);
|
||||
[ref] native nsIntRectRef(nsIntRect);
|
||||
[ref] native LayoutDeviceIntRectRef(mozilla::LayoutDeviceIntRect);
|
||||
[ptr] native nsPresContextPtr(nsPresContext);
|
||||
[ptr] native nsViewPtr(nsView);
|
||||
[ptr] native nsDOMNavigationTimingPtr(nsDOMNavigationTiming);
|
||||
@ -46,7 +46,7 @@ class RemotePrintJobChild;
|
||||
interface nsIDocumentViewer : nsISupports
|
||||
{
|
||||
[noscript] void init(in nsIWidgetPtr aParentWidget,
|
||||
[const] in nsIntRectRef aBounds,
|
||||
[const] in LayoutDeviceIntRectRef aBounds,
|
||||
in WindowGlobalChildPtr aWindowActor);
|
||||
|
||||
attribute nsIDocShell container;
|
||||
@ -163,13 +163,13 @@ interface nsIDocumentViewer : nsISupports
|
||||
*/
|
||||
[noscript,nostdcall] void setDocument(in Document aDocument);
|
||||
|
||||
[noscript] void getBounds(in nsIntRectRef aBounds);
|
||||
[noscript] void setBounds([const] in nsIntRectRef aBounds);
|
||||
[noscript] void getBounds(in LayoutDeviceIntRectRef aBounds);
|
||||
[noscript] void setBounds([const] in LayoutDeviceIntRectRef aBounds);
|
||||
/**
|
||||
* The 'aFlags' argument to setBoundsWithFlags is a set of these bits.
|
||||
*/
|
||||
const unsigned long eDelayResize = 1;
|
||||
[noscript] void setBoundsWithFlags([const] in nsIntRectRef aBounds,
|
||||
[noscript] void setBoundsWithFlags([const] in LayoutDeviceIntRectRef aBounds,
|
||||
in unsigned long aFlags);
|
||||
|
||||
/**
|
||||
|
@ -993,7 +993,7 @@ nsresult ExternalResourceMap::AddExternalResource(nsIURI* aURI,
|
||||
// Make sure that hiding our viewer will tear down its presentation.
|
||||
aViewer->SetSticky(false);
|
||||
|
||||
rv = aViewer->Init(nullptr, nsIntRect(0, 0, 0, 0), nullptr);
|
||||
rv = aViewer->Init(nullptr, LayoutDeviceIntRect(), nullptr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = aViewer->Open(nullptr, nullptr);
|
||||
}
|
||||
|
@ -3654,17 +3654,14 @@ static void PrepareForFullscreenChange(nsIDocShell* aDocShell,
|
||||
nsCOMPtr<nsIDocumentViewer> viewer;
|
||||
aDocShell->GetDocViewer(getter_AddRefs(viewer));
|
||||
if (viewer) {
|
||||
nsIntRect viewerBounds;
|
||||
LayoutDeviceIntRect viewerBounds;
|
||||
viewer->GetBounds(viewerBounds);
|
||||
nscoord auPerDev = presShell->GetPresContext()->AppUnitsPerDevPixel();
|
||||
if (aOldSize) {
|
||||
*aOldSize = LayoutDeviceIntSize::ToAppUnits(
|
||||
LayoutDeviceIntSize::FromUnknownSize(viewerBounds.Size()),
|
||||
auPerDev);
|
||||
*aOldSize =
|
||||
LayoutDeviceIntSize::ToAppUnits(viewerBounds.Size(), auPerDev);
|
||||
}
|
||||
LayoutDeviceIntSize newSize =
|
||||
LayoutDeviceIntSize::FromAppUnitsRounded(aSize, auPerDev);
|
||||
|
||||
auto newSize = LayoutDeviceIntSize::FromAppUnitsRounded(aSize, auPerDev);
|
||||
viewerBounds.SizeTo(newSize.width, newSize.height);
|
||||
viewer->SetBounds(viewerBounds);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ nsresult gfxSVGGlyphsDocument::SetupPresentation() {
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
auto upem = mOwner->FontEntry()->UnitsPerEm();
|
||||
rv = viewer->Init(nullptr, gfx::IntRect(0, 0, upem, upem), nullptr);
|
||||
rv = viewer->Init(nullptr, LayoutDeviceIntRect(0, 0, upem, upem), nullptr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = viewer->Open(nullptr, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -72,12 +72,14 @@ void SVGDocumentWrapper::UpdateViewportBounds(const nsIntSize& aViewportSize) {
|
||||
MOZ_ASSERT(!mIgnoreInvalidation, "shouldn't be reentrant");
|
||||
mIgnoreInvalidation = true;
|
||||
|
||||
nsIntRect currentBounds;
|
||||
LayoutDeviceIntRect currentBounds;
|
||||
mViewer->GetBounds(currentBounds);
|
||||
|
||||
// If the bounds have changed, we need to do a layout flush.
|
||||
if (currentBounds.Size() != aViewportSize) {
|
||||
mViewer->SetBounds(IntRect(IntPoint(0, 0), aViewportSize));
|
||||
if (currentBounds.Size().ToUnknownSize() != aViewportSize) {
|
||||
mViewer->SetBounds(LayoutDeviceIntRect(
|
||||
LayoutDeviceIntPoint(),
|
||||
LayoutDeviceIntSize::FromUnknownSize(aViewportSize)));
|
||||
FlushLayout();
|
||||
}
|
||||
|
||||
@ -207,7 +209,7 @@ SVGDocumentWrapper::OnStartRequest(nsIRequest* aRequest) {
|
||||
mViewer->GetDocument()->SetIsBeingUsedAsImage();
|
||||
StopAnimation(); // otherwise animations start automatically in helper doc
|
||||
|
||||
rv = mViewer->Init(nullptr, nsIntRect(0, 0, 0, 0), nullptr);
|
||||
rv = mViewer->Init(nullptr, LayoutDeviceIntRect(), nullptr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mViewer->Open(nullptr, nullptr);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ class nsDocumentViewer final : public nsIDocumentViewer,
|
||||
*/
|
||||
nsresult InitInternal(nsIWidget* aParentWidget, nsISupports* aState,
|
||||
mozilla::dom::WindowGlobalChild* aActor,
|
||||
const nsIntRect& aBounds, bool aDoCreation,
|
||||
const LayoutDeviceIntRect& aBounds, bool aDoCreation,
|
||||
bool aNeedMakeCX = true,
|
||||
bool aForceSetNewDocument = true);
|
||||
/**
|
||||
@ -434,7 +434,7 @@ class nsDocumentViewer final : public nsIDocumentViewer,
|
||||
nsIWidget* mParentWidget; // purposely won't be ref counted. May be null
|
||||
bool mAttachedToParent; // view is attached to the parent widget
|
||||
|
||||
nsIntRect mBounds;
|
||||
LayoutDeviceIntRect mBounds;
|
||||
|
||||
int16_t mNumURLStarts;
|
||||
int16_t mDestroyBlockedCount;
|
||||
@ -673,7 +673,8 @@ nsDocumentViewer::GetContainer(nsIDocShell** aResult) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentViewer::Init(nsIWidget* aParentWidget, const nsIntRect& aBounds,
|
||||
nsDocumentViewer::Init(nsIWidget* aParentWidget,
|
||||
const LayoutDeviceIntRect& aBounds,
|
||||
WindowGlobalChild* aActor) {
|
||||
return InitInternal(aParentWidget, nullptr, aActor, aBounds, true);
|
||||
}
|
||||
@ -729,11 +730,10 @@ nsresult nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) {
|
||||
p2a ==
|
||||
mPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
|
||||
|
||||
nscoord width = p2a * mBounds.width;
|
||||
nscoord height = p2a * mBounds.height;
|
||||
const nsSize size = LayoutDevicePixel::ToAppUnits(mBounds.Size(), p2a);
|
||||
|
||||
mViewManager->SetWindowDimensions(width, height);
|
||||
mPresContext->SetInitialVisibleArea(nsRect(0, 0, width, height));
|
||||
mViewManager->SetWindowDimensions(size.width, size.height);
|
||||
mPresContext->SetInitialVisibleArea(nsRect(nsPoint(), size));
|
||||
// We rely on the default zoom not being initialized until here.
|
||||
mPresContext->RecomputeBrowsingContextDependentData();
|
||||
}
|
||||
@ -796,8 +796,8 @@ static already_AddRefed<nsPresContext> CreatePresContext(
|
||||
// all the new objects or just initialize the existing ones
|
||||
nsresult nsDocumentViewer::InitInternal(
|
||||
nsIWidget* aParentWidget, nsISupports* aState, WindowGlobalChild* aActor,
|
||||
const nsIntRect& aBounds, bool aDoCreation, bool aNeedMakeCX /*= true*/,
|
||||
bool aForceSetNewDocument /* = true*/) {
|
||||
const LayoutDeviceIntRect& aBounds, bool aDoCreation,
|
||||
bool aNeedMakeCX /*= true*/, bool aForceSetNewDocument /* = true*/) {
|
||||
// We don't want any scripts to run here. That can cause flushing,
|
||||
// which can cause reentry into initialization of this document viewer,
|
||||
// which would be disastrous.
|
||||
@ -1883,7 +1883,7 @@ nsPresContext* nsDocumentViewer::GetPresContext() { return mPresContext; }
|
||||
nsViewManager* nsDocumentViewer::GetViewManager() { return mViewManager; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentViewer::GetBounds(nsIntRect& aResult) {
|
||||
nsDocumentViewer::GetBounds(LayoutDeviceIntRect& aResult) {
|
||||
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
|
||||
aResult = mBounds;
|
||||
return NS_OK;
|
||||
@ -1926,7 +1926,7 @@ void nsDocumentViewer::SetPreviousViewer(nsIDocumentViewer* aViewer) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds,
|
||||
nsDocumentViewer::SetBoundsWithFlags(const LayoutDeviceIntRect& aBounds,
|
||||
uint32_t aFlags) {
|
||||
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
@ -1963,13 +1963,12 @@ nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds,
|
||||
// need to invalidate because what we want to draw to the screen has
|
||||
// changed.
|
||||
if (viewDims.width == width && viewDims.height == height) {
|
||||
nsIFrame* f = rootView->GetFrame();
|
||||
if (f) {
|
||||
if (nsIFrame* f = rootView->GetFrame()) {
|
||||
f->InvalidateFrame();
|
||||
|
||||
// Forcibly refresh the viewport sizes even if the view size is not
|
||||
// changed since it is possible that the |mBounds| change means that
|
||||
// the software keyboard appeared/disappered, in such cases we might
|
||||
// the software keyboard appeared/disappeared. In such cases we might
|
||||
// need to fire visual viewport events.
|
||||
mPresShell->RefreshViewportSize();
|
||||
}
|
||||
@ -1996,7 +1995,7 @@ nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentViewer::SetBounds(const nsIntRect& aBounds) {
|
||||
nsDocumentViewer::SetBounds(const LayoutDeviceIntRect& aBounds) {
|
||||
return SetBoundsWithFlags(aBounds, 0);
|
||||
}
|
||||
|
||||
@ -2639,8 +2638,7 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsDocumentViewer::GetContentSize(
|
||||
// Leave our viewport in a consistent state.
|
||||
{
|
||||
auto newBounds = LayoutDeviceIntRect::FromAppUnitsToOutside(
|
||||
shellArea, presContext->AppUnitsPerDevPixel())
|
||||
.ToUnknownRect();
|
||||
shellArea, presContext->AppUnitsPerDevPixel());
|
||||
newBounds.MoveTo(mBounds.TopLeft());
|
||||
SetBounds(newBounds);
|
||||
}
|
||||
|
@ -8022,7 +8022,7 @@ bool nsLayoutUtils::GetDocumentViewerSize(
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIntRect bounds;
|
||||
LayoutDeviceIntRect bounds;
|
||||
viewer->GetBounds(bounds);
|
||||
|
||||
if (aPresContext->IsRootContentDocumentCrossProcess() &&
|
||||
@ -8038,7 +8038,7 @@ bool nsLayoutUtils::GetDocumentViewerSize(
|
||||
}
|
||||
}
|
||||
|
||||
aOutSize = LayoutDeviceIntRect::FromUnknownRect(bounds).Size();
|
||||
aOutSize = bounds.Size();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1322,7 +1322,7 @@ nsresult nsPrintJob::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO) {
|
||||
do_QueryInterface(mDocViewerPrint)) {
|
||||
// If we're print-previewing and the top level document, use the bounds
|
||||
// from our doc viewer. Page bounds is not what we want.
|
||||
nsIntRect bounds;
|
||||
LayoutDeviceIntRect bounds;
|
||||
viewer->GetBounds(bounds);
|
||||
adjSize = nsSize(bounds.width * p2a, bounds.height * p2a);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user