NS_IMETHODIMP ImageDocument::HandleEvent(nsIDOMEvent* aEvent) { nsAutoString eventType; aEvent->GetType(eventType); if (eventType.EqualsLiteral("resize")) { CheckOverflowing(false); } else if (eventType.EqualsLiteral("click") && mClickResizingEnabled) { ResetZoomLevel(); mShouldResize = true; if (mImageIsResized) { int32_t x = 0, y = 0; nsCOMPtr<nsIDOMMouseEvent> event(do_QueryInterface(aEvent)); if (event) { event->GetClientX(&x); event->GetClientY(&y); int32_t left = 0, top = 0; nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mImageContent); htmlElement->GetOffsetLeft(&left); htmlElement->GetOffsetTop(&top); x -= left; y -= top; } mShouldResize = false; RestoreImageTo(x, y); } else if (mImageIsOverflowing) { ShrinkToFit(); } } return NS_OK; }
NS_IMETHODIMP ImageDocument::DOMRestoreImageTo(int32_t aX, int32_t aY) { RestoreImageTo(aX, aY); return NS_OK; }