diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 4e2c732c5672..abe419a8f54f 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -1367,7 +1367,7 @@ NS_IMETHODIMP nsAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PR // We have the union of the rectangle, now we need to put it in absolute screen coords - nsRect orgRectPixels = aBoundingFrame->GetScreenRectExternal(); + nsIntRect orgRectPixels = aBoundingFrame->GetScreenRectExternal(); *x += orgRectPixels.x; *y += orgRectPixels.y; diff --git a/accessible/src/base/nsCaretAccessible.cpp b/accessible/src/base/nsCaretAccessible.cpp index 76e6cea922f3..4bcf3310742e 100644 --- a/accessible/src/base/nsCaretAccessible.cpp +++ b/accessible/src/base/nsCaretAccessible.cpp @@ -344,10 +344,10 @@ nsCaretAccessible::SpellcheckSelectionChanged(nsIDOMDocument *aDoc, return mRootAccessible->FireAccessibleEvent(event); } -nsRect +nsIntRect nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget) { - nsRect caretRect; + nsIntRect caretRect; NS_ENSURE_TRUE(aOutWidget, caretRect); *aOutWidget = nsnull; NS_ENSURE_TRUE(mRootAccessible, caretRect); @@ -375,28 +375,27 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget) nsCOMPtr caretSelection(do_QueryReferent(mLastUsedSelection)); NS_ENSURE_TRUE(caretSelection, caretRect); + nsRect rect; caret->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates, caretSelection, - &caretRect, &isCollapsed, &view); - if (!view || caretRect.IsEmpty()) { - return nsRect(); // Return empty rect + &rect, &isCollapsed, &view); + if (!view || rect.IsEmpty()) { + return nsIntRect(); // Return empty rect } PRBool isVisible; caret->GetCaretVisible(&isVisible); if (!isVisible) { - return nsRect(); // Return empty rect + return nsIntRect(); // Return empty rect } nsPoint offsetFromWidget; *aOutWidget = view->GetNearestWidget(&offsetFromWidget); - NS_ENSURE_TRUE(*aOutWidget, nsRect()); + NS_ENSURE_TRUE(*aOutWidget, nsIntRect()); nsPresContext *presContext = presShell->GetPresContext(); - NS_ENSURE_TRUE(presContext, nsRect()); + NS_ENSURE_TRUE(presContext, nsIntRect()); - caretRect.x = presContext->AppUnitsToDevPixels(caretRect.x + offsetFromWidget.x); - caretRect.y = presContext->AppUnitsToDevPixels(caretRect.y + offsetFromWidget.y); - caretRect.width = presContext->AppUnitsToDevPixels(caretRect.width); - caretRect.height = presContext->AppUnitsToDevPixels(caretRect.height); + rect += offsetFromWidget; + caretRect = nsRect::ToOutsidePixels(rect, presContext->AppUnitsPerDevPixel()); (*aOutWidget)->WidgetToScreen(caretRect, caretRect); diff --git a/accessible/src/base/nsCaretAccessible.h b/accessible/src/base/nsCaretAccessible.h index 9fcc96343b5e..6c0221c5fbd2 100644 --- a/accessible/src/base/nsCaretAccessible.h +++ b/accessible/src/base/nsCaretAccessible.h @@ -119,7 +119,7 @@ public: */ nsresult RemoveDocSelectionListener(nsIPresShell *aShell); - nsRect GetCaretRect(nsIWidget **aOutWidget); + nsIntRect GetCaretRect(nsIWidget **aOutWidget); protected: nsresult NormalSelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel); diff --git a/accessible/src/html/nsHTMLAreaAccessible.cpp b/accessible/src/html/nsHTMLAreaAccessible.cpp index b31fccb265c6..0097c8e77c34 100644 --- a/accessible/src/html/nsHTMLAreaAccessible.cpp +++ b/accessible/src/html/nsHTMLAreaAccessible.cpp @@ -149,7 +149,8 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y, imageFrame->GetImageMap(presContext, getter_AddRefs(map)); NS_ENSURE_TRUE(map, NS_ERROR_FAILURE); - nsRect rect, orgRectPixels; + nsRect rect; + nsIntRect orgRectPixels; rv = map->GetBoundsForAreaContent(ourContent, presContext, rect); NS_ENSURE_SUCCESS(rv, rv); diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index 982ade210682..475a00d2415f 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -301,13 +301,13 @@ nsIntRect nsHyperTextAccessible::GetBoundsForString(nsIFrame *aFrame, PRUint32 a // Add the point where the string starts to the frameScreenRect nsPoint frameTextStartPoint; rv = frame->GetPointFromOffset(startContentOffset, &frameTextStartPoint); - NS_ENSURE_SUCCESS(rv, nsRect()); + NS_ENSURE_SUCCESS(rv, nsIntRect()); frameScreenRect.x += context->AppUnitsToDevPixels(frameTextStartPoint.x); // Use the point for the end offset to calculate the width nsPoint frameTextEndPoint; rv = frame->GetPointFromOffset(startContentOffset + frameSubStringLength, &frameTextEndPoint); - NS_ENSURE_SUCCESS(rv, nsRect()); + NS_ENSURE_SUCCESS(rv, nsIntRect()); frameScreenRect.width = context->AppUnitsToDevPixels(frameTextEndPoint.x - frameTextStartPoint.x); screenRect.UnionRect(frameScreenRect, screenRect); @@ -1346,12 +1346,12 @@ nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, if (!frameScreenRect.Contains(coords.x, coords.y)) { return NS_OK; // Not found, will return -1 } - nsPoint pointInHyperText(coords.x - frameScreenRect.x, + nsIntPoint pxInHyperText(coords.x - frameScreenRect.x, coords.y - frameScreenRect.y); nsPresContext *context = GetPresContext(); NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); - pointInHyperText.x = context->DevPixelsToAppUnits(pointInHyperText.x); - pointInHyperText.y = context->DevPixelsToAppUnits(pointInHyperText.y); + nsPoint pointInHyperText(context->DevPixelsToAppUnits(pxInHyperText.x), + context->DevPixelsToAppUnits(pxInHyperText.y)); // Go through the frames to check if each one has the point. // When one does, add up the character offsets until we have a match diff --git a/content/base/src/nsImageLoadingContent.cpp b/content/base/src/nsImageLoadingContent.cpp index f6f892841511..8b4a8937f73f 100644 --- a/content/base/src/nsImageLoadingContent.cpp +++ b/content/base/src/nsImageLoadingContent.cpp @@ -158,7 +158,7 @@ nsImageLoadingContent::~nsImageLoadingContent() NS_IMETHODIMP nsImageLoadingContent::FrameChanged(imgIContainer* aContainer, gfxIImageFrame* aFrame, - nsRect* aDirtyRect) + nsIntRect* aDirtyRect) { LOOP_OVER_OBSERVERS(FrameChanged(aContainer, aFrame, aDirtyRect)); return NS_OK; @@ -204,7 +204,7 @@ nsImageLoadingContent::OnStartFrame(imgIRequest* aRequest, NS_IMETHODIMP nsImageLoadingContent::OnDataAvailable(imgIRequest* aRequest, gfxIImageFrame* aFrame, - const nsRect* aRect) + const nsIntRect* aRect) { LOOP_OVER_OBSERVERS(OnDataAvailable(aRequest, aFrame, aRect)); return NS_OK; diff --git a/content/events/src/nsDOMUIEvent.cpp b/content/events/src/nsDOMUIEvent.cpp index 47765ce90902..57bbf4c833bf 100644 --- a/content/events/src/nsDOMUIEvent.cpp +++ b/content/events/src/nsDOMUIEvent.cpp @@ -121,28 +121,32 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMUIEvent) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(UIEvent) NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent) -nsPoint nsDOMUIEvent::GetScreenPoint() { +nsIntPoint +nsDOMUIEvent::GetScreenPoint() +{ if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_POPUP_EVENT && mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT && mEvent->eventStructType != NS_DRAG_EVENT)) { - return nsPoint(0, 0); + return nsIntPoint(0, 0); } if (!((nsGUIEvent*)mEvent)->widget ) { return mEvent->refPoint; } - nsRect bounds(mEvent->refPoint, nsSize(1, 1)); - nsRect offset; + nsIntRect bounds(mEvent->refPoint, nsIntSize(1, 1)); + nsIntRect offset; ((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset ); - PRInt32 factor = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel(); - return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor), - nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor)); + nscoord factor = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel(); + return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor), + nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor)); } -nsPoint nsDOMUIEvent::GetClientPoint() { +nsIntPoint +nsDOMUIEvent::GetClientPoint() +{ if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_POPUP_EVENT && @@ -156,14 +160,14 @@ nsPoint nsDOMUIEvent::GetClientPoint() { nsPoint pt(0, 0); nsIPresShell* shell = mPresContext->GetPresShell(); if (!shell) { - return pt; + return nsIntPoint(0, 0); } nsIFrame* rootFrame = shell->GetRootFrame(); if (rootFrame) pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, rootFrame); - return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x), - nsPresContext::AppUnitsToIntCSSPixels(pt.y)); + return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x), + nsPresContext::AppUnitsToIntCSSPixels(pt.y)); } NS_IMETHODIMP @@ -194,14 +198,14 @@ nsDOMUIEvent::InitUIEvent(const nsAString & typeArg, PRBool canBubbleArg, PRBool } // ---- nsDOMNSUIEvent implementation ------------------- -nsPoint +nsIntPoint nsDOMUIEvent::GetPagePoint() { if (mPrivateDataDuplicated) { return mPagePoint; } - nsPoint pagePoint = GetClientPoint(); + nsIntPoint pagePoint(GetClientPoint()); // If there is some scrolling, add scroll info to client point. if (mPresContext && mPresContext->GetPresShell()) { @@ -209,8 +213,8 @@ nsDOMUIEvent::GetPagePoint() nsIScrollableFrame* scrollframe = shell->GetRootScrollFrameAsScrollable(); if (scrollframe) { nsPoint pt = scrollframe->GetScrollPosition(); - pagePoint += nsPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x), - nsPresContext::AppUnitsToIntCSSPixels(pt.y)); + pagePoint += nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x), + nsPresContext::AppUnitsToIntCSSPixels(pt.y)); } } @@ -306,7 +310,9 @@ nsDOMUIEvent::SetCancelBubble(PRBool aCancelBubble) return NS_OK; } -nsPoint nsDOMUIEvent::GetLayerPoint() { +nsIntPoint +nsDOMUIEvent::GetLayerPoint() +{ if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_POPUP_EVENT && @@ -323,9 +329,8 @@ nsPoint nsDOMUIEvent::GetLayerPoint() { return mLayerPoint; nsIFrame* layer = nsLayoutUtils::GetClosestLayer(targetFrame); nsPoint pt(nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, layer)); - pt.x = nsPresContext::AppUnitsToIntCSSPixels(pt.x); - pt.y = nsPresContext::AppUnitsToIntCSSPixels(pt.y); - return pt; + return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x), + nsPresContext::AppUnitsToIntCSSPixels(pt.y)); } NS_IMETHODIMP @@ -389,7 +394,7 @@ nsDOMUIEvent::DuplicatePrivateData() mLayerPoint = GetLayerPoint(); mPagePoint = GetPagePoint(); // GetScreenPoint converts mEvent->refPoint to right coordinates. - nsPoint screenPoint = GetScreenPoint(); + nsIntPoint screenPoint(GetScreenPoint()); nsresult rv = nsDOMEvent::DuplicatePrivateData(); if (NS_SUCCEEDED(rv)) { mEvent->refPoint = screenPoint; diff --git a/content/events/src/nsDOMUIEvent.h b/content/events/src/nsDOMUIEvent.h index 275a4496e175..0ad95145102a 100644 --- a/content/events/src/nsDOMUIEvent.h +++ b/content/events/src/nsDOMUIEvent.h @@ -74,18 +74,18 @@ public: protected: // Internal helper functions - nsPoint GetClientPoint(); - nsPoint GetScreenPoint(); - nsPoint GetLayerPoint(); - nsPoint GetPagePoint(); + nsIntPoint GetClientPoint(); + nsIntPoint GetScreenPoint(); + nsIntPoint GetLayerPoint(); + nsIntPoint GetPagePoint(); protected: nsCOMPtr mView; PRInt32 mDetail; - nsPoint mClientPoint; + nsIntPoint mClientPoint; // Screenpoint is mEvent->refPoint. - nsPoint mLayerPoint; - nsPoint mPagePoint; + nsIntPoint mLayerPoint; + nsIntPoint mPagePoint; }; #define NS_FORWARD_TO_NSDOMUIEVENT \ diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 47b281edaa9d..c1ace7cff59c 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -1380,7 +1380,7 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext, // see if we should use the caret position for the popup if (contextMenuKey) { - nsPoint caretPoint; + nsIntPoint caretPoint; // Beware! This may flush notifications via synchronous // ScrollSelectionIntoView. if (PrepareToUseCaretPosition(((nsGUIEvent*)aEvent)->widget, @@ -1413,7 +1413,7 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext, if (currentFocus) { // Reset event coordinates relative to focused frame in view - nsPoint targetPt; + nsIntPoint targetPt; GetCoordinatesFor(currentFocus, aPresContext, shell, targetPt); aEvent->refPoint.x = targetPt.x; aEvent->refPoint.y = targetPt.y; @@ -1441,7 +1441,7 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext, PRBool nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIPresShell* aShell, - nsPoint& aTargetPt) + nsIntPoint& aTargetPt) { nsresult rv; @@ -1534,7 +1534,7 @@ nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget, widgetView->GetNearestWidget(&viewToWidget); nsPoint viewDelta = view->GetOffsetTo(widgetView) + viewToWidget; - // caret coordinates are in twips, convert to pixels + // caret coordinates are in app units, convert to pixels nsPresContext* presContext = aShell->GetPresContext(); aTargetPt.x = presContext->AppUnitsToDevPixels(viewDelta.x + caretCoords.x + caretCoords.width); aTargetPt.y = presContext->AppUnitsToDevPixels(viewDelta.y + caretCoords.y + caretCoords.height); @@ -1548,7 +1548,7 @@ void nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl, nsPresContext *aPresContext, nsIPresShell *aPresShell, - nsPoint& aTargetPt) + nsIntPoint& aTargetPt) { nsCOMPtr focusedContent(do_QueryInterface(aCurrentEl)); aPresShell->ScrollContentIntoView(focusedContent, diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h index f78eac05b9eb..e4982b9f6685 100644 --- a/content/events/src/nsEventListenerManager.h +++ b/content/events/src/nsEventListenerManager.h @@ -181,9 +181,9 @@ protected: nsIDOMEvent** aDOMEvent); PRBool PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIPresShell* aShell, - nsPoint& aTargetPt); + nsIntPoint& aTargetPt); void GetCoordinatesFor(nsIDOMElement *aCurrentEl, nsPresContext *aPresContext, - nsIPresShell *aPresShell, nsPoint& aTargetPt); + nsIPresShell *aPresShell, nsIntPoint& aTargetPt); nsresult GetDOM2EventGroup(nsIDOMEventGroup** aGroup); PRBool ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent); diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 1957bfb2b362..12c0d86dbd3f 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -313,7 +313,7 @@ public: static void EndTransaction(); static void OnEvent(nsEvent* aEvent); protected: - static nsPoint GetScreenPoint(nsGUIEvent* aEvent); + static nsIntPoint GetScreenPoint(nsGUIEvent* aEvent); static PRUint32 GetTimeoutTime(); static PRUint32 GetIgnoreMoveDelayTime(); @@ -385,7 +385,7 @@ nsMouseWheelTransaction::OnEvent(nsEvent* aEvent) if (((nsMouseEvent*)aEvent)->reason == nsMouseEvent::eReal) { // If the cursor is moving to be outside the frame, // terminate the scrollwheel transaction. - nsPoint pt = GetScreenPoint((nsGUIEvent*)aEvent); + nsIntPoint pt(GetScreenPoint((nsGUIEvent*)aEvent)); nsIntRect r = sTargetFrame->GetScreenRectExternal(); if (!r.Contains(pt)) { EndTransaction(); @@ -416,13 +416,13 @@ nsMouseWheelTransaction::OnEvent(nsEvent* aEvent) } } -nsPoint +nsIntPoint nsMouseWheelTransaction::GetScreenPoint(nsGUIEvent* aEvent) { NS_ASSERTION(aEvent, "aEvent is null"); NS_ASSERTION(aEvent->widget, "aEvent-widget is null"); - nsRect tmpRect; - aEvent->widget->WidgetToScreen(nsRect(aEvent->refPoint, nsSize(1, 1)), + nsIntRect tmpRect; + aEvent->widget->WidgetToScreen(nsIntRect(aEvent->refPoint, nsIntSize(1, 1)), tmpRect); return tmpRect.TopLeft(); } @@ -1885,8 +1885,8 @@ nsEventStateManager::BeginTrackingDragGesture(nsPresContext* aPresContext, { // Note that |inDownEvent| could be either a mouse down event or a // synthesized mouse move event. - nsRect screenPt; - inDownEvent->widget->WidgetToScreen(nsRect(inDownEvent->refPoint, nsSize(1, 1)), + nsIntRect screenPt; + inDownEvent->widget->WidgetToScreen(nsIntRect(inDownEvent->refPoint, nsIntSize(1, 1)), screenPt); mGestureDownPoint = screenPt.TopLeft(); @@ -1929,7 +1929,7 @@ nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent) // Set the coordinates in the new event to the coordinates of // the old event, adjusted for the fact that the widget might be // different - nsRect tmpRect(0, 0, 1, 1); + nsIntRect tmpRect(0, 0, 1, 1); aEvent->widget->WidgetToScreen(tmpRect, tmpRect); aEvent->refPoint = mGestureDownPoint - tmpRect.TopLeft(); aEvent->isShift = mGestureDownShift; @@ -1990,10 +1990,10 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext, } // fire drag gesture if mouse has moved enough - nsRect tmpRect; - aEvent->widget->WidgetToScreen(nsRect(aEvent->refPoint, nsSize(1, 1)), + nsIntRect tmpRect; + aEvent->widget->WidgetToScreen(nsIntRect(aEvent->refPoint, nsIntSize(1, 1)), tmpRect); - nsPoint pt = tmpRect.TopLeft(); + nsIntPoint pt(tmpRect.TopLeft()); if (PR_ABS(pt.x - mGestureDownPoint.x) > pixelThresholdX || PR_ABS(pt.y - mGestureDownPoint.y) > pixelThresholdY) { #ifdef CLICK_HOLD_CONTEXT_MENUS diff --git a/content/events/src/nsEventStateManager.h b/content/events/src/nsEventStateManager.h index 7a85fc284638..57e5c0df390b 100644 --- a/content/events/src/nsEventStateManager.h +++ b/content/events/src/nsEventStateManager.h @@ -385,7 +385,7 @@ protected: nsWeakFrame mLastDragOverFrame; // member variables for the d&d gesture state machine - nsPoint mGestureDownPoint; // screen coordinates + nsIntPoint mGestureDownPoint; // screen coordinates // The content to use as target if we start a d&d (what we drag). nsCOMPtr mGestureDownContent; // The content of the frame where the mouse-down event occurred. It's the same diff --git a/content/events/src/nsQueryContentEventHandler.cpp b/content/events/src/nsQueryContentEventHandler.cpp index 0116679bda53..fdcd34a0168b 100644 --- a/content/events/src/nsQueryContentEventHandler.cpp +++ b/content/events/src/nsQueryContentEventHandler.cpp @@ -437,25 +437,25 @@ nsQueryContentEventHandler::QueryRectFor(nsQueryContentEvent* aEvent, rv = frame->GetPointFromOffset(aRange->StartOffset(), &posInFrame); NS_ENSURE_SUCCESS(rv, rv); - aEvent->mReply.mRect.y = posInFrame.y; - aEvent->mReply.mRect.height = frame->GetSize().height; + nsRect rect; + rect.y = posInFrame.y; + rect.height = frame->GetSize().height; if (aEvent->message == NS_QUERY_CHARACTER_RECT) { nsPoint nextPos; rv = frame->GetPointFromOffset(aRange->EndOffset(), &nextPos); NS_ENSURE_SUCCESS(rv, rv); - aEvent->mReply.mRect.x = PR_MIN(posInFrame.x, nextPos.x); - aEvent->mReply.mRect.width = PR_ABS(posInFrame.x - nextPos.x); + rect.x = PR_MIN(posInFrame.x, nextPos.x); + rect.width = PR_ABS(posInFrame.x - nextPos.x); } else { - aEvent->mReply.mRect.x = posInFrame.x; - aEvent->mReply.mRect.width = aCaret->GetCaretRect().width; + rect.x = posInFrame.x; + rect.width = aCaret->GetCaretRect().width; } - // The coordinates are app units here, they will be converted to system - // coordinates by view manager. - rv = ConvertToRootViewRelativeOffset(frame, aEvent->mReply.mRect); + rv = ConvertToRootViewRelativeOffset(frame, rect); NS_ENSURE_SUCCESS(rv, rv); + aEvent->mReply.mRect = nsRect::ToOutsidePixels(rect, mPresContext->AppUnitsPerDevPixel()); aEvent->mSucceeded = PR_TRUE; return NS_OK; } @@ -504,9 +504,11 @@ nsQueryContentEventHandler::OnQueryCaretRect(nsQueryContentEvent* aEvent) NS_ENSURE_SUCCESS(rv, rv); if (offset == aEvent->mInput.mOffset) { PRBool isCollapsed; + nsRect rect; rv = caret->GetCaretCoordinates(nsCaret::eTopLevelWindowCoordinates, - mSelection, &aEvent->mReply.mRect, + mSelection, &rect, &isCollapsed, nsnull); + aEvent->mReply.mRect = nsRect::ToOutsidePixels(rect, mPresContext->AppUnitsPerDevPixel()); NS_ENSURE_SUCCESS(rv, rv); aEvent->mSucceeded = PR_TRUE; return NS_OK; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 5597626000a4..5b63329d5eff 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5495,7 +5495,7 @@ nsDocShell::CaptureState() if (rootView) { nsIWidget *widget = rootView->GetWidget(); if (widget) { - nsRect bounds(0, 0, 0, 0); + nsIntRect bounds(0, 0, 0, 0); widget->GetBounds(bounds); rv = mOSHE->SetViewerBounds(bounds); } @@ -5820,7 +5820,7 @@ nsDocShell::RestoreFromHistory() // bounds of the root view's widget. nsIView *rootViewSibling = nsnull, *rootViewParent = nsnull; - nsRect newBounds(0, 0, 0, 0); + nsIntRect newBounds(0, 0, 0, 0); nsCOMPtr oldPresShell; nsDocShell::GetPresShell(getter_AddRefs(oldPresShell)); @@ -5876,7 +5876,7 @@ nsDocShell::RestoreFromHistory() } // get the previous content viewer size - nsRect oldBounds(0, 0, 0, 0); + nsIntRect oldBounds(0, 0, 0, 0); mLSHE->GetViewerBounds(oldBounds); // Restore the refresh URI list. The refresh timers will be restarted @@ -6450,7 +6450,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) nsCOMPtr widget; NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE); - nsRect bounds(x, y, cx, cy); + nsIntRect bounds(x, y, cx, cy); if (NS_FAILED(mContentViewer->Init(widget, bounds))) { mContentViewer = nsnull; diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 747acf880a2d..a3d1d77a98a2 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -620,7 +620,7 @@ protected: nsCOMPtr mRefreshURIList; nsCOMPtr mSavedRefreshURIList; nsRefPtr mContentListener; - nsRect mBounds; // Dimensions of the docshell + nsIntRect mBounds; // Dimensions of the docshell nsCOMPtr mContentViewer; nsCOMPtr mDocumentCharsetInfo; nsCOMPtr mParentWidget; @@ -633,7 +633,7 @@ protected: nsCOMPtr mSessionHistory; nsCOMPtr mGlobalHistory; nsCOMPtr mFind; - nsPoint mDefaultScrollbarPref; // persistent across doc loads + nsIntPoint mDefaultScrollbarPref; // persistent across doc loads // Reference to the SHEntry for this docshell until the page is destroyed. // Somebody give me better name nsCOMPtr mOSHE; diff --git a/docshell/base/nsIContentViewer.idl b/docshell/base/nsIContentViewer.idl index aee96d4ba924..87ce75361be0 100644 --- a/docshell/base/nsIContentViewer.idl +++ b/docshell/base/nsIContentViewer.idl @@ -7,18 +7,18 @@ interface nsIPrintSettings; %{ C++ class nsIWidget; -struct nsRect; +struct nsIntRect; %} [ptr] native nsIWidgetPtr(nsIWidget); -[ref] native nsRectRef(nsRect); +[ref] native nsIntRectRef(nsIntRect); -[scriptable, uuid(05b290ac-d880-4900-bb1f-2211b5f8accc)] +[scriptable, uuid(c9aba5da-7d8b-46a8-87cd-9ab7e16480b8)] interface nsIContentViewer : nsISupports { [noscript] void init(in nsIWidgetPtr aParentWidget, - [const] in nsRectRef aBounds); + [const] in nsIntRectRef aBounds); attribute nsISupports container; @@ -55,8 +55,8 @@ interface nsIContentViewer : nsISupports attribute nsIDOMDocument DOMDocument; - [noscript] void getBounds(in nsRectRef aBounds); - [noscript] void setBounds([const] in nsRectRef aBounds); + [noscript] void getBounds(in nsIntRectRef aBounds); + [noscript] void setBounds([const] in nsIntRectRef aBounds); /** * The previous content viewer, which has been |close|d but not diff --git a/docshell/shistory/public/nsISHEntry.idl b/docshell/shistory/public/nsISHEntry.idl index 11bb8c6311a6..6235345c9eb2 100644 --- a/docshell/shistory/public/nsISHEntry.idl +++ b/docshell/shistory/public/nsISHEntry.idl @@ -51,14 +51,14 @@ interface nsIInputStream; interface nsIDocShellTreeItem; interface nsISupportsArray; %{C++ -struct nsRect; +struct nsIntRect; class nsDocShellEditorData; %} -[ref] native nsRect(nsRect); +[ref] native nsIntRect(nsIntRect); [ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData); -[scriptable, uuid(c16fde76-3108-450e-8c8c-ae8286f286ed)] +[scriptable, uuid(09fecea6-5453-43ba-bf91-3ff32618f037)] interface nsISHEntry : nsIHistoryEntry { /** URI for the document */ @@ -81,8 +81,8 @@ interface nsISHEntry : nsIHistoryEntry * root view's widget accordingly if this has changed when the presentation * is restored. */ - [noscript] void getViewerBounds(in nsRect bounds); - [noscript] void setViewerBounds([const] in nsRect bounds); + [noscript] void getViewerBounds(in nsIntRect bounds); + [noscript] void setViewerBounds([const] in nsIntRect bounds); /** * Saved child docshells corresponding to contentViewer. The child shells diff --git a/docshell/shistory/src/nsSHEntry.cpp b/docshell/shistory/src/nsSHEntry.cpp index 7d807bc48a1f..0da6e47897d4 100644 --- a/docshell/shistory/src/nsSHEntry.cpp +++ b/docshell/shistory/src/nsSHEntry.cpp @@ -536,14 +536,14 @@ nsSHEntry::GetWindowState(nsISupports **aState) } NS_IMETHODIMP -nsSHEntry::SetViewerBounds(const nsRect &aBounds) +nsSHEntry::SetViewerBounds(const nsIntRect &aBounds) { mViewerBounds = aBounds; return NS_OK; } NS_IMETHODIMP -nsSHEntry::GetViewerBounds(nsRect &aBounds) +nsSHEntry::GetViewerBounds(nsIntRect &aBounds) { aBounds = mViewerBounds; return NS_OK; diff --git a/docshell/shistory/src/nsSHEntry.h b/docshell/shistory/src/nsSHEntry.h index e87c6f4a99ff..3eebc2b6daea 100644 --- a/docshell/shistory/src/nsSHEntry.h +++ b/docshell/shistory/src/nsSHEntry.h @@ -110,7 +110,7 @@ private: nsCOMPtr mCacheKey; nsISHEntry * mParent; // weak reference nsCOMPtr mWindowState; - nsRect mViewerBounds; + nsIntRect mViewerBounds; nsCOMArray mChildShells; nsCOMPtr mRefreshURIList; nsCOMPtr mOwner; diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index a75cf269c325..20fcb5bf6306 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -1983,18 +1983,23 @@ nsEditor::QueryComposition(nsTextEventReply* aReply) // XXX_kin: END HACK! HACK! HACK! nsIView *view = nsnull; + nsRect rect; result = caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates, selection, - &(aReply->mCursorPosition), + &rect, &(aReply->mCursorIsCollapsed), &view); + aReply->mCursorPosition = + nsRect::ToOutsidePixels(rect, + ps->GetPresContext()->AppUnitsPerDevPixel()); if (NS_SUCCEEDED(result) && view) aReply->mReferenceWidget = view->GetWidget(); } } return result; } + NS_IMETHODIMP nsEditor::BeginComposition(nsTextEventReply* aReply) { diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index e42e84383844..8795b61068f0 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -1737,11 +1737,15 @@ nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString, nsI if (caretP) { nsIView *view = nsnull; + nsRect rect; result = caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates, selection, - &(aReply->mCursorPosition), + &rect, &(aReply->mCursorIsCollapsed), &view); + aReply->mCursorPosition = + nsRect::ToOutsidePixels(rect, + ps->GetPresContext()->AppUnitsPerDevPixel()); NS_ASSERTION(NS_SUCCEEDED(result), "cannot get caret position"); if (NS_SUCCEEDED(result) && view) aReply->mReferenceWidget = view->GetWidget(); diff --git a/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp b/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp index 2bb6178a44b5..442488d47554 100644 --- a/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp +++ b/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp @@ -94,7 +94,7 @@ EmbedContextMenuInfo::EmbedContextMenuInfo(EmbedPrivate *aOwner) : mCtxFrameNum( mNSHHTMLElementSc = nsnull; mCtxEvent = nsnull; mEventNode = nsnull; - mFormRect = nsRect(0,0,0,0); + mFormRect = nsIntRect(0,0,0,0); } EmbedContextMenuInfo::~EmbedContextMenuInfo(void) diff --git a/embedding/browser/gtk/src/EmbedContextMenuInfo.h b/embedding/browser/gtk/src/EmbedContextMenuInfo.h index 0b1f69e3f4aa..f3b0d8902bdc 100644 --- a/embedding/browser/gtk/src/EmbedContextMenuInfo.h +++ b/embedding/browser/gtk/src/EmbedContextMenuInfo.h @@ -84,7 +84,7 @@ public: nsCOMPtr mEventNode; nsCOMPtr mEventTarget; nsCOMPtrmCtxDocument; - nsRect mFormRect; + nsIntRect mFormRect; nsCOMPtr mCtxDomWindow; nsCOMPtr mCtxEvent; nsCOMPtr mNSHHTMLElement; diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 331250930473..d42e82ec5f43 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -1482,8 +1482,8 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer, if (textFound) { nsString tipText(tooltipText); self->CreateAutoHideTimer(); - nsRect widgetDot(0, 0, 1, 1); - nsRect screenDot; + nsIntRect widgetDot(0, 0, 1, 1); + nsIntRect screenDot; widget->WidgetToScreen(widgetDot, screenDot); self->ShowTooltip (self->mMouseScreenX - screenDot.x, self->mMouseScreenY - screenDot.y, diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp index b31ae17489c1..262685a526fe 100644 --- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -1129,7 +1129,7 @@ NS_IMETHODIMP nsWebBrowser::Create() mContentType == typeChromeWrapper)? eContentTypeUI: eContentTypeContent; widgetInit.mWindowType = eWindowType_child; - nsRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy); + nsIntRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy); mInternalWidget->SetClientData(static_cast(this)); mInternalWidget->Create(mParentNativeWindow, bounds, nsWebBrowser::HandleEvent, @@ -1317,7 +1317,7 @@ NS_IMETHODIMP nsWebBrowser::GetPositionAndSize(PRInt32* aX, PRInt32* aY, { if(mInternalWidget) { - nsRect bounds; + nsIntRect bounds; NS_ENSURE_SUCCESS(mInternalWidget->GetBounds(bounds), NS_ERROR_FAILURE); if(aX) diff --git a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp index f2cb197490a3..7884684ee4eb 100644 --- a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp +++ b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp @@ -513,7 +513,7 @@ static HWND CreateControl(LPCTSTR aType, HWND aHdlg, int aId, const nsAString& aStr, - const nsRect& aRect) + const nsIntRect& aRect) { nsCAutoString str; if (NS_FAILED(NS_CopyUnicodeToNative(aStr, str))) @@ -541,7 +541,7 @@ static HWND CreateRadioBtn(HINSTANCE aHInst, HWND aHdlg, int aId, const char* aStr, - const nsRect& aRect) + const nsIntRect& aRect) { nsString cStr; cStr.AssignWithConversion(aStr); @@ -554,7 +554,7 @@ static HWND CreateGroupBox(HINSTANCE aHInst, HWND aHdlg, int aId, const nsAString& aStr, - const nsRect& aRect) + const nsIntRect& aRect) { return CreateControl("BUTTON", BS_GROUPBOX, aHInst, aHdlg, aId, aStr, aRect); } @@ -665,7 +665,7 @@ static UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM int y = top+(rad1Rect.top-dlgRect.top); // starting pos of first radio int rbWidth = dlgRect.right - rad1Rect.left - 5; // measure from rb left to the edge of the groupbox // (5 is arbitrary) - nsRect rect; + nsIntRect rect; // Create and position the radio buttons // diff --git a/gfx/public/nsITheme.h b/gfx/public/nsITheme.h index cf3ca7448712..d2cc76ab1e46 100644 --- a/gfx/public/nsITheme.h +++ b/gfx/public/nsITheme.h @@ -46,9 +46,9 @@ #include "nsColor.h" struct nsRect; -struct nsSize; +struct nsIntSize; struct nsFont; -struct nsMargin; +struct nsIntMargin; class nsPresContext; class nsIRenderingContext; class nsIDeviceContext; @@ -57,9 +57,9 @@ class nsIContent; class nsIAtom; // IID for the nsITheme interface -// {df8baf21-5ea7-49eb-a2bc-f2fd4a9fd896} +// {887e8902-db6b-41b4-8481-a80f49c5a93a} #define NS_ITHEME_IID \ -{ 0xdf8baf21, 0x5ea7, 0x49eb, { 0xa2, 0xbc, 0xf2, 0xfd, 0x4a, 0x9f, 0xd8, 0x96 } } +{ 0x887e8902, 0xdb6b, 0x41b4, { 0x84, 0x81, 0xa8, 0x0f, 0x49, 0xc5, 0xa9, 0x3a } } // {D930E29B-6909-44e5-AB4B-AF10D6923705} #define NS_THEMERENDERER_CID \ @@ -91,7 +91,7 @@ public: NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult)=0; + nsIntMargin* aResult)=0; /** * This method can return PR_FALSE to indicate that the CSS padding @@ -105,7 +105,7 @@ public: virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult) = 0; + nsIntMargin* aResult) = 0; /** * On entry, *aResult is positioned at 0,0 and sized to the new size @@ -130,7 +130,7 @@ public: NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, + nsIntSize* aResult, PRBool* aIsOverridable)=0; NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, diff --git a/gfx/public/nsMargin.h b/gfx/public/nsMargin.h index f939c47e8a22..e9fee87263d3 100644 --- a/gfx/public/nsMargin.h +++ b/gfx/public/nsMargin.h @@ -105,7 +105,6 @@ struct nsMargin { return *this;} }; -#ifdef NS_COORD_IS_FLOAT struct nsIntMargin { PRInt32 top, right, bottom, left; @@ -115,9 +114,25 @@ struct nsIntMargin { nsIntMargin(PRInt32 aLeft, PRInt32 aTop, PRInt32 aRight, PRInt32 aBottom) {left = aLeft; top = aTop; right = aRight; bottom = aBottom;} + void SizeTo(PRInt32 aLeft, PRInt32 aTop, + PRInt32 aRight, PRInt32 aBottom) {left = aLeft; top = aTop; + right = aRight; bottom = aBottom;} + PRInt32& side(PRUint8 aSide) { + NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side"); + return *(&top + aSide); + } + + PRInt32 side(PRUint8 aSide) const { + NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side"); + return *(&top + aSide); + } + PRInt32 LeftRight() const { return left + right; } + PRInt32 TopBottom() const { return top + bottom; } + + nsIntMargin operator+(const nsIntMargin& aMargin) const { + return nsIntMargin(left + aMargin.left, top + aMargin.top, + right + aMargin.right, bottom + aMargin.bottom); + } }; -#else -typedef nsMargin nsIntMargin; -#endif #endif /* NSMARGIN_H */ diff --git a/gfx/public/nsPoint.h b/gfx/public/nsPoint.h index cf2977500123..1c59ab1ec0fe 100644 --- a/gfx/public/nsPoint.h +++ b/gfx/public/nsPoint.h @@ -81,7 +81,6 @@ struct nsPoint { } }; -#ifdef NS_COORD_IS_FLOAT struct nsIntPoint { PRInt32 x, y; @@ -90,50 +89,29 @@ struct nsIntPoint { nsIntPoint(const nsIntPoint& aPoint) { x = aPoint.x; y = aPoint.y;} nsIntPoint(PRInt32 aX, PRInt32 aY) { x = aX; y = aY;} - void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;} -}; - -typedef nsPoint nsFloatPoint; -#else -typedef nsPoint nsIntPoint; - -struct nsFloatPoint { - float x, y; - - // Constructors - nsFloatPoint() {} - nsFloatPoint(const nsFloatPoint& aPoint) {x = aPoint.x; y = aPoint.y;} - nsFloatPoint(float aX, float aY) {x = aX; y = aY;} - - void MoveTo(float aX, float aY) {x = aX; y = aY;} - void MoveTo(nscoord aX, nscoord aY) {x = (float)aX; y = (float)aY;} - void MoveBy(float aDx, float aDy) {x += aDx; y += aDy;} - - // Overloaded operators. Note that '=' isn't defined so we'll get the - // compiler generated default assignment operator - PRBool operator==(const nsFloatPoint& aPoint) const { + PRBool operator==(const nsIntPoint& aPoint) const { return (PRBool) ((x == aPoint.x) && (y == aPoint.y)); } - PRBool operator!=(const nsFloatPoint& aPoint) const { + PRBool operator!=(const nsIntPoint& aPoint) const { return (PRBool) ((x != aPoint.x) || (y != aPoint.y)); } - nsFloatPoint operator+(const nsFloatPoint& aPoint) const { - return nsFloatPoint(x + aPoint.x, y + aPoint.y); + nsIntPoint operator+(const nsIntPoint& aPoint) const { + return nsIntPoint(x + aPoint.x, y + aPoint.y); } - nsFloatPoint operator-(const nsFloatPoint& aPoint) const { - return nsFloatPoint(x - aPoint.x, y - aPoint.y); + nsIntPoint operator-(const nsIntPoint& aPoint) const { + return nsIntPoint(x - aPoint.x, y - aPoint.y); } - nsFloatPoint& operator+=(const nsFloatPoint& aPoint) { + nsIntPoint& operator+=(const nsIntPoint& aPoint) { x += aPoint.x; y += aPoint.y; return *this; } - nsFloatPoint& operator-=(const nsFloatPoint& aPoint) { + nsIntPoint& operator-=(const nsIntPoint& aPoint) { x -= aPoint.x; y -= aPoint.y; return *this; } + void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;} }; -#endif // !NS_COORD_IS_FLOAT #endif /* NSPOINT_H */ diff --git a/gfx/public/nsRect.h b/gfx/public/nsRect.h index cf96e10f9278..b50f6a8616c1 100644 --- a/gfx/public/nsRect.h +++ b/gfx/public/nsRect.h @@ -47,6 +47,8 @@ #include "gfxCore.h" #include "nsTraceRefcnt.h" +struct nsIntRect; + struct NS_GFX nsRect { nscoord x, y; nscoord width, height; @@ -168,26 +170,6 @@ struct NS_GFX nsRect { nsRect& operator+=(const nsPoint& aPoint) {x += aPoint.x; y += aPoint.y; return *this;} nsRect& operator-=(const nsPoint& aPoint) {x -= aPoint.x; y -= aPoint.y; return *this;} - nsRect& operator*=(const float aScale) {x = NSToCoordRound(x * aScale); - y = NSToCoordRound(y * aScale); - width = NSToCoordRound(width * aScale); - height = NSToCoordRound(height * aScale); - return *this;} - - // Scale by aScale, converting coordinates to integers so that the result - // is the smallest integer-coordinate rectangle containing the unrounded result - nsRect& ScaleRoundOut(float aScale); - // Scale by the inverse of aScale, converting coordinates to integers so that the result - // is the smallest integer-coordinate rectangle containing the unrounded result. - // More accurate than ScaleRoundOut(1.0/aScale). - nsRect& ScaleRoundOutInverse(float aScale); - // Scale by aScale, converting coordinates to integers so that the result - // is the larges integer-coordinate rectangle contained in the unrounded result - nsRect& ScaleRoundIn(float aScale); - // Scale by the inverse of aScale, converting coordinates to integers so that - // the result contains the same pixel centers as the unrounded result - nsRect& ScaleRoundPreservingCentersInverse(float aScale); - // Helpers for accessing the vertices nsPoint TopLeft() const { return nsPoint(x, y); } nsPoint TopRight() const { return nsPoint(XMost(), y); } @@ -199,9 +181,14 @@ struct NS_GFX nsRect { // Helper methods for computing the extents nscoord XMost() const {return x + width;} nscoord YMost() const {return y + height;} + + inline nsRect ScaleRoundOutInverse(float aFactor); + + static inline nsIntRect ToNearestPixels(const nsRect &aRect, nscoord aAppUnitsPerPixel); + static inline nsIntRect ToOutsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel); + static inline nsIntRect ToInsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel); }; -#ifdef NS_COORD_IS_FLOAT struct NS_GFX nsIntRect { PRInt32 x, y; PRInt32 width, height; @@ -209,6 +196,10 @@ struct NS_GFX nsIntRect { // Constructors nsIntRect() : x(0), y(0), width(0), height(0) {} nsIntRect(const nsIntRect& aRect) {*this = aRect;} + nsIntRect(const nsIntPoint& aOrigin, const nsIntSize &aSize) { + x = aOrigin.x; y = aOrigin.y; + width = aSize.width; height = aSize.height; + } nsIntRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) { x = aX; y = aY; width = aWidth; height = aHeight; } @@ -218,11 +209,74 @@ struct NS_GFX nsIntRect { PRBool IsEmpty() const { return (PRBool) ((height <= 0) || (width <= 0)); } + void Empty() {width = height = 0;} + + // Inflate the rect by the specified width/height or margin + void Inflate(PRInt32 aDx, PRInt32 aDy) { + x -= aDx; + y -= aDy; + width += aDx*2; + height += aDy*2; + } + void Inflate(const nsIntMargin &aMargin) { + x -= aMargin.left; + y -= aMargin.top; + width += aMargin.left + aMargin.right; + height += aMargin.top + aMargin.bottom; + } + + // Overloaded operators. Note that '=' isn't defined so we'll get the + // compiler generated default assignment operator. + PRBool operator==(const nsIntRect& aRect) const { + return (PRBool) ((IsEmpty() && aRect.IsEmpty()) || + ((x == aRect.x) && (y == aRect.y) && + (width == aRect.width) && (height == aRect.height))); + } + PRBool operator!=(const nsIntRect& aRect) const { + return (PRBool) !operator==(aRect); + } + + nsIntRect operator+(const nsIntPoint& aPoint) const { + return nsIntRect(x + aPoint.x, y + aPoint.y, width, height); + } + nsIntRect operator-(const nsIntPoint& aPoint) const { + return nsIntRect(x - aPoint.x, y - aPoint.y, width, height); + } + nsIntRect& operator+=(const nsIntPoint& aPoint) {x += aPoint.x; y += aPoint.y; return *this;} + nsIntRect& operator-=(const nsIntPoint& aPoint) {x -= aPoint.x; y -= aPoint.y; return *this;} void SetRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) { x = aX; y = aY; width = aWidth; height = aHeight; } + void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;} + void MoveTo(const nsIntPoint& aPoint) {x = aPoint.x; y = aPoint.y;} + void MoveBy(PRInt32 aDx, PRInt32 aDy) {x += aDx; y += aDy;} + void MoveBy(const nsIntPoint& aPoint) {x += aPoint.x; y += aPoint.y;} + void SizeTo(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;} + void SizeTo(const nsIntSize& aSize) {SizeTo(aSize.width, aSize.height);} + void SizeBy(PRInt32 aDeltaWidth, PRInt32 aDeltaHeight) {width += aDeltaWidth; + height += aDeltaHeight;} + + PRBool Contains(const nsIntRect& aRect) const + { + return (PRBool) ((aRect.x >= x) && (aRect.y >= y) && + (aRect.XMost() <= XMost()) && (aRect.YMost() <= YMost())); + } + PRBool Contains(PRInt32 aX, PRInt32 aY) const + { + return (PRBool) ((aX >= x) && (aY >= y) && + (aX < XMost()) && (aY < YMost())); + } + PRBool Contains(const nsIntPoint& aPoint) const { return Contains(aPoint.x, aPoint.y); } + + // Intersection. Returns TRUE if the receiver overlaps aRect and + // FALSE otherwise + PRBool Intersects(const nsIntRect& aRect) const { + return (PRBool) ((x < aRect.XMost()) && (y < aRect.YMost()) && + (aRect.x < XMost()) && (aRect.y < YMost())); + } + // Computes the area in which aRect1 and aRect2 overlap, and fills 'this' with // the result. Returns FALSE if the rectangles don't intersect, and sets 'this' // rect to be an empty rect. @@ -237,13 +291,86 @@ struct NS_GFX nsIntRect { // 'this' can be the same object as either aRect1 or aRect2 PRBool UnionRect(const nsIntRect& aRect1, const nsIntRect& aRect2); + // Helpers for accessing the vertices + nsIntPoint TopLeft() const { return nsIntPoint(x, y); } + nsIntPoint TopRight() const { return nsIntPoint(XMost(), y); } + nsIntPoint BottomLeft() const { return nsIntPoint(x, YMost()); } + nsIntPoint BottomRight() const { return nsIntPoint(XMost(), YMost()); } + + nsIntSize Size() const { return nsIntSize(width, height); } + // Helper methods for computing the extents PRInt32 XMost() const {return x + width;} PRInt32 YMost() const {return y + height;} + + static inline nsRect ToAppUnits(const nsIntRect &aRect, nscoord aAppUnitsPerPixel); }; -#else -typedef nsRect nsIntRect; -#endif + +inline nsRect +nsRect::ScaleRoundOutInverse(float aFactor) +{ + nsRect rect; + rect.x = NSToIntFloor(x / aFactor); + rect.y = NSToIntFloor(y / aFactor); + rect.width = NSToIntCeil(XMost() / aFactor) - rect.x; + rect.height = NSToIntCeil(YMost() / aFactor) - rect.y; + return rect; +} + +/* + * App Unit/Pixel conversions + */ +// scale the rect but round to preserve centers +inline nsIntRect +nsRect::ToNearestPixels(const nsRect &aRect, nscoord aAppUnitsPerPixel) +{ + nsIntRect rect; + rect.x = NSToIntRound(NSAppUnitsToFloatPixels(aRect.x, aAppUnitsPerPixel)); + rect.y = NSToIntRound(NSAppUnitsToFloatPixels(aRect.y, aAppUnitsPerPixel)); + rect.width = NSToIntRound(NSAppUnitsToFloatPixels(aRect.XMost(), + aAppUnitsPerPixel)) - rect.x; + rect.height = NSToIntRound(NSAppUnitsToFloatPixels(aRect.YMost(), + aAppUnitsPerPixel)) - rect.y; + return rect; +} + +// scale the rect but round to smallest containing rect +inline nsIntRect +nsRect::ToOutsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel) +{ + nsIntRect rect; + rect.x = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.x, aAppUnitsPerPixel)); + rect.y = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.y, aAppUnitsPerPixel)); + rect.width = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.XMost(), + aAppUnitsPerPixel)) - rect.x; + rect.height = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.YMost(), + aAppUnitsPerPixel)) - rect.y; + return rect; +} + +// scale the rect but round to largest contained rect +inline nsIntRect +nsRect::ToInsidePixels(const nsRect &aRect, nscoord aAppUnitsPerPixel) +{ + nsIntRect rect; + rect.x = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.x, aAppUnitsPerPixel)); + rect.y = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.y, aAppUnitsPerPixel)); + rect.width = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.XMost(), + aAppUnitsPerPixel)) - rect.x; + rect.height = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.YMost(), + aAppUnitsPerPixel)) - rect.y; + return rect; +} + +// app units are integer multiples of pixels, so no rounding needed +inline nsRect +nsIntRect::ToAppUnits(const nsIntRect &aRect, nscoord aAppUnitsPerPixel) +{ + return nsRect(NSIntPixelsToAppUnits(aRect.x, aAppUnitsPerPixel), + NSIntPixelsToAppUnits(aRect.y, aAppUnitsPerPixel), + NSIntPixelsToAppUnits(aRect.width, aAppUnitsPerPixel), + NSIntPixelsToAppUnits(aRect.height, aAppUnitsPerPixel)); +} #ifdef DEBUG // Diagnostics diff --git a/gfx/public/nsSize.h b/gfx/public/nsSize.h index 22b5daf6937c..53790b3fbc35 100644 --- a/gfx/public/nsSize.h +++ b/gfx/public/nsSize.h @@ -71,7 +71,6 @@ struct nsSize { return *this;} }; -#ifdef NS_COORD_IS_FLOAT struct nsIntSize { PRInt32 width, height; @@ -79,10 +78,16 @@ struct nsIntSize { nsIntSize(const nsIntSize& aSize) {width = aSize.width; height = aSize.height;} nsIntSize(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;} + // Overloaded operators. Note that '=' isn't defined so we'll get the + // compiler generated default assignment operator + PRBool operator==(const nsIntSize& aSize) const { + return (PRBool) ((width == aSize.width) && (height == aSize.height)); + } + PRBool operator!=(const nsIntSize& aSize) const { + return (PRBool) ((width != aSize.width) || (height != aSize.height)); + } + void SizeTo(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;} }; -#else -typedef nsSize nsIntSize; -#endif #endif /* NSSIZE_H */ diff --git a/gfx/src/nsRect.cpp b/gfx/src/nsRect.cpp index e7ba395672ca..25dcd34f07ec 100644 --- a/gfx/src/nsRect.cpp +++ b/gfx/src/nsRect.cpp @@ -173,52 +173,6 @@ void nsRect::Deflate(const nsMargin &aMargin) height = PR_MAX(0, height - aMargin.TopBottom()); } -// scale the rect but round to smallest containing rect -nsRect& nsRect::ScaleRoundOut(float aScale) -{ - nscoord right = NSToCoordCeil(float(XMost()) * aScale); - nscoord bottom = NSToCoordCeil(float(YMost()) * aScale); - x = NSToCoordFloor(float(x) * aScale); - y = NSToCoordFloor(float(y) * aScale); - width = (right - x); - height = (bottom - y); - return *this; -} - -nsRect& nsRect::ScaleRoundOutInverse(float aScale) -{ - nscoord right = NSToCoordCeil(float(XMost()) / aScale); - nscoord bottom = NSToCoordCeil(float(YMost()) / aScale); - x = NSToCoordFloor(float(x) / aScale); - y = NSToCoordFloor(float(y) / aScale); - width = (right - x); - height = (bottom - y); - return *this; -} - -// scale the rect but round to largest contained rect -nsRect& nsRect::ScaleRoundIn(float aScale) -{ - nscoord right = NSToCoordFloor(float(XMost()) * aScale); - nscoord bottom = NSToCoordFloor(float(YMost()) * aScale); - x = NSToCoordCeil(float(x) * aScale); - y = NSToCoordCeil(float(y) * aScale); - width = (right - x); - height = (bottom - y); - return *this; -} - -nsRect& nsRect::ScaleRoundPreservingCentersInverse(float aScale) -{ - nscoord right = NSToCoordRound(float(XMost()) / aScale); - nscoord bottom = NSToCoordRound(float(YMost()) / aScale); - x = NSToCoordRound(float(x) / aScale); - y = NSToCoordRound(float(y) / aScale); - width = (right - x); - height = (bottom - y); - return *this; -} - #ifdef DEBUG // Diagnostics @@ -244,7 +198,8 @@ FILE* operator<<(FILE* out, const nsRect& rect) return out; } -#ifdef NS_COORD_IS_FLOAT +#endif // DEBUG + // Computes the area in which aRect1 and aRect2 overlap and fills 'this' with // the result. Returns FALSE if the rectangles don't intersect. PRBool nsIntRect::IntersectRect(const nsIntRect &aRect1, const nsIntRect &aRect2) @@ -314,6 +269,4 @@ PRBool nsIntRect::UnionRect(const nsIntRect &aRect1, const nsIntRect &aRect2) return result; } -#endif -#endif // DEBUG diff --git a/gfx/src/thebes/nsThebesImage.cpp b/gfx/src/thebes/nsThebesImage.cpp index 4081d8993e31..0e099c5d43f1 100644 --- a/gfx/src/thebes/nsThebesImage.cpp +++ b/gfx/src/thebes/nsThebesImage.cpp @@ -220,7 +220,7 @@ nsThebesImage::GetAlphaLineStride() } nsresult -nsThebesImage::ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect) +nsThebesImage::ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsIntRect *aUpdateRect) { // Check to see if we are running OOM nsCOMPtr mem; @@ -245,7 +245,7 @@ PRBool nsThebesImage::GetIsImageComplete() { if (!mImageComplete) - mImageComplete = (mDecoded == nsRect(0, 0, mWidth, mHeight)); + mImageComplete = (mDecoded == nsIntRect(0, 0, mWidth, mHeight)); return mImageComplete; } diff --git a/gfx/src/thebes/nsThebesImage.h b/gfx/src/thebes/nsThebesImage.h index b7840a51d71b..5620b6fb0b6a 100644 --- a/gfx/src/thebes/nsThebesImage.h +++ b/gfx/src/thebes/nsThebesImage.h @@ -71,7 +71,7 @@ public: virtual PRUint8 *GetAlphaBits(); virtual PRInt32 GetAlphaLineStride(); virtual PRBool GetIsImageComplete(); - virtual nsresult ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect); + virtual nsresult ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsIntRect *aUpdateRect); virtual nsresult Optimize(nsIDeviceContext* aContext); virtual nsColorMap *GetColorMap(); @@ -159,7 +159,7 @@ protected: PRInt32 mWidth; PRInt32 mHeight; PRInt32 mStride; - nsRect mDecoded; + nsIntRect mDecoded; PRPackedBool mImageComplete; PRPackedBool mSinglePixel; PRPackedBool mFormatChanged; diff --git a/gfx/src/thebes/nsThebesRenderingContext.cpp b/gfx/src/thebes/nsThebesRenderingContext.cpp index 28eac5509444..d1aba112e436 100644 --- a/gfx/src/thebes/nsThebesRenderingContext.cpp +++ b/gfx/src/thebes/nsThebesRenderingContext.cpp @@ -780,7 +780,7 @@ nsThebesRenderingContext::DrawTile(imgIContainer *aImage, aImage->GetCurrentFrame(getter_AddRefs(imgFrame)); if (!imgFrame) return NS_ERROR_FAILURE; - nsRect imgFrameRect; + nsIntRect imgFrameRect; imgFrame->GetRect(imgFrameRect); nsCOMPtr img(do_GetInterface(imgFrame)); diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 80275f59fc44..91c788deca80 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -1582,12 +1582,13 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext, nsCOMPtr image; req->GetImage(getter_AddRefs(image)); - nsSize imageSize; - image->GetWidth(&imageSize.width); - image->GetHeight(&imageSize.height); + nsIntSize imageIntSize; + image->GetWidth(&imageIntSize.width); + image->GetHeight(&imageIntSize.height); - imageSize.width = nsPresContext::CSSPixelsToAppUnits(imageSize.width); - imageSize.height = nsPresContext::CSSPixelsToAppUnits(imageSize.height); + nsSize imageSize; + imageSize.width = nsPresContext::CSSPixelsToAppUnits(imageIntSize.width); + imageSize.height = nsPresContext::CSSPixelsToAppUnits(imageIntSize.height); req = nsnull; @@ -1659,10 +1660,10 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext, gfxImgFrame->GetNeedsBackground(&needBackgroundColor); /* check for tiling of a image where frame smaller than container */ - nsSize iSize; + nsIntSize iSize; image->GetWidth(&iSize.width); image->GetHeight(&iSize.height); - nsRect iframeRect; + nsIntRect iframeRect; gfxImgFrame->GetRect(iframeRect); if (iSize.width != iframeRect.width || iSize.height != iframeRect.height) { @@ -1968,9 +1969,9 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext, } else { // Note that the subimage is in tile space so it may cover // multiple tiles of the image. - subimageRect.ScaleRoundOutInverse(nsIDeviceContext::AppUnitsPerCSSPixel()); + nsIntRect subimagePxRect(nsRect::ToOutsidePixels(subimageRect, nsIDeviceContext::AppUnitsPerCSSPixel())); aRenderingContext.DrawTile(image, absTileRect.x, absTileRect.y, - &drawRect, &subimageRect); + &drawRect, &subimagePxRect); } } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index f0a8b1080834..f0e804496ad3 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -368,7 +368,7 @@ private: */ nsresult InitInternal(nsIWidget* aParentWidget, nsISupports *aState, - const nsRect& aBounds, + const nsIntRect& aBounds, PRBool aDoCreation, PRBool aInPrintPreview, PRBool aNeedMakeCX = PR_TRUE); @@ -666,7 +666,7 @@ DocumentViewerImpl::GetContainer(nsISupports** aResult) NS_IMETHODIMP DocumentViewerImpl::Init(nsIWidget* aParentWidget, - const nsRect& aBounds) + const nsIntRect& aBounds) { nsresult rv = CreateDeviceContext(aParentWidget); NS_ENSURE_SUCCESS(rv, rv); @@ -709,7 +709,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow, PRBool aReena mPresShell->BeginObservingDocument(); // Initialize our view manager - nsRect bounds; + nsIntRect bounds; mWindow->GetBounds(bounds); nscoord width = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel() * bounds.width; @@ -805,7 +805,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow, PRBool aReena nsresult DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget, nsISupports *aState, - const nsRect& aBounds, + const nsIntRect& aBounds, PRBool aDoCreation, PRBool aInPrintPreview, PRBool aNeedMakeCX /*= PR_TRUE*/) @@ -1247,7 +1247,7 @@ DocumentViewerImpl::Open(nsISupports *aState, nsISHEntry *aSHEntry) if (!container) return NS_ERROR_NOT_AVAILABLE; - nsRect bounds; + nsIntRect bounds; mWindow->GetBounds(bounds); nsresult rv = InitInternal(mParentWidget, aState, bounds, PR_FALSE, PR_FALSE); @@ -1738,7 +1738,7 @@ DocumentViewerImpl::GetPresContext(nsPresContext** aResult) } NS_IMETHODIMP -DocumentViewerImpl::GetBounds(nsRect& aResult) +DocumentViewerImpl::GetBounds(nsIntRect& aResult) { NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); NS_PRECONDITION(mWindow, "null window"); @@ -1793,7 +1793,7 @@ DocumentViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) } NS_IMETHODIMP -DocumentViewerImpl::SetBounds(const nsRect& aBounds) +DocumentViewerImpl::SetBounds(const nsIntRect& aBounds) { NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); @@ -1900,7 +1900,7 @@ DocumentViewerImpl::Show(void) return rv; } - nsRect tbounds; + nsIntRect tbounds; mParentWidget->GetBounds(tbounds); rv = MakeWindow(nsSize(mPresContext->DevPixelsToAppUnits(tbounds.width), @@ -4088,7 +4088,7 @@ NS_IMETHODIMP DocumentViewerImpl::SetPageMode(PRBool aPageMode, nsIPrintSettings // reftests that require a paginated context mIsPageMode = aPageMode; // Get the current size of what is being viewed - nsRect bounds; + nsIntRect bounds; mWindow->GetBounds(bounds); if (mPresShell) { diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index af3b5723289e..fdec63d23d62 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -102,11 +102,10 @@ class gfxContext; typedef short SelectionType; typedef PRUint32 nsFrameState; - -// 134e504f-4fd1-4590-9f5d-899afee63d0f +// b86c23c5-602d-4ca6-a968-379b244fed9e #define NS_IPRESSHELL_IID \ -{ 0x134e504f, 0x4fd1, 0x4590, \ - { 0x9f, 0x5d, 0x89, 0x9a, 0xfe, 0xe6, 0x3d, 0x0f } } +{ 0xb86c23c5, 0x602d, 0x4ca6, \ + { 0xa9, 0x68, 0x37, 0x9b, 0x24, 0x4f, 0xed, 0x9e } } // Constants for ScrollContentIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -739,8 +738,8 @@ public: */ virtual already_AddRefed RenderNode(nsIDOMNode* aNode, nsIRegion* aRegion, - nsPoint& aPoint, - nsRect* aScreenRect) = 0; + nsIntPoint& aPoint, + nsIntRect* aScreenRect) = 0; /* * Renders a selection to a surface and returns it. This method is primarily @@ -758,8 +757,8 @@ public: * as the position can be determined from the displayed frames. */ virtual already_AddRefed RenderSelection(nsISelection* aSelection, - nsPoint& aPoint, - nsRect* aScreenRect) = 0; + nsIntPoint& aPoint, + nsIntRect* aScreenRect) = 0; void AddWeakFrame(nsWeakFrame* aWeakFrame); void RemoveWeakFrame(nsWeakFrame* aWeakFrame); diff --git a/layout/base/nsImageLoader.cpp b/layout/base/nsImageLoader.cpp index f917dbb115c2..cc3be8faa7ed 100644 --- a/layout/base/nsImageLoader.cpp +++ b/layout/base/nsImageLoader.cpp @@ -184,7 +184,7 @@ NS_IMETHODIMP nsImageLoader::OnStopFrame(imgIRequest *aRequest, NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect) + nsIntRect *dirtyRect) { if (!mFrame) return NS_ERROR_FAILURE; @@ -194,12 +194,7 @@ NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer, return NS_OK; } - nsRect r(*dirtyRect); - - r.x = nsPresContext::CSSPixelsToAppUnits(r.x); - r.y = nsPresContext::CSSPixelsToAppUnits(r.y); - r.width = nsPresContext::CSSPixelsToAppUnits(r.width); - r.height = nsPresContext::CSSPixelsToAppUnits(r.height); + nsRect r(nsIntRect::ToAppUnits(*dirtyRect, nsPresContext::AppUnitsPerCSSPixel())); RedrawDirtyFrame(&r); diff --git a/layout/base/nsImageLoader.h b/layout/base/nsImageLoader.h index 578ea40a56f1..9f8fc129b2ab 100644 --- a/layout/base/nsImageLoader.h +++ b/layout/base/nsImageLoader.h @@ -67,7 +67,7 @@ public: // imgIContainerObserver (override nsStubImageDecoderObserver) NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect); + nsIntRect *dirtyRect); void Init(nsIFrame *aFrame, nsPresContext *aPresContext, PRBool aReflowOnLoad); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 6c817e739a70..2a4ff459c117 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -816,11 +816,11 @@ nsLayoutUtils::GetEventCoordinatesForNearestView(nsEvent* aEvent, GUIEvent->refPoint, frameView); } -static nsPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) { - nsPoint offset(0, 0); +static nsIntPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) { + nsIntPoint offset(0, 0); nsIWidget* parent = aWidget->GetParent(); while (parent) { - nsRect bounds; + nsIntRect bounds; aWidget->GetBounds(bounds); offset += bounds.TopLeft(); aWidget = parent; @@ -839,9 +839,9 @@ nsLayoutUtils::TranslateWidgetToView(nsPresContext* aPresContext, nsIWidget* viewWidget = aView->GetNearestWidget(&viewOffset); nsIWidget* fromRoot; - nsPoint fromOffset = GetWidgetOffset(aWidget, fromRoot); + nsIntPoint fromOffset(GetWidgetOffset(aWidget, fromRoot)); nsIWidget* toRoot; - nsPoint toOffset = GetWidgetOffset(viewWidget, toRoot); + nsIntPoint toOffset(GetWidgetOffset(viewWidget, toRoot)); nsIntPoint widgetPoint; if (fromRoot == toRoot) { @@ -1986,7 +1986,7 @@ nsLayoutUtils::IntrinsicForContainer(nsIRenderingContext *aRenderingContext, const nsStyleDisplay *disp = aFrame->GetStyleDisplay(); if (aFrame->IsThemed(disp)) { - nsSize size(0, 0); + nsIntSize size(0, 0); PRBool canOverride = PR_TRUE; nsPresContext *presContext = aFrame->PresContext(); presContext->GetTheme()-> diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 25fa1b463ee7..3b95988e52c3 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -565,7 +565,7 @@ public: mDeviceContext->AppUnitsPerInch()); } // Margin-specific version, since they often need TwipsToAppUnits - nsMargin TwipsToAppUnits(const nsMargin &marginInTwips) const + nsMargin TwipsToAppUnits(const nsIntMargin &marginInTwips) const { return nsMargin(TwipsToAppUnits(marginInTwips.left), TwipsToAppUnits(marginInTwips.top), TwipsToAppUnits(marginInTwips.right), diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 5189cd8008ee..1b0c476135bd 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -887,12 +887,12 @@ public: virtual already_AddRefed RenderNode(nsIDOMNode* aNode, nsIRegion* aRegion, - nsPoint& aPoint, - nsRect* aScreenRect); + nsIntPoint& aPoint, + nsIntRect* aScreenRect); virtual already_AddRefed RenderSelection(nsISelection* aSelection, - nsPoint& aPoint, - nsRect* aScreenRect); + nsIntPoint& aPoint, + nsIntRect* aScreenRect); //nsIViewObserver interface @@ -1097,8 +1097,8 @@ protected: nsISelection* aSelection, nsIRegion* aRegion, nsRect aArea, - nsPoint& aPoint, - nsRect* aScreenRect); + nsIntPoint& aPoint, + nsIntRect* aScreenRect); /** * Methods to handle changes to user and UA sheet lists that we get @@ -5158,8 +5158,8 @@ PresShell::PaintRangePaintInfo(nsTArray >* aItems, nsISelection* aSelection, nsIRegion* aRegion, nsRect aArea, - nsPoint& aPoint, - nsRect* aScreenRect) + nsIntPoint& aPoint, + nsIntRect* aScreenRect) { nsPresContext* pc = GetPresContext(); if (!pc || aArea.width == 0 || aArea.height == 0) @@ -5168,8 +5168,7 @@ PresShell::PaintRangePaintInfo(nsTArray >* aItems, nsIDeviceContext* deviceContext = pc->DeviceContext(); // use the rectangle to create the surface - nsRect pixelArea = aArea; - pixelArea.ScaleRoundOut(1.0 / pc->AppUnitsPerDevPixel()); + nsIntRect pixelArea(nsRect::ToOutsidePixels(aArea, pc->AppUnitsPerDevPixel())); // if the area of the image is larger than the maximum area, scale it down float scale = 0.0; @@ -5273,8 +5272,8 @@ PresShell::PaintRangePaintInfo(nsTArray >* aItems, already_AddRefed PresShell::RenderNode(nsIDOMNode* aNode, nsIRegion* aRegion, - nsPoint& aPoint, - nsRect* aScreenRect) + nsIntPoint& aPoint, + nsIntRect* aScreenRect) { // area will hold the size of the surface needed to draw the node, measured // from the root frame. @@ -5298,12 +5297,11 @@ PresShell::RenderNode(nsIDOMNode* aNode, if (aRegion) { // combine the area with the supplied region - nsRect rrectPixels; + nsIntRect rrectPixels; aRegion->GetBoundingBox(&rrectPixels.x, &rrectPixels.y, &rrectPixels.width, &rrectPixels.height); - nsRect rrect = rrectPixels; - rrect.ScaleRoundOut(nsPresContext::AppUnitsPerCSSPixel()); + nsRect rrect(nsIntRect::ToAppUnits(rrectPixels, nsPresContext::AppUnitsPerCSSPixel())); area.IntersectRect(area, rrect); nsPresContext* pc = GetPresContext(); @@ -5321,8 +5319,8 @@ PresShell::RenderNode(nsIDOMNode* aNode, already_AddRefed PresShell::RenderSelection(nsISelection* aSelection, - nsPoint& aPoint, - nsRect* aScreenRect) + nsIntPoint& aPoint, + nsIntRect* aScreenRect) { // area will hold the size of the surface needed to draw the selection, // measured from the root frame. @@ -6709,6 +6707,37 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg, printf(" %s\n", aMsg); } +static void +LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg, + const nsIntRect& r1, const nsIntRect& r2) +{ + printf("VerifyReflow Error:\n"); + nsAutoString name; + nsIFrameDebug* frameDebug; + + if (NS_SUCCEEDED(k1->QueryInterface(NS_GET_IID(nsIFrameDebug), + (void**)&frameDebug))) { + fprintf(stdout, " "); + frameDebug->GetFrameName(name); + fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout); + fprintf(stdout, " %p ", (void*)k1); + } + printf("{%d, %d, %d, %d}", r1.x, r1.y, r1.width, r1.height); + + printf(" != \n"); + + if (NS_SUCCEEDED(k2->QueryInterface(NS_GET_IID(nsIFrameDebug), + (void**)&frameDebug))) { + fprintf(stdout, " "); + frameDebug->GetFrameName(name); + fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout); + fprintf(stdout, " %p ", (void*)k2); + } + printf("{%d, %d, %d, %d}\n", r2.x, r2.y, r2.width, r2.height); + + printf(" %s\n", aMsg); +} + static PRBool CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame, nsPresContext* aSecondPresContext, nsIFrame* aSecondFrame) @@ -6736,7 +6765,7 @@ CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame, } } - nsRect r1, r2; + nsIntRect r1, r2; nsIView* v1, *v2; for (;;) { if (((nsnull == k1) && (nsnull != k2)) || diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index 927c67fde8d0..025f451d2f8c 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -72,12 +72,12 @@ public: // imgIDecoderObserver (override nsStubImageDecoderObserver) NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage); NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect); + const nsIntRect *aRect); NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status, const PRUnichar *statusArg); // imgIContainerObserver (override nsStubImageDecoderObserver) NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect); + nsIntRect *dirtyRect); void SetFrame(nsBulletFrame *frame) { mFrame = frame; } @@ -1462,7 +1462,7 @@ NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest, NS_IMETHODIMP nsBulletFrame::OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect) + const nsIntRect *aRect) { // The image has changed. // Invalidate the entire content area. Maybe it's not optimal but it's simple and @@ -1493,7 +1493,7 @@ NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest, NS_IMETHODIMP nsBulletFrame::FrameChanged(imgIContainer *aContainer, gfxIImageFrame *aNewFrame, - nsRect *aDirtyRect) + nsIntRect *aDirtyRect) { // Invalidate the entire content area. Maybe it's not optimal but it's simple and // always correct. @@ -1551,7 +1551,7 @@ NS_IMETHODIMP nsBulletListener::OnStartContainer(imgIRequest *aRequest, NS_IMETHODIMP nsBulletListener::OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect) + const nsIntRect *aRect) { if (!mFrame) return NS_ERROR_FAILURE; @@ -1571,7 +1571,7 @@ NS_IMETHODIMP nsBulletListener::OnStopDecode(imgIRequest *aRequest, NS_IMETHODIMP nsBulletListener::FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect) + nsIntRect *dirtyRect) { if (!mFrame) return NS_ERROR_FAILURE; diff --git a/layout/generic/nsBulletFrame.h b/layout/generic/nsBulletFrame.h index 42e16faf5142..1ba738bdafc7 100644 --- a/layout/generic/nsBulletFrame.h +++ b/layout/generic/nsBulletFrame.h @@ -82,13 +82,13 @@ public: NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage); NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect * rect); + const nsIntRect *aRect); NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult aStatus, const PRUnichar *aStatusArg); NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *aNewframe, - nsRect *aDirtyRect); + nsIntRect *aDirtyRect); /* get list item text, without '.' */ static PRBool AppendCounterText(PRInt32 aListStyleType, diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 7cf7208e3ef9..00742c5e5444 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -584,16 +584,15 @@ nsIFrame::GetUsedBorder() const const nsStyleDisplay *disp = GetStyleDisplay(); if (mutable_this->IsThemed(disp)) { - nsMargin result; + nsIntMargin result; nsPresContext *presContext = PresContext(); presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(), mutable_this, disp->mAppearance, &result); - result.top = presContext->DevPixelsToAppUnits(result.top); - result.right = presContext->DevPixelsToAppUnits(result.right); - result.bottom = presContext->DevPixelsToAppUnits(result.bottom); - result.left = presContext->DevPixelsToAppUnits(result.left); - return result; + return nsMargin(presContext->DevPixelsToAppUnits(result.top), + presContext->DevPixelsToAppUnits(result.right), + presContext->DevPixelsToAppUnits(result.bottom), + presContext->DevPixelsToAppUnits(result.left)); } return GetStyleBorder()->GetActualBorder(); @@ -616,14 +615,15 @@ nsIFrame::GetUsedPadding() const const nsStyleDisplay *disp = GetStyleDisplay(); if (mutable_this->IsThemed(disp)) { nsPresContext *presContext = PresContext(); + nsIntMargin widget; if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(), mutable_this, disp->mAppearance, - &padding)) { - padding.top = presContext->DevPixelsToAppUnits(padding.top); - padding.right = presContext->DevPixelsToAppUnits(padding.right); - padding.bottom = presContext->DevPixelsToAppUnits(padding.bottom); - padding.left = presContext->DevPixelsToAppUnits(padding.left); + &widget)) { + padding.top = presContext->DevPixelsToAppUnits(widget.top); + padding.right = presContext->DevPixelsToAppUnits(widget.right); + padding.bottom = presContext->DevPixelsToAppUnits(widget.bottom); + padding.left = presContext->DevPixelsToAppUnits(widget.left); return padding; } } @@ -816,9 +816,9 @@ void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder, nsRect rect(aBuilder->ToReferenceFrame(mFrame), mFrame->GetSize()); rect.IntersectRect(rect, aDirtyRect); - rect.ScaleRoundOut(1.0f / mFrame->PresContext()->AppUnitsPerDevPixel()); + nsIntRect pxRect(nsRect::ToOutsidePixels(rect, mFrame->PresContext()->AppUnitsPerDevPixel())); ctx->NewPath(); - ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height), PR_TRUE); + ctx->Rectangle(gfxRect(pxRect.x, pxRect.y, pxRect.width, pxRect.height), PR_TRUE); ctx->Fill(); } @@ -3067,13 +3067,13 @@ nsFrame::IntrinsicWidthOffsets(nsIRenderingContext* aRenderingContext) if (IsThemed(disp)) { nsPresContext *presContext = PresContext(); - nsMargin border; + nsIntMargin border; presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(), this, disp->mAppearance, &border); result.hBorder = presContext->DevPixelsToAppUnits(border.LeftRight()); - nsMargin padding; + nsIntMargin padding; if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(), this, disp->mAppearance, &padding)) { @@ -3184,15 +3184,16 @@ nsFrame::ComputeSize(nsIRenderingContext *aRenderingContext, const nsStyleDisplay *disp = GetStyleDisplay(); if (IsThemed(disp)) { - nsSize size(0, 0); + nsIntSize widget(0, 0); PRBool canOverride = PR_TRUE; nsPresContext *presContext = PresContext(); presContext->GetTheme()-> GetMinimumWidgetSize(aRenderingContext, this, disp->mAppearance, - &size, &canOverride); + &widget, &canOverride); - size.width = presContext->DevPixelsToAppUnits(size.width); - size.height = presContext->DevPixelsToAppUnits(size.height); + nsSize size; + size.width = presContext->DevPixelsToAppUnits(widget.width); + size.height = presContext->DevPixelsToAppUnits(widget.height); // GMWS() returns border-box; we need content-box size.width -= aBorder.width + aPadding.width; @@ -3549,9 +3550,7 @@ nsIntRect nsIFrame::GetScreenRectExternal() const nsIntRect nsIFrame::GetScreenRect() const { - nsRect r = GetScreenRectInAppUnits().ScaleRoundOutInverse(PresContext()->AppUnitsPerDevPixel()); - // nsRect and nsIntRect are not necessarily the same - return nsIntRect(r.x, r.y, r.width, r.height); + return nsRect::ToOutsidePixels(GetScreenRectInAppUnits(), PresContext()->AppUnitsPerDevPixel()); } // virtual @@ -3571,7 +3570,6 @@ nsRect nsIFrame::GetScreenRectInAppUnits() const nsIWidget* widget = view->GetNearestWidget(&toWidgetOffset); if (widget) { - // WidgetToScreen really should take nsIntRect, not nsRect nsIntRect localRect(0,0,0,0), screenRect; widget->WidgetToScreen(localRect, screenRect); diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index c2672e3cb29e..53893da9dc6d 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -191,7 +191,7 @@ public: virtual void ReflowCallbackCanceled(); protected: - nsSize GetMargin(); + nsIntSize GetMargin(); PRBool IsInline() { return mIsInline; } nsresult ShowDocShell(); nsresult CreateViewAndWidget(nsContentType aContentType); @@ -803,9 +803,9 @@ nsSubDocumentFrame::HideViewer() } } -nsSize nsSubDocumentFrame::GetMargin() +nsIntSize nsSubDocumentFrame::GetMargin() { - nsSize result(-1, -1); + nsIntSize result(-1, -1); nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); if (content) { const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::marginwidth); @@ -919,7 +919,7 @@ nsSubDocumentFrame::ShowDocShell() // pass along marginwidth, marginheight, scrolling so sub document // can use it - nsSize margin = GetMargin(); + nsIntSize margin(GetMargin()); docShell->SetMarginWidth(margin.width); docShell->SetMarginHeight(margin.height); diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 459c236b2a80..1735c76e3f34 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -744,7 +744,7 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild) // only valid for non border children void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent, nsSize& aSize, - nsPoint& aCellIndex) + nsIntPoint& aCellIndex) { PRInt32 row = aIndexInParent / mNumCols; PRInt32 col = aIndexInParent - (row * mNumCols); // remainder from dividing index by mNumCols @@ -754,7 +754,8 @@ void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent, aCellIndex.x = col; aCellIndex.y = row; } else { - aSize.width = aSize.height = aCellIndex.x = aCellIndex.y = 0; + aSize.width = aSize.height = 0; + aCellIndex.x = aCellIndex.y = 0; } } @@ -768,7 +769,7 @@ void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, for (nsIFrame* child = mFrames.FirstChild(); child; child = child->GetNextSibling()) { if (aChild == child) { - nsPoint ignore; + nsIntPoint ignore; GetSizeOfChildAt(i, aSize, ignore); return; } @@ -863,7 +864,7 @@ nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild, const nsHTMLReflowState& aReflowState, nsPoint& aOffset, nsSize& aSize, - nsPoint* aCellIndex) + nsIntPoint* aCellIndex) { // reflow the child nsHTMLReflowState reflowState(aPresContext, aReflowState, aChild, aSize); @@ -1068,7 +1069,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext, nsIFrame* lastChild = mFrames.LastChild(); for (PRInt32 childX = 0; childX < mNonBorderChildCount; childX++) { - nsPoint cellIndex; + nsIntPoint cellIndex; GetSizeOfChildAt(childX, size, cellIndex); if (lastRow != cellIndex.y) { // changed to next row diff --git a/layout/generic/nsFrameSetFrame.h b/layout/generic/nsFrameSetFrame.h index 4b7de877a43f..9c045864452b 100644 --- a/layout/generic/nsFrameSetFrame.h +++ b/layout/generic/nsFrameSetFrame.h @@ -127,7 +127,7 @@ public: void GetSizeOfChildAt(PRInt32 aIndexInParent, nsSize& aSize, - nsPoint& aCellIndex); + nsIntPoint& aCellIndex); static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild); @@ -225,7 +225,7 @@ protected: const nsHTMLReflowState& aReflowState, nsPoint& aOffset, nsSize& aSize, - nsPoint* aCellIndex = 0); + nsIntPoint* aCellIndex = 0); PRBool CanResize(PRBool aVertical, PRBool aLeft); @@ -256,7 +256,7 @@ protected: nsHTMLFramesetBorderFrame* mDragger; nsFramesetDrag mDrag; - nsPoint mFirstDragPoint; + nsIntPoint mFirstDragPoint; PRInt32 mPrevNeighborOrigSize; // used during resize PRInt32 mNextNeighborOrigSize; PRInt32 mMinDrag; diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index fc2c5425556b..761ad3398655 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -59,7 +59,7 @@ nsHTMLCanvasFrame::~nsHTMLCanvasFrame() { } -nsSize +nsIntSize nsHTMLCanvasFrame::GetCanvasSize() { PRUint32 w, h; @@ -76,7 +76,7 @@ nsHTMLCanvasFrame::GetCanvasSize() h = w = 1; } - return nsSize(w, h); + return nsIntSize(w, h); } /* virtual */ nscoord @@ -102,7 +102,9 @@ nsHTMLCanvasFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext) /* virtual */ nsSize nsHTMLCanvasFrame::GetIntrinsicRatio() { - return GetCanvasSize(); + nsIntSize size(GetCanvasSize()); + return nsSize(nsPresContext::CSSPixelsToAppUnits(size.width), + nsPresContext::CSSPixelsToAppUnits(size.height)); } /* virtual */ nsSize @@ -111,13 +113,13 @@ nsHTMLCanvasFrame::ComputeSize(nsIRenderingContext *aRenderingContext, nsSize aMargin, nsSize aBorder, nsSize aPadding, PRBool aShrinkWrap) { - nsSize size = GetCanvasSize(); + nsIntSize size(GetCanvasSize()); IntrinsicSize intrinsicSize; intrinsicSize.width.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(size.width)); intrinsicSize.height.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(size.height)); - nsSize& intrinsicRatio = size; // won't actually be used + nsSize intrinsicRatio(size.width, size.height); // won't actually be used return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions( aRenderingContext, this, @@ -197,7 +199,7 @@ nsHTMLCanvasFrame::PaintCanvas(nsIRenderingContext& aRenderingContext, if (inner.width == 0 || inner.height == 0) return; - nsSize canvasSize = GetCanvasSize(); + nsIntSize canvasSize(GetCanvasSize()); nsSize sizeAppUnits(PresContext()->DevPixelsToAppUnits(canvasSize.width), PresContext()->DevPixelsToAppUnits(canvasSize.height)); diff --git a/layout/generic/nsHTMLCanvasFrame.h b/layout/generic/nsHTMLCanvasFrame.h index f16d0f589330..8b0d49496f3e 100644 --- a/layout/generic/nsHTMLCanvasFrame.h +++ b/layout/generic/nsHTMLCanvasFrame.h @@ -61,7 +61,7 @@ public: const nsRect& aDirtyRect, nsPoint aPt); /* get the size of the canvas's image */ - nsSize GetCanvasSize(); + nsIntSize GetCanvasSize(); virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext); virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext); diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 3c0087fefd89..1c9edce2792e 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -1829,14 +1829,15 @@ nsCSSOffsetState::InitOffsets(nscoord aContainingBlockWidth, PRBool isThemed = frame->IsThemed(disp); nsPresContext *presContext = frame->PresContext(); + nsIntMargin widget; if (isThemed && presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(), frame, disp->mAppearance, - &mComputedPadding)) { - mComputedPadding.top = presContext->DevPixelsToAppUnits(mComputedPadding.top); - mComputedPadding.right = presContext->DevPixelsToAppUnits(mComputedPadding.right); - mComputedPadding.bottom = presContext->DevPixelsToAppUnits(mComputedPadding.bottom); - mComputedPadding.left = presContext->DevPixelsToAppUnits(mComputedPadding.left); + &widget)) { + mComputedPadding.top = presContext->DevPixelsToAppUnits(widget.top); + mComputedPadding.right = presContext->DevPixelsToAppUnits(widget.right); + mComputedPadding.bottom = presContext->DevPixelsToAppUnits(widget.bottom); + mComputedPadding.left = presContext->DevPixelsToAppUnits(widget.left); } else if (aPadding) { // padding is an input arg mComputedPadding.top = aPadding->top; @@ -1849,17 +1850,18 @@ nsCSSOffsetState::InitOffsets(nscoord aContainingBlockWidth, } if (isThemed) { + nsIntMargin widget; presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(), frame, disp->mAppearance, - &mComputedBorderPadding); + &widget); mComputedBorderPadding.top = - presContext->DevPixelsToAppUnits(mComputedBorderPadding.top); + presContext->DevPixelsToAppUnits(widget.top); mComputedBorderPadding.right = - presContext->DevPixelsToAppUnits(mComputedBorderPadding.right); + presContext->DevPixelsToAppUnits(widget.right); mComputedBorderPadding.bottom = - presContext->DevPixelsToAppUnits(mComputedBorderPadding.bottom); + presContext->DevPixelsToAppUnits(widget.bottom); mComputedBorderPadding.left = - presContext->DevPixelsToAppUnits(mComputedBorderPadding.left); + presContext->DevPixelsToAppUnits(widget.left); } else if (aBorder) { // border is an input arg mComputedBorderPadding = *aBorder; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 52712112e904..73980542fccc 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -303,7 +303,7 @@ nsImageFrame::UpdateIntrinsicSize(imgIContainer* aImage) PRBool intrinsicSizeChanged = PR_FALSE; if (aImage) { - nsSize imageSizeInPx; + nsIntSize imageSizeInPx; aImage->GetWidth(&imageSizeInPx.width); aImage->GetHeight(&imageSizeInPx.height); nsSize newSize(nsPresContext::CSSPixelsToAppUnits(imageSizeInPx.width), @@ -387,7 +387,7 @@ nsImageFrame::IsPendingLoad(imgIContainer* aContainer) const } nsRect -nsImageFrame::SourceRectToDest(const nsRect& aRect) +nsImageFrame::SourceRectToDest(const nsIntRect& aRect) { // When scaling the image, row N of the source image may (depending on // the scaling function) be used to draw any row in the destination image @@ -532,7 +532,7 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) nsresult nsImageFrame::OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect) + const nsIntRect *aRect) { // XXX do we need to make sure that the reflow from the // OnStartContainer has been processed before we start calling @@ -644,7 +644,7 @@ nsImageFrame::OnStopDecode(imgIRequest *aRequest, nsresult nsImageFrame::FrameChanged(imgIContainer *aContainer, gfxIImageFrame *aNewFrame, - nsRect *aDirtyRect) + nsIntRect *aDirtyRect) { if (!GetStyleVisibility()->IsVisible()) { return NS_OK; @@ -1838,7 +1838,7 @@ NS_IMETHODIMP nsImageListener::OnStartContainer(imgIRequest *aRequest, NS_IMETHODIMP nsImageListener::OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect) + const nsIntRect *aRect) { if (!mFrame) return NS_ERROR_FAILURE; @@ -1858,7 +1858,7 @@ NS_IMETHODIMP nsImageListener::OnStopDecode(imgIRequest *aRequest, NS_IMETHODIMP nsImageListener::FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect) + nsIntRect * dirtyRect) { if (!mFrame) return NS_ERROR_FAILURE; diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index c1e66ae45766..d51589f1ce22 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -74,12 +74,12 @@ public: // imgIDecoderObserver (override nsStubImageDecoderObserver) NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage); NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect); + const nsIntRect *aRect); NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status, const PRUnichar *statusArg); // imgIContainerObserver (override nsStubImageDecoderObserver) NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect); + nsIntRect * dirtyRect); void SetFrame(nsImageFrame *frame) { mFrame = frame; } @@ -225,13 +225,13 @@ protected: nsresult OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage); nsresult OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect * rect); + const nsIntRect *rect); nsresult OnStopDecode(imgIRequest *aRequest, nsresult aStatus, const PRUnichar *aStatusArg); nsresult FrameChanged(imgIContainer *aContainer, gfxIImageFrame *aNewframe, - nsRect *aDirtyRect); + nsIntRect *aDirtyRect); private: // random helpers @@ -268,7 +268,7 @@ private: * Function to convert a dirty rect in the source image to a dirty * rect for the image frame. */ - nsRect SourceRectToDest(const nsRect & aRect); + nsRect SourceRectToDest(const nsIntRect & aRect); nsImageMap* mImageMap; diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 52be4b169c83..0039f5c5dc4a 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -523,10 +523,6 @@ private: }; -#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && defined(XP_MACOSX)) || defined(XP_OS2) -static void ConvertAppUnitsToPixels(const nsPresContext& aPresContext, const nsRect& aTwipsRect, nsIntRect& aPixelRect); -#endif - // Mac specific code to fix up port position and clip during paint #ifdef XP_MACOSX @@ -916,7 +912,7 @@ nsObjectFrame::FixupWindow(const nsSize& aSize) PRBool windowless = (window->type == nsPluginWindowType_Drawable); - nsPoint origin = GetWindowOriginInPixels(windowless); + nsIntPoint origin = GetWindowOriginInPixels(windowless); window->x = origin.x; window->y = origin.y; @@ -963,7 +959,7 @@ nsObjectFrame::CallSetWindow() PRBool windowless = (window->type == nsPluginWindowType_Drawable); - nsPoint origin = GetWindowOriginInPixels(windowless); + nsIntPoint origin = GetWindowOriginInPixels(windowless); window->x = origin.x; window->y = origin.y; @@ -1016,7 +1012,7 @@ nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const return PR_FALSE; } -nsPoint nsObjectFrame::GetWindowOriginInPixels(PRBool aWindowless) +nsIntPoint nsObjectFrame::GetWindowOriginInPixels(PRBool aWindowless) { nsIView * parentWithView; nsPoint origin(0,0); @@ -1045,10 +1041,8 @@ nsPoint nsObjectFrame::GetWindowOriginInPixels(PRBool aWindowless) } } - origin.x = PresContext()->AppUnitsToDevPixels(origin.x); - origin.y = PresContext()->AppUnitsToDevPixels(origin.y); - - return origin; + return nsIntPoint(PresContext()->AppUnitsToDevPixels(origin.x), + PresContext()->AppUnitsToDevPixels(origin.y)); } NS_IMETHODIMP @@ -1427,7 +1421,7 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext, // check if we need to call SetWindow with updated parameters PRBool doupdatewindow = PR_FALSE; // the offset of the DC - nsPoint origin; + nsIntPoint origin; /* * Layout now has an optimized way of painting. Now we always get @@ -1521,7 +1515,7 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext, // and we can safely use this message to tell the plugin exactly where it is in all cases. origin = GetWindowOriginInPixels(PR_TRUE); - nsRect winlessRect = nsRect(origin, nsSize(window->width, window->height)); + nsIntRect winlessRect(origin, nsIntSize(window->width, window->height)); // XXX I don't think we can be certain that the location wrt to // the window only changes when the location wrt to the drawable // changes, but the hdc probably changes on every paint so @@ -3710,8 +3704,8 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent) const nsMouseEvent& mouseEvent = static_cast(anEvent); // Get reference point relative to screen: - nsRect windowRect(anEvent.refPoint, nsSize(1, 1)); - nsRect rootPoint(-1,-1,1,1); + nsIntRect windowRect(anEvent.refPoint, nsIntSize(1, 1)); + nsIntRect rootPoint(-1,-1,1,1); if (widget) widget->WidgetToScreen(windowRect, rootPoint); #ifdef MOZ_WIDGET_GTK2 @@ -3984,12 +3978,8 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect) // Convert dirty rect relative coordinates to absolute and also get the containerWidget ConvertRelativeToWindowAbsolute(mOwner, rel, abs, *getter_AddRefs(containerWidget)); - nsRect absDirtyRect = nsRect(abs.x, abs.y, aDirtyRect.width, aDirtyRect.height); - // Convert to absolute pixel values for the dirty rect - nsIntRect absDirtyRectInPixels; - ConvertAppUnitsToPixels(*mOwner->GetPresContext(), absDirtyRect, - absDirtyRectInPixels); + nsIntRect absDirtyRect(nsRect::ToOutsidePixels(nsRect(abs, aDirtyRect), *mOwner->GetPresContext()->AppUnitsPerDevPixel())); #endif nsCOMPtr pluginWidget = do_QueryInterface(mWidget); @@ -4018,18 +4008,15 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HDC ndc) nsPluginWindow * window; GetWindow(window); - nsRect relDirtyRect = nsRect(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); - nsIntRect relDirtyRectInPixels; - ConvertAppUnitsToPixels(*mOwner->PresContext(), relDirtyRect, - relDirtyRectInPixels); + nsIntRect relDirtyRect(nsRect::ToOutsidePixels(aDirtyRect, mOwner->PresContext()->AppUnitsPerDevPixel())); // 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; + drc.left = relDirtyRect.x + window->x; + drc.top = relDirtyRect.y + window->y; + drc.right = drc.left + relDirtyRect.width; + drc.bottom = drc.top + relDirtyRect.height; nsPluginEvent pluginEvent; pluginEvent.event = WM_PAINT; @@ -4048,18 +4035,15 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HPS aHPS) nsPluginWindow * window; GetWindow(window); - nsRect relDirtyRect = nsRect(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); - nsIntRect relDirtyRectInPixels; - ConvertAppUnitsToPixels(*mOwner->PresContext(), relDirtyRect, - relDirtyRectInPixels); + nsIntRect relDirtyRect(nsRect::ToOutsidePixels(aDirtyRect, mOwner->PresContext()->AppUnitsPerDevicePixel())); // we got dirty rectangle in relative window coordinates, but we // need it in absolute units and in the (left, top, right, bottom) form RECTL rectl; - rectl.xLeft = relDirtyRectInPixels.x + window->x; - rectl.yBottom = relDirtyRectInPixels.y + window->y; - rectl.xRight = rectl.xLeft + relDirtyRectInPixels.width; - rectl.yTop = rectl.yBottom + relDirtyRectInPixels.height; + rectl.xLeft = relDirtyRect.x + window->x; + rectl.yBottom = relDirtyRect.y + window->y; + rectl.xRight = rectl.xLeft + relDirtyRect.width; + rectl.yTop = rectl.yBottom + relDirtyRect.height; nsPluginEvent pluginEvent; pluginEvent.event = WM_PAINT; @@ -4544,17 +4528,6 @@ void nsPluginInstanceOwner::SetPluginHost(nsIPluginHost* aHost) mPluginHost = aHost; } -#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && defined(XP_MACOSX)) || defined(XP_OS2) -// convert frame coordinates from twips to pixels -static void ConvertAppUnitsToPixels(const nsPresContext& aPresContext, const nsRect& aTwipsRect, nsIntRect& aPixelRect) -{ - aPixelRect.x = aPresContext.AppUnitsToDevPixels(aTwipsRect.x); - aPixelRect.y = aPresContext.AppUnitsToDevPixels(aTwipsRect.y); - aPixelRect.width = aPresContext.AppUnitsToDevPixels(aTwipsRect.width); - aPixelRect.height = aPresContext.AppUnitsToDevPixels(aTwipsRect.height); -} -#endif - // Mac specific code to fix up the port location and clipping region #ifdef XP_MACOSX @@ -4635,13 +4608,13 @@ WindowRef nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState) // use its native widget (an obj-c object) we have to go // from the widget's screen coordinates to its window coords // instead of straight to window coords. - nsRect geckoBounds; + nsIntRect geckoBounds; mWidget->GetBounds(geckoBounds); // we need a rect that is the entire *internal* rect, so the // x and y coords are 0, width is the same. geckoBounds.x = 0; geckoBounds.y = 0; - nsRect geckoScreenCoords; + nsIntRect geckoScreenCoords; mWidget->WidgetToScreen(geckoBounds, geckoScreenCoords); Rect windowRect; diff --git a/layout/generic/nsObjectFrame.h b/layout/generic/nsObjectFrame.h index f2ae3b7f1ccc..0a6be3b25f1c 100644 --- a/layout/generic/nsObjectFrame.h +++ b/layout/generic/nsObjectFrame.h @@ -175,7 +175,7 @@ protected: void NotifyContentObjectWrapper(); - nsPoint GetWindowOriginInPixels(PRBool aWindowless); + nsIntPoint GetWindowOriginInPixels(PRBool aWindowless); static void PaintPrintPlugin(nsIFrame* aFrame, nsIRenderingContext* aRenderingContext, @@ -197,7 +197,7 @@ protected: friend class nsPluginInstanceOwner; private: nsRefPtr mInstanceOwner; - nsRect mWindowlessRect; + nsIntRect mWindowlessRect; // For assertions that make it easier to determine if a crash is due // to the underlying problem described in bug 136927, and to prevent diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index d9a81c47e1ce..147801f854f0 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -545,9 +545,8 @@ nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext, aRenderingContext.Translate(framePos.x, framePos.y); // aPt translates to coords relative to this, then margins translate to // pageContentFrame's coords - rect -= framePos; aRenderingContext.Scale(scale, scale); - rect.ScaleRoundOut(1.0f / scale); + rect = (rect - framePos).ScaleRoundOutInverse(scale); // Make sure we don't draw where we aren't supposed to draw, especially // when printing selection nsRect clipRect(nsPoint(0, 0), pageContentFrame->GetSize()); diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index d0339f62d076..84b92b7b663d 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -199,13 +199,13 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext, // now get out margins & edges if (mPageData->mPrintSettings) { - nsMargin unwriteableTwips; + nsIntMargin unwriteableTwips; mPageData->mPrintSettings->GetUnwriteableMarginInTwips(unwriteableTwips); NS_ASSERTION(unwriteableTwips.left >= 0 && unwriteableTwips.top >= 0 && unwriteableTwips.right >= 0 && unwriteableTwips.bottom >= 0, "Unwriteable twips should be non-negative"); - nsMargin marginTwips; + nsIntMargin marginTwips; mPageData->mPrintSettings->GetMarginInTwips(marginTwips); mMargin = aPresContext->TwipsToAppUnits(marginTwips + unwriteableTwips); @@ -213,11 +213,11 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext, mPageData->mPrintSettings->GetPrintRange(&printType); mPrintRangeType = printType; - nsMargin edgeTwips; + nsIntMargin edgeTwips; mPageData->mPrintSettings->GetEdgeInTwips(edgeTwips); // sanity check the values. three inches are sometimes needed - nscoord inchInTwips = NS_INCHES_TO_TWIPS(3.0); + PRInt32 inchInTwips = NS_INCHES_TO_TWIPS(3.0); edgeTwips.top = PR_MIN(PR_MAX(edgeTwips.top, 0), inchInTwips); edgeTwips.bottom = PR_MIN(PR_MAX(edgeTwips.bottom, 0), inchInTwips); edgeTwips.left = PR_MIN(PR_MAX(edgeTwips.left, 0), inchInTwips); @@ -700,9 +700,8 @@ nsSimplePageSequenceFrame::PaintPageSequence(nsIRenderingContext& aRenderingCont aRenderingContext.PushState(); nsPoint framePos = aPt; aRenderingContext.Translate(framePos.x, framePos.y); - rect -= framePos; aRenderingContext.Scale(scale, scale); - rect.ScaleRoundOut(1.0f / scale); + rect = (rect - framePos).ScaleRoundOutInverse(scale); // Now the rect and the rendering coordinates are are relative to this frame. // Loop over the pages and paint them. diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 7be7f22845fb..f52732c1beae 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -2202,8 +2202,8 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO) if (NS_SUCCEEDED(rv)) { mPrt->mPrintSettings->SetStartPageRange(startPageNum); mPrt->mPrintSettings->SetEndPageRange(endPageNum); - nsMargin marginTwips(0,0,0,0); - nsMargin unwrtMarginTwips(0,0,0,0); + nsIntMargin marginTwips(0,0,0,0); + nsIntMargin unwrtMarginTwips(0,0,0,0); mPrt->mPrintSettings->GetMarginInTwips(marginTwips); mPrt->mPrintSettings->GetUnwriteableMarginInTwips(unwrtMarginTwips); nsMargin totalMargin = poPresContext->TwipsToAppUnits(marginTwips + diff --git a/layout/svg/base/src/nsSVGEffects.cpp b/layout/svg/base/src/nsSVGEffects.cpp index 8d639bfa427f..804427b8204b 100644 --- a/layout/svg/base/src/nsSVGEffects.cpp +++ b/layout/svg/base/src/nsSVGEffects.cpp @@ -127,8 +127,7 @@ nsSVGFilterProperty::UpdateRect() { nsSVGFilterFrame *filter = GetFilterFrame(nsnull); if (filter) { - mFilterRect = filter->GetFilterBBox(mFrame, nsnull); - mFilterRect.ScaleRoundOut(filter->PresContext()->AppUnitsPerDevPixel()); + mFilterRect = nsIntRect::ToAppUnits(filter->GetFilterBBox(mFrame, nsnull), filter->PresContext()->AppUnitsPerDevPixel()); } else { mFilterRect = nsRect(); } diff --git a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp index 4dcbad2cf958..3b58b55477f4 100644 --- a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp +++ b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp @@ -700,8 +700,7 @@ nsSVGForeignObjectFrame::InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter, nsPresContext* presContext = PresContext(); nsCOMPtr tm = GetTMIncludingOffset(); - nsIntRect r = aRect; - r.ScaleRoundOut(1.0f / presContext->AppUnitsPerDevPixel()); + nsIntRect r(nsRect::ToOutsidePixels(aRect, presContext->AppUnitsPerDevPixel())); float x = r.x, y = r.y, w = r.width, h = r.height; nsRect rect = GetTransformedRegion(x, y, w, h, tm, presContext); diff --git a/layout/svg/base/src/nsSVGIntegrationUtils.cpp b/layout/svg/base/src/nsSVGIntegrationUtils.cpp index 1f454d5f4367..b763d0920973 100644 --- a/layout/svg/base/src/nsSVGIntegrationUtils.cpp +++ b/layout/svg/base/src/nsSVGIntegrationUtils.cpp @@ -123,9 +123,9 @@ nsSVGIntegrationUtils::ComputeFrameEffectsRect(nsIFrame* aFrame, nsRect r = GetSVGBBox(firstFrame, aFrame, aOverflowRect, userSpaceRect); // r is relative to user space PRUint32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel(); - r.ScaleRoundOutInverse(appUnitsPerDevPixel); - r = filterFrame->GetFilterBBox(firstFrame, &r); - r.ScaleRoundOut(appUnitsPerDevPixel); + nsIntRect p(nsRect::ToOutsidePixels(r, appUnitsPerDevPixel)); + p = filterFrame->GetFilterBBox(firstFrame, &p); + r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel); // Make it relative to aFrame again return r + userSpaceRect.TopLeft() - aFrame->GetOffsetTo(firstFrame); } @@ -146,9 +146,9 @@ nsSVGIntegrationUtils::GetInvalidAreaForChangedSource(nsIFrame* aFrame, nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame); nsPoint offset = aFrame->GetOffsetTo(firstFrame) - userSpaceRect.TopLeft(); nsRect r = aInvalidRect + offset; - r.ScaleRoundOutInverse(appUnitsPerDevPixel); - r = filterFrame->GetInvalidationBBox(firstFrame, r); - r.ScaleRoundOut(appUnitsPerDevPixel); + nsIntRect p(nsRect::ToOutsidePixels(r, appUnitsPerDevPixel)); + p = filterFrame->GetInvalidationBBox(firstFrame, p); + r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel); return r - offset; } @@ -169,9 +169,9 @@ nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(nsIFrame* aFrame, nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame); nsPoint offset = aFrame->GetOffsetTo(firstFrame) - userSpaceRect.TopLeft(); nsRect r = aDamageRect + offset; - r.ScaleRoundOutInverse(appUnitsPerDevPixel); - r = filterFrame->GetSourceForInvalidArea(firstFrame, r); - r.ScaleRoundOut(appUnitsPerDevPixel); + nsIntRect p(nsRect::ToOutsidePixels(r, appUnitsPerDevPixel)); + p = filterFrame->GetSourceForInvalidArea(firstFrame, p); + r = nsIntRect::ToAppUnits(p, appUnitsPerDevPixel); return r - offset; } @@ -216,8 +216,7 @@ public: nsIRenderingContext::AutoPushTranslation push(ctx, -mOffset.x, -mOffset.y); nsRect dirty; if (aDirtyRect) { - dirty = *aDirtyRect; - dirty.ScaleRoundOut(nsIDeviceContext::AppUnitsPerCSSPixel()); + dirty = nsIntRect::ToAppUnits(*aDirtyRect, nsIDeviceContext::AppUnitsPerCSSPixel()); dirty += mOffset; } else { dirty = mInnerList->GetBounds(mBuilder); @@ -290,8 +289,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsIRenderingContext* aCtx, nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame) + aBuilder->ToReferenceFrame(firstFrame); PRInt32 appUnitsPerDevPixel = aEffectsFrame->PresContext()->AppUnitsPerDevPixel(); - userSpaceRect.ScaleRoundPreservingCentersInverse(appUnitsPerDevPixel); - userSpaceRect.ScaleRoundOut(appUnitsPerDevPixel); + userSpaceRect = nsIntRect::ToAppUnits(nsRect::ToNearestPixels(userSpaceRect, appUnitsPerDevPixel), appUnitsPerDevPixel); aCtx->Translate(userSpaceRect.x, userSpaceRect.y); nsCOMPtr matrix = GetInitialMatrix(aEffectsFrame); @@ -316,8 +314,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsIRenderingContext* aCtx, /* Paint the child */ if (filterFrame) { RegularFramePaintCallback paint(aBuilder, aInnerList, userSpaceRect.TopLeft()); - nsRect r = aDirtyRect - userSpaceRect.TopLeft(); - r.ScaleRoundOutInverse(appUnitsPerDevPixel); + nsIntRect r(nsRect::ToOutsidePixels(aDirtyRect - userSpaceRect.TopLeft(), appUnitsPerDevPixel)); filterFrame->FilterPaint(&svgContext, aEffectsFrame, &paint, &r); } else { gfx->SetMatrix(savedCTM); diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index d80c6f897d67..0ffc76499844 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -560,7 +560,7 @@ nsSVGOuterSVGFrame::Paint(nsIRenderingContext& aRenderingContext, PRTime start = PR_Now(); #endif - dirtyRect.ScaleRoundOut(1.0f / PresContext()->AppUnitsPerDevPixel()); + nsIntRect dirtyPxRect(nsRect::ToOutsidePixels(dirtyRect, PresContext()->AppUnitsPerDevPixel())); nsSVGRenderState ctx(&aRenderingContext); @@ -575,7 +575,7 @@ nsSVGOuterSVGFrame::Paint(nsIRenderingContext& aRenderingContext, // paint children: for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsSVGUtils::PaintChildWithEffects(&ctx, &dirtyRect, kid); + nsSVGUtils::PaintChildWithEffects(&ctx, &dirtyPxRect, kid); } #ifdef XP_MACOSX diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index 7b39b018b63d..a8d19f2515d2 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -585,8 +585,7 @@ nsRect nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect) { PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel(); - nsRect rect = aRect; - rect.ScaleRoundOutInverse(appUnitsPerDevPixel); + nsIntRect rect(nsRect::ToOutsidePixels(aRect, appUnitsPerDevPixel)); while (aFrame) { if (aFrame->GetStateBits() & NS_STATE_IS_OUTER_SVG) @@ -602,8 +601,7 @@ nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect) aFrame = aFrame->GetParent(); } - rect.ScaleRoundOut(appUnitsPerDevPixel); - return rect; + return nsIntRect::ToAppUnits(rect, appUnitsPerDevPixel); } void @@ -997,8 +995,7 @@ nsSVGUtils::PaintChildWithEffects(nsSVGRenderState *aContext, if (!aDirtyRect->Intersects(filterFrame->GetFilterBBox(aFrame, nsnull))) return; } else { - nsRect rect = *aDirtyRect; - rect.ScaleRoundOut(aFrame->PresContext()->AppUnitsPerDevPixel()); + nsRect rect(nsIntRect::ToAppUnits(*aDirtyRect, aFrame->PresContext()->AppUnitsPerDevPixel())); if (!rect.Intersects(aFrame->GetRect())) return; } diff --git a/layout/xul/base/public/nsXULPopupManager.h b/layout/xul/base/public/nsXULPopupManager.h index 1a3c5c2fff85..f62103e9288f 100644 --- a/layout/xul/base/public/nsXULPopupManager.h +++ b/layout/xul/base/public/nsXULPopupManager.h @@ -724,7 +724,7 @@ protected: // range parent and offset set in SetTriggerEvent nsCOMPtr mRangeParent; PRInt32 mRangeOffset; - nsPoint mCachedMousePoint; + nsIntPoint mCachedMousePoint; // set to the currently active menu bar, if any nsMenuBarFrame* mActiveMenuBar; diff --git a/layout/xul/base/src/nsBox.cpp b/layout/xul/base/src/nsBox.cpp index 237dd14b5e3f..f23eab955473 100644 --- a/layout/xul/base/src/nsBox.cpp +++ b/layout/xul/base/src/nsBox.cpp @@ -344,7 +344,7 @@ nsBox::GetBorder(nsMargin& aMargin) // Go to the theme for the border. nsPresContext *context = PresContext(); if (gTheme->ThemeSupportsWidget(context, this, disp->mAppearance)) { - nsMargin margin(0, 0, 0, 0); + nsIntMargin margin(0, 0, 0, 0); gTheme->GetWidgetBorder(context->DeviceContext(), this, disp->mAppearance, &margin); aMargin.top = context->DevPixelsToAppUnits(margin.top); @@ -368,7 +368,7 @@ nsBox::GetPadding(nsMargin& aMargin) // Go to the theme for the padding. nsPresContext *context = PresContext(); if (gTheme->ThemeSupportsWidget(context, this, disp->mAppearance)) { - nsMargin margin(0, 0, 0, 0); + nsIntMargin margin(0, 0, 0, 0); PRBool useThemePadding; useThemePadding = gTheme->GetWidgetPadding(context->DeviceContext(), @@ -728,7 +728,7 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) if (display->mAppearance) { nsITheme *theme = aState.PresContext()->GetTheme(); if (theme && theme->ThemeSupportsWidget(aState.PresContext(), aBox, display->mAppearance)) { - nsSize size; + nsIntSize size; nsIRenderingContext* rendContext = aState.GetRenderingContext(); if (rendContext) { theme->GetMinimumWidgetSize(rendContext, aBox, diff --git a/layout/xul/base/src/nsBoxObject.cpp b/layout/xul/base/src/nsBoxObject.cpp index dce253a0bcf1..09a1b1f17dd5 100644 --- a/layout/xul/base/src/nsBoxObject.cpp +++ b/layout/xul/base/src/nsBoxObject.cpp @@ -159,10 +159,9 @@ nsBoxObject::GetPresShell(PRBool aFlushLayout) } nsresult -nsBoxObject::GetOffsetRect(nsRect& aRect) +nsBoxObject::GetOffsetRect(nsIntRect& aRect) { - aRect.x = aRect.y = 0; - aRect.Empty(); + aRect.SetRect(0, 0, 0, 0); if (!mContent) return NS_ERROR_NOT_INITIALIZED; @@ -241,7 +240,7 @@ nsBoxObject::GetScreenPosition(nsIntPoint& aPoint) NS_IMETHODIMP nsBoxObject::GetX(PRInt32* aResult) { - nsRect rect; + nsIntRect rect; GetOffsetRect(rect); *aResult = rect.x; return NS_OK; @@ -250,7 +249,7 @@ nsBoxObject::GetX(PRInt32* aResult) NS_IMETHODIMP nsBoxObject::GetY(PRInt32* aResult) { - nsRect rect; + nsIntRect rect; GetOffsetRect(rect); *aResult = rect.y; return NS_OK; @@ -259,7 +258,7 @@ nsBoxObject::GetY(PRInt32* aResult) NS_IMETHODIMP nsBoxObject::GetWidth(PRInt32* aResult) { - nsRect rect; + nsIntRect rect; GetOffsetRect(rect); *aResult = rect.width; return NS_OK; @@ -268,7 +267,7 @@ nsBoxObject::GetWidth(PRInt32* aResult) NS_IMETHODIMP nsBoxObject::GetHeight(PRInt32* aResult) { - nsRect rect; + nsIntRect rect; GetOffsetRect(rect); *aResult = rect.height; return NS_OK; diff --git a/layout/xul/base/src/nsBoxObject.h b/layout/xul/base/src/nsBoxObject.h index e0179aad4b63..4c1e7269da26 100644 --- a/layout/xul/base/src/nsBoxObject.h +++ b/layout/xul/base/src/nsBoxObject.h @@ -48,7 +48,7 @@ class nsIFrame; class nsIDocShell; -struct nsRect; +struct nsIntRect; class nsBoxObject : public nsPIBoxObject { @@ -66,7 +66,7 @@ public: nsIFrame* GetFrame(PRBool aFlushLayout); nsIPresShell* GetPresShell(PRBool aFlushLayout); - nsresult GetOffsetRect(nsRect& aRect); + nsresult GetOffsetRect(nsIntRect& aRect); nsresult GetScreenPosition(nsIntPoint& aPoint); // Given a parent frame and a child frame, find the frame whose diff --git a/layout/xul/base/src/nsImageBoxFrame.cpp b/layout/xul/base/src/nsImageBoxFrame.cpp index 334772aa6bb7..b767b10b53de 100644 --- a/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/layout/xul/base/src/nsImageBoxFrame.cpp @@ -542,7 +542,7 @@ NS_IMETHODIMP nsImageBoxFrame::OnStopDecode(imgIRequest *request, NS_IMETHODIMP nsImageBoxFrame::FrameChanged(imgIContainer *container, gfxIImageFrame *newframe, - nsRect * dirtyRect) + nsIntRect *dirtyRect) { nsBoxLayoutState state(PresContext()); this->Redraw(state); @@ -590,7 +590,7 @@ NS_IMETHODIMP nsImageBoxListener::OnStopDecode(imgIRequest *request, NS_IMETHODIMP nsImageBoxListener::FrameChanged(imgIContainer *container, gfxIImageFrame *newframe, - nsRect * dirtyRect) + nsIntRect *dirtyRect) { if (!mFrame) return NS_ERROR_FAILURE; diff --git a/layout/xul/base/src/nsImageBoxFrame.h b/layout/xul/base/src/nsImageBoxFrame.h index 2adfc907c904..f9d80e068297 100644 --- a/layout/xul/base/src/nsImageBoxFrame.h +++ b/layout/xul/base/src/nsImageBoxFrame.h @@ -60,7 +60,7 @@ public: const PRUnichar *statusArg); // imgIContainerObserver (override nsStubImageDecoderObserver) NS_IMETHOD FrameChanged(imgIContainer *container, gfxIImageFrame *newframe, - nsRect * dirtyRect); + nsIntRect *dirtyRect); void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; } @@ -123,7 +123,7 @@ public: const PRUnichar *statusArg); NS_IMETHOD FrameChanged(imgIContainer *container, gfxIImageFrame *newframe, - nsRect * dirtyRect); + nsIntRect *dirtyRect); virtual ~nsImageBoxFrame(); diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index fa0b8b964452..100490523d05 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -1000,7 +1000,8 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame) if (mAnchorContent) { anchorScreenRect = aAnchorFrame->GetScreenRectInAppUnits(); // adjust for differences in the anchor frame's scaling - anchorScreenRect.ScaleRoundOut(adj); + anchorScreenRect = nsIntRect::ToAppUnits(nsRect::ToOutsidePixels(anchorScreenRect, + aAnchorFrame->PresContext()->AppUnitsPerDevPixel()), presContext->AppUnitsPerDevPixel()); xpos = anchorScreenRect.x - rootScreenRect.x; ypos = anchorScreenRect.y - rootScreenRect.y; diff --git a/layout/xul/base/src/nsResizerFrame.h b/layout/xul/base/src/nsResizerFrame.h index 81ba08400a14..c1a97b87ee64 100644 --- a/layout/xul/base/src/nsResizerFrame.h +++ b/layout/xul/base/src/nsResizerFrame.h @@ -65,7 +65,7 @@ protected: PRInt32 aMovement, PRInt8 aResizerDirection); protected: - nsRect mWidgetRect; + nsIntRect mWidgetRect; }; // class nsResizerFrame #endif /* nsResizerFrame_h___ */ diff --git a/layout/xul/base/src/nsScrollBoxObject.cpp b/layout/xul/base/src/nsScrollBoxObject.cpp index 4d8471c367de..5bbab4992d3e 100644 --- a/layout/xul/base/src/nsScrollBoxObject.cpp +++ b/layout/xul/base/src/nsScrollBoxObject.cpp @@ -290,9 +290,9 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child) nsPoint cp; scrollableView->GetScrollPosition(cp.x,cp.y); - GetOffsetRect(crect); - crect.x = nsPresContext::CSSPixelsToAppUnits(crect.x); - crect.y = nsPresContext::CSSPixelsToAppUnits(crect.y); + nsIntRect prect; + GetOffsetRect(prect); + crect = nsIntRect::ToAppUnits(prect, nsPresContext::AppUnitsPerCSSPixel()); nscoord newx=cp.x, newy=cp.y; // we only scroll in the direction of the scrollbox orientation @@ -390,11 +390,9 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child) // get our current info nsPoint cp; scrollableView->GetScrollPosition(cp.x,cp.y); - GetOffsetRect(crect); - crect.x = nsPresContext::CSSPixelsToAppUnits(crect.x); - crect.y = nsPresContext::CSSPixelsToAppUnits(crect.y); - crect.width = nsPresContext::CSSPixelsToAppUnits(crect.width); - crect.height = nsPresContext::CSSPixelsToAppUnits(crect.height); + nsIntRect prect; + GetOffsetRect(prect); + crect = nsIntRect::ToAppUnits(prect, nsPresContext::AppUnitsPerCSSPixel()); nscoord newx=cp.x, newy=cp.y; diff --git a/layout/xul/base/src/nsTitleBarFrame.cpp b/layout/xul/base/src/nsTitleBarFrame.cpp index cfd4ef79a80d..4458d3341ded 100644 --- a/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/layout/xul/base/src/nsTitleBarFrame.cpp @@ -159,7 +159,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext, case NS_MOUSE_MOVE: { if(mTrackingMouseMove) { - nsPoint nsMoveBy = aEvent->refPoint - mLastPoint; + nsIntPoint nsMoveBy(aEvent->refPoint - mLastPoint); nsIFrame* parent = GetParent(); while (parent && parent->GetType() != nsGkAtoms::menuPopupFrame) @@ -171,7 +171,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext, nsCOMPtr widget; (static_cast(parent))-> GetWidget(getter_AddRefs(widget)); - nsRect bounds; + nsIntRect bounds; widget->GetScreenBounds(bounds); widget->Move(bounds.x + nsMoveBy.x, bounds.y + nsMoveBy.y); } diff --git a/layout/xul/base/src/nsTitleBarFrame.h b/layout/xul/base/src/nsTitleBarFrame.h index 01156ebd0807..0e3828368874 100644 --- a/layout/xul/base/src/nsTitleBarFrame.h +++ b/layout/xul/base/src/nsTitleBarFrame.h @@ -70,7 +70,7 @@ protected: protected: PRBool mTrackingMouseMove; - nsPoint mLastPoint; + nsIntPoint mLastPoint; }; // class nsTitleBarFrame diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 5d8ece253c0b..d6e8de87d566 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -308,7 +308,7 @@ nsXULPopupManager::GetMouseLocation(nsIDOMNode** aNode, PRInt32* aOffset) void nsXULPopupManager::SetTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup) { - mCachedMousePoint = nsPoint(0, 0); + mCachedMousePoint = nsIntPoint(0, 0); nsCOMPtr uiEvent = do_QueryInterface(aEvent); if (uiEvent) { @@ -338,15 +338,14 @@ nsXULPopupManager::SetTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup) mouseEvent->GetClientY(&mCachedMousePoint.y); // convert to device pixels - PRInt32 adj = presContext->DeviceContext()->AppUnitsPerDevPixel(); - mCachedMousePoint.x = nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.x) / adj; - mCachedMousePoint.y = nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.y) / adj; + mCachedMousePoint.x = presContext->AppUnitsToDevPixels(nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.x)); + mCachedMousePoint.y = presContext->AppUnitsToDevPixels(nsPresContext::CSSPixelsToAppUnits(mCachedMousePoint.y)); } else if (rootFrame) { nsPoint pnt = nsLayoutUtils::GetEventCoordinatesRelativeTo(event, rootFrame); - mCachedMousePoint = nsPoint(presContext->AppUnitsToDevPixels(pnt.x), - presContext->AppUnitsToDevPixels(pnt.y)); + mCachedMousePoint = nsIntPoint(presContext->AppUnitsToDevPixels(pnt.x), + presContext->AppUnitsToDevPixels(pnt.y)); } } } @@ -999,7 +998,7 @@ nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup, GetClosestView()->GetNearestWidget(&pnt); event.refPoint = mCachedMousePoint; nsEventDispatcher::Dispatch(aPopup, aPresContext, &event, nsnull, &status); - mCachedMousePoint = nsPoint(0, 0); + mCachedMousePoint = nsIntPoint(0, 0); // if a panel, blur whatever has focus so that the panel can take the focus. // This is done after the popupshowing event in case that event is cancelled. diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index fd3c990fff57..94899dc95501 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -658,8 +658,7 @@ nsTreeBodyFrame::GetSelectionRegion(nsIScriptableRegion **aRegion) region->Init(); nsRefPtr presContext = PresContext(); - nsRect rect = mRect; - rect.ScaleRoundOut(1.0 / presContext->AppUnitsPerCSSPixel()); + nsIntRect rect(nsRect::ToOutsidePixels(mRect, presContext->AppUnitsPerCSSPixel())); nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame(); nsPoint origin = GetOffsetTo(rootFrame); @@ -2127,14 +2126,15 @@ nsTreeBodyFrame::GetTwistyRect(PRInt32 aRowIndex, } if (useTheme) { - nsSize minTwistySize(0,0); + nsIntSize minTwistySizePx(0,0); PRBool canOverride = PR_TRUE; theme->GetMinimumWidgetSize(&aRenderingContext, this, twistyDisplayData->mAppearance, - &minTwistySize, &canOverride); + &minTwistySizePx, &canOverride); - // GMWS() returns size in pixels, we need to convert it back to twips - minTwistySize.width = aPresContext->DevPixelsToAppUnits(minTwistySize.width); - minTwistySize.height = aPresContext->DevPixelsToAppUnits(minTwistySize.height); + // GMWS() returns size in pixels, we need to convert it back to app units + nsSize minTwistySize; + minTwistySize.width = aPresContext->DevPixelsToAppUnits(minTwistySizePx.width); + minTwistySize.height = aPresContext->DevPixelsToAppUnits(minTwistySizePx.height); if (aTwistyRect.width < minTwistySize.width || !canOverride) aTwistyRect.width = minTwistySize.width; diff --git a/layout/xul/base/src/tree/src/nsTreeImageListener.cpp b/layout/xul/base/src/tree/src/nsTreeImageListener.cpp index 55ee320e8203..c44e36482143 100644 --- a/layout/xul/base/src/tree/src/nsTreeImageListener.cpp +++ b/layout/xul/base/src/tree/src/nsTreeImageListener.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP nsTreeImageListener::OnStartContainer(imgIRequest *aRequest, NS_IMETHODIMP nsTreeImageListener::OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect) + const nsIntRect *aRect) { Invalidate(); return NS_OK; @@ -73,7 +73,7 @@ NS_IMETHODIMP nsTreeImageListener::OnDataAvailable(imgIRequest *aRequest, NS_IMETHODIMP nsTreeImageListener::FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect) + nsIntRect *dirtyRect) { Invalidate(); return NS_OK; diff --git a/layout/xul/base/src/tree/src/nsTreeImageListener.h b/layout/xul/base/src/tree/src/nsTreeImageListener.h index 3461c8fa4cd5..44b81a01a889 100644 --- a/layout/xul/base/src/tree/src/nsTreeImageListener.h +++ b/layout/xul/base/src/tree/src/nsTreeImageListener.h @@ -73,10 +73,10 @@ public: // imgIDecoderObserver (override nsStubImageDecoderObserver) NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage); NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, gfxIImageFrame *aFrame, - const nsRect *aRect); + const nsIntRect *aRect); // imgIContainerObserver (override nsStubImageDecoderObserver) NS_IMETHOD FrameChanged(imgIContainer *aContainer, gfxIImageFrame *newframe, - nsRect * dirtyRect); + nsIntRect *dirtyRect); NS_IMETHOD AddCell(PRInt32 aIndex, nsITreeColumn* aCol); diff --git a/view/public/nsIViewManager.h b/view/public/nsIViewManager.h index 49c03c336888..13c4a90d8235 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsIViewManager.h @@ -60,10 +60,10 @@ enum nsRectVisibility { nsRectVisibility_kZeroAreaRect }; -// 7eae119d-9fc8-482d-92ec-145eef228a4a +// de2a2d24-9753-4488-9fdc-dd0accb484f7 #define NS_IVIEWMANAGER_IID \ -{ 0x7eae119d, 0x9fc8, 0x482d, \ - { 0x92, 0xec, 0x14, 0x5e, 0xef, 0x22, 0x8a, 0x4a } } +{ 0xde2a2d24, 0x9753, 0x4488, \ + { 0x9f, 0xdc, 0xdd, 0x0a, 0xcc, 0xb4, 0x84, 0xf7 } }; class nsIViewManager : public nsISupports { @@ -477,7 +477,7 @@ public: * otherwise it returns an enum indicating why not */ NS_IMETHOD GetRectVisibility(nsIView *aView, const nsRect &aRect, - PRUint16 aMinTwips, + nscoord aMinTwips, nsRectVisibility *aRectVisibility)=0; /** diff --git a/view/src/nsScrollPortView.cpp b/view/src/nsScrollPortView.cpp index 53586af17452..4a3eb56508a6 100644 --- a/view/src/nsScrollPortView.cpp +++ b/view/src/nsScrollPortView.cpp @@ -515,7 +515,7 @@ NS_IMETHODIMP nsScrollPortView::CanScroll(PRBool aHorizontal, return NS_OK; } -void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoint aPixDelta, +void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsIntPoint aPixDelta, PRInt32 aP2A) { if (aTwipsDelta.x != 0 || aTwipsDelta.y != 0) @@ -565,10 +565,10 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoin // consistent with the view hierarchy. mViewManager->UpdateView(this, NS_VMREFRESH_DEFERRED); } else { // if we can blit and have a scrollwidget then scroll. - nsRect* toScrollPtr = nsnull; + nsIntRect* toScrollPtr = nsnull; #ifdef XP_WIN - nsRect toScroll; + nsIntRect toScroll; if (!updateRegion.IsEmpty()) { nsRegion regionToScroll; regionToScroll.Sub(nsRect(nsPoint(0,0), GetBounds().Size()), @@ -577,15 +577,13 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoin nsRect biggestRect(0,0,0,0); const nsRect* r; for (r = iter.Next(); r; r = iter.Next()) { - if (r->width*r->height > biggestRect.width*biggestRect.height) { + if (PRInt64(r->width)*PRInt64(r->height) > PRInt64(biggestRect.width)*PRInt64(biggestRect.height)) { biggestRect = *r; } } toScrollPtr = &toScroll; - biggestRect.ScaleRoundIn(1.0/aP2A); - toScroll = biggestRect; - biggestRect *= aP2A; - regionToScroll.Sub(regionToScroll, biggestRect); + toScroll = nsRect::ToInsidePixels(biggestRect, aP2A); + regionToScroll.Sub(regionToScroll, nsIntRect::ToAppUnits(toScroll, aP2A)); updateRegion.Or(updateRegion, regionToScroll); } #endif @@ -671,7 +669,7 @@ NS_IMETHODIMP nsScrollPortView::ScrollToImpl(nscoord aX, nscoord aY, PRUint32 aU mOffsetX = aX; mOffsetY = aY; - Scroll(scrolledView, twipsDelta, nsPoint(dxPx, dyPx), p2a); + Scroll(scrolledView, twipsDelta, nsIntPoint(dxPx, dyPx), p2a); mViewManager->SynthesizeMouseMove(PR_TRUE); diff --git a/view/src/nsScrollPortView.h b/view/src/nsScrollPortView.h index 0df4ec113e02..c9208af07c4b 100644 --- a/view/src/nsScrollPortView.h +++ b/view/src/nsScrollPortView.h @@ -102,7 +102,7 @@ protected: virtual ~nsScrollPortView(); //private - void Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoint aPixDelta, PRInt32 p2a); + void Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsIntPoint aPixDelta, nscoord aP2A); PRBool CannotBitBlt(nsView* aScrolledView); nscoord mOffsetX, mOffsetY; diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 2999eee03a21..fa4f11a3e47a 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -356,7 +356,7 @@ void nsView::ResetWidgetBounds(PRBool aRecurse, PRBool aMoveOnly, } } -nsRect nsView::CalcWidgetBounds(nsWindowType aType) +nsIntRect nsView::CalcWidgetBounds(nsWindowType aType) { nsCOMPtr dx; mViewManager->GetDeviceContext(*getter_AddRefs(dx)); @@ -373,15 +373,14 @@ nsRect nsView::CalcWidgetBounds(nsWindowType aType) if (parentWidget && aType == eWindowType_popup && mVis == nsViewVisibility_kShow) { - nsRect screenRect(0,0,1,1); + nsIntRect screenRect(0,0,1,1); parentWidget->WidgetToScreen(screenRect, screenRect); viewBounds += nsPoint(NSIntPixelsToAppUnits(screenRect.x, p2a), NSIntPixelsToAppUnits(screenRect.y, p2a)); } } - nsRect newBounds(viewBounds); - newBounds.ScaleRoundPreservingCentersInverse(p2a); + nsIntRect newBounds(nsRect::ToNearestPixels(viewBounds, p2a)); nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.x, p2a), NSIntPixelsToAppUnits(newBounds.y, p2a)); @@ -398,7 +397,7 @@ void nsView::DoResetWidgetBounds(PRBool aMoveOnly, return; } - nsRect curBounds; + nsIntRect curBounds; mWindow->GetBounds(curBounds); nsWindowType type; mWindow->GetWindowType(type); @@ -414,7 +413,7 @@ void nsView::DoResetWidgetBounds(PRBool aMoveOnly, NS_PRECONDITION(mWindow, "Why was this called??"); - nsRect newBounds = CalcWidgetBounds(type); + nsIntRect newBounds = CalcWidgetBounds(type); PRBool changedPos = curBounds.TopLeft() != newBounds.TopLeft(); PRBool changedSize = curBounds.Size() != newBounds.Size(); @@ -636,9 +635,9 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID, nsView* v = static_cast(this); - nsRect trect = v->CalcWidgetBounds(aWidgetInitData - ? aWidgetInitData->mWindowType - : eWindowType_child); + nsIntRect trect = v->CalcWidgetBounds(aWidgetInitData + ? aWidgetInitData->mWindowType + : eWindowType_child); if (NS_OK == v->LoadWidget(aWindowIID)) { @@ -755,17 +754,15 @@ void nsIView::List(FILE* out, PRInt32 aIndent) const for (i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "%p ", (void*)this); if (nsnull != mWindow) { - nsRect windowBounds; - nsRect nonclientBounds; - float p2t; nsIDeviceContext *dx; mViewManager->GetDeviceContext(dx); - p2t = (float) dx->AppUnitsPerDevPixel(); + nscoord p2a = dx->AppUnitsPerDevPixel(); NS_RELEASE(dx); - mWindow->GetClientBounds(windowBounds); - windowBounds *= p2t; - mWindow->GetBounds(nonclientBounds); - nonclientBounds *= p2t; + nsIntRect rect; + mWindow->GetClientBounds(rect); + nsRect windowBounds(nsIntRect::ToAppUnits(rect, p2a)); + mWindow->GetBounds(rect); + nsRect nonclientBounds(nsIntRect::ToAppUnits(rect, p2a)); nsrefcnt widgetRefCnt = mWindow->AddRef() - 1; mWindow->Release(); PRInt32 Z; diff --git a/view/src/nsView.h b/view/src/nsView.h index a99aae5656ef..4e23dd89119e 100644 --- a/view/src/nsView.h +++ b/view/src/nsView.h @@ -192,7 +192,7 @@ public: return mViewToWidgetOffset; } - nsRect CalcWidgetBounds(nsWindowType aType); + nsIntRect CalcWidgetBounds(nsWindowType aType); protected: // Do the actual work of ResetWidgetBounds, unconditionally. Don't diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 4905839da1a6..4a23c1f36421 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -868,8 +868,7 @@ nsViewManager::UpdateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedReg const nsRect* r; for (nsRegionRectIterator iter(leftOver); (r = iter.Next());) { - nsRect bounds = *r; - ViewToWidget(aWidgetView, aWidgetView, bounds); + nsIntRect bounds(ViewToWidget(aWidgetView, aWidgetView, *r)); widget->Invalidate(bounds, PR_FALSE); } } @@ -1009,14 +1008,6 @@ void nsViewManager::SuppressFocusEvents(PRBool aSuppress) } -static void ConvertRectAppUnitsToIntPixels(nsRect& aRect, PRInt32 p2a) -{ - aRect.x = NSAppUnitsToIntPixels(aRect.x, p2a); - aRect.y = NSAppUnitsToIntPixels(aRect.y, p2a); - aRect.width = NSAppUnitsToIntPixels(aRect.width, p2a); - aRect.height = NSAppUnitsToIntPixels(aRect.height, p2a); -} - NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aStatus) { *aStatus = nsEventStatus_eIgnore; @@ -1066,7 +1057,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS if (NS_FAILED(CreateRegion(getter_AddRefs(region)))) break; - const nsRect& damrect = *event->rect; + const nsIntRect& damrect = *event->rect; region->SetTo(damrect.x, damrect.y, damrect.width, damrect.height); } @@ -1148,10 +1139,9 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS } else { // since we got an NS_PAINT event, we need to // draw something so we don't get blank areas. - nsRect damRect; - region->GetBoundingBox(&damRect.x, &damRect.y, &damRect.width, &damRect.height); - PRInt32 p2a = mContext->AppUnitsPerDevPixel(); - damRect.ScaleRoundOut(float(p2a)); + nsIntRect damIntRect; + region->GetBoundingBox(&damIntRect.x, &damIntRect.y, &damIntRect.width, &damIntRect.height); + nsRect damRect(nsIntRect::ToAppUnits(damIntRect, mContext->AppUnitsPerDevPixel())); DefaultRefresh(view, event->renderingContext, &damRect); // Clients like the editor can trigger multiple @@ -1290,8 +1280,8 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS nsPoint rootOffset = baseView->GetDimensions().TopLeft(); rootOffset += baseView->GetOffsetTo(RootViewManager()->mRootView); RootViewManager()->mMouseLocation = aEvent->refPoint + - nsPoint(NSAppUnitsToIntPixels(rootOffset.x, p2a), - NSAppUnitsToIntPixels(rootOffset.y, p2a)); + nsIntPoint(NSAppUnitsToIntPixels(rootOffset.x, p2a), + NSAppUnitsToIntPixels(rootOffset.y, p2a)); #ifdef DEBUG_MOUSE_LOCATION if (aEvent->message == NS_MOUSE_ENTER) printf("[vm=%p]got mouse enter for %p\n", @@ -1309,7 +1299,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS // won't matter at all since we'll get the mouse move or // enter after the mouse exit when the mouse moves from one // of our widgets into another. - RootViewManager()->mMouseLocation = nsPoint(NSCOORD_NONE, NSCOORD_NONE); + RootViewManager()->mMouseLocation = nsIntPoint(NSCOORD_NONE, NSCOORD_NONE); #ifdef DEBUG_MOUSE_LOCATION printf("[vm=%p]got mouse exit for %p\n", this, aEvent->widget); @@ -1346,26 +1336,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS pt += offset; *aStatus = HandleEvent(view, pt, aEvent, capturedEvent); - - // - // need to map the reply back into platform coordinates - // - switch (aEvent->message) { - case NS_TEXT_TEXT: - ConvertRectAppUnitsToIntPixels( - ((nsTextEvent*)aEvent)->theReply.mCursorPosition, p2a); - break; - case NS_COMPOSITION_START: - case NS_COMPOSITION_QUERY: - ConvertRectAppUnitsToIntPixels( - ((nsCompositionEvent*)aEvent)->theReply.mCursorPosition, p2a); - break; - case NS_QUERY_CHARACTER_RECT: - case NS_QUERY_CARET_RECT: - ConvertRectAppUnitsToIntPixels( - ((nsQueryContentEvent*)aEvent)->mReply.mRect, p2a); - break; - } } break; @@ -2050,25 +2020,26 @@ nsPoint nsViewManager::ComputeViewOffset(const nsView *aView) return origin; } -void nsViewManager::ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const +nsIntRect nsViewManager::ViewToWidget(nsView *aView, nsView* aWidgetView, const nsRect &aRect) const { + nsRect rect = aRect; while (aView != aWidgetView) { - aView->ConvertToParentCoords(&aRect.x, &aRect.y); + aView->ConvertToParentCoords(&rect.x, &rect.y); aView = aView->GetParent(); } // intersect aRect with bounds of aWidgetView, to prevent generating any illegal rectangles. nsRect bounds; aWidgetView->GetDimensions(bounds); - aRect.IntersectRect(aRect, bounds); + rect.IntersectRect(rect, bounds); // account for the view's origin not lining up with the widget's - aRect.x -= bounds.x; - aRect.y -= bounds.y; - - aRect += aView->ViewToWidgetOffset(); + rect.x -= bounds.x; + rect.y -= bounds.y; + + rect += aView->ViewToWidgetOffset(); // finally, convert to device coordinates. - aRect.ScaleRoundOut(1.0f / mContext->AppUnitsPerDevPixel()); + return nsRect::ToOutsidePixels(rect, mContext->AppUnitsPerDevPixel()); } nsresult nsViewManager::GetVisibleRect(nsRect& aVisibleRect) @@ -2126,7 +2097,7 @@ nsresult nsViewManager::GetAbsoluteRect(nsView *aView, const nsRect &aRect, NS_IMETHODIMP nsViewManager::GetRectVisibility(nsIView *aView, const nsRect &aRect, - PRUint16 aMinTwips, + nscoord aMinTwips, nsRectVisibility *aRectVisibility) { nsView* view = static_cast(aView); @@ -2317,7 +2288,7 @@ nsViewManager::SynthesizeMouseMove(PRBool aFromScroll) if (!IsRootVM()) return RootViewManager()->SynthesizeMouseMove(aFromScroll); - if (mMouseLocation == nsPoint(NSCOORD_NONE, NSCOORD_NONE)) + if (mMouseLocation == nsIntPoint(NSCOORD_NONE, NSCOORD_NONE)) return NS_OK; if (!mSynthMouseMoveEvent.IsPending()) { @@ -2372,7 +2343,7 @@ nsViewManager::ProcessSynthMouseMoveEvent(PRBool aFromScroll) NS_ASSERTION(IsRootVM(), "Only the root view manager should be here"); - if (mMouseLocation == nsPoint(NSCOORD_NONE, NSCOORD_NONE) || !mRootView) { + if (mMouseLocation == nsIntPoint(NSCOORD_NONE, NSCOORD_NONE) || !mRootView) { mSynthMouseMoveEvent.Forget(); return; } @@ -2386,20 +2357,20 @@ nsViewManager::ProcessSynthMouseMoveEvent(PRBool aFromScroll) this, mMouseLocation.x, mMouseLocation.y); #endif - nsPoint pt = mMouseLocation; + nsPoint pt; PRInt32 p2a = mContext->AppUnitsPerDevPixel(); pt.x = NSIntPixelsToAppUnits(mMouseLocation.x, p2a); pt.y = NSIntPixelsToAppUnits(mMouseLocation.y, p2a); // This could be a bit slow (traverses entire view hierarchy) // but it's OK to do it once per synthetic mouse event nsView* view = FindFloatingViewContaining(mRootView, pt); - nsPoint offset(0, 0); + nsIntPoint offset(0, 0); if (!view) { view = mRootView; } else { - offset = view->GetOffsetTo(mRootView); - offset.x = NSAppUnitsToIntPixels(offset.x, p2a); - offset.y = NSAppUnitsToIntPixels(offset.y, p2a); + nsPoint viewoffset(view->GetOffsetTo(mRootView)); + offset.x = NSAppUnitsToIntPixels(viewoffset.x, p2a); + offset.y = NSAppUnitsToIntPixels(viewoffset.y, p2a); } nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, view->GetWidget(), nsMouseEvent::eSynthesized); diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 87d1671eeda8..ed22cfbf2e9a 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -193,7 +193,7 @@ public: * otherwise it returns an enum indicating why not */ NS_IMETHOD GetRectVisibility(nsIView *aView, const nsRect &aRect, - PRUint16 aMinTwips, + nscoord aMinTwips, nsRectVisibility *aRectVisibility); NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll); @@ -291,7 +291,7 @@ private: * system of the widget attached to aWidgetView, which should be an ancestor * of aView. */ - void ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const; + nsIntRect ViewToWidget(nsView *aView, nsView* aWidgetView, const nsRect &aRect) const; /** * Transforms a rectangle from specified view's coordinate system to @@ -433,7 +433,7 @@ private: nsIViewObserver *mObserver; nsIScrollableView *mRootScrollable; nscolor mDefaultBackgroundColor; - nsPoint mMouseLocation; // device units, relative to mRootView + nsIntPoint mMouseLocation; // device units, relative to mRootView // The size for a resize that we delayed until the root view becomes // visible again. diff --git a/widget/public/nsGUIEvent.h b/widget/public/nsGUIEvent.h index 651932cf5a59..c1c2abefd7e8 100644 --- a/widget/public/nsGUIEvent.h +++ b/widget/public/nsGUIEvent.h @@ -445,7 +445,7 @@ public: // See GUI MESSAGES, PRUint32 message; // In widget relative coordinates, not modified by layout code. - nsPoint refPoint; + nsIntPoint refPoint; // Elapsed time, in milliseconds, from a platform-specific zero time // to the time the message was created PRUint32 time; @@ -531,7 +531,7 @@ public: } /// x,y width, height in pixels (client area) - nsRect *windowSize; + nsIntRect *windowSize; /// width of entire window (in pixels) PRInt32 mWinWidth; /// height of entire window (in pixels) @@ -593,7 +593,7 @@ public: /// area to paint (should be used instead of rect) nsIRegion *region; /// x,y, width, height in pixels of area to paint - nsRect *rect; + nsIntRect *rect; }; /** @@ -822,7 +822,7 @@ struct nsTextEventReply { } - nsRect mCursorPosition; + nsIntRect mCursorPosition; PRBool mCursorIsCollapsed; nsIWidget* mReferenceWidget; }; @@ -961,7 +961,7 @@ public: void* mContentsRoot; PRUint32 mOffset; nsString mString; - nsRect mRect; // Finally, the coordinates is system coordinates. + nsIntRect mRect; // Finally, the coordinates is system coordinates. // The return widget has the caret. This is set at all query events. nsIWidget* mFocusedWidget; } mReply; diff --git a/widget/public/nsIPrintSettings.idl b/widget/public/nsIPrintSettings.idl index df33258d19f2..da351bb6cc6b 100644 --- a/widget/public/nsIPrintSettings.idl +++ b/widget/public/nsIPrintSettings.idl @@ -49,7 +49,7 @@ /** * Native types */ - [ref] native nsNativeMarginRef(nsMargin); + [ref] native nsNativeIntMarginRef(nsIntMargin); interface nsIPrintSession; @@ -58,7 +58,7 @@ interface nsIPrintSession; * * @status UNDER_REVIEW */ -[scriptable, uuid(5af07661-6477-4235-8814-4a45215855b8)] +[scriptable, uuid(343700dd-078b-42b6-a809-b9c1d7e951d0)] interface nsIPrintSettings : nsISupports { @@ -304,11 +304,11 @@ interface nsIPrintSettings : nsISupports attribute boolean isInitializedFromPrefs; /* C++ Helper Functions */ - [noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin); - [noscript] void SetEdgeInTwips(in nsNativeMarginRef aEdge); + [noscript] void SetMarginInTwips(in nsNativeIntMarginRef aMargin); + [noscript] void SetEdgeInTwips(in nsNativeIntMarginRef aEdge); /* Purposely made this an "in" arg */ - [noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin); - [noscript] void GetEdgeInTwips(in nsNativeMarginRef aEdge); + [noscript] void GetMarginInTwips(in nsNativeIntMarginRef aMargin); + [noscript] void GetEdgeInTwips(in nsNativeIntMarginRef aEdge); /** * We call this function so that anything that requires a run of the event loop @@ -329,6 +329,6 @@ interface nsIPrintSettings : nsISupports * negative margin values by falling back on the system default for * that margin. */ - [noscript] void SetUnwriteableMarginInTwips(in nsNativeMarginRef aEdge); - [noscript] void GetUnwriteableMarginInTwips(in nsNativeMarginRef aEdge); + [noscript] void SetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge); + [noscript] void GetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge); }; diff --git a/widget/public/nsIScreenManager.idl b/widget/public/nsIScreenManager.idl index 7c218e2f9f0f..c06419458ab3 100644 --- a/widget/public/nsIScreenManager.idl +++ b/widget/public/nsIScreenManager.idl @@ -46,7 +46,7 @@ interface nsIScreenManager : nsISupports // Returns the screen that contains the rectangle. If the rect overlaps // multiple screens, it picks the screen with the greatest area of intersection. // - // The coordinates are in pixels (not twips) and in screen coordinates. + // The coordinates are in pixels (not app units) and in screen coordinates. // nsIScreen screenForRect ( in long left, in long top, in long width, in long height ) ; diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index 84edd0af3fef..0da3afbcbdca 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -93,10 +93,10 @@ typedef nsEventStatus (*PR_CALLBACK EVENT_CALLBACK)(nsGUIEvent *event); #define NS_NATIVE_PLUGIN_PORT_CG 101 #endif -// 0e64821f-00a2-4adc-ac3b-3439d61f4491 +// a85944af-7fce-4e45-bf04-ac12c823394b #define NS_IWIDGET_IID \ -{ 0x0e64821f, 0x00a2, 0x4adc, \ - { 0xac, 0x3b, 0x34, 0x39, 0xd6, 0x1f, 0x44, 0x91 } } +{ 0xa85944af, 0x7fce, 0x4e45, \ + { 0xbf, 0x04, 0xac, 0x12, 0xc8, 0x23, 0x39, 0x4b } } // Hide the native window systems real window type so as to avoid // including native window system types and APIs. This is necessary @@ -312,7 +312,7 @@ class nsIWidget : public nsISupports { * */ NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, @@ -339,7 +339,7 @@ class nsIWidget : public nsISupports { * @param aHandleEventFunction the event handler callback function */ NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, @@ -583,7 +583,7 @@ class nsIWidget : public nsISupports { * @param aRect on return it holds the x, y, width and height of this widget * */ - NS_IMETHOD GetBounds(nsRect &aRect) = 0; + NS_IMETHOD GetBounds(nsIntRect &aRect) = 0; /** @@ -596,7 +596,7 @@ class nsIWidget : public nsISupports { * @param aRect on return it holds the x, y, width and height of this widget * */ - NS_IMETHOD GetScreenBounds(nsRect &aRect) = 0; + NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0; /** @@ -606,7 +606,7 @@ class nsIWidget : public nsISupports { * @param aRect on return it holds the x. y, width and height of the client area of this widget * */ - NS_IMETHOD GetClientBounds(nsRect &aRect) = 0; + NS_IMETHOD GetClientBounds(nsIntRect &aRect) = 0; /** * Gets the width and height of the borders @@ -745,7 +745,7 @@ class nsIWidget : public nsISupports { * @see #Update() */ - NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous) = 0; + NS_IMETHOD Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous) = 0; /** * Invalidate a specified region for a widget and repaints it. @@ -802,7 +802,7 @@ class nsIWidget : public nsISupports { * */ - NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) = 0; + NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect) = 0; /** * Scroll the contents of the widget. @@ -826,7 +826,7 @@ class nsIWidget : public nsISupports { * */ - NS_IMETHOD ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy) = 0; + NS_IMETHOD ScrollRect(nsIntRect &aSrcRect, PRInt32 aDx, PRInt32 aDy) = 0; /** * Internal methods @@ -896,7 +896,7 @@ class nsIWidget : public nsISupports { * @param aNewRect screen coordinates stored in the x,y members */ - NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) = 0; + NS_IMETHOD WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect) = 0; /** * Convert from screen coordinates to this widget's coordinates. @@ -905,7 +905,7 @@ class nsIWidget : public nsISupports { * @param aNewRect widget's coordinates stored in the x,y members */ - NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) = 0; + NS_IMETHOD ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect) = 0; /** * When adjustments are to made to a whole set of child widgets, call this diff --git a/widget/src/cocoa/nsChildView.h b/widget/src/cocoa/nsChildView.h index c11a07223785..04afec500566 100644 --- a/widget/src/cocoa/nsChildView.h +++ b/widget/src/cocoa/nsChildView.h @@ -259,14 +259,14 @@ public: // nsIWidget interface NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, nsIToolkit *aToolkit = nsnull, nsWidgetInitData *aInitData = nsnull); NS_IMETHOD Create(nsNativeWidget aNativeParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, @@ -277,7 +277,7 @@ public: // Create(nsNativeWidget...) virtual nsresult StandardCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -304,19 +304,19 @@ public: NS_IMETHOD Enable(PRBool aState); NS_IMETHOD IsEnabled(PRBool *aState); NS_IMETHOD SetFocus(PRBool aRaise); - NS_IMETHOD SetBounds(const nsRect &aRect); - NS_IMETHOD GetBounds(nsRect &aRect); + NS_IMETHOD SetBounds(const nsIntRect &aRect); + NS_IMETHOD GetBounds(nsIntRect &aRect); NS_IMETHOD Invalidate(PRBool aIsSynchronous); - NS_IMETHOD Invalidate(const nsRect &aRect,PRBool aIsSynchronous); + NS_IMETHOD Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous); NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous); NS_IMETHOD Validate(); virtual void* GetNativeData(PRUint32 aDataType); NS_IMETHOD SetColorMap(nsColorMap *aColorMap); - NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect); - NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect); - NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect); + NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect); + NS_IMETHOD WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect); + NS_IMETHOD ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect); NS_IMETHOD BeginResizingChildren(void); NS_IMETHOD EndResizingChildren(void); virtual PRBool ShowsResizeIndicator(nsIntRect* aResizerRect); @@ -328,9 +328,9 @@ public: NS_IMETHOD Update(); virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY); - void LocalToWindowCoordinate(nsPoint& aPoint) { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); } + void LocalToWindowCoordinate(nsIntPoint& aPoint) { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); } void LocalToWindowCoordinate(nscoord& aX, nscoord& aY) { ConvertToDeviceCoordinates(aX, aY); } - void LocalToWindowCoordinate(nsRect& aRect) { ConvertToDeviceCoordinates(aRect.x, aRect.y); } + void LocalToWindowCoordinate(nsIntRect& aRect) { ConvertToDeviceCoordinates(aRect.x, aRect.y); } NS_IMETHOD SetMenuBar(void* aMenuBar); NS_IMETHOD ShowMenuBar(PRBool aShow); diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index eeb4c2b86998..222925ceca80 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -139,7 +139,7 @@ nsIWidget * gRollupWidget = nsnull; - (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild; // sends gecko an ime composition event -- (nsRect) sendCompositionEvent:(PRInt32)aEventType; +- (nsIntRect) sendCompositionEvent:(PRInt32)aEventType; // sends gecko an ime text event - (void) sendTextEvent:(PRUnichar*) aBuffer @@ -208,7 +208,7 @@ nsIWidget * gRollupWidget = nsnull; static inline void -GeckoRectToNSRect(const nsRect & inGeckoRect, NSRect & outCocoaRect) +GeckoRectToNSRect(const nsIntRect & inGeckoRect, NSRect & outCocoaRect) { outCocoaRect.origin.x = inGeckoRect.x; outCocoaRect.origin.y = inGeckoRect.y; @@ -217,12 +217,12 @@ GeckoRectToNSRect(const nsRect & inGeckoRect, NSRect & outCocoaRect) } static inline void -NSRectToGeckoRect(const NSRect & inCocoaRect, nsRect & outGeckoRect) +NSRectToGeckoRect(const NSRect & inCocoaRect, nsIntRect & outGeckoRect) { - outGeckoRect.x = static_cast(inCocoaRect.origin.x); - outGeckoRect.y = static_cast(inCocoaRect.origin.y); - outGeckoRect.width = static_cast(inCocoaRect.size.width); - outGeckoRect.height = static_cast(inCocoaRect.size.height); + outGeckoRect.x = NSToIntFloor(inCocoaRect.origin.x); + outGeckoRect.y = NSToIntFloor(inCocoaRect.origin.y); + outGeckoRect.width = NSToIntCeil(inCocoaRect.size.width); + outGeckoRect.height = NSToIntCeil(inCocoaRect.size.height); } @@ -452,7 +452,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsChildView, nsBaseWidget, nsIPluginWidget) // Utility method for implementing both Create(nsIWidget ...) // and Create(nsNativeWidget...) nsresult nsChildView::StandardCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -582,7 +582,7 @@ void nsChildView::TearDownView() // create a nsChildView NS_IMETHODIMP nsChildView::Create(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -596,7 +596,7 @@ NS_IMETHODIMP nsChildView::Create(nsIWidget *aParent, // Creates a main nsChildView using a native widget (an NSView) NS_IMETHODIMP nsChildView::Create(nsNativeWidget aNativeParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -990,14 +990,14 @@ NS_IMETHODIMP nsChildView::SetCursor(imgIContainer* aCursor, // Get this component dimension -NS_IMETHODIMP nsChildView::GetBounds(nsRect &aRect) +NS_IMETHODIMP nsChildView::GetBounds(nsIntRect &aRect) { aRect = mBounds; return NS_OK; } -NS_IMETHODIMP nsChildView::SetBounds(const nsRect &aRect) +NS_IMETHODIMP nsChildView::SetBounds(const nsIntRect &aRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -1526,7 +1526,7 @@ NS_IMETHODIMP nsChildView::Invalidate(PRBool aIsSynchronous) // Invalidate this component's visible area -NS_IMETHODIMP nsChildView::Invalidate(const nsRect &aRect, PRBool aIsSynchronous) +NS_IMETHODIMP nsChildView::Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -1576,7 +1576,7 @@ NS_IMETHODIMP nsChildView::InvalidateRegion(const nsIRegion *aRegion, PRBool aIs // FIXME rewrite to use a Cocoa region when nsIRegion isn't a QD Region NSRect r; - nsRect bounds; + nsIntRect bounds; nsIRegion* region = const_cast(aRegion); // ugh. this method should be const region->GetBoundingBox(&bounds.x, &bounds.y, &bounds.width, &bounds.height); GeckoRectToNSRect(bounds, r); @@ -1626,7 +1626,7 @@ NS_IMETHODIMP nsChildView::Update() // Scroll the bits of a view and its children // FIXME: I'm sure the invalidating can be optimized, just no time now. -NS_IMETHODIMP nsChildView::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) +NS_IMETHODIMP nsChildView::Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -1648,7 +1648,7 @@ NS_IMETHODIMP nsChildView::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) // over repainting. We can scroll like a bat out of hell // by not wasting time invalidating the widgets, since it's // completely unnecessary to do so. - nsRect bounds; + nsIntRect bounds; kid->GetBounds(bounds); kid->Resize(bounds.x + aDx, bounds.y + aDy, bounds.width, bounds.height, PR_FALSE); } @@ -1867,11 +1867,11 @@ NS_IMETHODIMP nsChildView::CalcOffset(PRInt32 &aX,PRInt32 &aY) PRBool nsChildView::PointInWidget(Point aThePoint) { // get the origin in local coordinates - nsPoint widgetOrigin(0, 0); + nsIntPoint widgetOrigin(0, 0); LocalToWindowCoordinate(widgetOrigin); // get rectangle relatively to the parent - nsRect widgetRect; + nsIntRect widgetRect; GetBounds(widgetRect); // convert the topLeft corner to local coordinates @@ -1887,7 +1887,7 @@ PRBool nsChildView::PointInWidget(Point aThePoint) // Convert the given rect to global coordinates. // @param aLocalRect -- rect in local coordinates of this widget // @param aGlobalRect -- |aLocalRect| in global coordinates -NS_IMETHODIMP nsChildView::WidgetToScreen(const nsRect& aLocalRect, nsRect& aGlobalRect) +NS_IMETHODIMP nsChildView::WidgetToScreen(const nsIntRect& aLocalRect, nsIntRect& aGlobalRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -1927,7 +1927,7 @@ NS_IMETHODIMP nsChildView::WidgetToScreen(const nsRect& aLocalRect, nsRect& aGlo // Convert the given rect to local coordinates. // @param aGlobalRect -- rect in screen coordinates // @param aLocalRect -- |aGlobalRect| in coordinates of this widget -NS_IMETHODIMP nsChildView::ScreenToWidget(const nsRect& aGlobalRect, nsRect& aLocalRect) +NS_IMETHODIMP nsChildView::ScreenToWidget(const nsIntRect& aGlobalRect, nsIntRect& aLocalRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -2743,7 +2743,7 @@ NSEvent* gLastDragEvent = nil; CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - nsRect geckoBounds; + nsIntRect geckoBounds; mGeckoChild->GetBounds(geckoBounds); NSRect bounds = [self bounds]; @@ -2787,7 +2787,7 @@ NSEvent* gLastDragEvent = nil; targetContext->Clip(); // bounding box of the dirty area - nsRect fullRect; + nsIntRect fullRect; NSRectToGeckoRect(aRect, fullRect); nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, mGeckoChild); @@ -4696,14 +4696,14 @@ GetUSLayoutCharFromKeyTranslate(UInt32 aKeyCode, UInt32 aModifiers) } -- (nsRect)sendCompositionEvent:(PRInt32) aEventType +- (nsIntRect)sendCompositionEvent:(PRInt32) aEventType { #ifdef DEBUG_IME NSLog(@"****in sendCompositionEvent; type = %d", aEventType); #endif if (!mGeckoChild) - return nsRect(0, 0, 0, 0); + return nsIntRect(0, 0, 0, 0); // static void init_composition_event( *aEvent, int aType) nsCompositionEvent event(PR_TRUE, aEventType, mGeckoChild); @@ -5068,7 +5068,7 @@ GetUSLayoutCharFromKeyTranslate(UInt32 aKeyCode, UInt32 aModifiers) if (!mGeckoChild || theRange.location == NSNotFound) return rect; - nsRect r; + nsIntRect r; PRBool useCaretRect = theRange.length == 0; if (!useCaretRect) { nsQueryContentEvent charRect(PR_TRUE, NS_QUERY_CHARACTER_RECT, mGeckoChild); diff --git a/widget/src/cocoa/nsCocoaUtils.h b/widget/src/cocoa/nsCocoaUtils.h index 8c2bca2577c9..5a177d311f49 100644 --- a/widget/src/cocoa/nsCocoaUtils.h +++ b/widget/src/cocoa/nsCocoaUtils.h @@ -115,10 +115,10 @@ class nsCocoaUtils // (NSRect) contain an origin (x,y) in a coordinate system with (0,0) // in the bottom-left of the primary screen. Both nsRect and NSRect // contain width/height info, with no difference in their use. - static NSRect GeckoRectToCocoaRect(const nsRect &geckoRect); + static NSRect GeckoRectToCocoaRect(const nsIntRect &geckoRect); // See explanation for geckoRectToCocoaRect, guess what this does... - static nsRect CocoaRectToGeckoRect(const NSRect &cocoaRect); + static nsIntRect CocoaRectToGeckoRect(const NSRect &cocoaRect); // Gives the location for the event in screen coordinates. Do not call this // unless the window the event was originally targeted at is still alive! diff --git a/widget/src/cocoa/nsCocoaUtils.mm b/widget/src/cocoa/nsCocoaUtils.mm index 7f7700d473db..0e32a65e2fc8 100644 --- a/widget/src/cocoa/nsCocoaUtils.mm +++ b/widget/src/cocoa/nsCocoaUtils.mm @@ -70,7 +70,7 @@ float nsCocoaUtils::FlippedScreenY(float y) } -NSRect nsCocoaUtils::GeckoRectToCocoaRect(const nsRect &geckoRect) +NSRect nsCocoaUtils::GeckoRectToCocoaRect(const nsIntRect &geckoRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; @@ -85,15 +85,17 @@ NSRect nsCocoaUtils::GeckoRectToCocoaRect(const nsRect &geckoRect) } -nsRect nsCocoaUtils::CocoaRectToGeckoRect(const NSRect &cocoaRect) +nsIntRect nsCocoaUtils::CocoaRectToGeckoRect(const NSRect &cocoaRect) { // We only need to change the Y coordinate by starting with the primary screen // height and subtracting both the cocoa y origin and the height of the // cocoa rect. - return nsRect((nscoord)cocoaRect.origin.x, - (nscoord)(MenuBarScreenHeight() - (cocoaRect.origin.y + cocoaRect.size.height)), - (nscoord)cocoaRect.size.width, - (nscoord)cocoaRect.size.height); + nsIntRect rect; + rect.x = NSToIntFloor(cocoaRect.origin.x); + rect.y = NSToIntFloor(MenuBarScreenHeight() - (cocoaRect.origin.y + cocoaRect.size.height)); + rect.width = NSToIntCeil(cocoaRect.origin.x + cocoaRect.size.width) - rect.x; + rect.height = NSToIntCeil(MenuBarScreenHeight() - cocoaRect.origin.y) - rect.y; + return rect; } diff --git a/widget/src/cocoa/nsCocoaWindow.h b/widget/src/cocoa/nsCocoaWindow.h index 8c59903d7b36..5d0c27f6122f 100644 --- a/widget/src/cocoa/nsCocoaWindow.h +++ b/widget/src/cocoa/nsCocoaWindow.h @@ -203,7 +203,7 @@ public: NS_DECL_NSPIWIDGETCOCOA NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, @@ -211,7 +211,7 @@ public: nsWidgetInitData *aInitData = nsnull); NS_IMETHOD Create(nsIWidget* aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, @@ -223,7 +223,7 @@ public: // Create(nsNativeWidget...) virtual nsresult StandardCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -242,8 +242,8 @@ public: NS_IMETHOD SetMenuBar(void* aMenuBar); virtual nsMenuBarX* GetMenuBar(); NS_IMETHOD ShowMenuBar(PRBool aShow); - NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect); - NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect); + NS_IMETHOD WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect); + NS_IMETHOD ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect); virtual void* GetNativeData(PRUint32 aDataType) ; @@ -256,16 +256,16 @@ public: NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint); NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint); - NS_IMETHOD GetScreenBounds(nsRect &aRect); + NS_IMETHOD GetScreenBounds(nsIntRect &aRect); virtual PRBool OnPaint(nsPaintEvent &event); void ReportSizeEvent(NSRect *overrideRect = nsnull); NS_IMETHOD SetTitle(const nsAString& aTitle); - NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous); + NS_IMETHOD Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous); NS_IMETHOD Invalidate(PRBool aIsSynchronous); NS_IMETHOD Update(); - NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *alCipRect) { return NS_OK; } + NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *alCipRect) { return NS_OK; } NS_IMETHOD SetColorMap(nsColorMap *aColorMap) { return NS_OK; } NS_IMETHOD BeginResizingChildren(void) { return NS_OK; } NS_IMETHOD EndResizingChildren(void) { return NS_OK; } diff --git a/widget/src/cocoa/nsCocoaWindow.mm b/widget/src/cocoa/nsCocoaWindow.mm index c6fe916558d0..ca0fa34c0adb 100644 --- a/widget/src/cocoa/nsCocoaWindow.mm +++ b/widget/src/cocoa/nsCocoaWindow.mm @@ -180,7 +180,7 @@ static bool WindowSizeAllowed(PRInt32 aWidth, PRInt32 aHeight) // Utility method for implementing both Create(nsIWidget ...) and // Create(nsNativeWidget...) nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -406,7 +406,7 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent, // Create a nsCocoaWindow using a native window provided by the application NS_IMETHODIMP nsCocoaWindow::Create(nsNativeWidget aNativeWindow, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -419,7 +419,7 @@ NS_IMETHODIMP nsCocoaWindow::Create(nsNativeWidget aNativeWindow, NS_IMETHODIMP nsCocoaWindow::Create(nsIWidget* aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -938,14 +938,14 @@ NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRIn if (!WindowSizeAllowed(aWidth, aHeight)) return NS_ERROR_FAILURE; - nsRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame])); + nsIntRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame])); BOOL isMoving = (windowBounds.x != aX || windowBounds.y != aY); BOOL isResizing = (windowBounds.width != aWidth || windowBounds.height != aHeight); if (IsResizing() || !mWindow || (!isMoving && !isResizing)) return NS_OK; - nsRect geckoRect(aX, aY, aWidth, aHeight); + nsIntRect geckoRect(aX, aY, aWidth, aHeight); NSRect newFrame = nsCocoaUtils::GeckoRectToCocoaRect(geckoRect); // We have to report the size event -first-, to make sure that content @@ -985,22 +985,18 @@ NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRep if (!WindowSizeAllowed(aWidth, aHeight)) return NS_ERROR_FAILURE; - nsRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame])); + nsIntRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame])); return Resize(windowBounds.x, windowBounds.y, aWidth, aHeight, aRepaint); NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; } -NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(nsRect &aRect) +NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(nsIntRect &aRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; - nsRect windowFrame = nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]); - aRect.x = windowFrame.x; - aRect.y = windowFrame.y; - aRect.width = windowFrame.width; - aRect.height = windowFrame.height; + aRect = nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]); // printf("GetScreenBounds: output: %d,%d,%d,%d\n", aRect.x, aRect.y, aRect.width, aRect.height); return NS_OK; @@ -1028,7 +1024,7 @@ NS_IMETHODIMP nsCocoaWindow::SetTitle(const nsAString& aTitle) } -NS_IMETHODIMP nsCocoaWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) +NS_IMETHODIMP nsCocoaWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous) { if (mPopupContentView) return mPopupContentView->Invalidate(aRect, aIsSynchronous); @@ -1226,11 +1222,11 @@ NS_IMETHODIMP nsCocoaWindow::ShowMenuBar(PRBool aShow) } -NS_IMETHODIMP nsCocoaWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) +NS_IMETHODIMP nsCocoaWindow::WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; - nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]]); + nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]])); aNewRect.x = r.x + aOldRect.x; aNewRect.y = r.y + aOldRect.y; @@ -1243,11 +1239,11 @@ NS_IMETHODIMP nsCocoaWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNew } -NS_IMETHODIMP nsCocoaWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) +NS_IMETHODIMP nsCocoaWindow::ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; - nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]]); + nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mWindow contentRectForFrameRect:[mWindow frame]])); aNewRect.x = aOldRect.x - r.x; aNewRect.y = aOldRect.y - r.y; @@ -1546,7 +1542,7 @@ NS_IMETHODIMP nsCocoaWindow::EndSecureKeyboardInput() { // Dispatch the move event to Gecko nsGUIEvent guiEvent(PR_TRUE, NS_MOVE, mGeckoWindow); - nsRect rect; + nsIntRect rect; mGeckoWindow->GetScreenBounds(rect); guiEvent.refPoint.x = rect.x; guiEvent.refPoint.y = rect.y; diff --git a/widget/src/cocoa/nsDragService.h b/widget/src/cocoa/nsDragService.h index 4fe2cf9a696d..3304394f93eb 100644 --- a/widget/src/cocoa/nsDragService.h +++ b/widget/src/cocoa/nsDragService.h @@ -67,7 +67,7 @@ public: private: NSImage* ConstructDragImage(nsIDOMNode* aDOMNode, - nsRect* aDragRect, + nsIntRect* aDragRect, nsIScriptableRegion* aRegion); nsCOMPtr mDataItems; // only valid for a drag started within gecko diff --git a/widget/src/cocoa/nsDragService.mm b/widget/src/cocoa/nsDragService.mm index 90b74510fb4d..43277a01fde1 100644 --- a/widget/src/cocoa/nsDragService.mm +++ b/widget/src/cocoa/nsDragService.mm @@ -160,7 +160,7 @@ static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray) NSImage* nsDragService::ConstructDragImage(nsIDOMNode* aDOMNode, - nsRect* aDragRect, + nsIntRect* aDragRect, nsIScriptableRegion* aRegion) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL; @@ -264,7 +264,7 @@ nsDragService::InvokeDragSession(nsIDOMNode* aDOMNode, nsISupportsArray* aTransf if (NS_FAILED(SetUpDragClipboard(aTransferableArray))) return NS_ERROR_FAILURE; - nsRect dragRect(0, 0, 20, 20); + nsIntRect dragRect(0, 0, 20, 20); NSImage* image = ConstructDragImage(aDOMNode, &dragRect, aDragRgn); if (!image) { // if no image was returned, just draw a rectangle diff --git a/widget/src/cocoa/nsNativeThemeCocoa.h b/widget/src/cocoa/nsNativeThemeCocoa.h index 98d229f1a088..5397af0ca839 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.h +++ b/widget/src/cocoa/nsNativeThemeCocoa.h @@ -68,19 +68,19 @@ public: NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult); + nsIntMargin* aResult); virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult); + nsIntMargin* aResult); virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, nsRect* aOverflowRect); NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, PRBool* aIsOverridable); + nsIntSize* aResult, PRBool* aIsOverridable); NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, nsIAtom* aAttribute, PRBool* aShouldRepaint); NS_IMETHOD ThemeChanged(); diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index e27aff539834..48b676c226d2 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -1498,7 +1498,7 @@ NS_IMETHODIMP nsNativeThemeCocoa::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult) + nsIntMargin* aResult) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -1586,7 +1586,7 @@ PRBool nsNativeThemeCocoa::GetWidgetPadding(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult) + nsIntMargin* aResult) { // We don't want CSS padding being used for certain widgets. // See bug 381639 for an example of why. @@ -1643,7 +1643,7 @@ NS_IMETHODIMP nsNativeThemeCocoa::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, + nsIntSize* aResult, PRBool* aIsOverridable) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; diff --git a/widget/src/cocoa/nsScreenCocoa.mm b/widget/src/cocoa/nsScreenCocoa.mm index 34540dc3a673..aca71d520292 100644 --- a/widget/src/cocoa/nsScreenCocoa.mm +++ b/widget/src/cocoa/nsScreenCocoa.mm @@ -63,7 +63,7 @@ nsScreenCocoa::~nsScreenCocoa () NS_IMETHODIMP nsScreenCocoa::GetRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight) { - nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mScreen frame]); + nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mScreen frame])); *outX = r.x; *outY = r.y; @@ -76,7 +76,7 @@ nsScreenCocoa::GetRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 NS_IMETHODIMP nsScreenCocoa::GetAvailRect(PRInt32 *outX, PRInt32 *outY, PRInt32 *outWidth, PRInt32 *outHeight) { - nsRect r = nsCocoaUtils::CocoaRectToGeckoRect([mScreen visibleFrame]); + nsIntRect r(nsCocoaUtils::CocoaRectToGeckoRect([mScreen visibleFrame])); *outX = r.x; *outY = r.y; diff --git a/widget/src/cocoa/nsScreenManagerCocoa.mm b/widget/src/cocoa/nsScreenManagerCocoa.mm index a6252551751c..3e9f14835397 100644 --- a/widget/src/cocoa/nsScreenManagerCocoa.mm +++ b/widget/src/cocoa/nsScreenManagerCocoa.mm @@ -76,7 +76,7 @@ nsScreenManagerCocoa::ScreenForRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRI NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator]; - NSRect inRect = nsCocoaUtils::GeckoRectToCocoaRect(nsRect(aX, aY, aWidth, aHeight)); + NSRect inRect(nsCocoaUtils::GeckoRectToCocoaRect(nsIntRect(aX, aY, aWidth, aHeight))); NSScreen *screenWindowIsOn = [NSScreen mainScreen]; float greatestArea = 0; diff --git a/widget/src/gtk2/nsCommonWidget.cpp b/widget/src/gtk2/nsCommonWidget.cpp index a90354ca4b58..833ee543e375 100644 --- a/widget/src/gtk2/nsCommonWidget.cpp +++ b/widget/src/gtk2/nsCommonWidget.cpp @@ -128,7 +128,7 @@ nsCommonWidget::DispatchDeactivateEvent(void) } void -nsCommonWidget::DispatchResizeEvent(nsRect &aRect, nsEventStatus &aStatus) +nsCommonWidget::DispatchResizeEvent(nsIntRect &aRect, nsEventStatus &aStatus) { nsSizeEvent event(PR_TRUE, NS_SIZE, this); @@ -204,7 +204,7 @@ nsCommonWidget::Show(PRBool aState) NS_IMETHODIMP nsCommonWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { - mBounds.SizeTo(GetSafeWindowSize(nsSize(aWidth, aHeight))); + mBounds.SizeTo(GetSafeWindowSize(nsIntSize(aWidth, aHeight))); if (!mCreated) return NS_OK; @@ -263,7 +263,7 @@ nsCommonWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) // synthesize a resize event if this isn't a toplevel if (mIsTopLevel || mListenForResizes) { - nsRect rect(mBounds.x, mBounds.y, aWidth, aHeight); + nsIntRect rect(mBounds.x, mBounds.y, aWidth, aHeight); nsEventStatus status; DispatchResizeEvent(rect, status); } @@ -277,7 +277,7 @@ nsCommonWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, { mBounds.x = aX; mBounds.y = aY; - mBounds.SizeTo(GetSafeWindowSize(nsSize(aWidth, aHeight))); + mBounds.SizeTo(GetSafeWindowSize(nsIntSize(aWidth, aHeight))); mPlaced = PR_TRUE; @@ -328,7 +328,7 @@ nsCommonWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, if (mIsTopLevel || mListenForResizes) { // synthesize a resize event - nsRect rect(aX, aY, aWidth, aHeight); + nsIntRect rect(aX, aY, aWidth, aHeight); nsEventStatus status; DispatchResizeEvent(rect, status); } diff --git a/widget/src/gtk2/nsCommonWidget.h b/widget/src/gtk2/nsCommonWidget.h index 15a1efb849d7..459695e8319f 100644 --- a/widget/src/gtk2/nsCommonWidget.h +++ b/widget/src/gtk2/nsCommonWidget.h @@ -85,7 +85,7 @@ public: void DispatchLostFocusEvent(void); void DispatchActivateEvent(void); void DispatchDeactivateEvent(void); - void DispatchResizeEvent(nsRect &aRect, nsEventStatus &aStatus); + void DispatchResizeEvent(nsIntRect &aRect, nsEventStatus &aStatus); NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &aStatus); @@ -102,7 +102,7 @@ public: virtual void NativeShow (PRBool aAction) = 0; - virtual nsSize GetSafeWindowSize(nsSize aSize) = 0; + virtual nsIntSize GetSafeWindowSize(const nsIntSize &aSize) = 0; // Some of the nsIWidget methods NS_IMETHOD Show (PRBool aState); diff --git a/widget/src/gtk2/nsDragService.cpp b/widget/src/gtk2/nsDragService.cpp index c09809dea8fb..52cce3734423 100644 --- a/widget/src/gtk2/nsDragService.cpp +++ b/widget/src/gtk2/nsDragService.cpp @@ -208,7 +208,7 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode, &event); PRBool needsFallbackIcon = PR_FALSE; - nsRect dragRect; + nsIntRect dragRect; nsPresContext* pc; nsRefPtr surface; if (mHasImage || mSelection) { @@ -220,8 +220,8 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode, PRInt32 sx = mScreenX, sy = mScreenY; ConvertToUnscaledDevPixels(pc, &sx, &sy); - PRInt32 offsetX = sx - NSToIntRound(dragRect.x); - PRInt32 offsetY = sy - NSToIntRound(dragRect.y); + PRInt32 offsetX = sx - dragRect.x; + PRInt32 offsetY = sy - dragRect.y; if (!SetAlphaPixmap(surface, context, offsetX, offsetY, dragRect)) { GdkPixbuf* dragPixbuf = nsImageToPixbuf::SurfaceToPixbuf(surface, dragRect.width, dragRect.height); @@ -248,7 +248,7 @@ nsDragService::SetAlphaPixmap(gfxASurface *aSurface, GdkDragContext *aContext, PRInt32 aXOffset, PRInt32 aYOffset, - const nsRect& dragRect) + const nsIntRect& dragRect) { GdkScreen* screen = gtk_widget_get_screen(mHiddenWidget); diff --git a/widget/src/gtk2/nsDragService.h b/widget/src/gtk2/nsDragService.h index f20c67184ab0..aa86e122cae6 100644 --- a/widget/src/gtk2/nsDragService.h +++ b/widget/src/gtk2/nsDragService.h @@ -144,11 +144,11 @@ private: // attempts to create a semi-transparent drag image. Returns TRUE if // successful, FALSE if not - PRBool SetAlphaPixmap(gfxASurface *aPixbuf, - GdkDragContext *aContext, - PRInt32 aXOffset, - PRInt32 aYOffset, - const nsRect& dragRect); + PRBool SetAlphaPixmap(gfxASurface *aPixbuf, + GdkDragContext *aContext, + PRInt32 aXOffset, + PRInt32 aYOffset, + const nsIntRect &dragRect); }; diff --git a/widget/src/gtk2/nsNativeThemeGTK.cpp b/widget/src/gtk2/nsNativeThemeGTK.cpp index 55e25cbd845e..e91f4840720f 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -814,7 +814,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext, NS_IMETHODIMP nsNativeThemeGTK::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, - PRUint8 aWidgetType, nsMargin* aResult) + PRUint8 aWidgetType, nsIntMargin* aResult) { GtkTextDirection direction = GetTextDirection(aFrame); aResult->top = aResult->left = aResult->right = aResult->bottom = 0; @@ -867,7 +867,7 @@ nsNativeThemeGTK::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRBool nsNativeThemeGTK::GetWidgetPadding(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult) + nsIntMargin* aResult) { switch (aWidgetType) { case NS_THEME_BUTTON_FOCUS: @@ -931,7 +931,7 @@ nsNativeThemeGTK::GetWidgetOverflow(nsIDeviceContext* aContext, NS_IMETHODIMP nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, PRBool* aIsOverridable) + nsIntSize* aResult, PRBool* aIsOverridable) { aResult->width = aResult->height = 0; *aIsOverridable = PR_TRUE; @@ -1087,7 +1087,7 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsCOMPtr dc; aContext->GetDeviceContext(*getter_AddRefs(dc)); - nsMargin border; + nsIntMargin border; nsNativeThemeGTK::GetWidgetBorder(dc, aFrame, aWidgetType, &border); aResult->width = border.left + border.right; aResult->height = border.top + border.bottom; diff --git a/widget/src/gtk2/nsNativeThemeGTK.h b/widget/src/gtk2/nsNativeThemeGTK.h index 291b0bc651da..b3f10100576e 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.h +++ b/widget/src/gtk2/nsNativeThemeGTK.h @@ -60,12 +60,12 @@ public: const nsRect& aDirtyRect); NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, - PRUint8 aWidgetType, nsMargin* aResult); + PRUint8 aWidgetType, nsIntMargin* aResult); virtual NS_HIDDEN_(PRBool) GetWidgetPadding(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult); + nsIntMargin* aResult); virtual NS_HIDDEN_(PRBool) GetWidgetOverflow(nsIDeviceContext* aContext, nsIFrame* aFrame, @@ -74,7 +74,7 @@ public: NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, PRBool* aIsOverridable); + nsIntSize* aResult, PRBool* aIsOverridable); NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, nsIAtom* aAttribute, PRBool* aShouldRepaint); diff --git a/widget/src/gtk2/nsPrintSettingsGTK.cpp b/widget/src/gtk2/nsPrintSettingsGTK.cpp index 53832fbadaae..2df0eb25d1eb 100644 --- a/widget/src/gtk2/nsPrintSettingsGTK.cpp +++ b/widget/src/gtk2/nsPrintSettingsGTK.cpp @@ -611,7 +611,7 @@ nsPrintSettingsGTK::InitUnwriteableMargin() * are ignored by the nsPrintSettings::SetUnwriteableMargin functions.) */ NS_IMETHODIMP -nsPrintSettingsGTK::SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin) +nsPrintSettingsGTK::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) { nsPrintSettings::SetUnwriteableMarginInTwips(aUnwriteableMargin); gtk_page_setup_set_top_margin(mPageSetup, diff --git a/widget/src/gtk2/nsPrintSettingsGTK.h b/widget/src/gtk2/nsPrintSettingsGTK.h index c0c85190f309..b340048668d2 100644 --- a/widget/src/gtk2/nsPrintSettingsGTK.h +++ b/widget/src/gtk2/nsPrintSettingsGTK.h @@ -121,7 +121,7 @@ public: NS_IMETHOD GetPaperName(PRUnichar * *aPaperName); NS_IMETHOD SetPaperName(const PRUnichar * aPaperName); - NS_IMETHOD SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin); + NS_IMETHOD SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin); NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop); NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft); NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom); diff --git a/widget/src/gtk2/nsScreenGtk.cpp b/widget/src/gtk2/nsScreenGtk.cpp index 0a927d5c978b..68c6e659f840 100644 --- a/widget/src/gtk2/nsScreenGtk.cpp +++ b/widget/src/gtk2/nsScreenGtk.cpp @@ -114,7 +114,7 @@ nsScreenGtk :: Init (GdkWindow *aRootWindow) // changes to this rect. We could listen for "size_changed" signals // on the default screen to do this, except that doesn't work with // versions of GDK predating the GdkScreen object. See bug 256646. - mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height()); + mAvailRect = mRect = nsIntRect(0, 0, gdk_screen_width(), gdk_screen_height()); #ifdef MOZ_X11 // We need to account for the taskbar, etc in the available rect. @@ -162,8 +162,8 @@ nsScreenGtk :: Init (GdkWindow *aRootWindow) int num_items = length_returned / sizeof(long); for (int i = 0; i < num_items; i += 4) { - nsRect workarea(workareas[i], workareas[i + 1], - workareas[i + 2], workareas[i + 3]); + nsIntRect workarea(workareas[i], workareas[i + 1], + workareas[i + 2], workareas[i + 3]); if (!mRect.Contains(workarea)) { // Note that we hit this when processing screen size changes, // since we'll get the configure event before the toolbars have @@ -187,8 +187,8 @@ nsScreenGtk :: Init (GdkWindow *aRootWindow) void nsScreenGtk :: Init (XineramaScreenInfo *aScreenInfo) { - nsRect xineRect(aScreenInfo->x_org, aScreenInfo->y_org, - aScreenInfo->width, aScreenInfo->height); + nsIntRect xineRect(aScreenInfo->x_org, aScreenInfo->y_org, + aScreenInfo->width, aScreenInfo->height); mScreenNum = aScreenInfo->screen_number; diff --git a/widget/src/gtk2/nsScreenGtk.h b/widget/src/gtk2/nsScreenGtk.h index 825bfb0e9bf3..258e6a2c7d5b 100644 --- a/widget/src/gtk2/nsScreenGtk.h +++ b/widget/src/gtk2/nsScreenGtk.h @@ -72,8 +72,8 @@ public: private: PRUint32 mScreenNum; - nsRect mRect; // in pixels, not twips - nsRect mAvailRect; // in pixels, not twips + nsIntRect mRect; + nsIntRect mAvailRect; }; #endif // nsScreenGtk_h___ diff --git a/widget/src/gtk2/nsScreenManagerGtk.cpp b/widget/src/gtk2/nsScreenManagerGtk.cpp index 488b168afaeb..612ee5c5006c 100644 --- a/widget/src/gtk2/nsScreenManagerGtk.cpp +++ b/widget/src/gtk2/nsScreenManagerGtk.cpp @@ -257,7 +257,7 @@ nsScreenManagerGtk :: Init() // Returns the screen that contains the rectangle. If the rect overlaps // multiple screens, it picks the screen with the greatest area of intersection. // -// The coordinates are in pixels (not twips) and in screen coordinates. +// The coordinates are in pixels (not app units) and in screen coordinates. // NS_IMETHODIMP nsScreenManagerGtk :: ScreenForRect ( PRInt32 aX, PRInt32 aY, @@ -279,13 +279,13 @@ nsScreenManagerGtk :: ScreenForRect ( PRInt32 aX, PRInt32 aY, // walk the list of screens and find the one that has the most // surface area. PRUint32 area = 0; - nsRect windowRect(aX, aY, aWidth, aHeight); + nsIntRect windowRect(aX, aY, aWidth, aHeight); for (PRInt32 i = 0, i_end = mCachedScreenArray.Count(); i < i_end; ++i) { PRInt32 x, y, width, height; x = y = width = height = 0; mCachedScreenArray[i]->GetRect(&x, &y, &width, &height); // calculate the surface area - nsRect screenRect(x, y, width, height); + nsIntRect screenRect(x, y, width, height); screenRect.IntersectRect(screenRect, windowRect); PRUint32 tempArea = screenRect.width * screenRect.height; if (tempArea >= area) { diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index 57ba33c2280c..24266f55b210 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -465,7 +465,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsWindow, nsCommonWidget, NS_IMETHODIMP nsWindow::Create(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -479,7 +479,7 @@ nsWindow::Create(nsIWidget *aParent, NS_IMETHODIMP nsWindow::Create(nsNativeWidget aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -994,9 +994,9 @@ nsWindow::SetFocus(PRBool aRaise) } NS_IMETHODIMP -nsWindow::GetScreenBounds(nsRect &aRect) +nsWindow::GetScreenBounds(nsIntRect &aRect) { - nsRect origin(0, 0, mBounds.width, mBounds.height); + nsIntRect origin(0, 0, mBounds.width, mBounds.height); WidgetToScreen(origin, aRect); LOG(("GetScreenBounds %d %d | %d %d | %d %d\n", aRect.x, aRect.y, @@ -1264,8 +1264,8 @@ nsWindow::Invalidate(PRBool aIsSynchronous) } NS_IMETHODIMP -nsWindow::Invalidate(const nsRect &aRect, - PRBool aIsSynchronous) +nsWindow::Invalidate(const nsIntRect &aRect, + PRBool aIsSynchronous) { GdkRectangle rect; @@ -1331,9 +1331,9 @@ nsWindow::SetColorMap(nsColorMap *aColorMap) } NS_IMETHODIMP -nsWindow::Scroll(PRInt32 aDx, - PRInt32 aDy, - nsRect *aClipRect) +nsWindow::Scroll(PRInt32 aDx, + PRInt32 aDy, + nsIntRect *aClipRect) { if (!mDrawingarea) return NS_OK; @@ -1349,7 +1349,7 @@ nsWindow::Scroll(PRInt32 aDx, // Update bounds on our child windows for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) { - nsRect bounds; + nsIntRect bounds; kid->GetBounds(bounds); bounds.x += aDx; bounds.y += aDy; @@ -1373,9 +1373,9 @@ nsWindow::ScrollWidgets(PRInt32 aDx, } NS_IMETHODIMP -nsWindow::ScrollRect(nsRect &aSrcRect, - PRInt32 aDx, - PRInt32 aDy) +nsWindow::ScrollRect(nsIntRect &aSrcRect, + PRInt32 aDx, + PRInt32 aDy) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1500,7 +1500,7 @@ nsWindow::ShowMenuBar(PRBool aShow) } NS_IMETHODIMP -nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) +nsWindow::WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect) { gint x = 0, y = 0; @@ -1523,7 +1523,7 @@ nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) } NS_IMETHODIMP -nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) +nsWindow::ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect) { gint x = 0, y = 0; @@ -1895,7 +1895,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent) if (bufferPixmap) { bufferPixmapSurface = GetSurfaceForGdkDrawable(GDK_DRAWABLE(bufferPixmap), - nsSize(bufferPixmapSize.width, bufferPixmapSize.height)); + nsIntSize(bufferPixmapSize.width, bufferPixmapSize.height)); if (bufferPixmapSurface && bufferPixmapSurface->CairoStatus()) { bufferPixmapSurface = nsnull; @@ -1969,8 +1969,8 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent) imgCtx->Paint(); } - UpdateTranslucentWindowAlphaInternal(nsRect(boundsRect.x, boundsRect.y, - boundsRect.width, boundsRect.height), + UpdateTranslucentWindowAlphaInternal(nsIntRect(boundsRect.x, boundsRect.y, + boundsRect.width, boundsRect.height), img->Data(), img->Stride()); } } else { @@ -2021,7 +2021,7 @@ nsWindow::OnConfigureEvent(GtkWidget *aWidget, GdkEventConfigure *aEvent) if (mIsTopLevel) { mPlaced = PR_TRUE; // Need to translate this into the right coordinates - nsRect oldrect, newrect; + nsIntRect oldrect, newrect; WidgetToScreen(oldrect, newrect); mBounds.x = newrect.x; mBounds.y = newrect.y; @@ -2047,8 +2047,8 @@ nsWindow::OnSizeAllocate(GtkWidget *aWidget, GtkAllocation *aAllocation) (void *)this, aAllocation->x, aAllocation->y, aAllocation->width, aAllocation->height)); - nsRect rect(aAllocation->x, aAllocation->y, - aAllocation->width, aAllocation->height); + nsIntRect rect(aAllocation->x, aAllocation->y, + aAllocation->width, aAllocation->height); ResizeTransparencyBitmap(rect.width, rect.height); @@ -2256,8 +2256,8 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent) event.refPoint.x = nscoord(aEvent->x); event.refPoint.y = nscoord(aEvent->y); } else { - nsRect windowRect; - ScreenToWidget(nsRect(nscoord(aEvent->x_root), nscoord(aEvent->y_root), 1, 1), windowRect); + nsIntRect windowRect; + ScreenToWidget(nsIntRect(NSToIntFloor(aEvent->x_root), NSToIntFloor(aEvent->y_root), 1, 1), windowRect); event.refPoint.x = windowRect.x; event.refPoint.y = windowRect.y; @@ -2287,8 +2287,8 @@ nsWindow::InitButtonEvent(nsMouseEvent &aEvent, aEvent.refPoint.x = nscoord(aGdkEvent->x); aEvent.refPoint.y = nscoord(aGdkEvent->y); } else { - nsRect windowRect; - ScreenToWidget(nsRect(nscoord(aGdkEvent->x_root), nscoord(aGdkEvent->y_root), 1, 1), windowRect); + nsIntRect windowRect; + ScreenToWidget(nsIntRect(NSToIntFloor(aGdkEvent->x_root), NSToIntFloor(aGdkEvent->y_root), 1, 1), windowRect); aEvent.refPoint.x = windowRect.x; aEvent.refPoint.y = windowRect.y; @@ -2838,8 +2838,8 @@ nsWindow::OnScrollEvent(GtkWidget *aWidget, GdkEventScroll *aEvent) // XXX we're never quite sure which GdkWindow the event came from due to our custom bubbling // in scroll_event_cb(), so use ScreenToWidget to translate the screen root coordinates into // coordinates relative to this widget. - nsRect windowRect; - ScreenToWidget(nsRect(nscoord(aEvent->x_root), nscoord(aEvent->y_root), 1, 1), windowRect); + nsIntRect windowRect; + ScreenToWidget(nsIntRect(NSToIntFloor(aEvent->x_root), NSToIntFloor(aEvent->y_root), 1, 1), windowRect); event.refPoint.x = windowRect.x; event.refPoint.y = windowRect.y; @@ -3276,7 +3276,7 @@ GetBrandName(nsXPIDLString& brandName) nsresult nsWindow::NativeCreate(nsIWidget *aParent, nsNativeWidget aNativeParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -3897,10 +3897,10 @@ nsWindow::NativeShow (PRBool aAction) } } -nsSize -nsWindow::GetSafeWindowSize(nsSize aSize) +nsIntSize +nsWindow::GetSafeWindowSize(const nsIntSize &aSize) { - nsSize result = aSize; + nsIntSize result = aSize; const PRInt32 kInt16Max = 32767; if (result.width > kInt16Max) { NS_WARNING("Clamping huge window width"); @@ -4026,7 +4026,7 @@ nsWindow::ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight) static PRBool ChangedMaskBits(gchar* aMaskBits, PRInt32 aMaskWidth, PRInt32 aMaskHeight, - const nsRect& aRect, PRUint8* aAlphas, PRInt32 aStride) + const nsIntRect& aRect, PRUint8* aAlphas, PRInt32 aStride) { PRInt32 x, y, xMax = aRect.XMost(), yMax = aRect.YMost(); PRInt32 maskBytesPerRow = (aMaskWidth + 7)/8; @@ -4052,7 +4052,7 @@ ChangedMaskBits(gchar* aMaskBits, PRInt32 aMaskWidth, PRInt32 aMaskHeight, static void UpdateMaskBits(gchar* aMaskBits, PRInt32 aMaskWidth, PRInt32 aMaskHeight, - const nsRect& aRect, PRUint8* aAlphas, PRInt32 aStride) + const nsIntRect& aRect, PRUint8* aAlphas, PRInt32 aStride) { PRInt32 x, y, xMax = aRect.XMost(), yMax = aRect.YMost(); PRInt32 maskBytesPerRow = (aMaskWidth + 7)/8; @@ -4087,7 +4087,7 @@ nsWindow::ApplyTransparencyBitmap() } nsresult -nsWindow::UpdateTranslucentWindowAlphaInternal(const nsRect& aRect, +nsWindow::UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect, PRUint8* aAlphas, PRInt32 aStride) { if (!mShell) { @@ -5507,7 +5507,7 @@ void key_event_to_context_menu_event(nsMouseEvent &aEvent, GdkEventKey *aGdkEvent) { - aEvent.refPoint = nsPoint(0, 0); + aEvent.refPoint = nsIntPoint(0, 0); aEvent.isShift = PR_FALSE; aEvent.isControl = PR_FALSE; aEvent.isAlt = PR_FALSE; @@ -6576,7 +6576,7 @@ IM_get_input_context(nsWindow *aWindow) #ifdef MOZ_X11 /* static */ already_AddRefed nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, - const nsSize& aSize) + const nsIntSize& aSize) { GdkVisual* visual = gdk_drawable_get_visual(aDrawable); Display* xDisplay = gdk_x11_drawable_get_xdisplay(aDrawable); diff --git a/widget/src/gtk2/nsWindow.h b/widget/src/gtk2/nsWindow.h index 32773fc390ed..12363cf483b4 100644 --- a/widget/src/gtk2/nsWindow.h +++ b/widget/src/gtk2/nsWindow.h @@ -87,14 +87,14 @@ public: // nsIWidget NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, nsIToolkit *aToolkit, nsWidgetInitData *aInitData); NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -116,7 +116,7 @@ public: NS_IMETHOD SetSizeMode(PRInt32 aMode); NS_IMETHOD Enable(PRBool aState); NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE); - NS_IMETHOD GetScreenBounds(nsRect &aRect); + NS_IMETHOD GetScreenBounds(nsIntRect &aRect); NS_IMETHOD SetForegroundColor(const nscolor &aColor); NS_IMETHOD SetBackgroundColor(const nscolor &aColor); NS_IMETHOD SetCursor(nsCursor aCursor); @@ -124,20 +124,20 @@ public: PRUint32 aHotspotX, PRUint32 aHotspotY); NS_IMETHOD Validate(); NS_IMETHOD Invalidate(PRBool aIsSynchronous); - NS_IMETHOD Invalidate(const nsRect &aRect, - PRBool aIsSynchronous); + NS_IMETHOD Invalidate(const nsIntRect &aRect, + PRBool aIsSynchronous); NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous); NS_IMETHOD Update(); NS_IMETHOD SetColorMap(nsColorMap *aColorMap); - NS_IMETHOD Scroll(PRInt32 aDx, - PRInt32 aDy, - nsRect *aClipRect); + NS_IMETHOD Scroll(PRInt32 aDx, + PRInt32 aDy, + nsIntRect *aClipRect); NS_IMETHOD ScrollWidgets(PRInt32 aDx, PRInt32 aDy); - NS_IMETHOD ScrollRect(nsRect &aSrcRect, - PRInt32 aDx, - PRInt32 aDy); + NS_IMETHOD ScrollRect(nsIntRect &aSrcRect, + PRInt32 aDx, + PRInt32 aDy); virtual void* GetNativeData(PRUint32 aDataType); NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle); NS_IMETHOD SetTitle(const nsAString& aTitle); @@ -145,10 +145,10 @@ public: NS_IMETHOD SetWindowClass(const nsAString& xulWinType); NS_IMETHOD SetMenuBar(void * aMenuBar); NS_IMETHOD ShowMenuBar(PRBool aShow); - NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, - nsRect& aNewRect); - NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, - nsRect& aNewRect); + NS_IMETHOD WidgetToScreen(const nsIntRect& aOldRect, + nsIntRect& aNewRect); + NS_IMETHOD ScreenToWidget(const nsIntRect& aOldRect, + nsIntRect& aNewRect); NS_IMETHOD BeginResizingChildren(void); NS_IMETHOD EndResizingChildren(void); NS_IMETHOD EnableDragDrop(PRBool aEnable); @@ -230,7 +230,7 @@ public: nsresult NativeCreate(nsIWidget *aParent, nsNativeWidget aNativeParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -248,7 +248,7 @@ public: PRBool aRepaint); void NativeShow (PRBool aAction); - virtual nsSize GetSafeWindowSize(nsSize aSize); + virtual nsIntSize GetSafeWindowSize(const nsIntSize &aSize); void EnsureGrabs (void); void GrabPointer (void); @@ -368,13 +368,13 @@ public: void ApplyTransparencyBitmap(); virtual void SetTransparencyMode(nsTransparencyMode aMode); virtual nsTransparencyMode GetTransparencyMode(); - nsresult UpdateTranslucentWindowAlphaInternal(const nsRect& aRect, + nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect, PRUint8* aAlphas, PRInt32 aStride); gfxASurface *GetThebesSurface(); static already_AddRefed GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, - const nsSize& aSize); + const nsIntSize& aSize); #ifdef ACCESSIBILITY static PRBool sAccessibilityEnabled; diff --git a/widget/src/windows/nsDragService.cpp b/widget/src/windows/nsDragService.cpp index 4c589b6a5b98..37c0164d552b 100644 --- a/widget/src/windows/nsDragService.cpp +++ b/widget/src/windows/nsDragService.cpp @@ -109,7 +109,7 @@ nsDragService::CreateDragImage(nsIDOMNode *aDOMNode, return PR_FALSE; // Prepare the drag image - nsRect dragRect; + nsIntRect dragRect; nsRefPtr surface; nsPresContext* pc; DrawDrag(aDOMNode, aRegion, diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index d5ef57febaca..09cade67ced4 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -98,7 +98,7 @@ nsNativeThemeWin::~nsNativeThemeWin() { nsUXThemeData::Invalidate(); } -static void GetNativeRect(const nsRect& aSrc, RECT& aDst) +static void GetNativeRect(const nsIntRect& aSrc, RECT& aDst) { aDst.top = aSrc.y; aDst.bottom = aSrc.y + aSrc.height; @@ -1186,7 +1186,7 @@ NS_IMETHODIMP nsNativeThemeWin::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult) + nsIntMargin* aResult) { HANDLE theme = GetTheme(aWidgetType); if (!theme) @@ -1235,7 +1235,7 @@ nsNativeThemeWin::GetWidgetBorder(nsIDeviceContext* aContext, return NS_ERROR_FAILURE; // Now compute the delta in each direction and place it in our - // nsMargin struct. + // nsIntMargin struct. aResult->top = contentRect.top - outerRect.top; aResult->bottom = outerRect.bottom - contentRect.bottom; aResult->left = contentRect.left - outerRect.left; @@ -1268,7 +1268,7 @@ PRBool nsNativeThemeWin::GetWidgetPadding(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult) + nsIntMargin* aResult) { switch (aWidgetType) { // Radios and checkboxes return a fixed size in GetMinimumWidgetSize @@ -1414,7 +1414,7 @@ nsNativeThemeWin::GetWidgetOverflow(nsIDeviceContext* aContext, NS_IMETHODIMP nsNativeThemeWin::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, PRBool* aIsOverridable) + nsIntSize* aResult, PRBool* aIsOverridable) { (*aResult).width = (*aResult).height = 0; *aIsOverridable = PR_TRUE; @@ -1743,7 +1743,7 @@ nsresult nsNativeThemeWin::ClassicGetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult) + nsIntMargin* aResult) { switch (aWidgetType) { case NS_THEME_BUTTON: @@ -1822,7 +1822,7 @@ nsNativeThemeWin::ClassicGetWidgetBorder(nsIDeviceContext* aContext, nsresult nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, PRBool* aIsOverridable) + nsIntSize* aResult, PRBool* aIsOverridable) { (*aResult).width = (*aResult).height = 0; *aIsOverridable = PR_TRUE; diff --git a/widget/src/windows/nsNativeThemeWin.h b/widget/src/windows/nsNativeThemeWin.h index b0e7993af3ba..172e8bbd896d 100644 --- a/widget/src/windows/nsNativeThemeWin.h +++ b/widget/src/windows/nsNativeThemeWin.h @@ -43,6 +43,9 @@ #include "nsNativeTheme.h" #include +struct nsIntRect; +struct nsIntSize; + class nsNativeThemeWin : private nsNativeTheme, public nsITheme { public: @@ -58,12 +61,12 @@ public: NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult); + nsIntMargin* aResult); virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult); + nsIntMargin* aResult); virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext, nsIFrame* aFrame, @@ -72,7 +75,7 @@ public: NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, + nsIntSize* aResult, PRBool* aIsOverridable); NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, @@ -107,11 +110,11 @@ protected: nsresult ClassicGetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsMargin* aResult); + nsIntMargin* aResult); nsresult ClassicGetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, - nsSize* aResult, + nsIntSize* aResult, PRBool* aIsOverridable); PRBool ClassicThemeSupportsWidget(nsPresContext* aPresContext, diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 41c867a9eca6..c9219b4aec09 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -820,7 +820,7 @@ NS_METHOD nsWindow::EndResizingChildren(void) return NS_OK; } -NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) +NS_METHOD nsWindow::WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect) { POINT point; point.x = aOldRect.x; @@ -833,7 +833,7 @@ NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) return NS_OK; } -NS_METHOD nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) +NS_METHOD nsWindow::ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect) { POINT point; point.x = aOldRect.x; @@ -869,10 +869,10 @@ LPARAM nsWindow::lParamToClient(LPARAM lParam) // Initialize an event to dispatch // //------------------------------------------------------------------------- -void nsWindow::InitEvent(nsGUIEvent& event, nsPoint* aPoint) +void nsWindow::InitEvent(nsGUIEvent& event, nsIntPoint* aPoint) { if (nsnull == aPoint) { // use the point from the event - // get the message position in client coordinates and in twips + // get the message position in client coordinates if (mWnd != NULL) { DWORD pos = ::GetMessagePos(); @@ -1199,7 +1199,7 @@ LRESULT CALLBACK nsWindow::DefaultWindowProc(HWND hWnd, UINT msg, WPARAM wParam, nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -1363,7 +1363,7 @@ nsWindow::StandardWindowCreate(nsIWidget *aParent, // //------------------------------------------------------------------------- NS_METHOD nsWindow::Create(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -1385,7 +1385,7 @@ NS_METHOD nsWindow::Create(nsIWidget *aParent, //------------------------------------------------------------------------- NS_METHOD nsWindow::Create(nsNativeWidget aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -2131,7 +2131,7 @@ NS_METHOD nsWindow::SetFocus(PRBool aRaise) // Get this component dimension // //------------------------------------------------------------------------- -NS_METHOD nsWindow::GetBounds(nsRect &aRect) +NS_METHOD nsWindow::GetBounds(nsIntRect &aRect) { if (mWnd) { RECT r; @@ -2163,7 +2163,7 @@ NS_METHOD nsWindow::GetBounds(nsRect &aRect) // Get this component dimension // //------------------------------------------------------------------------- -NS_METHOD nsWindow::GetClientBounds(nsRect &aRect) +NS_METHOD nsWindow::GetClientBounds(nsIntRect &aRect) { if (mWnd) { RECT r; @@ -2183,7 +2183,7 @@ NS_METHOD nsWindow::GetClientBounds(nsRect &aRect) //get the bounds, but don't take into account the client size -void nsWindow::GetNonClientBounds(nsRect &aRect) +void nsWindow::GetNonClientBounds(nsIntRect &aRect) { if (mWnd) { RECT r; @@ -2209,7 +2209,7 @@ void nsWindow::GetNonClientBounds(nsRect &aRect) } // like GetBounds, but don't offset by the parent -NS_METHOD nsWindow::GetScreenBounds(nsRect &aRect) +NS_METHOD nsWindow::GetScreenBounds(nsIntRect &aRect) { if (mWnd) { RECT r; @@ -2682,7 +2682,7 @@ NS_METHOD nsWindow::Invalidate(PRBool aIsSynchronous) // Invalidate this component visible area // //------------------------------------------------------------------------- -NS_METHOD nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) +NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous) { if (mWnd) { @@ -2860,7 +2860,7 @@ BOOL CALLBACK nsWindow::InvalidateForeignChildWindows(HWND aWnd, LPARAM aMsg) // //------------------------------------------------------------------------- //XXX Scroll is obsolete and should go away soon -NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) +NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect) { RECT trect; @@ -2891,7 +2891,7 @@ NS_IMETHODIMP nsWindow::ScrollWidgets(PRInt32 aDx, PRInt32 aDy) return NS_OK; } -NS_IMETHODIMP nsWindow::ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy) +NS_IMETHODIMP nsWindow::ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy) { RECT trect; @@ -2923,7 +2923,7 @@ BOOL nsWindow::CallMethod(MethodInfo *info) case nsWindow::CREATE: NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod"); Create((nsIWidget*)(info->args[0]), - (nsRect&)*(nsRect*)(info->args[1]), + (nsIntRect&)*(nsIntRect*)(info->args[1]), (EVENT_CALLBACK)(info->args[2]), (nsIDeviceContext*)(info->args[3]), (nsIAppShell *)(info->args[4]), @@ -2934,7 +2934,7 @@ BOOL nsWindow::CallMethod(MethodInfo *info) case nsWindow::CREATE_NATIVE: NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod"); Create((nsNativeWidget)(info->args[0]), - (nsRect&)*(nsRect*)(info->args[1]), + (nsIntRect&)*(nsIntRect*)(info->args[1]), (EVENT_CALLBACK)(info->args[2]), (nsIDeviceContext*)(info->args[3]), (nsIAppShell *)(info->args[4]), @@ -3021,7 +3021,7 @@ PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode, LPARAM aKeyData, PRUint32 aFlags) { nsKeyEvent event(PR_TRUE, aEventType, this); - nsPoint point(0, 0); + nsIntPoint point(0, 0); InitEvent(event, &point); // this add ref's event.widget @@ -4134,7 +4134,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT WORD wNotifyCode = HIWORD(wParam); // notification code if ((CBN_SELENDOK == wNotifyCode) || (CBN_SELENDCANCEL == wNotifyCode)) { // Combo box change nsGUIEvent event(PR_TRUE, NS_CONTROL_CHANGE, this); - nsPoint point(0,0); + nsIntPoint point(0,0); InitEvent(event, &point); // this add ref's event.widget result = DispatchWindowEvent(&event); } else if (wNotifyCode == 0) { // Menu selection @@ -4855,7 +4855,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT PRInt32 newWidth, newHeight; newWidth = PRInt32(r.right - r.left); newHeight = PRInt32(r.bottom - r.top); - nsRect rect(wp->x, wp->y, newWidth, newHeight); + nsIntRect rect(wp->x, wp->y, newWidth, newHeight); #ifdef MOZ_XUL @@ -5764,7 +5764,6 @@ ConvertHRGNToRegion(HRGN aRgn) //------------------------------------------------------------------------- PRBool nsWindow::OnPaint(HDC aDC) { - nsRect bounds; PRBool result = PR_TRUE; PAINTSTRUCT ps; nsEventStatus eventStatus = nsEventStatus_eIgnore; @@ -5948,7 +5947,7 @@ PRBool nsWindow::OnPaint(HDC aDC) // Send a resize message to the listener // //------------------------------------------------------------------------- -PRBool nsWindow::OnResize(nsRect &aWindowRect) +PRBool nsWindow::OnResize(nsIntRect &aWindowRect) { // call the event callback if (mEventCallback) { @@ -6002,7 +6001,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, return result; } - nsPoint eventPoint; + nsIntPoint eventPoint; eventPoint.x = GET_X_LPARAM(lParam); eventPoint.y = GET_Y_LPARAM(lParam); @@ -6011,7 +6010,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, ? nsMouseEvent::eContextMenuKey : nsMouseEvent::eNormal); if (aEventType == NS_CONTEXTMENU && aIsContextMenuKey) { - nsPoint zero(0, 0); + nsIntPoint zero(0, 0); InitEvent(event, &zero); } else { InitEvent(event, &eventPoint); @@ -6023,8 +6022,8 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, event.isAlt = IS_VK_DOWN(NS_VK_ALT); event.button = aButton; - nsRect mpWidget; - nsRect mpScreen; + nsIntRect mpWidget; + nsIntRect mpScreen; mpWidget.x = eventPoint.x; mpWidget.y = eventPoint.y; WidgetToScreen(mpWidget, mpScreen); @@ -6171,7 +6170,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, if (nsToolkit::gMouseTrailer && !mIsInMouseCapture) { nsToolkit::gMouseTrailer->SetMouseTrailerWindow(mWnd); } - nsRect rect; + nsIntRect rect; GetBounds(rect); rect.x = 0; rect.y = 0; @@ -6215,7 +6214,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, // //------------------------------------------------------------------------- #ifdef ACCESSIBILITY -PRBool nsWindow::DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAcc, nsPoint* aPoint) +PRBool nsWindow::DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAcc, nsIntPoint* aPoint) { PRBool result = PR_FALSE; @@ -6459,7 +6458,7 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr) return; nsTextEvent event(PR_TRUE, NS_TEXT_TEXT, this); - nsPoint point(0, 0); + nsIntPoint point(0, 0); InitEvent(event, &point); @@ -6486,7 +6485,7 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr) // if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height) { - nsRect cursorPosition; + nsIntRect cursorPosition; ResolveIMECaretPos(event.theReply.mReferenceWidget, event.theReply.mCursorPosition, this, cursorPosition); @@ -6552,7 +6551,7 @@ nsWindow::HandleStartComposition(HIMC hIMEContext) return PR_TRUE; nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_START, this); - nsPoint point(0, 0); + nsIntPoint point(0, 0); CANDIDATEFORM candForm; InitEvent(event, &point); @@ -6563,7 +6562,7 @@ nsWindow::HandleStartComposition(HIMC hIMEContext) // if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height) { - nsRect cursorPosition; + nsIntRect cursorPosition; ResolveIMECaretPos(event.theReply.mReferenceWidget, event.theReply.mCursorPosition, this, cursorPosition); @@ -6615,7 +6614,7 @@ nsWindow::HandleEndComposition(void) return; nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_END, this); - nsPoint point(0, 0); + nsIntPoint point(0, 0); if (gPinYinIMECaretCreated) { @@ -7090,7 +7089,7 @@ PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult) RECONVERTSTRING* pReconv = (RECONVERTSTRING*) aData; nsQueryContentEvent selection(PR_TRUE, NS_QUERY_SELECTED_TEXT, this); - nsPoint point(0, 0); + nsIntPoint point(0, 0); InitEvent(selection, &point); DispatchWindowEvent(&selection); if (!selection.mSucceeded) @@ -7146,7 +7145,7 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult) pCharPosition->dwCharPos > len) return PR_FALSE; - nsPoint point(0, 0); + nsIntPoint point(0, 0); nsQueryContentEvent selection(PR_TRUE, NS_QUERY_SELECTED_TEXT, this); InitEvent(selection, &point); @@ -7157,7 +7156,7 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult) PRUint32 offset = selection.mReply.mOffset + pCharPosition->dwCharPos; PRBool useCaretRect = selection.mReply.mString.IsEmpty(); - nsRect r; + nsIntRect r; if (!useCaretRect) { nsQueryContentEvent charRect(PR_TRUE, NS_QUERY_CHARACTER_RECT, this); charRect.InitForQueryCharacterRect(offset); @@ -7179,7 +7178,7 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult) r = caretRect.mReply.mRect; } - nsRect screenRect; + nsIntRect screenRect; // We always need top level window that is owner window of the popup window // even if the content of the popup window has focus. ResolveIMECaretPos(GetTopLevelWindow(PR_FALSE), r, nsnull, screenRect); @@ -7198,9 +7197,9 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult) //========================================================================== void nsWindow::ResolveIMECaretPos(nsIWidget* aReferenceWidget, - nsRect& aCursorRect, + nsIntRect& aCursorRect, nsIWidget* aNewOriginWidget, - nsRect& aOutRect) + nsIntRect& aOutRect) { aOutRect = aCursorRect; diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index 044825194dec..776feb3afa31 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -129,14 +129,14 @@ public: // nsIWidget interface NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, nsIToolkit *aToolkit = nsnull, nsWidgetInitData *aInitData = nsnull); NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell = nsnull, @@ -147,7 +147,7 @@ public: // Create(nsNativeWidget...) virtual nsresult StandardWindowCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -171,9 +171,9 @@ public: NS_IMETHOD Enable(PRBool aState); NS_IMETHOD IsEnabled(PRBool *aState); NS_IMETHOD SetFocus(PRBool aRaise); - NS_IMETHOD GetBounds(nsRect &aRect); - NS_IMETHOD GetClientBounds(nsRect &aRect); - NS_IMETHOD GetScreenBounds(nsRect &aRect); + NS_IMETHOD GetBounds(nsIntRect &aRect); + NS_IMETHOD GetClientBounds(nsIntRect &aRect); + NS_IMETHOD GetScreenBounds(nsIntRect &aRect); NS_IMETHOD SetBackgroundColor(const nscolor &aColor); NS_IMETHOD SetCursor(nsCursor aCursor); NS_IMETHOD SetCursor(imgIContainer* aCursor, @@ -181,22 +181,22 @@ public: NS_IMETHOD HideWindowChrome(PRBool aShouldHide); NS_IMETHOD Validate(); NS_IMETHOD Invalidate(PRBool aIsSynchronous); - NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous); + NS_IMETHOD Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous); NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous); NS_IMETHOD Update(); virtual void* GetNativeData(PRUint32 aDataType); virtual void FreeNativeData(void * data, PRUint32 aDataType);//~~~ NS_IMETHOD SetColorMap(nsColorMap *aColorMap); //XXX-Scroll is obsolete it is going away soon - NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect); + NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect); NS_IMETHOD ScrollWidgets(PRInt32 aDx, PRInt32 aDy); - NS_IMETHOD ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy); + NS_IMETHOD ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy); NS_IMETHOD SetTitle(const nsAString& aTitle); NS_IMETHOD SetIcon(const nsAString& aIconSpec); NS_IMETHOD SetMenuBar(void * aMenuBar) { return NS_ERROR_FAILURE; } NS_IMETHOD ShowMenuBar(PRBool aShow) { return NS_ERROR_FAILURE; } - NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect); - NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect); + NS_IMETHOD WidgetToScreen(const nsIntRect& aOldRect, nsIntRect& aNewRect); + NS_IMETHOD ScreenToWidget(const nsIntRect& aOldRect, nsIntRect& aNewRect); NS_IMETHOD BeginResizingChildren(void); NS_IMETHOD EndResizingChildren(void); NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight); @@ -256,15 +256,15 @@ public: PRBool aIsContextMenuKey = PR_FALSE, PRInt16 aButton = nsMouseEvent::eLeftButton); #ifdef ACCESSIBILITY - virtual PRBool DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAccessible, nsPoint* aPoint = nsnull); + virtual PRBool DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAccessible, nsIntPoint* aPoint = nsnull); already_AddRefed GetRootAccessible(); #endif virtual PRBool AutoErase(); - nsPoint* GetLastPoint() { return &mLastPoint; } + nsIntPoint* GetLastPoint() { return &mLastPoint; } PRInt32 GetNewCmdMenuId() { mMenuCmdId++; return mMenuCmdId; } - void InitEvent(nsGUIEvent& event, nsPoint* aPoint = nsnull); + void InitEvent(nsGUIEvent& event, nsIntPoint* aPoint = nsnull); void SuppressBlurEvents(PRBool aSuppress); PRBool BlurEventsSuppressed(); @@ -314,7 +314,7 @@ protected: virtual void OnDestroy(); virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnPaint(HDC aDC = nsnull); - virtual PRBool OnResize(nsRect &aWindowRect); + virtual PRBool OnResize(nsIntRect &aWindowRect); void SetupModKeyState(); BOOL OnChar(UINT charCode, UINT aScanCode, PRUint32 aFlags = 0); @@ -355,9 +355,9 @@ protected: * @param aOutRect The converted cursor rect. */ void ResolveIMECaretPos(nsIWidget* aReferenceWidget, - nsRect& aCursorRect, + nsIntRect& aCursorRect, nsIWidget* aNewOriginWidget, - nsRect& aOutRect); + nsIntRect& aOutRect); virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, const nsTArray* aAlternativeChars, @@ -379,7 +379,7 @@ protected: PRBool DispatchCommandEvent(PRUint32 aEventCommand); void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam); - void GetNonClientBounds(nsRect &aRect); + void GetNonClientBounds(nsIntRect &aRect); void HandleTextEvent(HIMC hIMEContext, PRBool aCheckAttr=PR_TRUE); BOOL HandleStartComposition(HIMC hIMEContext); void HandleEndComposition(void); @@ -429,9 +429,9 @@ protected: static TriStateBool sCanQuit; - nsSize mLastSize; + nsIntSize mLastSize; static nsWindow* gCurrentWindow; - nsPoint mLastPoint; + nsIntPoint mLastPoint; HWND mWnd; HDC mPaintDC; // only set during painting #if 0 diff --git a/widget/src/xpwidgets/nsBaseDragService.cpp b/widget/src/xpwidgets/nsBaseDragService.cpp index 889cc32d410c..be17402a7100 100644 --- a/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/widget/src/xpwidgets/nsBaseDragService.cpp @@ -401,7 +401,7 @@ nsresult nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, nsIScriptableRegion* aRegion, PRInt32 aScreenX, PRInt32 aScreenY, - nsRect* aScreenDragRect, + nsIntRect* aScreenDragRect, gfxASurface** aSurface, nsPresContext** aPresContext) { @@ -441,10 +441,11 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, // the region's coordinates are relative to the root frame nsIFrame* rootFrame = presShell->GetRootFrame(); if (rootFrame && *aPresContext) { - nsRect dragRect; + nsIntRect dragRect; aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height); - dragRect.ScaleRoundOut(nsPresContext::AppUnitsPerCSSPixel()); - dragRect.ScaleRoundOut(1.0 / (*aPresContext)->AppUnitsPerDevPixel()); + dragRect = nsRect::ToOutsidePixels(nsIntRect::ToAppUnits(dragRect, + nsPresContext::AppUnitsPerCSSPixel()), + (*aPresContext)->AppUnitsPerDevPixel()); nsIntRect screenRect = rootFrame->GetScreenRectExternal(); aScreenDragRect->SetRect(screenRect.x + dragRect.x, screenRect.y + dragRect.y, @@ -468,7 +469,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, // draw the image for selections if (mSelection) { - nsPoint pnt(aScreenDragRect->x, aScreenDragRect->y); + nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y); nsRefPtr surface = presShell->RenderSelection(mSelection, pnt, aScreenDragRect); *aSurface = surface; NS_IF_ADDREF(*aSurface); @@ -498,7 +499,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, if (aRegion) aRegion->GetRegion(getter_AddRefs(clipRegion)); - nsPoint pnt(aScreenDragRect->x, aScreenDragRect->y); + nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y); nsRefPtr surface = presShell->RenderNode(dragNode, clipRegion, pnt, aScreenDragRect); @@ -520,7 +521,7 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext, nsIImageLoadingContent* aImageLoader, nsICanvasElement* aCanvas, PRInt32 aScreenX, PRInt32 aScreenY, - nsRect* aScreenDragRect, + nsIntRect* aScreenDragRect, gfxASurface** aSurface) { nsCOMPtr img; @@ -559,9 +560,9 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext, aScreenDragRect->height = height; } - nsRect srcRect = *aScreenDragRect; + nsIntRect srcRect = *aScreenDragRect; srcRect.MoveTo(0, 0); - nsRect destRect = srcRect; + nsIntRect destRect = srcRect; if (destRect.width == 0 || destRect.height == 0) return NS_ERROR_FAILURE; diff --git a/widget/src/xpwidgets/nsBaseDragService.h b/widget/src/xpwidgets/nsBaseDragService.h index 442be9ef5b55..f17e06550409 100644 --- a/widget/src/xpwidgets/nsBaseDragService.h +++ b/widget/src/xpwidgets/nsBaseDragService.h @@ -103,7 +103,7 @@ protected: nsresult DrawDrag(nsIDOMNode* aDOMNode, nsIScriptableRegion* aRegion, PRInt32 aScreenX, PRInt32 aScreenY, - nsRect* aScreenDragRect, + nsIntRect* aScreenDragRect, gfxASurface** aSurface, nsPresContext **aPresContext); @@ -115,7 +115,7 @@ protected: nsIImageLoadingContent* aImageLoader, nsICanvasElement* aCanvas, PRInt32 aScreenX, PRInt32 aScreenY, - nsRect* aScreenDragRect, + nsIntRect* aScreenDragRect, gfxASurface** aSurface); /** diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 01a46159cb97..2657d818058f 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -145,7 +145,7 @@ nsBaseWidget::~nsBaseWidget() // //------------------------------------------------------------------------- void nsBaseWidget::BaseCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -591,7 +591,7 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen) if (aFullScreen) { if (!mOriginalBounds) - mOriginalBounds = new nsRect(); + mOriginalBounds = new nsIntRect(); GetScreenBounds(*mOriginalBounds); // Move to top-left corner of screen and size to the screen dimensions @@ -739,7 +739,7 @@ NS_METHOD nsBaseWidget::AddEventListener(nsIEventListener * aListener) * If the implementation of nsWindow supports borders this method MUST be overridden * **/ -NS_METHOD nsBaseWidget::GetClientBounds(nsRect &aRect) +NS_METHOD nsBaseWidget::GetClientBounds(nsIntRect &aRect) { return GetBounds(aRect); } @@ -748,7 +748,7 @@ NS_METHOD nsBaseWidget::GetClientBounds(nsRect &aRect) * If the implementation of nsWindow supports borders this method MUST be overridden * **/ -NS_METHOD nsBaseWidget::GetBounds(nsRect &aRect) +NS_METHOD nsBaseWidget::GetBounds(nsIntRect &aRect) { aRect = mBounds; return NS_OK; @@ -759,7 +759,7 @@ NS_METHOD nsBaseWidget::GetBounds(nsRect &aRect) * this method must be overridden * **/ -NS_METHOD nsBaseWidget::GetScreenBounds(nsRect &aRect) +NS_METHOD nsBaseWidget::GetScreenBounds(nsIntRect &aRect) { return GetBounds(aRect); } @@ -768,7 +768,7 @@ NS_METHOD nsBaseWidget::GetScreenBounds(nsRect &aRect) * * **/ -NS_METHOD nsBaseWidget::SetBounds(const nsRect &aRect) +NS_METHOD nsBaseWidget::SetBounds(const nsIntRect &aRect) { mBounds = aRect; @@ -783,8 +783,8 @@ NS_METHOD nsBaseWidget::SetBounds(const nsRect &aRect) **/ NS_METHOD nsBaseWidget::GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight) { - nsRect rectWin; - nsRect rect; + nsIntRect rectWin; + nsIntRect rect; GetBounds(rectWin); GetClientBounds(rect); @@ -799,7 +799,7 @@ NS_IMETHODIMP nsBaseWidget::ScrollWidgets(PRInt32 aDx, PRInt32 aDy) return NS_ERROR_FAILURE; } -NS_IMETHODIMP nsBaseWidget::ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy) +NS_IMETHODIMP nsBaseWidget::ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy) { return NS_ERROR_FAILURE; } @@ -1250,7 +1250,7 @@ nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut, /* static */ void nsBaseWidget::debug_DumpInvalidate(FILE * aFileOut, nsIWidget * aWidget, - const nsRect * aRect, + const nsIntRect * aRect, PRBool aIsSynchronous, const nsCAutoString & aWidgetName, PRInt32 aWindowID) diff --git a/widget/src/xpwidgets/nsBaseWidget.h b/widget/src/xpwidgets/nsBaseWidget.h index e15d1b9fd55c..b4d2b035dd3a 100644 --- a/widget/src/xpwidgets/nsBaseWidget.h +++ b/widget/src/xpwidgets/nsBaseWidget.h @@ -118,12 +118,12 @@ public: NS_IMETHOD SetWindowClass(const nsAString& xulWinType); NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle); NS_IMETHOD AddEventListener(nsIEventListener * aListener); - NS_IMETHOD SetBounds(const nsRect &aRect); - NS_IMETHOD GetBounds(nsRect &aRect); - NS_IMETHOD GetClientBounds(nsRect &aRect); - NS_IMETHOD GetScreenBounds(nsRect &aRect); + NS_IMETHOD SetBounds(const nsIntRect &aRect); + NS_IMETHOD GetBounds(nsIntRect &aRect); + NS_IMETHOD GetClientBounds(nsIntRect &aRect); + NS_IMETHOD GetScreenBounds(nsIntRect &aRect); NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight); - NS_IMETHOD ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy); + NS_IMETHOD ScrollRect(nsIntRect &aRect, PRInt32 aDx, PRInt32 aDy); NS_IMETHOD ScrollWidgets(PRInt32 aDx, PRInt32 aDy); NS_IMETHOD EnableDragDrop(PRBool aEnable); NS_IMETHOD GetAttention(PRInt32 aCycleCount); @@ -153,7 +153,7 @@ protected: nsILocalFile **aResult); virtual void OnDestroy(); virtual void BaseCreate(nsIWidget *aParent, - const nsRect &aRect, + const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, @@ -188,8 +188,8 @@ protected: PRPackedBool mIsAltDown; PRPackedBool mIsDestroying; PRPackedBool mOnDestroyCalled; - nsRect mBounds; - nsRect* mOriginalBounds; + nsIntRect mBounds; + nsIntRect* mOriginalBounds; PRInt32 mZIndex; nsSizeMode mSizeMode; @@ -216,7 +216,7 @@ protected: static void debug_DumpInvalidate(FILE * aFileOut, nsIWidget * aWidget, - const nsRect * aRect, + const nsIntRect * aRect, PRBool aIsSynchronous, const nsCAutoString & aWidgetName, PRInt32 aWindowID); diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp index ec1626f8396c..31f4a7fe868e 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp @@ -38,7 +38,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsPrintOptionsImpl.h" -#include "nsCoord.h" #include "nsReadableUtils.h" #include "nsPrintSettingsImpl.h" @@ -252,9 +251,8 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, NS_ENSURE_ARG_POINTER(aPS); if (aFlags & nsIPrintSettings::kInitSaveMargins) { - nscoord halfInch = NS_INCHES_TO_TWIPS(0.5); - nsMargin margin; - margin.SizeTo(halfInch, halfInch, halfInch, halfInch); + PRInt32 halfInch = NS_INCHES_TO_TWIPS(0.5); + nsIntMargin margin(halfInch, halfInch, halfInch, halfInch); ReadInchesToTwipsPref(GetPrefName(kMarginTop, aPrinterName), margin.top, kMarginTop); DUMP_INT(kReadStr, kMarginTop, margin.top); @@ -271,8 +269,7 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, } if (aFlags & nsIPrintSettings::kInitSaveEdges) { - nsMargin margin; - margin.SizeTo(0,0,0,0); + nsIntMargin margin(0,0,0,0); ReadInchesIntToTwipsPref(GetPrefName(kEdgeTop, aPrinterName), margin.top, kEdgeTop); DUMP_INT(kReadStr, kEdgeTop, margin.top); @@ -289,8 +286,7 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, } if (aFlags & nsIPrintSettings::kInitSaveUnwriteableMargins) { - nsMargin margin; - margin.SizeTo(0,0,0,0); + nsIntMargin margin; ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginTop, aPrinterName), margin.top, kUnwriteableMarginTop); DUMP_INT(kReadStr, kUnwriteableMarginTop, margin.top); @@ -558,7 +554,7 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, NS_ENSURE_ARG_POINTER(aPS); NS_ENSURE_STATE(mPrefBranch); - nsMargin margin; + nsIntMargin margin; if (aFlags & nsIPrintSettings::kInitSaveMargins) { if (NS_SUCCEEDED(aPS->GetMarginInTwips(margin))) { WriteInchesFromTwipsPref(GetPrefName(kMarginTop, aPrinterName), @@ -576,7 +572,7 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, } } - nsMargin edge; + nsIntMargin edge; if (aFlags & nsIPrintSettings::kInitSaveEdges) { if (NS_SUCCEEDED(aPS->GetEdgeInTwips(edge))) { WriteInchesIntFromTwipsPref(GetPrefName(kEdgeTop, aPrinterName), @@ -594,7 +590,7 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, } } - nsMargin unwriteableMargin; + nsIntMargin unwriteableMargin; if (aFlags & nsIPrintSettings::kInitSaveUnwriteableMargins) { if (NS_SUCCEEDED(aPS->GetUnwriteableMarginInTwips(unwriteableMargin))) { WriteInchesIntFromTwipsPref(GetPrefName(kUnwriteableMarginTop, aPrinterName), @@ -1170,7 +1166,7 @@ nsPrintOptions::WritePrefDouble(const char * aPrefId, double aVal) } void -nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, nscoord& aTwips, +nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, PRInt32& aTwips, const char * aMarginPref) { if (!mPrefBranch) { @@ -1196,7 +1192,7 @@ nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, nscoord& aTwips, } void -nsPrintOptions::WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips) +nsPrintOptions::WriteInchesFromTwipsPref(const char * aPrefId, PRInt32 aTwips) { if (!mPrefBranch) { return; @@ -1210,7 +1206,7 @@ nsPrintOptions::WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips) } void -nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, nscoord& aTwips, +nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, PRInt32& aTwips, const char * aMarginPref) { if (!mPrefBranch) { @@ -1230,7 +1226,7 @@ nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, nscoord& aTwips, } void -nsPrintOptions::WriteInchesIntFromTwipsPref(const char * aPrefId, nscoord aTwips) +nsPrintOptions::WriteInchesIntFromTwipsPref(const char * aPrefId, PRInt32 aTwips) { if (!mPrefBranch) { return; diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.h b/widget/src/xpwidgets/nsPrintOptionsImpl.h index 15c07367a581..53e01e5c288a 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.h +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.h @@ -76,12 +76,12 @@ protected: void ReadJustification(const char * aPrefId, PRInt16& aJust, PRInt16 aInitValue); void WriteJustification(const char * aPrefId, PRInt16 aJust); - void ReadInchesToTwipsPref(const char * aPrefId, nscoord& aTwips, + void ReadInchesToTwipsPref(const char * aPrefId, PRInt32& aTwips, const char * aMarginPref); - void WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips); - void ReadInchesIntToTwipsPref(const char * aPrefId, nscoord& aTwips, + void WriteInchesFromTwipsPref(const char * aPrefId, PRInt32 aTwips); + void ReadInchesIntToTwipsPref(const char * aPrefId, PRInt32& aTwips, const char * aMarginPref); - void WriteInchesIntFromTwipsPref(const char * aPrefId, nscoord aTwips); + void WriteInchesIntFromTwipsPref(const char * aPrefId, PRInt32 aTwips); nsresult ReadPrefString(const char * aPrefId, nsAString& aString); /** diff --git a/widget/src/xpwidgets/nsPrintSettingsImpl.cpp b/widget/src/xpwidgets/nsPrintSettingsImpl.cpp index 5487d5a1cc34..8bb6288d9324 100644 --- a/widget/src/xpwidgets/nsPrintSettingsImpl.cpp +++ b/widget/src/xpwidgets/nsPrintSettingsImpl.cpp @@ -36,7 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsPrintSettingsImpl.h" -#include "nsCoord.h" #include "nsReadableUtils.h" #include "nsIPrintSession.h" @@ -82,7 +81,7 @@ nsPrintSettings::nsPrintSettings() : { /* member initializers and constructor code */ - nscoord marginWidth = NS_INCHES_TO_TWIPS(DEFAULT_MARGIN_WIDTH); + PRInt32 marginWidth = NS_INCHES_TO_TWIPS(DEFAULT_MARGIN_WIDTH); mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth); mEdge.SizeTo(0, 0, 0, 0); mUnwriteableMargin.SizeTo(0,0,0,0); @@ -1004,14 +1003,14 @@ NS_IMETHODIMP nsPrintSettings::SetPaperData(PRInt16 aPaperData) * @update 1/12/01 rods */ NS_IMETHODIMP -nsPrintSettings::SetMarginInTwips(nsMargin& aMargin) +nsPrintSettings::SetMarginInTwips(nsIntMargin& aMargin) { mMargin = aMargin; return NS_OK; } NS_IMETHODIMP -nsPrintSettings::SetEdgeInTwips(nsMargin& aEdge) +nsPrintSettings::SetEdgeInTwips(nsIntMargin& aEdge) { mEdge = aEdge; return NS_OK; @@ -1021,7 +1020,7 @@ nsPrintSettings::SetEdgeInTwips(nsMargin& aEdge) // to check for negative margin values in aUnwriteableMargin (which // would indicate that we should use the system default unwriteable margin.) NS_IMETHODIMP -nsPrintSettings::SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin) +nsPrintSettings::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) { if (aUnwriteableMargin.top >= 0) { mUnwriteableMargin.top = aUnwriteableMargin.top; @@ -1043,21 +1042,21 @@ nsPrintSettings::SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin) * @update 6/21/00 dwc */ NS_IMETHODIMP -nsPrintSettings::GetMarginInTwips(nsMargin& aMargin) +nsPrintSettings::GetMarginInTwips(nsIntMargin& aMargin) { aMargin = mMargin; return NS_OK; } NS_IMETHODIMP -nsPrintSettings::GetEdgeInTwips(nsMargin& aEdge) +nsPrintSettings::GetEdgeInTwips(nsIntMargin& aEdge) { aEdge = mEdge; return NS_OK; } NS_IMETHODIMP -nsPrintSettings::GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin) +nsPrintSettings::GetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) { aUnwriteableMargin = mUnwriteableMargin; return NS_OK; diff --git a/widget/src/xpwidgets/nsPrintSettingsImpl.h b/widget/src/xpwidgets/nsPrintSettingsImpl.h index ed9805a0d1d6..4cbce17d2e4f 100644 --- a/widget/src/xpwidgets/nsPrintSettingsImpl.h +++ b/widget/src/xpwidgets/nsPrintSettingsImpl.h @@ -82,9 +82,9 @@ protected: nsWeakPtr mSession; // Should never be touched by Clone or Assign // mMargin, mEdge, and mUnwriteableMargin are stored in twips - nsMargin mMargin; - nsMargin mEdge; - nsMargin mUnwriteableMargin; + nsIntMargin mMargin; + nsIntMargin mEdge; + nsIntMargin mUnwriteableMargin; PRInt32 mPrintOptions; diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index b3243a3db4b8..ccb5267b7fcd 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -182,7 +182,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent, // XXX: need to get the default window size from prefs... // Doesn't come from prefs... will come from CSS/XUL/RDF - nsRect r(0, 0, aInitialWidth, aInitialHeight); + nsIntRect r(0, 0, aInitialWidth, aInitialHeight); // Create top level window mWindow = do_CreateInstance(kWindowCID, &rv); diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index a5351ac0a7fd..d602e5762fda 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -616,7 +616,7 @@ NS_IMETHODIMP nsXULWindow::SetPositionAndSize(PRInt32 aX, PRInt32 aY, NS_IMETHODIMP nsXULWindow::GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx, PRInt32* cy) { - nsRect rect; + nsIntRect rect; if (!mWindow) return NS_ERROR_FAILURE;