dirty rect in WM_PAINT events looks incorrect

RESOLVED FIXED

Status

()

defect
RESOLVED FIXED
12 years ago
10 years ago

People

(Reporter: karlt, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

nsPluginInstanceOwner::Paint appears to expect aDirtyRect to be in coordinates relative to the plugin rectangle, but the coordinates from PaintPlugin do not appear to be adjusted appropriately for this.

(Not tested - just looking at the source code)

static void PaintPlugin(nsIFrame* aFrame, nsIRenderingContext* aCtx,
                        const nsRect& aDirtyRect, nsPoint aPt)
{
  nsIRenderingContext::AutoPushTranslation translate(aCtx, aPt.x, aPt.y);
#ifdef MOZ_X11 // FIXME: Bug : Don't others want this too!
  nsRect relativeDirtyRect = aDirtyRect - aPt;
  NS_STATIC_CAST(nsObjectFrame*, aFrame)->PaintPlugin(*aCtx, relativeDirtyRect);
#else
  NS_STATIC_CAST(nsObjectFrame*, aFrame)->PaintPlugin(*aCtx, aDirtyRect);
#endif
}

void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HDC ndc)
{
  if (!mInstance || !mOwner)
    return;

  nsPluginWindow * window;
  GetWindow(window);
  nsRect relDirtyRect = nsRect(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
  nsIntRect relDirtyRectInPixels;
  ConvertAppUnitsToPixels(*mOwner->PresContext(), relDirtyRect,
                          relDirtyRectInPixels);

  // we got dirty rectangle in relative window coordinates, but we
  // need it in absolute units and in the (left, top, right, bottom) form
  RECT drc;
  drc.left   = relDirtyRectInPixels.x + window->x;
  drc.top    = relDirtyRectInPixels.y + window->y;
  drc.right  = drc.left + relDirtyRectInPixels.width;
  drc.bottom = drc.top + relDirtyRectInPixels.height;

  nsPluginEvent pluginEvent;
  pluginEvent.event = WM_PAINT;
  pluginEvent.wParam = (uint32)ndc;
  pluginEvent.lParam = (uint32)&drc;
  PRBool eventHandled = PR_FALSE;
  mInstance->HandleEvent(&pluginEvent, &eventHandled);
}
This was fixed for NPDrawingModelCoreGraphics in bug 500630,
and for XP_WIN in bug 458928.
(For other XP_MACOSX plugins and nsObjectFrame::PaintPrintPlugin(), aDirtyRect is not translated, but not used either.  Not sure how clipping is done there.)
Status: NEW → RESOLVED
Closed: 10 years ago
Depends on: 500630, 458928
Resolution: --- → FIXED
Blocks: 538711
You need to log in before you can comment on or make changes to this bug.