From 8d3360f96f64e6c08fa5806d6b200dedf6bb730f Mon Sep 17 00:00:00 2001 From: Oleg Romashin Date: Tue, 7 Sep 2010 19:51:50 -0700 Subject: [PATCH] Bug 556487 - Snap plugin rect to integer pixels. r=roc a=blocking2.0 --HG-- extra : rebase_source : 6442890eb41dce7a134173b5d1e1c87c589cadd1 --- layout/generic/nsObjectFrame.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 7a6f63410c4..9a402c20873 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1071,14 +1071,24 @@ nsObjectFrame::CallSetWindow() PRBool windowless = (window->type == NPWindowTypeDrawable); - nsIntPoint origin = GetWindowOriginInPixels(windowless); - - window->x = origin.x; - window->y = origin.y; - // refresh the plugin port as well window->window = mInstanceOwner->GetPluginPortFromWidget(); + // Adjust plugin dimensions according to pixel snap results + // and reduce amount of SetWindow calls + nsPresContext* presContext = PresContext(); + nsRootPresContext* rootPC = presContext->GetRootPresContext(); + if (!rootPC) + return; + PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel(); + nsIFrame* rootFrame = rootPC->PresShell()->FrameManager()->GetRootFrame(); + nsRect bounds = GetContentRect() + GetParent()->GetOffsetToCrossDoc(rootFrame); + nsIntRect intBounds = bounds.ToNearestPixels(appUnitsPerDevPixel); + window->x = intBounds.x; + window->y = intBounds.y; + window->width = intBounds.width; + window->height = intBounds.height; + // this will call pi->SetWindow and take care of window subclassing // if needed, see bug 132759. window->CallSetWindow(pi);