Bug 448830. Make nsIntRect/nsIntMargin/nsIntSize/nsIntPoint different types from nsRect/nsMargin/nsSize/nsPoint different types for better compile-type unit checking. r+sr=roc

--HG--
extra : rebase_source : a331a9e49fbc5931f546919281fcca7f008ab615
This commit is contained in:
Jeremy Lea 2009-01-15 16:27:09 +13:00
parent 925938f029
commit ce80f69254
130 changed files with 970 additions and 920 deletions

View File

@ -1337,7 +1337,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;

View File

@ -290,10 +290,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);
@ -322,28 +322,27 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
nsCOMPtr<nsISelection> 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);

View File

@ -119,7 +119,7 @@ public:
*/
nsresult RemoveDocSelectionListener(nsIPresShell *aShell);
nsRect GetCaretRect(nsIWidget **aOutWidget);
nsIntRect GetCaretRect(nsIWidget **aOutWidget);
protected:
nsresult NormalSelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel);

View File

@ -140,7 +140,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);

View File

@ -291,13 +291,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

View File

@ -1916,7 +1916,7 @@ void nsAccessibleWrap::UpdateSystemCaret()
}
nsIWidget *widget;
nsRect caretRect = caretAccessible->GetCaretRect(&widget);
nsIntRect caretRect = caretAccessible->GetCaretRect(&widget);
HWND caretWnd;
if (caretRect.IsEmpty() || !(caretWnd = (HWND)widget->GetNativeData(NS_NATIVE_WINDOW))) {
return;

View File

@ -127,9 +127,9 @@ __try {
accessible->GetBounds(&docX, &docY, &docWidth, &docHeight);
nsRect unclippedRect(x, y, width, height);
nsRect docRect(docX, docY, docWidth, docHeight);
nsRect clippedRect;
nsIntRect unclippedRect(x, y, width, height);
nsIntRect docRect(docX, docY, docWidth, docHeight);
nsIntRect clippedRect;
clippedRect.IntersectRect(unclippedRect, docRect);
@ -222,11 +222,11 @@ nsresult nsTextAccessibleWrap::GetCharacterExtents(PRInt32 aStartOffset, PRInt32
return E_FAIL;
}
nsRect sum(0, 0, 0, 0);
nsIntRect sum(0, 0, 0, 0);
nsIFrame *iter = startFrame;
nsIFrame *stopLoopFrame = endFrame->GetNextContinuation();
for (; iter != stopLoopFrame; iter = iter->GetNextContinuation()) {
nsRect rect = iter->GetScreenRectExternal();
nsIntRect rect = iter->GetScreenRectExternal();
nscoord start = (iter == startFrame) ? presContext->AppUnitsToDevPixels(startPoint.x) : 0;
nscoord end = (iter == endFrame) ? presContext->AppUnitsToDevPixels(endPoint.x) :
rect.width;

View File

@ -901,7 +901,7 @@ nsExternalResourceMap::AddExternalResource(nsIURI* aURI,
} else {
doc->SetDisplayDocument(aDisplayDocument);
rv = aViewer->Init(nsnull, nsRect(0, 0, 0, 0));
rv = aViewer->Init(nsnull, nsIntRect(0, 0, 0, 0));
if (NS_SUCCEEDED(rv)) {
rv = aViewer->Open(nsnull, nsnull);
}

View File

@ -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;

View File

@ -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;

View File

@ -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<nsIDOMAbstractView> mView;
PRInt32 mDetail;
nsPoint mClientPoint;
nsIntPoint mClientPoint;
// Screenpoint is mEvent->refPoint.
nsPoint mLayerPoint;
nsPoint mPagePoint;
nsIntPoint mLayerPoint;
nsIntPoint mPagePoint;
};
#define NS_FORWARD_TO_NSDOMUIEVENT \

View File

@ -1390,7 +1390,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,
@ -1423,7 +1423,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;
@ -1451,7 +1451,7 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
PRBool
nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget,
nsIPresShell* aShell,
nsPoint& aTargetPt)
nsIntPoint& aTargetPt)
{
nsresult rv;
@ -1544,7 +1544,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);
@ -1558,7 +1558,7 @@ void
nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl,
nsPresContext *aPresContext,
nsIPresShell *aPresShell,
nsPoint& aTargetPt)
nsIntPoint& aTargetPt)
{
nsCOMPtr<nsIContent> focusedContent(do_QueryInterface(aCurrentEl));
aPresShell->ScrollContentIntoView(focusedContent,

View File

@ -186,9 +186,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);
nsPIDOMWindow* GetInnerWindowForTarget();

View File

@ -379,7 +379,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();
@ -451,7 +451,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();
@ -482,13 +482,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();
}
@ -1960,8 +1960,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();
@ -2004,7 +2004,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;
@ -2065,10 +2065,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

View File

@ -386,7 +386,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<nsIContent> mGestureDownContent;
// The content of the frame where the mouse-down event occurred. It's the same

View File

@ -439,25 +439,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;
}
@ -506,9 +506,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;

View File

@ -5582,7 +5582,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);
}
@ -5907,7 +5907,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<nsIPresShell> oldPresShell;
nsDocShell::GetPresShell(getter_AddRefs(oldPresShell));
@ -5963,7 +5963,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
@ -6537,7 +6537,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
nsCOMPtr<nsIWidget> 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;

View File

@ -638,7 +638,7 @@ protected:
nsCOMPtr<nsISupportsArray> mRefreshURIList;
nsCOMPtr<nsISupportsArray> mSavedRefreshURIList;
nsRefPtr<nsDSURIContentListener> mContentListener;
nsRect mBounds; // Dimensions of the docshell
nsIntRect mBounds; // Dimensions of the docshell
nsCOMPtr<nsIContentViewer> mContentViewer;
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
nsCOMPtr<nsIWidget> mParentWidget;
@ -651,7 +651,7 @@ protected:
nsCOMPtr<nsISHistory> mSessionHistory;
nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
nsCOMPtr<nsIWebBrowserFind> 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<nsISHEntry> mOSHE;

View File

@ -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

View File

@ -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

View File

@ -535,14 +535,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;

View File

@ -110,7 +110,7 @@ private:
nsCOMPtr<nsISupports> mCacheKey;
nsISHEntry * mParent; // weak reference
nsCOMPtr<nsISupports> mWindowState;
nsRect mViewerBounds;
nsIntRect mViewerBounds;
nsCOMArray<nsIDocShellTreeItem> mChildShells;
nsCOMPtr<nsISupportsArray> mRefreshURIList;
nsCOMPtr<nsISupports> mOwner;

View File

@ -76,12 +76,12 @@ function testElement(element)
checkClientState(element, borderLeft, borderTop, clientWidth, clientHeight, element.id);
var boundingrect = element.getBoundingClientRect();
is(Math.round(boundingrect.width), borderLeft + paddingLeft + width + paddingRight + borderLeft,
is(Math.round(boundingrect.width), borderLeft + paddingLeft + width + paddingRight + borderRight,
element.id + " bounding rect width");
is(Math.round(boundingrect.height), borderTop + paddingTop + height + paddingBottom + borderBottom,
element.id + " bounding rect height");
is(Math.round(boundingrect.right - boundingrect.left),
borderLeft + paddingLeft + width + paddingRight + borderLeft,
borderLeft + paddingLeft + width + paddingRight + borderRight,
element.id + " bounding rect right");
is(Math.round(boundingrect.bottom - boundingrect.top),
borderTop + paddingTop + height + paddingBottom + borderBottom,

View File

@ -1997,18 +1997,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)
{

View File

@ -1755,11 +1755,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();

View File

@ -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)

View File

@ -84,7 +84,7 @@ public:
nsCOMPtr<nsIDOMNode> mEventNode;
nsCOMPtr<nsIDOMEventTarget> mEventTarget;
nsCOMPtr<nsIDOMDocument>mCtxDocument;
nsRect mFormRect;
nsIntRect mFormRect;
nsCOMPtr<nsIDOMWindow> mCtxDomWindow;
nsCOMPtr<nsIDOMEvent> mCtxEvent;
nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElement;

View File

@ -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,

View File

@ -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<nsWebBrowser *>(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)

View File

@ -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
//

View File

@ -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
// {f5eb2e02-ed3f-4340-82fc-22f55bb556f9}
#define NS_ITHEME_IID \
{ 0xf5eb2e02, 0xed3f, 0x4340, { 0x82, 0xfc, 0x22, 0xf5, 0x5b, 0xb5, 0x56, 0xf9 } }
// {887e8902-db6b-41b4-8481-a80f49c5a93a}
#define NS_ITHEME_IID \
{ 0x887e8902, 0xdb6b, 0x41b4, { 0x84, 0x81, 0xa8, 0x0f, 0x49, 0xc5, 0xa9, 0x3a } }
// {D930E29B-6909-44e5-AB4B-AF10D6923705}
#define NS_THEMERENDERER_CID \
@ -97,7 +97,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
@ -111,7 +111,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
@ -136,7 +136,7 @@ public:
NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext,
nsIFrame* aFrame,
PRUint8 aWidgetType,
nsSize* aResult,
nsIntSize* aResult,
PRBool* aIsOverridable)=0;
virtual nsTransparencyMode GetWidgetTransparency(PRUint8 aWidgetType)=0;

View File

@ -105,7 +105,6 @@ struct nsMargin {
return *this;}
};
#ifdef NS_COORD_IS_FLOAT
struct nsIntMargin {
PRInt32 top, right, bottom, left;
@ -115,9 +114,29 @@ 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; }
PRBool operator!=(const nsIntMargin& aMargin) const {
return (PRBool) ((left != aMargin.left) || (top != aMargin.top) ||
(right != aMargin.right) || (bottom != aMargin.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 */

View File

@ -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 */

View File

@ -47,6 +47,8 @@
#include "gfxCore.h"
#include "nsTraceRefcnt.h"
struct nsIntRect;
struct NS_GFX nsRect {
nscoord x, y;
nscoord width, height;
@ -168,25 +170,9 @@ 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); }
@ -199,9 +185,12 @@ struct NS_GFX nsRect {
// Helper methods for computing the extents
nscoord XMost() const {return x + width;}
nscoord YMost() const {return y + height;}
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 +198,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 +211,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 +293,75 @@ 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
/*
* 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, float(aAppUnitsPerPixel)));
rect.y = NSToIntRound(NSAppUnitsToFloatPixels(aRect.y, float(aAppUnitsPerPixel)));
rect.width = NSToIntRound(NSAppUnitsToFloatPixels(aRect.XMost(),
float(aAppUnitsPerPixel))) - rect.x;
rect.height = NSToIntRound(NSAppUnitsToFloatPixels(aRect.YMost(),
float(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, float(aAppUnitsPerPixel)));
rect.y = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.y, float(aAppUnitsPerPixel)));
rect.width = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.XMost(),
float(aAppUnitsPerPixel))) - rect.x;
rect.height = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.YMost(),
float(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, float(aAppUnitsPerPixel)));
rect.y = NSToIntCeil(NSAppUnitsToFloatPixels(aRect.y, float(aAppUnitsPerPixel)));
rect.width = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.XMost(),
float(aAppUnitsPerPixel))) - rect.x;
rect.height = NSToIntFloor(NSAppUnitsToFloatPixels(aRect.YMost(),
float(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

View File

@ -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 */

View File

@ -185,40 +185,6 @@ nsRect& nsRect::ScaleRoundOut(float aScale)
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 +210,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 +281,4 @@ PRBool nsIntRect::UnionRect(const nsIntRect &aRect1, const nsIntRect &aRect2)
return result;
}
#endif
#endif // DEBUG

View File

@ -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<nsIMemory> 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;
}

View File

@ -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();
@ -152,7 +152,7 @@ protected:
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mStride;
nsRect mDecoded;
nsIntRect mDecoded;
PRPackedBool mImageComplete;
PRPackedBool mSinglePixel;
PRPackedBool mFormatChanged;

View File

@ -1457,12 +1457,13 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
nsCOMPtr<imgIContainer> 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;
@ -1531,10 +1532,10 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
// If the current frame is smaller than its container, we
// need to paint the background color even if the frame
// itself is opaque.
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) {

View File

@ -367,7 +367,7 @@ private:
*/
nsresult InitInternal(nsIWidget* aParentWidget,
nsISupports *aState,
const nsRect& aBounds,
const nsIntRect& aBounds,
PRBool aDoCreation,
PRBool aInPrintPreview,
PRBool aNeedMakeCX = PR_TRUE);
@ -663,7 +663,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);
@ -706,7 +706,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;
@ -802,7 +802,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*/)
@ -1246,7 +1246,7 @@ DocumentViewerImpl::Open(nsISupports *aState, nsISHEntry *aSHEntry)
{
NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
nsRect bounds;
nsIntRect bounds;
mWindow->GetBounds(bounds);
if (mDocument)
@ -1724,7 +1724,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");
@ -1779,7 +1779,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);
@ -1886,12 +1886,12 @@ DocumentViewerImpl::Show(void)
return rv;
}
nsRect tbounds;
nsIntRect tbounds;
if (mParentWidget) {
mParentWidget->GetBounds(tbounds);
} else {
// No good default size; just size to 0 by 0 for lack of anything better.
tbounds = nsRect(0, 0, 0, 0);
tbounds = nsIntRect(0, 0, 0, 0);
}
rv = MakeWindow(nsSize(mPresContext->DevPixelsToAppUnits(tbounds.width),
@ -4162,7 +4162,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) {

View File

@ -102,10 +102,10 @@ class gfxContext;
typedef short SelectionType;
typedef PRUint32 nsFrameState;
// b5bc1dd3-9fd3-4fe7-8311-5dfca55ea371
// b86c23c5-602d-4ca6-a968-379b244fed9e
#define NS_IPRESSHELL_IID \
{ 0xb5bc1dd3, 0x9fd3, 0x4fe7, \
{ 0x83, 0x11, 0x5d, 0xfc, 0xa5, 0x5e, 0xa3, 0x71 } }
{ 0xb86c23c5, 0x602d, 0x4ca6, \
{ 0xa9, 0x68, 0x37, 0x9b, 0x24, 0x4f, 0xed, 0x9e } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -744,8 +744,8 @@ public:
*/
virtual already_AddRefed<gfxASurface> 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
@ -763,8 +763,8 @@ public:
* as the position can be determined from the displayed frames.
*/
virtual already_AddRefed<gfxASurface> RenderSelection(nsISelection* aSelection,
nsPoint& aPoint,
nsRect* aScreenRect) = 0;
nsIntPoint& aPoint,
nsIntRect* aScreenRect) = 0;
void AddWeakFrame(nsWeakFrame* aWeakFrame);
void RemoveWeakFrame(nsWeakFrame* aWeakFrame);

View File

@ -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);

View File

@ -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);

View File

@ -812,11 +812,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;
@ -835,9 +835,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) {
@ -2006,7 +2006,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()->

View File

@ -566,7 +566,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),

View File

@ -881,12 +881,12 @@ public:
virtual already_AddRefed<gfxASurface> RenderNode(nsIDOMNode* aNode,
nsIRegion* aRegion,
nsPoint& aPoint,
nsRect* aScreenRect);
nsIntPoint& aPoint,
nsIntRect* aScreenRect);
virtual already_AddRefed<gfxASurface> RenderSelection(nsISelection* aSelection,
nsPoint& aPoint,
nsRect* aScreenRect);
nsIntPoint& aPoint,
nsIntRect* aScreenRect);
//nsIViewObserver interface
@ -1087,8 +1087,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
@ -5113,8 +5113,8 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* 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)
@ -5123,8 +5123,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* 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;
@ -5228,8 +5227,8 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
already_AddRefed<gfxASurface>
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.
@ -5254,12 +5253,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();
@ -5277,8 +5275,8 @@ PresShell::RenderNode(nsIDOMNode* aNode,
already_AddRefed<gfxASurface>
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.
@ -6664,6 +6662,35 @@ 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 = do_QueryFrame(k1);
if (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");
frameDebug = do_QueryFrame(k2);
if (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)
@ -6691,7 +6718,7 @@ CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
}
}
nsRect r1, r2;
nsIntRect r1, r2;
nsIView* v1, *v2;
for (;;) {
if (((nsnull == k1) && (nsnull != k2)) ||

View File

@ -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;

View File

@ -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,

View File

@ -569,16 +569,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.left),
presContext->DevPixelsToAppUnits(result.top),
presContext->DevPixelsToAppUnits(result.right),
presContext->DevPixelsToAppUnits(result.bottom));
}
return GetStyleBorder()->GetActualBorder();
@ -601,14 +600,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;
}
}
@ -801,9 +801,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();
}
@ -3045,13 +3045,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)) {
@ -3162,15 +3162,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;
@ -3527,9 +3528,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
@ -3549,7 +3548,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);

View File

@ -188,7 +188,7 @@ public:
virtual void ReflowCallbackCanceled();
protected:
nsSize GetMargin();
nsIntSize GetMargin();
PRBool IsInline() { return mIsInline; }
nsresult ShowDocShell();
nsresult CreateViewAndWidget(nsContentType aContentType);
@ -772,9 +772,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);
@ -888,7 +888,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);

View File

@ -735,7 +735,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
@ -745,7 +745,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;
}
}
@ -759,7 +760,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;
}
@ -854,7 +855,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);
@ -1059,7 +1060,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

View File

@ -122,7 +122,7 @@ public:
void GetSizeOfChildAt(PRInt32 aIndexInParent,
nsSize& aSize,
nsPoint& aCellIndex);
nsIntPoint& aCellIndex);
static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild);
@ -220,7 +220,7 @@ protected:
const nsHTMLReflowState& aReflowState,
nsPoint& aOffset,
nsSize& aSize,
nsPoint* aCellIndex = 0);
nsIntPoint* aCellIndex = 0);
PRBool CanResize(PRBool aVertical,
PRBool aLeft);
@ -251,7 +251,7 @@ protected:
nsHTMLFramesetBorderFrame* mDragger;
nsFramesetDrag mDrag;
nsPoint mFirstDragPoint;
nsIntPoint mFirstDragPoint;
PRInt32 mPrevNeighborOrigSize; // used during resize
PRInt32 mNextNeighborOrigSize;
PRInt32 mMinDrag;

View File

@ -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 = GetIntrinsicRatio(); // 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));

View File

@ -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);

View File

@ -1850,14 +1850,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;
@ -1870,17 +1871,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;

View File

@ -294,7 +294,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),
@ -378,7 +378,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
@ -523,7 +523,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
@ -635,7 +635,7 @@ nsImageFrame::OnStopDecode(imgIRequest *aRequest,
nsresult
nsImageFrame::FrameChanged(imgIContainer *aContainer,
gfxIImageFrame *aNewFrame,
nsRect *aDirtyRect)
nsIntRect *aDirtyRect)
{
if (!GetStyleVisibility()->IsVisible()) {
return NS_OK;
@ -1826,7 +1826,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;
@ -1846,7 +1846,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;

View File

@ -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; }
@ -224,13 +224,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
@ -267,7 +267,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;

View File

@ -552,10 +552,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
@ -932,7 +928,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;
@ -979,7 +975,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;
@ -1032,7 +1028,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);
@ -1061,10 +1057,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
@ -1489,7 +1483,7 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext,
// and we can safely use this message to tell the plugin exactly where it is in all cases.
nsIntPoint origin = GetWindowOriginInPixels(PR_TRUE);
nsRect winlessRect = nsRect(origin, nsSize(window->width, window->height));
nsIntRect winlessRect = nsIntRect(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
@ -1572,7 +1566,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
@ -3797,8 +3791,8 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
const nsMouseEvent& mouseEvent =
static_cast<const nsMouseEvent&>(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
@ -4076,12 +4070,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.Size()), *mOwner->GetPresContext()->AppUnitsPerDevPixel());
#endif
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
@ -4125,18 +4115,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;
@ -4629,17 +4616,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
@ -4702,8 +4678,8 @@ WindowRef nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
nsPoint pluginOrigin;
nsRect widgetClip;
nsIntPoint pluginOrigin;
nsIntRect widgetClip;
PRBool widgetVisible;
pluginWidget->GetPluginClipRect(widgetClip, pluginOrigin, /* out */ widgetVisible);
@ -4727,13 +4703,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;

View File

@ -170,7 +170,7 @@ protected:
void NotifyContentObjectWrapper();
nsPoint GetWindowOriginInPixels(PRBool aWindowless);
nsIntPoint GetWindowOriginInPixels(PRBool aWindowless);
static void PaintPrintPlugin(nsIFrame* aFrame,
nsIRenderingContext* aRenderingContext,
@ -192,7 +192,7 @@ protected:
friend class nsPluginInstanceOwner;
private:
nsRefPtr<nsPluginInstanceOwner> 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

View File

@ -191,13 +191,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);
@ -205,11 +205,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);

View File

@ -2200,8 +2200,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 +

View File

@ -687,8 +687,7 @@ nsSVGForeignObjectFrame::InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter,
nsPresContext* presContext = PresContext();
nsCOMPtr<nsIDOMSVGMatrix> 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);

View File

@ -126,9 +126,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);
}
@ -157,9 +157,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;
}
@ -180,9 +180,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;
}
@ -221,8 +221,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);
@ -291,8 +290,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<nsIDOMSVGMatrix> matrix = GetInitialMatrix(aEffectsFrame);
@ -317,8 +315,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);

View File

@ -558,7 +558,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);
@ -570,7 +570,7 @@ nsSVGOuterSVGFrame::Paint(nsIRenderingContext& aRenderingContext,
}
#endif
nsSVGUtils::PaintFrameWithEffects(&ctx, &dirtyRect, this);
nsSVGUtils::PaintFrameWithEffects(&ctx, &dirtyPxRect, this);
#ifdef XP_MACOSX
if (mEnableBitmapFallback) {

View File

@ -564,8 +564,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)
@ -578,8 +577,7 @@ nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
aFrame = aFrame->GetParent();
}
rect.ScaleRoundOut(appUnitsPerDevPixel);
return rect;
return nsIntRect::ToAppUnits(rect, appUnitsPerDevPixel);
}
void
@ -982,8 +980,7 @@ nsSVGUtils::PaintFrameWithEffects(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;
}

View File

@ -716,7 +716,7 @@ protected:
// range parent and offset set in SetTriggerEvent
nsCOMPtr<nsIDOMNode> mRangeParent;
PRInt32 mRangeOffset;
nsPoint mCachedMousePoint;
nsIntPoint mCachedMousePoint;
// set to the currently active menu bar, if any
nsMenuBarFrame* mActiveMenuBar;

View File

@ -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,

View File

@ -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;

View File

@ -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

View File

@ -543,7 +543,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);
@ -591,7 +591,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;

View File

@ -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();

View File

@ -910,7 +910,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
}
// the dimensions of the anchor in its app units
nsSize parentSize = aAnchorFrame->GetSize();
nsRect parentRect = aAnchorFrame->GetScreenRectInAppUnits();
// the anchor may be in a different document with a different scale,
// so adjust the size so that it is in the app units of the popup instead
@ -919,8 +919,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
// app units by multiplying by the popup's app units per device pixel.
float adj = float(presContext->AppUnitsPerDevPixel()) /
aAnchorFrame->PresContext()->AppUnitsPerDevPixel();
parentSize.width = NSToCoordCeil(parentSize.width * adj);
parentSize.height = NSToCoordCeil(parentSize.height * adj);
parentRect.ScaleRoundOut(adj);
// Set the popup's size to the preferred size. Below, this size will be
// adjusted to fit on the screen or within the content area. If the anchor
@ -928,7 +927,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
// width. The preferred size should already be set by the parent frame.
NS_ASSERTION(mPrefSize.width >= 0 || mPrefSize.height >= 0,
"preferred size of popup not set");
mRect.width = sizedToPopup ? parentSize.width : mPrefSize.width;
mRect.width = sizedToPopup ? parentRect.width : mPrefSize.width;
mRect.height = mPrefSize.height;
// the screen position in app units where the popup should appear
@ -936,7 +935,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
// For anchored popups, the anchor rectangle. For non-anchored popups, the
// size will be 0.
nsRect anchorRect;
nsRect anchorRect = parentRect;
// indicators of whether the popup should be flipped or resized.
PRBool hFlip = PR_FALSE, vFlip = PR_FALSE;
@ -960,9 +959,6 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
// the most room. The combination of anchor and alignment dictate if we
// readjust above/below or to the left/right.
if (mAnchorContent) {
anchorRect = aAnchorFrame->GetScreenRectInAppUnits();
anchorRect.ScaleRoundOut(adj);
// move the popup according to the anchor and alignment. This will also
// tell us which axis the popup is flush against in case we have to move
// it around later. The AdjustPositionForAnchorAlign method accounts for
@ -1077,7 +1073,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
if (sizedToPopup) {
nsBoxLayoutState state(PresContext());
// XXXndeakin can parentSize.width still extend outside?
SetBounds(state, nsRect(mRect.x, mRect.y, parentSize.width, mRect.height));
SetBounds(state, nsRect(mRect.x, mRect.y, parentRect.width, mRect.height));
}
return NS_OK;

View File

@ -65,7 +65,7 @@ protected:
PRInt32 aMovement, PRInt8 aResizerDirection);
protected:
nsRect mWidgetRect;
nsIntRect mWidgetRect;
}; // class nsResizerFrame
#endif /* nsResizerFrame_h___ */

View File

@ -288,9 +288,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
@ -388,11 +388,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;

View File

@ -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<nsIWidget> widget;
(static_cast<nsMenuPopupFrame*>(parent))->
GetWidget(getter_AddRefs(widget));
nsRect bounds;
nsIntRect bounds;
widget->GetScreenBounds(bounds);
widget->Move(bounds.x + nsMoveBy.x, bounds.y + nsMoveBy.y);
}

View File

@ -70,7 +70,7 @@ protected:
protected:
PRBool mTrackingMouseMove;
nsPoint mLastPoint;
nsIntPoint mLastPoint;
}; // class nsTitleBarFrame

View File

@ -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<nsIDOMNSUIEvent> 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));
}
}
}
@ -1000,7 +999,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.

View File

@ -648,8 +648,7 @@ nsTreeBodyFrame::GetSelectionRegion(nsIScriptableRegion **aRegion)
region->Init();
nsRefPtr<nsPresContext> 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);
@ -2134,14 +2133,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;

View File

@ -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;

View File

@ -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);

View File

@ -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;
/**

View File

@ -518,7 +518,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)
@ -568,10 +568,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()),
@ -580,14 +580,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;
toScroll = nsRect::ToInsidePixels(biggestRect, aP2A);
biggestRect = nsIntRect::ToAppUnits(toScroll, aP2A);
regionToScroll.Sub(regionToScroll, biggestRect);
updateRegion.Or(updateRegion, regionToScroll);
}
@ -674,7 +673,7 @@ NS_IMETHODIMP nsScrollPortView::ScrollToImpl(nscoord aX, nscoord aY)
mOffsetX = aX;
mOffsetY = aY;
Scroll(scrolledView, twipsDelta, nsPoint(dxPx, dyPx), p2a);
Scroll(scrolledView, twipsDelta, nsIntPoint(dxPx, dyPx), p2a);
mViewManager->SynthesizeMouseMove(PR_TRUE);

View File

@ -105,7 +105,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;

View File

@ -356,7 +356,7 @@ void nsView::ResetWidgetBounds(PRBool aRecurse, PRBool aMoveOnly,
}
}
nsRect nsView::CalcWidgetBounds(nsWindowType aType)
nsIntRect nsView::CalcWidgetBounds(nsWindowType aType)
{
nsCOMPtr<nsIDeviceContext> 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<nsView*>(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;

View File

@ -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

View File

@ -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);
}
}
@ -993,14 +992,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;
@ -1050,7 +1041,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);
}
@ -1132,10 +1123,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
@ -1277,8 +1267,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",
@ -1296,7 +1286,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);
@ -1333,26 +1323,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;
@ -2026,25 +1996,26 @@ NS_IMETHODIMP nsViewManager::ForceUpdate()
return NS_OK;
}
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;
rect.x -= bounds.x;
rect.y -= bounds.y;
aRect += aView->ViewToWidgetOffset();
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)
@ -2102,7 +2073,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<nsView*>(aView);
@ -2293,7 +2264,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()) {
@ -2376,7 +2347,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;
}
@ -2390,14 +2361,14 @@ 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);
nsViewManager *pointVM;
if (!view) {
view = mRootView;
@ -2405,9 +2376,9 @@ nsViewManager::ProcessSynthMouseMoveEvent(PRBool aFromScroll)
// pointView can be null in situations related to mouse capture
pointVM = (pointView ? pointView : view)->GetViewManager();
} 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);
pointVM = view->GetViewManager();
}
nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, view->GetWidget(),

View File

@ -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
@ -428,7 +428,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.

View File

@ -460,7 +460,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;
@ -547,7 +547,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)
@ -609,7 +609,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;
};
/**
@ -846,7 +846,7 @@ struct nsTextEventReply
{
}
nsRect mCursorPosition;
nsIntRect mCursorPosition;
PRBool mCursorIsCollapsed;
nsIWidget* mReferenceWidget;
};
@ -988,7 +988,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;

View File

@ -53,7 +53,7 @@ class NS_NO_VTABLE nsIPluginWidget : public nsISupports
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPLUGINWIDGET_IID)
NS_IMETHOD GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible) = 0;
NS_IMETHOD GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& outOrigin, PRBool& outWidgetVisible) = 0;
NS_IMETHOD StartDrawPlugin(void) = 0;

View File

@ -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);
};

View File

@ -94,10 +94,10 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#define NS_NATIVE_PLUGIN_PORT_CG 101
#endif
// 7E01D11D-DAFC-4A5E-8C0A-7442A2E17252
// a85944af-7fce-4e45-bf04-ac12c823394b
#define NS_IWIDGET_IID \
{ 0x7E01D11D, 0xDAFC, 0x4A5E, \
{ 0x8C, 0x0A, 0x74, 0x42, 0xA2, 0xE1, 0x72, 0x52 } }
{ 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
@ -315,7 +315,7 @@ class nsIWidget : public nsISupports {
*
*/
NS_IMETHOD Create(nsIWidget *aParent,
const nsRect &aRect,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
@ -342,7 +342,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,
@ -586,7 +586,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;
/**
@ -599,7 +599,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;
/**
@ -609,7 +609,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
@ -753,7 +753,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.
@ -810,7 +810,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.
@ -834,7 +834,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
@ -904,7 +904,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.
@ -913,7 +913,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

View File

@ -299,14 +299,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,
@ -317,7 +317,7 @@ public:
// Create(nsNativeWidget...)
virtual nsresult StandardCreate(nsIWidget *aParent,
const nsRect &aRect,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
@ -345,19 +345,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);
@ -369,9 +369,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);
@ -400,7 +400,7 @@ public:
PRBool* aLEDState);
// nsIPluginWidget
NS_IMETHOD GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible);
NS_IMETHOD GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& outOrigin, PRBool& outWidgetVisible);
NS_IMETHOD StartDrawPlugin();
NS_IMETHOD EndDrawPlugin();
NS_IMETHOD SetPluginInstanceOwner(nsIPluginInstanceOwner* aInstanceOwner);

View File

@ -147,7 +147,7 @@ PRUint32 gLastModifierState = 0;
- (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
@ -311,7 +311,7 @@ enum
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;
@ -320,17 +320,16 @@ 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<nscoord>(inCocoaRect.origin.x);
outGeckoRect.y = static_cast<nscoord>(inCocoaRect.origin.y);
outGeckoRect.width = static_cast<nscoord>(inCocoaRect.size.width);
outGeckoRect.height = static_cast<nscoord>(inCocoaRect.size.height);
outGeckoRect.x = NSToIntRound(inCocoaRect.origin.x);
outGeckoRect.y = NSToIntRound(inCocoaRect.origin.y);
outGeckoRect.width = NSToIntRound(inCocoaRect.origin.x + inCocoaRect.size.width) - outGeckoRect.x;
outGeckoRect.height = NSToIntRound(inCocoaRect.origin.y + inCocoaRect.size.height) - outGeckoRect.y;
}
static inline void
ConvertGeckoRectToMacRect(const nsRect& aRect, Rect& outMacRect)
ConvertGeckoRectToMacRect(const nsIntRect& aRect, Rect& outMacRect)
{
outMacRect.left = aRect.x;
outMacRect.top = aRect.y;
@ -557,7 +556,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,
@ -687,7 +686,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,
@ -701,7 +700,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,
@ -1149,14 +1148,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;
@ -1317,7 +1316,7 @@ PRBool nsChildView::ShowsResizeIndicator(nsIntRect* aResizerRect)
}
NS_IMETHODIMP nsChildView::GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible)
NS_IMETHODIMP nsChildView::GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& outOrigin, PRBool& outWidgetVisible)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -1338,15 +1337,15 @@ NS_IMETHODIMP nsChildView::GetPluginClipRect(nsRect& outClipRect, nsPoint& outOr
// Convert from cocoa to QuickDraw coordinates
clipOrigin.y = frame.size.height - clipOrigin.y;
outClipRect.x = (nscoord)clipOrigin.x;
outClipRect.y = (nscoord)clipOrigin.y;
outClipRect.x = NSToIntRound(clipOrigin.x);
outClipRect.y = NSToIntRound(clipOrigin.y);
PRBool isVisible;
IsVisible(isVisible);
if (isVisible && [mView window] != nil) {
outClipRect.width = (nscoord)visibleBounds.size.width;
outClipRect.height = (nscoord)visibleBounds.size.height;
outClipRect.width = NSToIntRound(visibleBounds.origin.x + visibleBounds.size.width) - NSToIntRound(visibleBounds.origin.x);
outClipRect.height = NSToIntRound(visibleBounds.origin.y + visibleBounds.size.height) - NSToIntRound(visibleBounds.origin.y);
outWidgetVisible = PR_TRUE;
}
else {
@ -1357,8 +1356,8 @@ NS_IMETHODIMP nsChildView::GetPluginClipRect(nsRect& outClipRect, nsPoint& outOr
// need to convert view's origin to window coordinates.
// then, encode as "SetOrigin" ready values.
outOrigin.x = (nscoord)-viewOrigin.x;
outOrigin.y = (nscoord)-viewOrigin.y;
outOrigin.x = -NSToIntRound(viewOrigin.x);
outOrigin.y = -NSToIntRound(viewOrigin.y);
return NS_OK;
@ -1410,8 +1409,8 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
::SetOrigin(0, 0);
nsRect clipRect; // this is in native window coordinates
nsPoint origin;
nsIntRect clipRect; // this is in native window coordinates
nsIntPoint origin;
PRBool visible;
GetPluginClipRect(clipRect, origin, visible);
@ -1720,7 +1719,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;
@ -1770,7 +1769,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<nsIRegion*>(aRegion); // ugh. this method should be const
region->GetBoundingBox(&bounds.x, &bounds.y, &bounds.width, &bounds.height);
GeckoRectToNSRect(bounds, r);
@ -1816,7 +1815,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;
@ -1838,7 +1837,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);
}
@ -2060,11 +2059,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
@ -2080,7 +2079,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;
@ -2120,7 +2119,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;
@ -3001,7 +3000,7 @@ static const PRInt32 sShadowInvalidationInterval = 100;
CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
nsRect geckoBounds;
nsIntRect geckoBounds;
mGeckoChild->GetBounds(geckoBounds);
NSRect bounds = [self bounds];
@ -3045,7 +3044,7 @@ static const PRInt32 sShadowInvalidationInterval = 100;
targetContext->Clip();
// bounding box of the dirty area
nsRect fullRect;
nsIntRect fullRect;
NSRectToGeckoRect(aRect, fullRect);
nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, mGeckoChild);
@ -5087,14 +5086,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);
if (aEventType == NS_COMPOSITION_START)
[self initTSMDocument];
@ -5467,7 +5466,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);

View File

@ -120,10 +120,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!

View File

@ -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 = NSToIntRound(cocoaRect.origin.x);
rect.y = NSToIntRound(FlippedScreenY(cocoaRect.origin.y + cocoaRect.size.height));
rect.width = NSToIntRound(cocoaRect.origin.x + cocoaRect.size.width) - rect.x;
rect.height = NSToIntRound(FlippedScreenY(cocoaRect.origin.y)) - rect.y;
return rect;
}

View File

@ -183,7 +183,7 @@ public:
NS_DECL_NSPIWIDGETCOCOA
NS_IMETHOD Create(nsNativeWidget aParent,
const nsRect &aRect,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
@ -191,7 +191,7 @@ public:
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create(nsIWidget* aParent,
const nsRect &aRect,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
@ -203,7 +203,7 @@ public:
// Create(nsNativeWidget...)
virtual nsresult StandardCreate(nsIWidget *aParent,
const nsRect &aRect,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
@ -222,8 +222,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) ;
@ -236,16 +236,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; }

View File

@ -174,7 +174,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,
@ -399,7 +399,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,
@ -412,7 +412,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,
@ -926,14 +926,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
@ -973,22 +973,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;
@ -1016,7 +1012,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);
@ -1214,11 +1210,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;
@ -1231,11 +1227,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;
@ -1567,7 +1563,7 @@ nsCocoaWindow::UnifiedShading(void* aInfo, const float* aIn, float* aOut)
{
// 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;

View File

@ -67,7 +67,7 @@ public:
private:
NSImage* ConstructDragImage(nsIDOMNode* aDOMNode,
nsRect* aDragRect,
nsIntRect* aDragRect,
nsIScriptableRegion* aRegion);
nsCOMPtr<nsISupportsArray> mDataItems; // only valid for a drag started within gecko

View File

@ -164,7 +164,7 @@ static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray)
NSImage*
nsDragService::ConstructDragImage(nsIDOMNode* aDOMNode,
nsRect* aDragRect,
nsIntRect* aDragRect,
nsIScriptableRegion* aRegion)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
@ -268,7 +268,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

View File

@ -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();

Some files were not shown because too many files have changed in this diff Show More